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

Go to the source code of this file.

Macros

#define USE_STATE   functionTemp[0]
 
#define TEST_COLLISION_AT_ANGLE(testAngle)
 

Enumerations

enum  { SHELL_TOSS_HITBOX_DISABLED = 0 , SHELL_TOSS_HITBOX_ENABLED = 1 , SHELL_TOSS_HITBOX_HIT_ENEMY = 2 }
 

Functions

s32 entity_try_partner_interaction_trigger (s32)
 
s32 test_item_entity_position (f32, f32, f32, f32)
 
void fx_damage_stars (s32, f32, f32, f32, f32, f32, f32, s32)
 
void auto_collect_item_entity (s32)
 
s32 N lateral_hit_interactable_entity (Npc *npc)
 
void N vertical_hit_interactable_entity (Npc *kooper)
 
s32 N check_for_item_collision (Npc *kooper)
 
void N init (Npc *kooper)
 
void N try_cancel_tweester (Npc *kooper)
 
s32 N test_first_strike (Npc *kooper, Npc *enemy)
 
void N pre_battle (Npc *kooper)
 
void N post_battle (Npc *npc)
 

Variables

BSS s32 D_802BEC7C
 
s32 ShellTossHitboxState = SHELL_TOSS_HITBOX_DISABLED
 
EvtScript EVS_WorldKooper_TakeOut
 
EvtScript EVS_WorldKooper_Update
 
EvtScript EVS_WorldKooper_UseAbility
 
EvtScript EVS_WorldKooper_PutAway
 

Macro Definition Documentation

◆ USE_STATE

#define USE_STATE   functionTemp[0]

◆ TEST_COLLISION_AT_ANGLE

#define TEST_COLLISION_AT_ANGLE ( testAngle)
Value:
( \
posX = kooper->pos.x, \
posY = kooper->pos.y, \
posZ = kooper->pos.z, \
npc_test_move_taller_with_slipping(COLLIDER_FLAG_IGNORE_SHELL, \
&posX, &posY, &posZ, kooper->moveSpeed, testAngle, \
kooper->collisionHeight, kooper->collisionDiameter / 2) \
)
@ COLLIDER_FLAG_IGNORE_SHELL
Definition enums.h:4695

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SHELL_TOSS_HITBOX_DISABLED 
SHELL_TOSS_HITBOX_ENABLED 
SHELL_TOSS_HITBOX_HIT_ENEMY 

Definition at line 27 of file kooper.c.

27 {
31};
@ SHELL_TOSS_HITBOX_HIT_ENEMY
Definition kooper.c:30
@ SHELL_TOSS_HITBOX_ENABLED
Definition kooper.c:29
@ SHELL_TOSS_HITBOX_DISABLED
Definition kooper.c:28

Function Documentation

◆ entity_try_partner_interaction_trigger()

s32 entity_try_partner_interaction_trigger ( s32 entityIdx)

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 lateral_hit_interactable_entity(), and vertical_hit_interactable_entity().

◆ test_item_entity_position()

s32 test_item_entity_position ( f32 x,
f32 y,
f32 z,
f32 dist )

Definition at line 1482 of file item_entity.c.

1482 {
1483 ItemEntity* item;
1484 f32 dx, dy, dz;
1485 s32 i;
1486
1489 {
1490 return -1;
1491 }
1492
1493 for (i = 0; i < MAX_ITEM_ENTITIES; i++){
1494 item = gCurrentItemEntities[i];
1495
1496 if (item == NULL) {
1497 continue;
1498 }
1499
1500 if (item->flags == 0) {
1501 continue;
1502 }
1503
1505 continue;
1506 }
1507
1508 if (item->spawnType == ITEM_SPAWN_MODE_INVISIBLE) {
1509 continue;
1510 }
1511
1512 if (item->flags & ITEM_ENTITY_FLAG_HIDDEN) {
1513 continue;
1514 }
1515
1517 continue;
1518 }
1519
1520 dx = item->pos.x - x;
1521 dz = item->pos.y - y;
1522 dy = item->pos.z - z;
1523 if (sqrtf(SQ(dx) + SQ(dz) + SQ(dy)) < dist) {
1524 return i;
1525 }
1526 }
1527 return -1;
1528}
#define sqrtf
@ ITEM_ENTITY_FLAG_CANT_COLLECT
Definition enums.h:2715
@ ITEM_ENTITY_FLAG_HIDDEN
Definition enums.h:2700
@ ITEM_SPAWN_MODE_DECORATION
Definition enums.h:2292
@ ITEM_SPAWN_MODE_INVISIBLE
Definition enums.h:2293
@ GLOBAL_OVERRIDES_CANT_PICK_UP_ITEMS
Definition enums.h:4339
s32 is_starting_conversation(void)
Definition encounter.c:2818
s32 get_time_freeze_mode(void)
Definition main_loop.c:390
#define MAX_ITEM_ENTITIES
Definition item_entity.c:16
BSS s16 isPickingUpItem
Definition item_entity.c:42
BSS ItemEntity ** gCurrentItemEntities
Definition item_entity.c:41
#define SQ(x)
Definition macros.h:166
s32 gOverrideFlags
Definition main_loop.c:11

