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

Go to the source code of this file.

Macros

#define USE_STATE   functionTemp[0]
 

Functions

void entity_try_partner_interaction_trigger (s32 arg0)
 
void N blast_affect_entities (Npc *npc)
 
void N init (Npc *bombette)
 
void N try_cancel_tweester (Npc *npc)
 
s32 N can_use_ability (Npc *npc)
 
s32 N can_open_menus (Npc *npc)
 
s32 N test_first_strike (Npc *bombette, Npc *enemy)
 
void N pre_battle (Npc *bombette)
 

Variables

EvtScript EVS_WorldBombette_TakeOut
 
EvtScript EVS_WorldBombette_Update
 
EvtScript EVS_WorldBombette_UseAbility
 
EvtScript EVS_WorldBombette_PutAway
 

Macro Definition Documentation

◆ USE_STATE

#define USE_STATE   functionTemp[0]

Function Documentation

◆ entity_try_partner_interaction_trigger()

void entity_try_partner_interaction_trigger ( s32 arg0)

Definition at line 677 of file entity.c.

677 {
678 s32 interacted = FALSE;
679 u32 entityType = get_entity_type(entityIdx);
680 s32 partnerID = get_current_partner_id();
681 Entity* entity;
682
683 switch (partnerID) {
684 case PARTNER_BOMBETTE:
685 switch (entityType) {
686 default:
687 return FALSE;
702 entity = get_entity_by_index(entityIdx);
704 interacted = TRUE;
705 }
706 break;
707 case PARTNER_KOOPER:
708 switch (entityType) {
709 default:
710 return FALSE;
722 case ENTITY_TYPE_1C:
725 entity = get_entity_by_index(entityIdx);
727 interacted = TRUE;
728 }
729 break;
730 }
731 return interacted;
732}
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
u32 get_entity_type(s32 index)
Definition entity.c:568
@ ENTITY_TYPE_HAMMER1_BLOCK
Definition enums.h:2564
@ ENTITY_TYPE_SINGLE_TRIGGER_BLOCK
Definition enums.h:2559
@ ENTITY_TYPE_BOMBABLE_ROCK
Definition enums.h:2581
@ ENTITY_TYPE_HIDDEN_RED_BLOCK
Definition enums.h:2561
@ ENTITY_TYPE_1C
Definition enums.h:2571
@ ENTITY_TYPE_SUPER_BLOCK
Definition enums.h:2577
@ ENTITY_TYPE_HEALING_BLOCK
Definition enums.h:2570
@ ENTITY_TYPE_BLUE_SWITCH
Definition enums.h:2550
@ ENTITY_TYPE_MULTI_COIN_BRICK
Definition enums.h:2557
@ ENTITY_TYPE_RED_SWITCH
Definition enums.h:2551
@ ENTITY_TYPE_BRICK_BLOCK
Definition enums.h:2556
@ ENTITY_TYPE_HIDDEN_YELLOW_BLOCK
Definition enums.h:2560
@ ENTITY_TYPE_RED_BLOCK
Definition enums.h:2563
@ ENTITY_TYPE_SAVE_POINT
Definition enums.h:2575
@ ENTITY_TYPE_MULTI_TRIGGER_BLOCK
Definition enums.h:2554
@ ENTITY_TYPE_HAMMER1_BLOCK_TINY
Definition enums.h:2567
@ ENTITY_TYPE_YELLOW_BLOCK
Definition enums.h:2558
@ ENTITY_FLAG_PARTNER_COLLISION
Definition enums.h:2630
@ PARTNER_BOMBETTE
Definition enums.h:2888
@ PARTNER_KOOPER
Definition enums.h:2887
s8 get_current_partner_id(void)
Definition 7BB60.c:1101

Referenced by blast_affect_entities().

◆ blast_affect_entities()

void N blast_affect_entities ( Npc * npc)

Definition at line 20 of file bombette.c.

