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

Go to the source code of this file.

Macros

#define _AI_PROJECTILE_HITBOX_INC_   0
 

Functions

s32 N ProjectileHitbox_GetUsableProjectileID (Evt *script)
 
void N UnkNpcAIFunc48 (Evt *script, f32 arg1, f32 arg2, EnemyDetectVolume *territory)
 
void N ProjectileHitbox_30 (Evt *script)
 
void N ProjectileHitbox_31 (Evt *script)
 
void N ProjectileHitbox_32 (Evt *script)
 
void N ProjectileHitbox_33 (Evt *script)
 

Macro Definition Documentation

◆ _AI_PROJECTILE_HITBOX_INC_

#define _AI_PROJECTILE_HITBOX_INC_   0

Definition at line 2 of file ProjectileHitbox.inc.c.

Function Documentation

◆ ProjectileHitbox_GetUsableProjectileID()

s32 N ProjectileHitbox_GetUsableProjectileID ( Evt * script)

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

8 {
9 Enemy* enemy = script->owner1.enemy;
10 Bytecode* args = script->ptrReadPos;
11 Camera* camera = &gCameras[gCurrentCamID];
12 Npc* npc = get_npc_unsafe(enemy->npcID);
13 MobileAISettings* aiSettings = (MobileAISettings*)evt_get_variable(script, *args++);
14 f32 facingAngle;
15 f32 angleToPlayer;
16 f32 deltaAngle;
17 s32 i;
18
19 if (ai_check_player_dist(enemy, 0, aiSettings->chaseRadius, aiSettings->chaseOffsetDist)) {
20 if (clamp_angle(get_clamped_angle_diff(camera->curYaw, npc->yaw)) < 180.0) {
21 facingAngle = 90.0f;
22 } else {
23 facingAngle = 270.0f;
24 }
25
26 angleToPlayer = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
27 deltaAngle = get_clamped_angle_diff(facingAngle, angleToPlayer);
28 if (fabsf(deltaAngle) > 75.0 || (2.0 * npc->collisionHeight <= fabsf(npc->pos.y - gPlayerStatusPtr->pos.y))) {
29 return -1;
30 }
32 return -1;
33 }
35 return -1;
36 }
37
38 // choose the first idle projectile hitbox
39 for (i = 0; i < enemy->AI_PROJECTILE_AMMO_COUNT; i++) {
40 s32 projectileNpcID = enemy->npcID + i + 1;
41 Enemy* projectileEnemy = get_enemy(projectileNpcID);
42
43 get_npc_unsafe(projectileNpcID);
44
45 if (projectileEnemy->VAR_PROJECTILE_HITBOX_STATE == 0) {
46 return projectileNpcID;
47 }
48 }
49 }
50 return -1;
51}
Bytecode * ptrReadPos
union Evt::@8 owner1
Initially -1.
#define clamp_angle
#define atan2
@ PARTNER_BOW
Definition enums.h:2894
@ PARTNER_SUSHIE
Definition enums.h:2892
s32 Bytecode
Definition evt.h:7
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
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
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
f32 chaseRadius
Definition npc.h:102
f32 chaseOffsetDist
Definition npc.h:103
Definition npc.h:294
s16 collisionHeight
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 ProjectileHitbox_30(), and UnkNpcAIFunc48().

◆ UnkNpcAIFunc48()

void N UnkNpcAIFunc48 ( Evt * script,
f32 arg1,
f32 arg2,
EnemyDetectVolume * territory )

Definition at line 53 of file ProjectileHitbox.inc.c.

