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

Go to the source code of this file.

Macros

#define AI_LAKITU_FIRST_SPINY_ID   0
 
#define AI_LAKITU_LAST_SPINY_ID   0
 

Functions

s32 N LakituAI_GetAvailableSpiny (void)
 
void N LakituAI_Wander (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N LakituAI_Loiter (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 

Macro Definition Documentation

◆ AI_LAKITU_FIRST_SPINY_ID

#define AI_LAKITU_FIRST_SPINY_ID   0

Definition at line 8 of file LakituAI.inc.c.

Referenced by LakituAI_GetAvailableSpiny().

◆ AI_LAKITU_LAST_SPINY_ID

#define AI_LAKITU_LAST_SPINY_ID   0

Definition at line 12 of file LakituAI.inc.c.

Referenced by LakituAI_GetAvailableSpiny().

Function Documentation

◆ LakituAI_GetAvailableSpiny()

s32 N LakituAI_GetAvailableSpiny ( void )

Definition at line 18 of file LakituAI.inc.c.

18 {
19 s32 npcID;
20
21 for (npcID = AI_LAKITU_FIRST_SPINY_ID; npcID <= AI_LAKITU_LAST_SPINY_ID; npcID++) {
22 if (get_enemy(npcID)->varTable[10] == 0) {
23 return npcID;
24 }
25 }
26
27 return -1;
28}
#define AI_LAKITU_LAST_SPINY_ID
#define AI_LAKITU_FIRST_SPINY_ID
Definition LakituAI.inc.c:8
Enemy * get_enemy(s32 npcID)
Looks for an enemy matching the specified npcID.
Definition npc.c:2540

◆ LakituAI_Wander()

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

Definition at line 30 of file LakituAI.inc.c.

30 {
31 Enemy* enemy = script->owner1.enemy;
32 Npc* npc = get_npc_unsafe(enemy->npcID);
33 f32 x, y, z, w;
34 EffectInstance* emoteTemp;
35 f32 temp_f20;
36 f32 temp_f22;
37 f32 temp_f24;
38 f32 var1 = enemy->varTable[4];
39 f32 var2 = enemy->varTable[3];
40 f32 var3;
41
42 temp_f22 = var1 / 100.0;
43 temp_f24 = var2 / 100.0;
44 if (npc->duration > 0) {
45 npc->duration--;
46 }
47 var3 = enemy->varTable[1];
48 temp_f20 = var3 / 100.0;
49
50 x = npc->pos.x;
51 y = npc->pos.y;
52 z = npc->pos.z;
53 w = 1000.0f;
54
55 npc_raycast_down_sides(npc->collisionChannel, &x, &y, &z, &w);
56 npc->pos.y = y + temp_f24 + (sin_deg(enemy->varTable[2]) * temp_f20);
57 enemy->varTable[2] = clamp_angle(enemy->varTable[2] + 12);
58
59 if (aiSettings->playerSearchInterval >= 0) {
60 if (script->functionTemp[1] <= 0) {
61 script->functionTemp[1] = aiSettings->playerSearchInterval;
62 if (basic_ai_check_player_dist(territory, enemy, aiSettings->alertRadius, aiSettings->alertOffsetDist, 0) != 0) {
63 fx_emote(EMOTE_EXCLAMATION, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 15, &emoteTemp);
65 x = npc->pos.x;
66 y = npc->pos.y;
67 z = npc->pos.z;
68 w = 1000.0f;
69 npc_raycast_down_sides(npc->collisionChannel, &x, &y, &z, &w);
70 npc->moveToPos.y = y + temp_f24;
71 script->functionTemp[0] = 12;
72 return;
73 }
74 }
75 script->functionTemp[1]--;
76 }
77
79 enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z, enemy->territory->wander.wanderSize.x,
80 enemy->territory->wander.wanderSize.z) != 0) {
81 npc->yaw = atan2(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z);
82 }
83
84 if (npc->turnAroundYawAdjustment == 0) {
85 if (npc->duration > 0) {
86 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
87 if (enemy->varTable[0] & 1) {
88 x = npc->pos.x;
89 y = temp_f22;
90 z = npc->pos.z;
91 w = 1000.0f;
92 npc_raycast_down_sides(npc->collisionChannel, &x, &y, &z, &w);
93 y += temp_f24;
94 w = y - temp_f22;
95 if (w > 2.0) {
96 temp_f22 += 2.0;
97 } else if (w < -2.0) {
98 temp_f22 -= 2.0;
99 } else {
100 temp_f22 = y;
101 }
102 enemy->varTable[4] = (temp_f22 * 100.0);
103 }
104 if (npc->duration > 0) {
105 return;
106 }
107 }
108 script->functionTemp[0] = 2;
109 script->functionTemp[1] = (rand_int(1000) % 3) + 2;
110 if ((aiSettings->unk_AI_2C <= 0) || (aiSettings->moveTime <= 0) || (script->functionTemp[1] == 0)) {
111 script->functionTemp[0] = 0;
112 }
113 }
114}
union Evt::@8 owner1
Initially -1.
#define npc_raycast_down_sides
#define sin_deg
#define rand_int
#define clamp_angle
#define atan2
@ EMOTE_EXCLAMATION
Definition enums.h:495
@ SOUND_AI_ALERT_A
Definition enums.h:1078
@ SOUND_PARAM_MORE_QUIET
Definition enums.h:1746
b32 is_point_outside_territory(s32 shape, f32 centerX, f32 centerZ, f32 pointX, f32 pointZ, f32 sizeX, f32 sizeZ)
Definition 23680.c:412
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 moveTime
Definition npc.h:94
s16 npcID
Definition npc.h:300
VecXZi wanderSize
Definition npc.h:212
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
f32 alertOffsetDist
Definition npc.h:97
s32 playerSearchInterval
Definition npc.h:98
f32 alertRadius
Definition npc.h:96
enum TerritoryShape wanderShape
Definition npc.h:214
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:986
s32 unk_AI_2C
Definition npc.h:104
EnemyTerritoryWander wander
Definition npc.h:232
EnemyTerritory * territory
Definition npc.h:342
Definition npc.h:294
Vec3f moveToPos
s32 collisionChannel
s16 collisionHeight
s16 turnAroundYawAdjustment
Vec3f pos
f32 moveSpeed
s16 duration