Referenced by check_for_item_collision().

◆ fx_damage_stars()

void fx_damage_stars ( s32 ,
f32 ,
f32 ,
f32 ,
f32 ,
f32 ,
f32 ,
s32  )

◆ auto_collect_item_entity()

void auto_collect_item_entity ( s32 index)

Definition at line 1547 of file item_entity.c.

1547 {
1548 ItemEntity* item = gCurrentItemEntities[index];
1551}
@ ITEM_ENTITY_FLAG_AUTO_COLLECT
Definition enums.h:2702
@ GLOBAL_OVERRIDES_40
Definition enums.h:4325

◆ lateral_hit_interactable_entity()

s32 N lateral_hit_interactable_entity ( Npc * npc)

Definition at line 35 of file kooper.c.

35 {
36 if (NpcHitQueryColliderID < 0) {
37 return FALSE;
38 }
39
41 return FALSE;
42 }
43
45}
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:152
s32 NpcHitQueryColliderID
s32 entity_try_partner_interaction_trigger(s32)
Definition entity.c:677

◆ vertical_hit_interactable_entity()

void N vertical_hit_interactable_entity ( Npc * kooper)

Definition at line 47 of file kooper.c.

◆ check_for_item_collision()

s32 N check_for_item_collision ( Npc * kooper)

Definition at line 59 of file kooper.c.

59 {
60 N(HeldItemIdx) = test_item_entity_position(kooper->pos.x, kooper->pos.y, kooper->pos.z, kooper->collisionDiameter);
61
62 if (N(HeldItemIdx) < 0) {
63 return FALSE;
64 }
65
66 N(HasItem) = TRUE;
69 return TRUE;
70}
void set_item_entity_flags(s32 itemEntityIndex, s32 flag)
ApiStatus HasItem(Evt *script, b32 isInitialCall)
s16 collisionDiameter
Vec3f pos
s32 test_item_entity_position(f32, f32, f32, f32)

◆ init()

void N init ( Npc * kooper)

Definition at line 72 of file kooper.c.

72 {
73 kooper->collisionHeight = 37;
74 kooper->collisionDiameter = 24;
76 N(TriggeredBattle) = FALSE;
77}
@ COLLIDER_FLAG_IGNORE_PLAYER
Definition enums.h:4696
s32 collisionChannel
s16 collisionHeight

◆ try_cancel_tweester()

void N try_cancel_tweester ( Npc * kooper)

Definition at line 185 of file kooper.c.

185 {
186 if (TweesterTouchingPartner != NULL) {
188 kooper->flags = N(TweesterPhysicsPtr)->prevFlags;
189 N(TweesterPhysicsPtr)->state = TWEESTER_PARTNER_INIT;
191 }
192}
@ 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

◆ test_first_strike()

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

Definition at line 669 of file kooper.c.

