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

Go to the source code of this file.

Macros

#define _AI_MELEE_HITBOX_INC_   0
 

Functions

void N MeleeHitbox_30 (Evt *script)
 
void N MeleeHitbox_31 (Evt *script)
 
void N MeleeHitbox_32 (Evt *script)
 
void N MeleeHitbox_33 (Evt *script)
 
s32 N MeleeHitbox_CanSeePlayer (Evt *script)
 

Macro Definition Documentation

◆ _AI_MELEE_HITBOX_INC_

#define _AI_MELEE_HITBOX_INC_   0

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

Function Documentation

◆ MeleeHitbox_30()

void N MeleeHitbox_30 ( Evt * script)

Definition at line 7 of file MeleeHitbox.inc.c.

7 {
8 Enemy* enemy = script->owner1.enemy;
9 Npc* npc = get_npc_unsafe(enemy->npcID);
10
11 enemy->AI_VAR_ATTACK_STATE = MELEE_HITBOX_STATE_INIT;
12 // if flipping, wait for it to finish
13 if (npc->turnAroundYawAdjustment == 0) {
14 enemy->AI_VAR_ATTACK_STATE = MELEE_HITBOX_STATE_PRE;
15 npc->duration = enemy->AI_VAR_MELEE_PRE_TIME;
17 script->AI_TEMP_STATE = AI_STATE_MELEE_HITBOX_PRE;
18 }
19}
union Evt::@8 owner1
Initially -1.
@ ENEMY_ANIM_INDEX_MELEE_PRE
Definition enums.h:3434
@ AI_STATE_MELEE_HITBOX_PRE
Definition enums.h:4601
@ MELEE_HITBOX_STATE_PRE
Definition enums.h:4645
@ MELEE_HITBOX_STATE_INIT
Definition enums.h:4644
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
s16 turnAroundYawAdjustment
s16 duration

◆ MeleeHitbox_31()

void N MeleeHitbox_31 ( Evt * script)

Definition at line 21 of file MeleeHitbox.inc.c.

21 {
22 Enemy* enemy = script->owner1.enemy;
23 Npc* npc = get_npc_unsafe(enemy->npcID);
24
25 npc->duration--;
26 if (npc->duration <= 0) {
27 enemy->AI_VAR_ATTACK_STATE = MELEE_HITBOX_STATE_ACTIVE;
28 npc->duration = enemy->AI_VAR_MELEE_HIT_TIME;
30 script->AI_TEMP_STATE = AI_STATE_MELEE_HITBOX_ACTIVE;
31 }
32}
@ ENEMY_ANIM_INDEX_MELEE_HIT
Definition enums.h:3435
@ AI_STATE_MELEE_HITBOX_ACTIVE
Definition enums.h:4602
@ MELEE_HITBOX_STATE_ACTIVE
Definition enums.h:4646

◆ MeleeHitbox_32()

void N MeleeHitbox_32 ( Evt * script)

Definition at line 34 of file MeleeHitbox.inc.c.

34 {
35 Enemy* enemy = script->owner1.enemy;
36 Npc* npc = get_npc_unsafe(enemy->npcID);
37 EffectInstance* emoteTemp;
38
39 npc->duration--;
40 if (npc->duration <= 0) {
41 enemy->AI_VAR_ATTACK_STATE = MELEE_HITBOX_STATE_POST;
43 npc->duration = enemy->AI_VAR_MELEE_MISS_TIME;
44 if (enemy->AI_VAR_MELEE_MISS_TIME >= 8) {
45 fx_emote(EMOTE_FRUSTRATION, npc, 0.0f, npc->collisionHeight, 1.0f, 2.0f, -20.0f, enemy->AI_VAR_MELEE_MISS_TIME - 1, &emoteTemp);
46 }
47 script->AI_TEMP_STATE = AI_STATE_MELEE_HITBOX_MISS;
48 }
49}
@ EMOTE_FRUSTRATION
Definition enums.h:498
@ ENEMY_ANIM_INDEX_IDLE
Definition enums.h:3426
@ AI_STATE_MELEE_HITBOX_MISS
Definition enums.h:4603
@ MELEE_HITBOX_STATE_POST
Definition enums.h:4647
s16 collisionHeight

◆ MeleeHitbox_33()

void N MeleeHitbox_33 ( Evt * script)

Definition at line 51 of file MeleeHitbox.inc.c.

51 {
52 Enemy* enemy = script->owner1.enemy;
53 Npc* npc = get_npc_unsafe(enemy->npcID);
54
55 npc->duration--;
56 if (npc->duration <= 0) {
57 enemy->AI_VAR_ATTACK_STATE = MELEE_HITBOX_STATE_NONE;
58 script->AI_TEMP_STATE = AI_STATE_CHASE_INIT;
59 }
60}
@ AI_STATE_CHASE_INIT
Definition enums.h:4592
@ MELEE_HITBOX_STATE_NONE
Definition enums.h:4643

◆ MeleeHitbox_CanSeePlayer()

s32 N MeleeHitbox_CanSeePlayer ( Evt * script)

Definition at line 62 of file MeleeHitbox.inc.c.

62 {
63 Enemy* enemy = script->owner1.enemy;
64 Npc* npc = get_npc_unsafe(enemy->npcID);
65 Camera* camera = &gCameras[gCurrentCamID];
66 Enemy* hitboxEnemy = get_enemy(enemy->npcID + 1);
67 f32 angle;
68 s32 ret = TRUE;
69
70 if (dist2D(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z) > hitboxEnemy->AI_VAR_HITNPC_2) {
71 ret = FALSE;
72 }
73
74 if (clamp_angle(get_clamped_angle_diff(camera->curYaw, npc->yaw)) < 180.0) {
75 angle = 90.0f;
76 } else {
77 angle = 270.0f;
78 }
79
81 gPlayerStatusPtr->pos.z))) > hitboxEnemy->AI_VAR_HITNPC_3) {
82 ret = FALSE;
83 }
84
85 if ((2.0 * npc->collisionHeight) <= fabsf(npc->pos.y - gPlayerStatusPtr->pos.y)) {
86 ret = FALSE;
87 }
88
90 ret = FALSE;
91 }
92
94 ret = FALSE;
95 }
96
97 return ret;
98}
#define clamp_angle
#define atan2
@ PARTNER_BOW
Definition enums.h:2894
@ PARTNER_SUSHIE
Definition enums.h:2892
f32 fabsf(f32 f)
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
f32 get_clamped_angle_diff(f32, f32)
Definition 43F0.c:606
Enemy * get_enemy(s32 npcID)
Looks for an enemy matching the specified npcID.
Definition npc.c:2540
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