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

Go to the source code of this file.

Functions

void N FlyingNoAttackAI_12 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N FlyingNoAttackAI_13 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void N FlyingNoAttackAI_20 (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 

Function Documentation

◆ FlyingNoAttackAI_12()

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

Definition at line 10 of file FlyingNoAttackAI.inc.c.

10 {
11 Enemy* enemy = script->owner1.enemy;
12 Npc* npc = get_npc_unsafe(enemy->npcID);
13 f32 tempAngle;
14 f32 angleDiff;
15
16 npc->duration = (aiSettings->chaseUpdateInterval / 2) + rand_int(aiSettings->chaseUpdateInterval / 2 + 1);
18 npc->moveSpeed = aiSettings->chaseSpeed;
19
20 tempAngle = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
21 angleDiff = get_clamped_angle_diff(npc->yaw, tempAngle);
22
23 if (aiSettings->chaseTurnRate < fabsf(angleDiff)) {
24 tempAngle = npc->yaw;
25
26 if (angleDiff < 0.0f) {
27 tempAngle += -aiSettings->chaseTurnRate;
28 } else {
29 tempAngle += aiSettings->chaseTurnRate;
30 }
31 }
32
33 npc->yaw = clamp_angle(tempAngle);
34 script->functionTemp[0] = 13;
35}
union Evt::@8 owner1
Initially -1.
#define rand_int
#define clamp_angle
#define atan2
@ ENEMY_ANIM_INDEX_CHASE
Definition enums.h:3429
f32 fabsf(f32 f)
f32 get_clamped_angle_diff(f32, f32)
Definition 43F0.c:606
f32 chaseSpeed
Definition npc.h:99
s32 chaseTurnRate
Definition npc.h:100
s32 chaseUpdateInterval
Definition npc.h:101
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
Vec3f pos
f32 moveSpeed
s16 duration
PlayerStatus * gPlayerStatusPtr

◆ FlyingNoAttackAI_13()

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

Definition at line 37 of file FlyingNoAttackAI.inc.c.

37 {
38 Enemy* enemy = script->owner1.enemy;
39 Npc* npc = get_npc_unsafe(enemy->npcID);
40 f32 x, y, z, w;
41 EffectInstance* var;
42 s32 flag;
43 f32 temp_f6;
44
45 if (basic_ai_check_player_dist(territory, enemy, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, 1) == 0) {
46 fx_emote(EMOTE_QUESTION, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 0xF, &var);
48 npc->duration = 30;
49 script->functionTemp[0] = 20;
50 enemy->varTable[9] = 30;
51 return;
52 }
53
54 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
55 flag = 0;
56 if (!(npc->flags & NPC_FLAG_FLYING)) {
57 x = npc->pos.x;
58 y = npc->pos.y + npc->collisionHeight;
59 z = npc->pos.z;
60 w = npc->collisionHeight + 3.0;
61 if ((npc_raycast_down_sides(npc->collisionChannel, &x, &y, &z, &w) != 0) && (w < npc->collisionHeight)) {
62 flag = 1;
63 }
64 }
65
66 if (flag) {
67 npc->pos.y = y + 1.0;
68 } else {
69 temp_f6 = npc->pos.y - (gPlayerStatusPtr->pos.y + 6.0);
70 if ((temp_f6 < 0.0) || (temp_f6 > 4.0)) {
71 temp_f6 = -temp_f6;
72 npc->pos.y += temp_f6 * 0.06;
73 }
74 }
75 if (npc->duration > 0) {
76 npc->duration--;
77 return;
78 }
79 script->functionTemp[0] = 12;
80}
#define npc_raycast_down_sides
@ EMOTE_QUESTION
Definition enums.h:497
@ ENEMY_ANIM_INDEX_IDLE
Definition enums.h:3426
@ NPC_FLAG_FLYING
Definition enums.h:3001
s32 basic_ai_check_player_dist(EnemyDetectVolume *arg0, Enemy *arg1, f32 arg2, f32 arg3, b8 arg4)
Definition 23680.c:429
f32 chaseRadius
Definition npc.h:102
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:986
f32 chaseOffsetDist
Definition npc.h:103
s32 flags
s32 collisionChannel
s16 collisionHeight

◆ FlyingNoAttackAI_20()

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

Definition at line 82 of file FlyingNoAttackAI.inc.c.

82 {
83 Enemy* enemy = script->owner1.enemy;
84 Npc* npc = get_npc_unsafe(enemy->npcID);
85
86 npc->duration--;
87 if (npc->duration <= 0) {
88 enemy->varTable[2] = 0;
89 npc->duration = 0;
90 script->functionTemp[0] = 0;
91 }
92}