669 {
670 f32 xTemp, yTemp, zTemp;
671 f32 enemyX, enemyY, enemyZ;
672 f32 kooperX;
673 f32 kooperZ;
674 f32 enemyCollHeight;
675 f32 kooperY;
676 f32 kooperCollHeight;
677 f32 enemyCollRadius;
678 f32 kooperCollRadius;
679 f32 angleToEnemy;
680 f32 distToEnemy;
681
683 enemyX = enemy->pos.x;
684 enemyY = enemy->pos.y;
685 enemyZ = enemy->pos.z;
686
687 kooperX = kooper->pos.x;
688 kooperY = kooper->pos.y;
689 kooperZ = kooper->pos.z;
690
691 enemyCollHeight = enemy->collisionHeight;
692 enemyCollRadius = enemy->collisionDiameter * 0.55;
693
694 kooperCollHeight = kooper->collisionHeight;
695 kooperCollRadius = kooper->collisionDiameter * 0.8;
696
697 angleToEnemy = atan2(enemyX, enemyZ, kooperX, kooperZ);
698 distToEnemy = dist2D(enemyX, enemyZ, kooperX, kooperZ);
699
700 xTemp = kooper->pos.x;
701 yTemp = kooper->pos.y;
702 zTemp = kooper->pos.z;
703
704 if (npc_test_move_taller_with_slipping(0, &xTemp, &yTemp, &zTemp, distToEnemy, angleToEnemy,
705 kooperCollHeight, kooperCollRadius + enemyCollRadius)
706 ) {
707 return FALSE;
708 }
709
710 if (kooperY > enemyY + enemyCollHeight) {
711 return FALSE;
712 }
713
714 if (enemyY > kooperY + kooperCollHeight) {
715 return FALSE;
716 }
717
718 kooperX = enemyX - kooperX;
719 kooperZ = enemyZ - kooperZ;
720 distToEnemy = SQ(kooperX) + SQ(kooperZ);
721
722 if (!(SQ(kooperCollRadius) + SQ(enemyCollRadius) <= distToEnemy)) {
724 return TRUE;
725 }
726 }
727 return FALSE;
728}
#define atan2
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
b32 npc_test_move_taller_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
s32 ShellTossHitboxState
Definition kooper.c:33

◆ pre_battle()

void N pre_battle ( Npc * kooper)

Definition at line 730 of file kooper.c.

730 {
731 PlayerStatus* playerStatus = &gPlayerStatus;
732 PartnerStatus* partnerStatus = &gPartnerStatus;
733 N(TriggeredBattle) = FALSE;
734
735 if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE) {
736 if (partnerStatus->partnerActionState == PARTNER_ACTION_KOOPER_TOSS) {
737 N(TriggeredBattle) = TRUE;
738 }
739
740 if (N(LockingPlayerInput)) {
742 N(LockingPlayerInput) = FALSE;
743 }
744
746 playerStatus->flags &= ~PS_FLAG_JUMPING;
747
748 kooper->jumpVel = 0.0f;
749 kooper->flags &= ~NPC_FLAG_JUMPING;
750 kooper->flags &= ~NPC_FLAG_IGNORE_WORLD_COLLISION;
751
755 disable_npc_blur(kooper);
756
757 partnerStatus->actingPartner = PARTNER_NONE;
759 }
760}
@ PARTNER_ACTION_KOOPER_TOSS
Definition enums.h:2935
@ PARTNER_ACTION_NONE
Definition enums.h:2932
@ SOUND_KOOPER_SHELL_SWIRL
Definition enums.h:996
@ PARTNER_NONE
Definition enums.h:2885
@ 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 sfx_stop_sound(s32 soundID)
Definition sfx.c:507
f32 jumpVel
PartnerStatus gPartnerStatus
Definition partners.c:42
PlayerStatus gPlayerStatus
Definition 77480.c:39

◆ post_battle()

void N post_battle ( Npc * npc)

Definition at line 762 of file kooper.c.

762 {
763 if (N(TriggeredBattle)) {
766 }
767}
s32 partner_use_ability(void)
Definition partners.c:964

Variable Documentation

◆ D_802BEC7C

BSS s32 D_802BEC7C

Definition at line 25 of file kooper.c.

◆ ShellTossHitboxState

s32 ShellTossHitboxState = SHELL_TOSS_HITBOX_DISABLED

Definition at line 33 of file kooper.c.

Referenced by pre_battle(), and test_first_strike().

◆ EVS_WorldKooper_TakeOut

EvtScript EVS_WorldKooper_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 93 of file kooper.c.

93 {
94 Call(N(TakeOut))
95 Return
96 End
97};

◆ EVS_WorldKooper_Update

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

Definition at line 194 of file kooper.c.

194 {
195 Call(N(Update))
196 Return
197 End
198};

◆ EVS_WorldKooper_UseAbility

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

Definition at line 647 of file kooper.c.

647 {
648 Call(N(UseAbility))
649 Return
650 End
651};

◆ EVS_WorldKooper_PutAway

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

Definition at line 663 of file kooper.c.

663 {
664 Call(N(PutAway))
665 Return
666 End
667};