Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
Boo_Patrol.inc.c File Reference

Go to the source code of this file.

Functions

void N BooPatrolAI_Move (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N BooPatrolAI_Loiter (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 

Function Documentation

◆ BooPatrolAI_Move()

void N BooPatrolAI_Move ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 5 of file Boo_Patrol.inc.c.

5 {
6 Enemy* enemy = script->owner1.enemy;
7 Npc* npc = get_npc_unsafe(enemy->npcID);
8 f32 posX, posY, posZ, posW;
9 f32 temp_f20;
10 f32 temp_f22;
11
12 posX = npc->pos.x;
13 posZ = npc->pos.z;
14 temp_f22 = script->functionTemp[2][enemy->territory->patrol.points].x;
15 temp_f20 = script->functionTemp[2][enemy->territory->patrol.points].z;
16
17 npc->yaw = atan2(posX, posZ, temp_f22, temp_f20);
18 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
19
20 posX = npc->pos.x;
21 posY = npc->pos.y + script->functionTemp[2][enemy->territory->patrol.points].y;
22 posZ = npc->pos.z;
23 posW = 1000.0f;
24 npc_raycast_down_sides(npc->collisionChannel, &posX, &posY, &posZ, &posW);
25 posY += script->functionTemp[2][enemy->territory->patrol.points].y;
26 posW = posY - npc->pos.y;
27 if (posW > 2.0) {
28 npc->pos.y += 2.0;
29 } else if (posW < -2.0) {
30 npc->pos.y -= 2.0;
31 } else {
32 npc->pos.y = posY;
33 }
34
35 posW = dist2D(npc->pos.x, npc->pos.z, temp_f22, temp_f20);
36 if (!(posW > npc->moveSpeed)) {
37 script->functionTemp[0] = 2;
38 }
39}
union Evt::@8 owner1
Initially -1.
#define npc_raycast_down_sides
#define atan2
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
s16 npcID
Definition npc.h:300
Vec3i points[10]
Definition npc.h:223
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
EnemyTerritoryPatrol patrol
Definition npc.h:233
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:986
EnemyTerritory * territory
Definition npc.h:342
Definition npc.h:294
s32 collisionChannel
Vec3f pos
f32 moveSpeed

◆ BooPatrolAI_Loiter()

void N BooPatrolAI_Loiter ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 41 of file Boo_Patrol.inc.c.

41 {
42 Enemy* enemy = script->owner1.enemy;
43 Npc* npc = get_npc_unsafe(enemy->npcID);
44
45 npc->duration--;
46 if (npc->duration < 0) {
47 script->functionTemp[1]--;
48 if (script->functionTemp[1] >= 0) {
49 npc->yaw = clamp_angle(npc->yaw + 180.0f);
50 npc->duration = aiSettings->waitTime / 2 + rand_int(aiSettings->waitTime / 2 + 1);
51 } else {
52 script->functionTemp[0] = 4;
54 }
55 }
56}
#define rand_int
#define clamp_angle
@ ENEMY_ANIM_INDEX_IDLE
Definition enums.h:3426
s32 waitTime
Definition npc.h:95
s32 * animList
Definition npc.h:341
AnimID curAnim
s16 duration