53 {
54 Enemy* enemy = script->owner1.enemy;
55 Npc* npc = get_npc_unsafe(enemy->npcID);
56
57 if (basic_ai_check_player_dist(territory, enemy, arg1, arg2, 1) == 0) {
58 EffectInstance* sp28;
59
60 fx_emote(EMOTE_QUESTION, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 15, &sp28);
62 npc->duration = 20;
63 script->functionTemp[0] = 33;
64 } else {
65 s32 npcID = N(ProjectileHitbox_GetUsableProjectileID)(script);
66
67 if (npcID != NPC_SELF && get_enemy(npcID)->varTable[0] == 0 && npc->turnAroundYawAdjustment == 0) {
69 npc->duration = enemy->varTable[1];
70 script->functionTemp[0] = 30;
71 }
72 }
73}
s32 N ProjectileHitbox_GetUsableProjectileID(Evt *script)
@ EMOTE_QUESTION
Definition enums.h:497
@ ENEMY_ANIM_INDEX_MELEE_PRE
Definition enums.h:3434
@ ENEMY_ANIM_INDEX_IDLE
Definition enums.h:3426
@ NPC_SELF
Definition enums.h:2526
s32 basic_ai_check_player_dist(EnemyDetectVolume *arg0, Enemy *arg1, f32 arg2, f32 arg3, b8 arg4)
Definition 23680.c:429
s32 * animList
Definition npc.h:341
AnimID curAnim
s16 turnAroundYawAdjustment
s16 duration

◆ ProjectileHitbox_30()

void N ProjectileHitbox_30 ( Evt * script)

Definition at line 75 of file ProjectileHitbox.inc.c.

75 {
76 Enemy* enemy = script->owner1.enemy;
77 Npc* npc = get_npc_unsafe(enemy->npcID);
78 s32 npcID;
79
80 npc->duration--;
81 if (npc->duration <= 0) {
83 if (npcID < 0) {
84 EffectInstance* emoteTemp;
85
86 fx_emote(EMOTE_QUESTION, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 15, &emoteTemp);
88 } else {
89 Enemy* hitboxEnemy;
90
92 hitboxEnemy = get_enemy(npcID);
93 hitboxEnemy->varTable[4] = enemy->npcID;
94 hitboxEnemy->varTable[0] = 1;
95 }
96 npc->duration = enemy->varTable[2];
97 script->functionTemp[0] = AI_STATE_PROJECTILE_HITBOX_33;
98 }
99}
@ ENEMY_ANIM_INDEX_MELEE_HIT
Definition enums.h:3435
@ AI_STATE_PROJECTILE_HITBOX_33
Definition enums.h:4608

◆ ProjectileHitbox_31()

void N ProjectileHitbox_31 ( Evt * script)

Definition at line 101 of file ProjectileHitbox.inc.c.

101 {
102 Enemy* enemy = script->owner1.enemy;
103
104 get_npc_unsafe(enemy->npcID)->duration = enemy->varTable[2];
105 script->functionTemp[0] = AI_STATE_PROJECTILE_HITBOX_33;
106}

◆ ProjectileHitbox_32()

void N ProjectileHitbox_32 ( Evt * script)

Definition at line 108 of file ProjectileHitbox.inc.c.

108 {
109 Enemy* enemy = script->owner1.enemy;
110 Npc* npc = get_npc_unsafe(enemy->npcID);
111 Enemy* enemy2 = get_enemy(enemy->npcID + 1);
112 Npc* npc2 = get_npc_unsafe(enemy2->npcID);
113
114 npc->yaw = atan2(npc->pos.x, npc->pos.z, npc2->pos.x, npc2->pos.z);
115 if (enemy2->varTable[0] == 0) {
117 npc->duration = enemy->varTable[2];
118 script->functionTemp[0] = AI_STATE_PROJECTILE_HITBOX_33;
119 }
120}

◆ ProjectileHitbox_33()

void N ProjectileHitbox_33 ( Evt * script)

Definition at line 123 of file ProjectileHitbox.inc.c.

123 {
124 Npc* npc = get_npc_unsafe(script->owner1.enemy->npcID);
125
126 npc->duration--;
127 if (npc->duration <= 0) {
128 script->functionTemp[0] = AI_STATE_WANDER_INIT;
129 }
130}
@ AI_STATE_WANDER_INIT
Definition enums.h:4581