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

Go to the source code of this file.

Enumerations

enum  AiStateParatroopa { AI_STATE_PARATROOPA_WINDUP = 12 , AI_STATE_PARATROOPA_DIVE = 13 , AI_STATE_PARATROOPA_OVERSHOOT = 14 , AI_STATE_PARATROOPA_RESET = 15 }
 

Functions

void N ParatroopaAI_Windup (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N ParatroopaAI_Dive (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N ParatroopaAI_Overshoot (Evt *script, MobileAISettings *arg1, EnemyDetectVolume *arg2)
 
void N ParatroopaAI_Reset (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 

Enumeration Type Documentation

◆ AiStateParatroopa

Enumerator
AI_STATE_PARATROOPA_WINDUP 
AI_STATE_PARATROOPA_DIVE 
AI_STATE_PARATROOPA_OVERSHOOT 
AI_STATE_PARATROOPA_RESET 

Definition at line 7 of file ParatroopaAI.inc.c.

7 {
12};
@ AI_STATE_PARATROOPA_DIVE
@ AI_STATE_PARATROOPA_WINDUP
@ AI_STATE_PARATROOPA_RESET
@ AI_STATE_PARATROOPA_OVERSHOOT

Function Documentation

◆ ParatroopaAI_Windup()

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

Definition at line 14 of file ParatroopaAI.inc.c.

14 {
15 Bytecode* args = script->ptrReadPos;
16 Enemy* enemy = script->owner1.enemy;
17 Npc* npc = get_npc_unsafe(enemy->npcID);
18 f32 yawTemp;
19
20 npc->curAnim = enemy->animList[9];
21 npc->jumpVel = -5.0f;
22 npc->jumpScale = 0.15f;
23 npc->collisionHeight = enemy->varTable[8] / 2;
24
26 npc->moveSpeed = 7.0f;
27 enemy->unk_10.x = npc->pos.x;
28 enemy->unk_10.y = npc->pos.y;
29 enemy->unk_10.z = npc->pos.z;
30 enemy->hitboxIsActive = TRUE;
31
33 yawTemp = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
34 npc->duration = 12;
35 npc->yaw = yawTemp;
36 script->AI_TEMP_STATE = AI_STATE_PARATROOPA_DIVE;
37}
Bytecode * ptrReadPos
union Evt::@8 owner1
Initially -1.
#define atan2
@ SOUND_PARAGOOMBA_DIVE
Definition enums.h:1029
s32 Bytecode
Definition evt.h:7
void ai_enemy_play_sound(Npc *npc, s32 arg1, s32 arg2)
Definition 23680.c:543
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
s16 npcID
Definition npc.h:300
s32 * animList
Definition npc.h:341
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
Vec3s unk_10
Definition npc.h:302
s8 hitboxIsActive
Definition npc.h:299
Definition npc.h:294
f32 jumpScale
f32 jumpVel
AnimID curAnim
s16 collisionHeight
Vec3f pos
f32 moveSpeed
s16 duration
PlayerStatus * gPlayerStatusPtr

◆ ParatroopaAI_Dive()

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

Definition at line 39 of file ParatroopaAI.inc.c.

39 {
40 Enemy* enemy = script->owner1.enemy;
41 Npc* npc = get_npc_unsafe(script->owner1.enemy->npcID);
42
43 npc->jumpVel += npc->jumpScale;
44 npc->pos.y += npc->jumpVel;
45 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
46 npc->duration--;
47
48 if (npc->duration <= 0) {
49 enemy->hitboxIsActive = FALSE;
50 npc->jumpScale = 0.3f;
51 npc->jumpVel = 0.0f;
52 npc->moveSpeed = 3.0f;
53 npc->curAnim = enemy->animList[10];
54 script->AI_TEMP_STATE = AI_STATE_PARATROOPA_OVERSHOOT;
55 }
56}
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:986

◆ ParatroopaAI_Overshoot()

void N ParatroopaAI_Overshoot ( Evt * script,
MobileAISettings * arg1,
EnemyDetectVolume * arg2 )

Definition at line 58 of file ParatroopaAI.inc.c.

59{
60 Enemy* enemy = script->owner1.enemy;
61 Npc* npc = get_npc_unsafe(enemy->npcID);
62 f32 overshootAmtRaw = enemy->varTable[3];
63 f32 posX, posY, posZ, hitDepth;
64 f32 endOvershootHeight;
65 f32 overshootAmt;
66
67 npc->jumpVel += npc->jumpScale;
68 npc->pos.y += npc->jumpVel;
69 overshootAmt = overshootAmtRaw / 100.0;
70 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
71
72 posX = npc->pos.x;
73 posY = npc->pos.y;
74 posZ = npc->pos.z;
75 hitDepth = 1000.0f;
76 if (npc_raycast_down_sides(npc->collisionChannel, &posX, &posY, &posZ, &hitDepth)) {
77 endOvershootHeight = posY + overshootAmt;
78 } else {
79 endOvershootHeight = overshootAmt;
80 }
81
82 if (!(npc->pos.y < endOvershootHeight)) {
83 npc->duration = 10;
84 npc->curAnim = enemy->animList[11];
85 npc->collisionHeight = enemy->varTable[8];
86 script->AI_TEMP_STATE = AI_STATE_PARATROOPA_RESET;
87 }
88}
#define npc_raycast_down_sides
s32 collisionChannel

◆ ParatroopaAI_Reset()

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

Definition at line 90 of file ParatroopaAI.inc.c.

90 {
91 Npc* npc = get_npc_unsafe(script->owner1.enemy->npcID);
92
93 npc->duration--;
94 if (npc->duration <= 0) {
95 script->AI_TEMP_STATE = AI_STATE_WANDER_INIT;
96 }
97}
@ AI_STATE_WANDER_INIT
Definition enums.h:4581