20 {
21 f32 x, y, z;
22 f32 angle = 0.0f;
23
24 // first pass looking for entities
25 while (angle < 360.0f) {
26 x = npc->pos.x;
27 y = npc->pos.y;
28 z = npc->pos.z;
30 &x, &y, &z, 30.0f, clamp_angle(npc->yaw + angle),
32 ) {
33 break;
34 }
35 angle += 45.0f;
36 }
37
38 // second pass looking for everything but entities
39 if (angle >= 360.0f) {
40 angle = 0.0f;
41
42 while (angle < 360.0f) {
43 x = npc->pos.x;
44 y = npc->pos.y;
45 z = npc->pos.z;
47 &x, &y, &z, 30.0f, clamp_angle(npc->yaw + angle),
49 ) {
50 break;
51 }
52 angle += 45.0f;
53 }
54
55 if (angle >= 360.0f) {
56 return;
57 }
58 }
59
60 // handle entity interaction if there was a collision
63 }
64}
#define clamp_angle
@ COLLISION_ONLY_ENTITIES
Definition enums.h:4700
@ COLLISION_IGNORE_ENTITIES
Definition enums.h:4698
b32 npc_test_move_taller_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:152
s16 collisionDiameter
s16 collisionHeight
Vec3f pos
s32 NpcHitQueryColliderID
void entity_try_partner_interaction_trigger(s32 arg0)
Definition entity.c:677

◆ init()

void N init ( Npc * bombette)

Definition at line 66 of file bombette.c.

66 {
67 bombette->collisionHeight = 28;
68 bombette->collisionDiameter = 24;
69 N(IsBlasting) = FALSE;
70 N(PlayingFuseSound) = FALSE;
71}

◆ try_cancel_tweester()

void N try_cancel_tweester ( Npc * npc)

Definition at line 186 of file bombette.c.

186 {
187 if (TweesterTouchingPartner != NULL) {
189 npc->flags = N(TweesterPhysicsPtr)->prevFlags;
190 N(TweesterPhysicsPtr)->state = TWEESTER_PARTNER_INIT;
192 }
193}
@ TWEESTER_PARTNER_INIT
Definition enums.h:2475
void partner_clear_player_tracking(Npc *partner)
Definition partners.c:2436
s32 flags
Entity * TweesterTouchingPartner
Definition 7B440.c:5

◆ can_use_ability()

s32 N can_use_ability ( Npc * npc)

Definition at line 195 of file bombette.c.

195 {
197 N(TriggeredEarlyDetonation) = TRUE;
198 return FALSE;
199 }
200 return TRUE;
201}
@ PARTNER_ACTION_NONE
Definition enums.h:2932
PartnerStatus gPartnerStatus
Definition partners.c:42

◆ can_open_menus()

s32 N can_open_menus ( Npc * npc)

Definition at line 203 of file bombette.c.

◆ test_first_strike()

s32 N test_first_strike ( Npc * bombette,
Npc * enemy )

Definition at line 597 of file bombette.c.

597 {
598 f32 bombetteX, bombetteZ;
599 f32 enemyX, enemyZ;
600 f32 x, y, z, dist;
601 f32 angle, distance;
602 f32 enemyRadius, blastRadius;
603 b32 hasCollision;
604 s32 enemyHit;
605
606 if (!N(IsBlasting)) {
607 return FALSE;
608 }
609
610 enemyX = enemy->pos.x;
611 enemyZ = enemy->pos.z;
612
613 bombetteX = bombette->pos.x;
614 bombetteZ = bombette->pos.z;
615
616 x = enemyX - bombetteX;
617 y = enemy->pos.y + (f32)(enemy->collisionHeight * 0.5) - bombette->pos.y;
618 z = enemyZ - bombetteZ;
619
620 enemyRadius = enemy->collisionDiameter * 0.55;
621 blastRadius = 35.0f;
622 dist = sqrtf(SQ(x) + SQ(y) + SQ(z));
623 enemyHit = FALSE;
624
625 if (dist < (enemyRadius + blastRadius)) {
626 enemyHit = TRUE;
627 }
628
629 angle = atan2(enemyX, enemyZ, bombetteX, bombetteZ);
630 distance = dist2D(enemyX, enemyZ, bombetteX, bombetteZ);
631
632 // check whether the enemy is protected from the explosion
633 x = bombette->pos.x;
634 y = bombette->pos.y;
635 z = bombette->pos.z;
636 hasCollision = npc_test_move_taller_with_slipping(0, &x, &y, &z, distance, angle, 35.0f, 2.0f);
637
638 if (hasCollision) {
639 return FALSE;
640 }
641
642 return enemyHit;
643}
s32 b32
#define sqrtf
#define atan2
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
#define SQ(x)
Definition macros.h:166