◆ LakituAI_Loiter()

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

Definition at line 116 of file LakituAI.inc.c.

116 {
117 Enemy* enemy = script->owner1.enemy;
118 Npc* npc = get_npc_unsafe(enemy->npcID);
119 f32 posX, posY, posZ, hitDepth;
120 EffectInstance* emoteTemp;
121 f32 var1 = enemy->varTable[3];
122 f32 var2;
123 f32 temp_f20;
124 f32 temp_f22;
125
126 temp_f22 = var1 / 100.0;
127 if (npc->duration > 0) {
128 npc->duration--;
129 }
130 var2 = enemy->varTable[1];
131 temp_f20 = var2 / 100.0;
132
133 posX = npc->pos.x;
134 posY = npc->pos.y;
135 posZ = npc->pos.z;
136 hitDepth = 1000.0f;
137
138 npc_raycast_down_sides(npc->collisionChannel, &posX, &posY, &posZ, &hitDepth);
139 npc->pos.y = posY + temp_f22 + (sin_deg(enemy->varTable[2]) * temp_f20);
140 enemy->varTable[2] = clamp_angle(enemy->varTable[2] + 12);
141 if (basic_ai_check_player_dist(territory, enemy, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, 1) != 0) {
142 fx_emote(EMOTE_EXCLAMATION, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 15, &emoteTemp);
144 script->AI_TEMP_STATE = AI_STATE_CHASE_INIT;
145 return;
146 }
147
148 if ((npc->turnAroundYawAdjustment == 0) && (npc->duration <= 0)) {
149 script->functionTemp[1]--;
150 if (script->functionTemp[1] > 0) {
151 npc->yaw = clamp_angle(npc->yaw + 180.0f);
152 npc->duration = (rand_int(1000) % 11) + 5;
153 return;
154 }
155 script->AI_TEMP_STATE = AI_STATE_WANDER_INIT;
156 }
157}
@ AI_STATE_WANDER_INIT
Definition enums.h:4581
@ AI_STATE_CHASE_INIT
Definition enums.h:4592
f32 chaseRadius
Definition npc.h:102
f32 chaseOffsetDist
Definition npc.h:103