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

Go to the source code of this file.

Functions

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

Function Documentation

◆ SpearGuyAI_LoiterInit()

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

Definition at line 6 of file SpearGuyAI.inc.c.

6 {
7 Enemy* enemy = script->owner1.enemy;
8 Npc* npc = get_npc_unsafe(enemy->npcID);
9
10 npc->duration = 0;
11 set_npc_yaw(npc, 270.0f);
12 enemy->varTable[0] = 0;
13 script->AI_TEMP_STATE = AI_STATE_LOITER;
14}
union Evt::@8 owner1
Initially -1.
@ AI_STATE_LOITER
Definition enums.h:4588
s16 npcID
Definition npc.h:300
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
void set_npc_yaw(Npc *npc, f32 yaw)
Definition npc.c:1246
Definition npc.h:294
s16 duration

◆ SpearGuyAI_Loiter()

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

Definition at line 16 of file SpearGuyAI.inc.c.

16 {
17 Enemy* enemy = script->owner1.enemy;
18 Npc* npc = get_npc_unsafe(enemy->npcID);
19 s32 d100;
20
21 if (enemy->varTable[0] == 0) {
22 if (rand_int(100) >= 50) {
23 enemy->varTable[0] = 3;
24 } else {
25 enemy->varTable[0] = 1;
26 }
27 set_npc_yaw(npc, 270.0f);
28 }
29
30 switch (enemy->varTable[0]) {
31 case 1:
32 enemy->varTable[0] = 2;
33 enemy->varTable[1] = 0;
34 npc->curAnim = ANIM_SpearGuy_Anim0F;
35 case 2:
36 enemy->varTable[1]++;
37 if (enemy->varTable[1] > 50) {
38 enemy->varTable[0] = 5;
39 }
40 break;
41 case 3:
42 enemy->varTable[0] = 4;
43 enemy->varTable[1] = 0;
44 npc->curAnim = ANIM_SpearGuy_Anim10;
45 case 4:
46 enemy->varTable[1]++;
47 if (enemy->varTable[1] == 25) {
48 npc->yaw = 90.0f;
49 }
50 if (enemy->varTable[1] > 60) {
51 enemy->varTable[0] = 5;
52 }
53 break;
54 case 5:
55 enemy->varTable[0] = 6;
56 enemy->varTable[1] = 0;
57 npc->curAnim = ANIM_SpearGuy_Anim03;
58 fx_sweat(0, npc->pos.x, npc->pos.y, npc->pos.z, npc->collisionHeight, 0, 10);
59 case 6:
60 enemy->varTable[1]++;
61 if (enemy->varTable[1] > 10) {
62 d100 = rand_int(100);
63
64 if (d100 < 90) {
65 enemy->varTable[0] = 7;
66 } else if (d100 >= 95) {
67 enemy->varTable[0] = 3;
68 } else {
69 enemy->varTable[0] = 1;
70 }
71 }
72 break;
73 }
74
75 if (enemy->varTable[0] == 7) {
76 script->AI_TEMP_STATE = AI_STATE_WANDER_INIT;
77 }
78}
#define rand_int
@ AI_STATE_WANDER_INIT
Definition enums.h:4581
AnimID curAnim
s16 collisionHeight
Vec3f pos