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

Go to the source code of this file.

Functions

s32 N MagikoopaAI_CanShootSpell (Evt *script, f32 arg1, f32 arg2, EnemyDetectVolume *territory)
 

Function Documentation

◆ MagikoopaAI_CanShootSpell()

s32 N MagikoopaAI_CanShootSpell ( Evt * script,
f32 arg1,
f32 arg2,
EnemyDetectVolume * territory )

Definition at line 4 of file MagikoopaSpellAI.inc.c.

4 {
5 Enemy* enemy = script->owner1.enemy;
6 Npc* npc = get_npc_unsafe(enemy->npcID);
7 Camera* camera = &gCameras[gCurrentCamID];
8
9 if (basic_ai_check_player_dist(territory, enemy, arg1, arg2, 0)) {
10 f32 angle;
11 f32 t1;
12
13 if (clamp_angle(get_clamped_angle_diff(camera->curYaw, npc->yaw)) < 180.0) {
14 angle = 90.0f;
15 } else {
16 angle = 270.0f;
17 }
18
19 t1 = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
20 if (fabsf(get_clamped_angle_diff(angle, t1)) > 75.0) {
21 return -1;
22 }
23
24 t1 = atan2(0.0f, npc->pos.y, fabsf(npc->pos.x - gPlayerStatusPtr->pos.x), gPlayerStatusPtr->pos.y);
25 if (fabsf(t1 - 90.0) > 70.0) {
26 return -1;
27 }
28
30 return -1;
31 }
32
33 if ((get_enemy(enemy->npcID + 1)->varTable[0] == 0)) {
34 return 1;
35 }
36 }
37
38 return -1;
39}
union Evt::@8 owner1
Initially -1.
#define clamp_angle
#define atan2
@ PARTNER_BOW
Definition enums.h:2894
@ PARTNER_SUSHIE
Definition enums.h:2892
f32 fabsf(f32 f)
f32 get_clamped_angle_diff(f32, f32)
Definition 43F0.c:606
s32 basic_ai_check_player_dist(EnemyDetectVolume *arg0, Enemy *arg1, f32 arg2, f32 arg3, b8 arg4)
Definition 23680.c:429
s16 npcID
Definition npc.h:300
Enemy * get_enemy(s32 npcID)
Looks for an enemy matching the specified npcID.
Definition npc.c:2540
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
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

Referenced by FlyingMagikoopaAI_11(), FlyingMagikoopaAI_21(), FlyingMagikoopaAI_23(), MagikoopaAI_21(), and MagikoopaAI_23().