◆ pre_battle()

void N pre_battle ( Npc * bombette)

Definition at line 645 of file bombette.c.

645 {
646 PlayerStatus* playerStatus = &gPlayerStatus;
647 PartnerStatus* partnerStatus = &gPartnerStatus;
648
649 if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE) {
650 if (N(LockingPlayerInput)) {
652 }
653
654 N(IsBlasting) = FALSE;
655 playerStatus->flags &= ~PS_FLAG_JUMPING;
656 bombette->jumpVel = 0.0f;
657 bombette->flags &= ~NPC_FLAG_JUMPING;
658
661
663 partnerStatus->actingPartner = 0;
664
665 bombette->pos.x = playerStatus->pos.x;
666 bombette->pos.y = playerStatus->pos.y;
667 bombette->pos.z = playerStatus->pos.z;
668
669 if (!N(PlayerWasFacingLeft)) {
670 add_vec2D_polar(&bombette->pos.x, &bombette->pos.z,
671 playerStatus->colliderDiameter / 4, clamp_angle(playerStatus->targetYaw + 90.0f));
672 } else {
673 add_vec2D_polar(&bombette->pos.x, &bombette->pos.z,
674 playerStatus->colliderDiameter / 4, clamp_angle(playerStatus->targetYaw - 90.0f));
675 }
676
677 bombette->jumpVel = 0.0f;
678 bombette->pos.y = playerStatus->pos.y;
679 bombette->rot.x = 0.0f;
680 bombette->rot.z = 0.0f;
681 bombette->curAnim = ANIM_WorldBombette_Idle;
683 disable_npc_blur(bombette);
684
685 if (N(PlayingFuseSound)) {
686 N(PlayingFuseSound) = FALSE;
688 }
689 }
690}
@ SOUND_LOOP_BOMBETTE_FUSE
Definition enums.h:1581
@ ACTION_STATE_IDLE
Definition enums.h:2426
void disable_npc_blur(Npc *npc)
Definition npc.c:1088
s32 enable_player_input(void)
Definition 77480.c:998
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:685
void sfx_stop_sound(s32 soundID)
Definition sfx.c:507
f32 jumpVel
AnimID curAnim
Vec3f rot
PlayerStatus gPlayerStatus
Definition 77480.c:39

Variable Documentation

◆ EVS_WorldBombette_TakeOut

EvtScript EVS_WorldBombette_TakeOut
Initial value:
= {
Call(N(TakeOut))
}
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define Return
Kills the current EVT thread.
Definition macros.h:217

Definition at line 87 of file bombette.c.

87 {
88 Call(N(TakeOut))
89 Return
90 End
91};

◆ EVS_WorldBombette_Update

EvtScript EVS_WorldBombette_Update
Initial value:
= {
Call(N(Update))
}

Definition at line 180 of file bombette.c.

180 {
181 Call(N(Update))
182 Return
183 End
184};

◆ EVS_WorldBombette_UseAbility

EvtScript EVS_WorldBombette_UseAbility
Initial value:
= {
Call(N(UseAbility))
}

Definition at line 571 of file bombette.c.

571 {
572 Call(N(UseAbility))
573 Return
574 End
575};

◆ EVS_WorldBombette_PutAway

EvtScript EVS_WorldBombette_PutAway
Initial value:
= {
Call(N(PutAway))
}

Definition at line 591 of file bombette.c.

591 {
592 Call(N(PutAway))
593 Return
594 End
595};