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

Go to the source code of this file.

Enumerations

enum  AiStateCleft {
  AI_STATE_CLEFT_HIDING_INIT = 0 , AI_STATE_CLEFT_HIDING = 1 , AI_STATE_CLEFT_PRE_AMBUSH = 2 , AI_STATE_CLEFT_AMBUSH = 3 ,
  AI_STATE_CLEFT_FIND_PLAYER_INIT = 4 , AI_STATE_CLEFT_FIND_PLAYER = 5 , AI_STATE_CLEFT_CHASE_INIT = 12 , AI_STATE_CLEFT_CHASE = 13 ,
  AI_STATE_CLEFT_CHASE_COOLDOWN = 14 , AI_STATE_CLEFT_REV_UP_INIT = 20 , AI_STATE_CLEFT_REV_UP = 21 , AI_STATE_CLEFT_TACKLE = 22 ,
  AI_STATE_CLEFT_LOSE_PLAYER = 40 , AI_STATE_RETURN_HOME = 41 , AI_STATE_CLEFT_DISGUISE_INIT = 50 , AI_STATE_CLEFT_DISGUISE = 51 ,
  AI_STATE_CLEFT_POST_DISGUISE = 52
}
 

Functions

s32 N CleftAI_CanSeePlayer (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_HidingInit (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_Hiding (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_PreAmbush (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_Ambush (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_FindPlayerInit (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_FindPlayer (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_RevUpInit (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_RevUp (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_Tackle (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_LosePlayer (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_ReturnHome (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_DisguiseInit (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_Disguise (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 
void N CleftAI_PostDisguise (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *volume)
 

Enumeration Type Documentation

◆ AiStateCleft

Enumerator
AI_STATE_CLEFT_HIDING_INIT 
AI_STATE_CLEFT_HIDING 
AI_STATE_CLEFT_PRE_AMBUSH 
AI_STATE_CLEFT_AMBUSH 
AI_STATE_CLEFT_FIND_PLAYER_INIT 
AI_STATE_CLEFT_FIND_PLAYER 
AI_STATE_CLEFT_CHASE_INIT 
AI_STATE_CLEFT_CHASE 
AI_STATE_CLEFT_CHASE_COOLDOWN 
AI_STATE_CLEFT_REV_UP_INIT 
AI_STATE_CLEFT_REV_UP 
AI_STATE_CLEFT_TACKLE 
AI_STATE_CLEFT_LOSE_PLAYER 
AI_STATE_RETURN_HOME 
AI_STATE_CLEFT_DISGUISE_INIT 
AI_STATE_CLEFT_DISGUISE 
AI_STATE_CLEFT_POST_DISGUISE 

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

5 {
23};
@ AI_STATE_RETURN_HOME
Definition CleftAI.inc.c:19
@ AI_STATE_CLEFT_TACKLE
Definition CleftAI.inc.c:17
@ AI_STATE_CLEFT_FIND_PLAYER_INIT
Definition CleftAI.inc.c:10
@ AI_STATE_CLEFT_DISGUISE_INIT
Definition CleftAI.inc.c:20
@ AI_STATE_CLEFT_AMBUSH
Definition CleftAI.inc.c:9
@ AI_STATE_CLEFT_HIDING_INIT
Definition CleftAI.inc.c:6
@ AI_STATE_CLEFT_REV_UP_INIT
Definition CleftAI.inc.c:15
@ AI_STATE_CLEFT_CHASE
Definition CleftAI.inc.c:13
@ AI_STATE_CLEFT_DISGUISE
Definition CleftAI.inc.c:21
@ AI_STATE_CLEFT_CHASE_COOLDOWN
Definition CleftAI.inc.c:14
@ AI_STATE_CLEFT_HIDING
Definition CleftAI.inc.c:7
@ AI_STATE_CLEFT_PRE_AMBUSH
Definition CleftAI.inc.c:8
@ AI_STATE_CLEFT_CHASE_INIT
Definition CleftAI.inc.c:12
@ AI_STATE_CLEFT_REV_UP
Definition CleftAI.inc.c:16
@ AI_STATE_CLEFT_FIND_PLAYER
Definition CleftAI.inc.c:11
@ AI_STATE_CLEFT_POST_DISGUISE
Definition CleftAI.inc.c:22
@ AI_STATE_CLEFT_LOSE_PLAYER
Definition CleftAI.inc.c:18

Function Documentation

◆ CleftAI_CanSeePlayer()

s32 N CleftAI_CanSeePlayer ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 25 of file CleftAI.inc.c.

25 {
26 Enemy* enemy = script->owner1.enemy;
27 Npc* npc = get_npc_unsafe(enemy->npcID);
28 Camera* camera = &gCameras[gCurrentCamID];
29 f32 playerX, playerZ;
30 f32 angle;
31 s32 seesPlayer = FALSE;
32
33 if (ai_check_player_dist(enemy, 0, aiSettings->alertRadius, aiSettings->alertOffsetDist)) {
34 seesPlayer = TRUE;
35 }
36 if (clamp_angle(get_clamped_angle_diff(camera->curYaw, npc->yaw)) < 180.0) {
37 angle = 90.0f;
38 } else {
39 angle = 270.0f;
40 }
41
42 playerX = gPlayerStatusPtr->pos.x;
43 playerZ = gPlayerStatusPtr->pos.z;
44 if (fabsf(get_clamped_angle_diff(angle, atan2(npc->pos.x, npc->pos.z, playerX, playerZ))) > 75.0) {
45 seesPlayer = FALSE;
46 }
47 if (fabsf(npc->pos.y - gPlayerStatusPtr->pos.y) >= 40.0f) {
48 seesPlayer = FALSE;
49 }
51 seesPlayer = FALSE;
52 }
53 return seesPlayer;
54}
union Evt::@8 owner1
Initially -1.
#define clamp_angle
#define atan2
@ PARTNER_BOW
Definition enums.h:2894
f32 fabsf(f32 f)
s32 ai_check_player_dist(Enemy *enemy, s32 arg1, f32 arg2, f32 arg3)
Definition 23680.c:515
f32 get_clamped_angle_diff(f32, f32)
Definition 43F0.c:606
s16 npcID
Definition npc.h:300
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
f32 alertOffsetDist
Definition npc.h:97
f32 alertRadius
Definition npc.h:96
Definition npc.h:294
Vec3f pos
PlayerStatus * gPlayerStatusPtr
PartnerStatus gPartnerStatus
Definition partners.c:42
Camera gCameras[4]
Definition cam_main.c:17
s16 gCurrentCamID
Definition cam_main.c:13

◆ CleftAI_HidingInit()

void N CleftAI_HidingInit ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 56 of file CleftAI.inc.c.

56 {
57 Enemy* enemy = script->owner1.enemy;
58 Npc* npc = get_npc_unsafe(enemy->npcID);
59
61 npc->collisionHeight = 22;
62 npc->collisionDiameter = 24;
63 script->functionTemp[1] = 0;
64 npc->duration = 0;
65 npc->curAnim = enemy->animList[8];
66 script->AI_TEMP_STATE = AI_STATE_CLEFT_HIDING;
67}
s32 * animList
Definition npc.h:341
void disable_npc_shadow(Npc *npc)
Definition npc.c:1037
s16 collisionDiameter
AnimID curAnim
s16 collisionHeight
s16 duration

◆ CleftAI_Hiding()

void N CleftAI_Hiding ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 69 of file CleftAI.inc.c.

69 {
70 Enemy* enemy = script->owner1.enemy;
71 Npc* npc = get_npc_unsafe(enemy->npcID);
72 EffectInstance* emoteTemp;
73
74 if (script->functionTemp[1] <= 0) {
75 script->functionTemp[1] = aiSettings->playerSearchInterval;
76 if (basic_ai_check_player_dist(volume, enemy, aiSettings->alertRadius * 0.85, aiSettings->alertOffsetDist, FALSE)) {
77 npc->curAnim = enemy->animList[9];
78 fx_emote(EMOTE_EXCLAMATION, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 15, &emoteTemp);
80 npc->duration = 12;
81 script->AI_TEMP_STATE = AI_STATE_CLEFT_PRE_AMBUSH;
82 }
83 }
84
85 script->functionTemp[1]--;
86}
@ EMOTE_EXCLAMATION
Definition enums.h:495
@ SOUND_AI_ALERT_A
Definition enums.h:1078
@ SOUND_PARAM_MORE_QUIET
Definition enums.h:1746
void ai_enemy_play_sound(Npc *npc, s32 arg1, s32 arg2)
Definition 23680.c:543
s32 basic_ai_check_player_dist(EnemyDetectVolume *arg0, Enemy *arg1, f32 arg2, f32 arg3, b8 arg4)
Definition 23680.c:429
s32 playerSearchInterval
Definition npc.h:98

◆ CleftAI_PreAmbush()

void N CleftAI_PreAmbush ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 88 of file CleftAI.inc.c.

88 {
89 Enemy* enemy = script->owner1.enemy;
90 Npc* npc = get_npc_unsafe(enemy->npcID);
91
92 npc->duration--;
93 if (npc->duration <= 0) {
94 npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
96 npc->curAnim = enemy->animList[10];
97 npc->duration = 8;
98 script->AI_TEMP_STATE = AI_STATE_CLEFT_AMBUSH;
99 }
100}
void enable_npc_shadow(Npc *npc)
Definition npc.c:1027

◆ CleftAI_Ambush()

void N CleftAI_Ambush ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 102 of file CleftAI.inc.c.

102 {
103 Npc* npc = get_npc_unsafe(script->owner1.enemy->npcID);
104
105 npc->duration--;
106 if (npc->duration <= 0) {
107 npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
108 npc->collisionHeight = 26;
109 npc->collisionDiameter = 24;
110 script->AI_TEMP_STATE = AI_STATE_CLEFT_FIND_PLAYER_INIT;
111 }
112}

◆ CleftAI_FindPlayerInit()

void N CleftAI_FindPlayerInit ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 114 of file CleftAI.inc.c.

114 {
115 Enemy* enemy = script->owner1.enemy;
116 Npc* npc = get_npc_unsafe(enemy->npcID);
117
118 npc->yaw = clamp_angle(npc->yaw + rand_int(180) - 90.0f);
120 script->functionTemp[1] = rand_int(1000) % 2 + 2;
121 script->AI_TEMP_STATE = AI_STATE_CLEFT_FIND_PLAYER;
122}
#define rand_int
@ ENEMY_ANIM_INDEX_IDLE
Definition enums.h:3426

◆ CleftAI_FindPlayer()

void N CleftAI_FindPlayer ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 124 of file CleftAI.inc.c.

124 {
125 Enemy* enemy = script->owner1.enemy;
126 Npc* npc = get_npc_unsafe(enemy->npcID);
127 EffectInstance* var;
128
129 if (basic_ai_check_player_dist(volume, enemy, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, 0)) {
130 npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
131 script->AI_TEMP_STATE = AI_STATE_CLEFT_CHASE_INIT;
132 } else {
133 npc->duration--;
134 if (npc->duration <= 0) {
135 script->functionTemp[1]--;
136 if (script->functionTemp[1] > 0) {
137 npc->yaw = clamp_angle(npc->yaw + 180.0f);
138 npc->duration = aiSettings->waitTime / 2 + rand_int(aiSettings->waitTime / 2 + 1);
139 } else {
140 fx_emote(EMOTE_QUESTION, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 12, &var);
141 npc->duration = 15;
142 script->AI_TEMP_STATE = AI_STATE_CLEFT_LOSE_PLAYER;
143 }
144 }
145 }
146}
@ EMOTE_QUESTION
Definition enums.h:497
s32 waitTime
Definition npc.h:95
f32 chaseRadius
Definition npc.h:102
f32 chaseOffsetDist
Definition npc.h:103

◆ CleftAI_RevUpInit()

void N CleftAI_RevUpInit ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 148 of file CleftAI.inc.c.

148 {
149 Enemy* enemy = script->owner1.enemy;
150 Npc* npc = get_npc_unsafe(enemy->npcID);
151
152 npc->duration = enemy->varTable[10];
153 npc->curAnim = enemy->animList[13];
154 script->AI_TEMP_STATE = AI_STATE_CLEFT_REV_UP;
155}

◆ CleftAI_RevUp()

void N CleftAI_RevUp ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 157 of file CleftAI.inc.c.

157 {
158 Enemy* enemy = script->owner1.enemy;
159 Npc* npc = get_npc_unsafe(enemy->npcID);
160
161 npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
162 if (npc->duration % 3 == 0) {
163 fx_walking_dust(2, npc->pos.x, npc->pos.y, npc->pos.z + 2.0f, 0, 0);
164 }
165
166 npc->duration--;
167 if (npc->duration <= 0) {
168 enemy->unk_10.x = npc->pos.x;
169 enemy->unk_10.y = npc->pos.y;
170 enemy->unk_10.z = npc->pos.z;
171 enemy->hitboxIsActive = TRUE;
172 npc->moveSpeed = aiSettings->chaseSpeed;
173 npc->duration = dist2D(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x,
174 gPlayerStatusPtr->pos.z) / npc->moveSpeed + 0.9;
175 if (npc->duration < 15) {
176 npc->duration = 15;
177 }
178 script->AI_TEMP_STATE = AI_STATE_CLEFT_TACKLE;
179 }
180}
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
f32 chaseSpeed
Definition npc.h:99
Vec3s unk_10
Definition npc.h:302
s8 hitboxIsActive
Definition npc.h:299
f32 moveSpeed

◆ CleftAI_Tackle()

void N CleftAI_Tackle ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 182 of file CleftAI.inc.c.

182 {
183 Enemy* enemy = script->owner1.enemy;
184 Npc* npc = get_npc_unsafe(enemy->npcID);
185 f32 posX, posY, posZ;
186 s32 phi_s1 = FALSE;
187
189 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
190
193 npc->pos.x, npc->pos.z,
195 phi_s1 = TRUE;
196 }
197
198 posX = npc->pos.x;
199 posY = npc->pos.y;
200 posZ = npc->pos.z;
202 &posX, &posY, &posZ,
203 1.0f, npc->yaw, npc->collisionHeight, npc->collisionDiameter)) {
204 phi_s1 = TRUE;
205 }
206
207 npc->duration--;
208 if (npc->duration <= 0) {
209 phi_s1 = TRUE;
210 }
211 if (phi_s1) {
212 script->AI_TEMP_STATE = AI_STATE_CLEFT_FIND_PLAYER_INIT;
213 enemy->hitboxIsActive = FALSE;
214 }
215}
@ SURFACE_INTERACT_RUN
Definition enums.h:4685
b32 is_point_outside_territory(s32 shape, f32 centerX, f32 centerZ, f32 pointX, f32 pointZ, f32 sizeX, f32 sizeZ)
Definition 23680.c:412
b32 npc_test_move_simple_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
VecXZi detectSize
Definition npc.h:216
enum TerritoryShape detectShape
Definition npc.h:217
void npc_surface_spawn_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:394
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:986
EnemyTerritoryWander wander
Definition npc.h:232
EnemyTerritory * territory
Definition npc.h:342
s32 collisionChannel

◆ CleftAI_LosePlayer()

void N CleftAI_LosePlayer ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 217 of file CleftAI.inc.c.

217 {
218 Enemy* enemy = script->owner1.enemy;
219 Npc* npc = get_npc_unsafe(enemy->npcID);
220
221 npc->duration--;
222 if (npc->duration <= 0) {
224 if (enemy->territory->wander.moveSpeedOverride < 0) {
225 npc->moveSpeed = aiSettings->moveSpeed;
226 } else {
227 npc->moveSpeed = enemy->territory->wander.moveSpeedOverride / 32767.0;
228 }
229 script->AI_TEMP_STATE = AI_STATE_RETURN_HOME;
230 }
231}
@ ENEMY_ANIM_INDEX_WALK
Definition enums.h:3427
f32 moveSpeed
Definition npc.h:93
s32 moveSpeedOverride
Definition npc.h:213

◆ CleftAI_ReturnHome()

void N CleftAI_ReturnHome ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 233 of file CleftAI.inc.c.

233 {
234 Enemy* enemy = script->owner1.enemy;
235 Npc* npc = get_npc_unsafe(enemy->npcID);
236
237 if (basic_ai_check_player_dist(volume, enemy, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, 0)) {
238 npc->yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
239 script->AI_TEMP_STATE = AI_STATE_CLEFT_CHASE_INIT;
240 } else if (dist2D(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z) <= npc->moveSpeed) {
241 npc->duration = 10;
242 script->AI_TEMP_STATE = AI_STATE_CLEFT_DISGUISE_INIT;
243 } else if (npc->turnAroundYawAdjustment == 0) {
244 npc->yaw = atan2(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z);
245 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
246 }
247}
s16 turnAroundYawAdjustment

◆ CleftAI_DisguiseInit()

void N CleftAI_DisguiseInit ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 249 of file CleftAI.inc.c.

249 {
250 Enemy* enemy = script->owner1.enemy;
251 Npc* npc = get_npc_unsafe(enemy->npcID);
252
253 if (npc->duration > 0) {
254 npc->duration--;
255 }
256
257 if (npc->turnAroundYawAdjustment == 0 && npc->duration <= 0) {
258 npc->duration = 8;
259 npc->curAnim = enemy->animList[11];
260 script->AI_TEMP_STATE = AI_STATE_CLEFT_DISGUISE;
261 }
262}

◆ CleftAI_Disguise()

void N CleftAI_Disguise ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 264 of file CleftAI.inc.c.

264 {
265 Enemy* enemy = script->owner1.enemy;
266 Npc* npc = get_npc_unsafe(enemy->npcID);
267
268 npc->duration--;
269 if (npc->duration <= 0) {
270 npc->duration = 8;
271 npc->curAnim = enemy->animList[14];
272 script->AI_TEMP_STATE = AI_STATE_CLEFT_POST_DISGUISE;
273 }
274}

◆ CleftAI_PostDisguise()

void N CleftAI_PostDisguise ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * volume )

Definition at line 276 of file CleftAI.inc.c.

276 {
277 Enemy* enemy = script->owner1.enemy;
278 Npc* npc = get_npc_unsafe(enemy->npcID);
279
280 npc->duration--;
281 if (npc->duration <= 0) {
282 script->AI_TEMP_STATE = AI_STATE_CLEFT_HIDING_INIT;
283 }
284}