8#define _AI_FLYING_INC_ 0
14f32 N(FlyingAI_JumpVels)[] = {
15 4.5, 3.5, 2.6, 2.0, 1.5, 20.0,
19 Enemy* enemy = script->owner1.enemy;
22 npc->
duration = aiSettings->moveTime / 2 +
rand_int(aiSettings->moveTime / 2 + 1);
32 script->functionTemp[1] = 0;
38 enemy->varTable[4] = npc->
pos.
y * 100.0;
43 Enemy* enemy = script->owner1.enemy;
46 f32 vt7 = (f32)enemy->varTable[7] / 100.0;
47 f32 vt3 = (f32)enemy->varTable[3] / 100.0;
48 f32 vt4 = (f32)enemy->varTable[4] / 100.0;
49 f32 vt1 = (f32)enemy->varTable[1] / 100.0;
50 f32 posX, posY, posZ, posW;
53 enemy->varTable[4] = npc->
pos.
y * 100.0;
57 if ((enemy->varTable[0] & 0x11) == 1) {
59 if (vt1 < temp_f24 - npc->
pos.
y) {
60 enemy->varTable[0] |= 0x10;
68 if (vt1 < (vt3 - posW)) {
69 enemy->varTable[0] |= 0x10;
74 if ((enemy->varTable[0] & 0x11) == 0x11) {
80 test = vt4 + ((temp_f24 - vt4) * 0.09);
91 test = vt4 + ((yTemp - vt4) * 0.09);
97 enemy->varTable[0] &= ~0x10;
100 if (enemy->varTable[1] > 0) {
101 f32 sinTemp =
sin_deg(enemy->varTable[2]);
115 npc->
pos.
y = posY + vt3 + (sinTemp * vt1);
117 npc->
pos.
y = temp_f24 + (sinTemp * vt1);
120 enemy->varTable[2] =
clamp_angle(enemy->varTable[2] + 10);
124 if (enemy->varTable[9] <= 0) {
125 if (aiSettings->playerSearchInterval >= 0) {
126 if (script->functionTemp[1] <= 0) {
127 script->functionTemp[1] = aiSettings->playerSearchInterval;
144 script->functionTemp[1]--;
147 enemy->varTable[9]--;
169 enemy->varTable[4] = npc->
pos.
y * 100.0;
170 if (aiSettings->moveTime > 0) {
173 script->functionTemp[1] = (
rand_int(1000) % 3) + 2;
174 if (aiSettings->unk_AI_2C <= 0 || aiSettings->waitTime <= 0 || script->functionTemp[1] < 3) {
182 Enemy* enemy = script->owner1.enemy;
185 npc->
duration = (aiSettings->waitTime / 2) +
rand_int((aiSettings->waitTime / 2) + 1);
188 script->functionTemp[0] = 3;
192 Enemy* enemy = script->owner1.enemy;
194 f32 posX, posY, posZ, posW;
195 f32 hoverHeight = (f32)enemy->varTable[3] / 100.0;
196 f32 temp_f26 = hoverHeight + (f32)((f32)enemy->varTable[7] / 100.0);
203 if (enemy->varTable[1] > 0) {
204 f32 undulateAmplitude = (f32)enemy->varTable[1] / 100.0;
205 f32 undulateAmount =
sin_deg(enemy->varTable[2]);
209 hasCollision = FALSE;
219 npc->
pos.
y = posY + hoverHeight + (undulateAmount * undulateAmplitude);
221 npc->
pos.
y = temp_f26 + (undulateAmount * undulateAmplitude);
224 enemy->varTable[2] =
clamp_angle(enemy->varTable[2] + 10);
227 if (enemy->varTable[9] <= 0) {
241 enemy->varTable[9]--;
245 script->functionTemp[1]--;
246 if (script->functionTemp[1] > 0) {
258 Enemy* enemy = script->owner1.enemy;
269 Enemy* enemy = script->owner1.enemy;
279 Enemy* enemy = script->owner1.enemy;
281 f32 jumpVel = (f32)enemy->varTable[5] / 100.0;
282 f32 jumpScale = (f32)enemy->varTable[6] / 100.0;
290 enemy->varTable[2] = 0;
317 Enemy* enemy = script->owner1.enemy;
319 f32 posX, posY, posZ, posW;
326 f32 a = enemy->varTable[3];
327 f32 b = enemy->varTable[7];
330 temp_f20 = a / 100.0;
331 temp_f22 = b / 100.0;
348 temp_f2 = posY + temp_f20;
349 if (temp_f2 <= npc->
pos.
y) {
350 npc->
pos.
y = temp_f2;
351 script->functionTemp[0] = 0;
354 script->functionTemp[0] = 0;
356 }
else if (npc->
jumpVel < 0.0) {
358 if (npc->
duration >= aiSettings->chaseUpdateInterval) {
362 if (aiSettings->chaseTurnRate <
fabsf(deltaAngle)) {
364 if (deltaAngle < 0.0f) {
365 angle += -aiSettings->chaseTurnRate;
367 angle += aiSettings->chaseTurnRate;
375 npc->
pos.
y = temp_f22;
404 f32 posX, posY, posZ, depth;
406 script->functionTemp[0] = 0;
409 npc->flags &= ~NPC_FLAG_GRAVITY;
411 if (enemy->territory->wander.isFlying) {
414 npc->flags &= ~NPC_FLAG_FLYING;
422 enemy->varTable[2] = 0;
423 enemy->varTable[9] = 0;
424 enemy->varTable[3] = (depth * 100.0) + 0.5;
425 enemy->varTable[7] = (posY * 100.0) + 0.5;
426 script->functionTemp[1] = aiSettings->playerSearchInterval;
430API_CALLABLE(N(FlyingAI_Main)) {
431 Enemy* enemy = script->owner1.enemy;
432 Bytecode* args = script->ptrReadPos;
457 enemy->
aiFlags &= ~AI_FLAG_SUSPEND;
460 switch (script->AI_TEMP_STATE) {
void N FlyingAI_ChaseInit(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_LoiterInit(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_Loiter(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_Jump(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_Wander(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_JumpInit(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_Init(Npc *npc, Enemy *enemy, Evt *script, MobileAISettings *aiSettings)
void N FlyingAI_WanderInit(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_Chase(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N FlyingAI_LosePlayer(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
#define npc_raycast_down_sides
@ ENEMY_ANIM_INDEX_MELEE_PRE
@ ENEMY_ANIM_INDEX_MELEE_HIT
@ AI_FLAG_SKIP_IDLE_ANIM_AFTER_FLEE
@ AI_ACTION_LOOK_AROUND_DURING_LOITER
@ AI_ACTION_JUMP_WHEN_SEE_PLAYER
s32 evt_get_variable(Evt *script, Bytecode var)
b32 is_point_outside_territory(s32 shape, f32 centerX, f32 centerZ, f32 pointX, f32 pointZ, f32 sizeX, f32 sizeZ)
void ai_enemy_play_sound(Npc *npc, s32 arg1, s32 arg2)
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
f32 get_clamped_angle_diff(f32, f32)
enum TerritoryShape shape
enum TerritoryShape detectShape
s32 basic_ai_check_player_dist(EnemyDetectVolume *arg0, Enemy *arg1, f32 arg2, f32 arg3, b8 arg4)
Npc * get_npc_unsafe(s32 npcID)
NpcSettings * npcSettings
enum TerritoryShape wanderShape
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
s32 skipPlayerDetectChance
EnemyTerritoryWander wander
EnemyTerritory * territory
s16 turnAroundYawAdjustment
PlayerStatus * gPlayerStatusPtr