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

Go to the source code of this file.

Enumerations

enum  AiStateNappingClubba {
  AI_STATE_NAPPING_CLUBBA_INIT = 0 , AI_STATE_NAPPING_CLUBBA_SLEEP = 1 , AI_STATE_NAPPING_CLUBBA_WAKE_UP = 2 , AI_STATE_NAPPING_CLUBBA_LOITER_INIT = 3 ,
  AI_STATE_NAPPING_CLUBBA_LOITER = 4 , AI_STATE_NAPPING_CLUBBA_50 = 50
}
 

Functions

void N ClubbaNappingAI_Init (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N ClubbaNappingAI_Sleep (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N ClubbaNappingAI_WakeUp (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N ClubbaNappingAI_LoiterInit (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N ClubbaNappingAI_Loiter (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N ClubbaNappingAI_ReturnHomeInit (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N ClubbaNappingAI_ReturnHome (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N ClubbaNappingAI_FallAsleep (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 

Enumeration Type Documentation

◆ AiStateNappingClubba

Enumerator
AI_STATE_NAPPING_CLUBBA_INIT 
AI_STATE_NAPPING_CLUBBA_SLEEP 
AI_STATE_NAPPING_CLUBBA_WAKE_UP 
AI_STATE_NAPPING_CLUBBA_LOITER_INIT 
AI_STATE_NAPPING_CLUBBA_LOITER 
AI_STATE_NAPPING_CLUBBA_50 

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

Function Documentation

◆ ClubbaNappingAI_Init()

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

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

16 {
17 Enemy* enemy = script->owner1.enemy;
18 Npc* npc = get_npc_unsafe(enemy->npcID);
19
20 if (npc->duration > 0) {
21 npc->duration--;
22 }
23
24 if (npc->duration == 1) {
25 npc->curAnim = enemy->animList[12];
26 } else if (npc->duration <= 0) {
27 npc->curAnim = enemy->animList[10];
28 npc->duration = 0;
29 script->AI_TEMP_STATE = AI_STATE_NAPPING_CLUBBA_SLEEP;
30 }
31}
union Evt::@8 owner1
Initially -1.
s16 npcID
Definition npc.h:300
s32 * animList
Definition npc.h:341
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
Definition npc.h:294
AnimID curAnim
s16 duration

◆ ClubbaNappingAI_Sleep()

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

Definition at line 33 of file ClubbaNappingAI.inc.c.

33 {
34 Enemy* enemy = script->owner1.enemy;
35 Npc* npc = get_npc_unsafe(enemy->npcID);
36 s32 shouldWakeUp = FALSE;
37 EffectInstance* emoteTemp;
38 f32 posX, posZ;
39
40 if (basic_ai_check_player_dist(territory, enemy, 80.0f, 0.0f, 0)) {
51 shouldWakeUp = TRUE;
52 }
53
56 shouldWakeUp = TRUE;
57 }
58 }
59 }
60
63 posX = npc->pos.x;
64 posZ = npc->pos.z;
65 add_vec2D_polar(&posX, &posZ, 0.0f, npc->yaw);
66 if (dist2D(posX, posZ, wPartnerNpc->pos.x, wPartnerNpc->pos.z) <= 80.0f) {
67 shouldWakeUp = TRUE;
68 }
69 }
70
71 if (shouldWakeUp) {
73 npc->curAnim = enemy->animList[11];
74 npc->duration = 10;
75 fx_emote(EMOTE_EXCLAMATION, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 15, &emoteTemp);
77 script->AI_TEMP_STATE = AI_STATE_NAPPING_CLUBBA_WAKE_UP;
78 }
79
80 npc->duration++;
81 if (npc->duration == 27) {
83 } else if (npc->duration == 57) {
85 } else if (npc->duration == 59) {
86 npc->curAnim = enemy->animList[12];
87 } else if (npc->duration == 60) {
88 npc->curAnim = enemy->animList[10];
89 npc->duration = 0;
90 }
91}
@ EMOTE_EXCLAMATION
Definition enums.h:495
@ PARTNER_ACTION_BOMBETTE_2
Definition enums.h:2937
@ PARTNER_ACTION_NONE
Definition enums.h:2932
@ SOUND_SEQ_SNORE_INHALE
Definition enums.h:1711
@ SOUND_SEQ_SNORE_EXHALE
Definition enums.h:1712
@ SOUND_AI_ALERT_A
Definition enums.h:1078
@ SOUND_SEQ_SNAP_AWAKE
Definition enums.h:1713
@ PARTNER_BOMBETTE
Definition enums.h:2888
@ PARTNER_KOOPER
Definition enums.h:2887
@ PARTNER_GOOMBARIO
Definition enums.h:2886
@ ACTION_STATE_JUMP
Definition enums.h:2430
@ ACTION_STATE_STEP_DOWN_LAND
Definition enums.h:2438
@ ACTION_STATE_SPIN_POUND
Definition enums.h:2442
@ ACTION_STATE_TORNADO_POUND
Definition enums.h:2444
@ ACTION_STATE_INVALID_25
Definition enums.h:2465
@ ACTION_STATE_LAND
Definition enums.h:2437
@ ACTION_STATE_13
Definition enums.h:2447
@ ACTION_STATE_HAMMER
Definition enums.h:2446
@ ACTION_STATE_SPIN
Definition enums.h:2454
@ ACTION_STATE_RUN
Definition enums.h:2428
@ SOUND_PARAM_MORE_QUIET
Definition enums.h:1746
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
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:685
s32 basic_ai_check_player_dist(EnemyDetectVolume *arg0, Enemy *arg1, f32 arg2, f32 arg3, b8 arg4)
Definition 23680.c:429
Npc * wPartnerNpc
Definition partners.c:43
s16 collisionHeight
Vec3f pos
PlayerStatus * gPlayerStatusPtr
PartnerStatus gPartnerStatus
Definition partners.c:42
PlayerData gPlayerData
Definition 77480.c:40

◆ ClubbaNappingAI_WakeUp()

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

Definition at line 93 of file ClubbaNappingAI.inc.c.

93 {
94 Enemy* enemy = script->owner1.enemy;
95 Npc* npc = get_npc_unsafe(enemy->npcID);
96
97 npc->duration--;
98 if (npc->duration <= 0) {
99 npc->duration = 1;
100 enemy->AI_VAR_NEXT_STATE = AI_RETURN_HOME_INIT;
101 script->AI_TEMP_STATE = AI_STATE_NAPPING_CLUBBA_LOITER_INIT;
102 }
103}
@ AI_RETURN_HOME_INIT
Definition enums.h:4596

◆ ClubbaNappingAI_LoiterInit()

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

Definition at line 105 of file ClubbaNappingAI.inc.c.

105 {
106 Enemy* enemy = script->owner1.enemy;
107 Npc* npc = get_npc_unsafe(enemy->npcID);
108
109 npc->yaw = clamp_angle((npc->yaw + rand_int(180)) - 90.0f);
111 script->functionTemp[1] = (rand_int(1000) % 2) + 2; // chose random number 2-3
112 script->AI_TEMP_STATE = AI_STATE_NAPPING_CLUBBA_LOITER;
113}
#define rand_int
#define clamp_angle
@ ENEMY_ANIM_INDEX_IDLE
Definition enums.h:3426

◆ ClubbaNappingAI_Loiter()

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

Definition at line 115 of file ClubbaNappingAI.inc.c.

115 {
116 Enemy* enemy = script->owner1.enemy;
117 Npc* npc = get_npc_unsafe(enemy->npcID);
118 s32 nextState;
119
120 // try to catch sight of player
121 if (basic_ai_check_player_dist(territory, enemy, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, 0)) {
122 npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
123 script->AI_TEMP_STATE = AI_STATE_CHASE_INIT;
124 return;
125 }
126
127 npc->duration--;
128 if (npc->duration <= 0) {
129 // try to turn around and check the other direction
130 script->functionTemp[1]--;
131 if (script->functionTemp[1] > 0) {
132 npc->yaw = clamp_angle(npc->yaw + 180.0f);
133 npc->duration = aiSettings->waitTime / 2 + rand_int(aiSettings->waitTime / 2 + 1);
134 return;
135 }
136
137 // didnt see player, continue to next state
138 nextState = enemy->AI_VAR_NEXT_STATE;
139 if (nextState == AI_RETURN_HOME_INIT) {
140 npc->duration = 20;
141 script->AI_TEMP_STATE = nextState;
142 } else if (nextState == AI_STATE_NAPPING_CLUBBA_50) {
143 npc->duration = 25;
144 script->AI_TEMP_STATE = nextState;
145 }
146 }
147}
#define atan2
@ AI_STATE_CHASE_INIT
Definition enums.h:4592
s32 waitTime
Definition npc.h:95
f32 chaseRadius
Definition npc.h:102
f32 chaseOffsetDist
Definition npc.h:103

◆ ClubbaNappingAI_ReturnHomeInit()

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

Definition at line 149 of file ClubbaNappingAI.inc.c.

149 {
150 Enemy* enemy = script->owner1.enemy;
151 Npc* npc = get_npc_unsafe(enemy->npcID);
152
153 npc->duration--;
154 if (npc->duration <= 0) {
156 if (enemy->territory->wander.moveSpeedOverride < 0) {
157 npc->moveSpeed = aiSettings->moveSpeed;
158 } else {
159 npc->moveSpeed = enemy->territory->wander.moveSpeedOverride / 32767.0;
160 }
161 script->AI_TEMP_STATE = AI_RETURN_HOME;
162 }
163}
@ ENEMY_ANIM_INDEX_WALK
Definition enums.h:3427
@ AI_RETURN_HOME
Definition enums.h:4597
f32 moveSpeed
Definition npc.h:93
s32 moveSpeedOverride
Definition npc.h:213
EnemyTerritoryWander wander
Definition npc.h:232
EnemyTerritory * territory
Definition npc.h:342
f32 moveSpeed

◆ ClubbaNappingAI_ReturnHome()

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

Definition at line 165 of file ClubbaNappingAI.inc.c.

165 {
166 Enemy* enemy = script->owner1.enemy;
167 Npc* npc = get_npc_unsafe(enemy->npcID);
168 f32 currentYaw;
169
170 if (basic_ai_check_player_dist(territory, enemy, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, 0)) {
171 npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
172 script->AI_TEMP_STATE = AI_STATE_CHASE_INIT;
173 } else if (dist2D(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x,
174 enemy->territory->wander.centerPos.z) <= npc->moveSpeed) {
176 npc->duration = 15;
177 enemy->AI_VAR_NEXT_STATE = AI_STATE_NAPPING_CLUBBA_50;
178 script->AI_TEMP_STATE = AI_STATE_NAPPING_CLUBBA_LOITER_INIT;
179 } else if (npc->turnAroundYawAdjustment == 0) {
180 currentYaw = npc->yaw;
181 ai_check_fwd_collisions(npc, 5.0f, &currentYaw, 0, 0, 0);
182 npc->yaw = currentYaw;
183 npc->yaw = atan2(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z);
184 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
185 }
186}
s32 ai_check_fwd_collisions(Npc *npc, f32 arg1, f32 *arg2, f32 *arg3, f32 *arg4, f32 *arg5)
Definition 25AF0.c:22
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:986
s16 turnAroundYawAdjustment

◆ ClubbaNappingAI_FallAsleep()

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

Definition at line 188 of file ClubbaNappingAI.inc.c.

188 {
189 Enemy* enemy = script->owner1.enemy;
190 Npc* npc = get_npc_unsafe(enemy->npcID);
191
192 if (npc->turnAroundYawAdjustment == 0) {
193 npc->duration--;
194 if (npc->duration <= 0) {
195 npc->duration = 0;
196 script->AI_TEMP_STATE = AI_STATE_NAPPING_CLUBBA_INIT;
197 }
198 }
199}