Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
pow_block.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "entity.h"
4#include "effects.h"
5#include "sprite/player.h"
6
7#define NAMESPACE battle_item_pow_block
8
10
11API_CALLABLE(N(ForceTriggerPOWBlockEntity)) {
12 BattleStatus* battleStatus = &gBattleStatus;
13 Actor* player = battleStatus->playerActor;
14 CollisionStatus* collisionStatus = &gCollisionStatus;
15 PlayerStatus* playerStatus = &gPlayerStatus;
16
17 if (player->scalingFactor == 1.0) {
18 s32 entityID = script->varTable[10];
19 get_entity_by_index(entityID);
20 collisionStatus->curCeiling = entityID | COLLISION_WITH_ENTITY_BIT;
21 playerStatus->flags |= PS_FLAG_JUMPING;
23 collisionStatus->curCeiling = -1;
24 playerStatus->flags &= ~PS_FLAG_JUMPING;
25 return ApiStatus_DONE2;
26 }
27
28 return ApiStatus_DONE2;
29}
30
31API_CALLABLE(N(DeletePOWBlockEntity)) {
32 Entity* entity = get_entity_by_index(script->varTable[10]);
33
35
36 return ApiStatus_DONE2;
37}
38
39API_CALLABLE(N(AdjustPOWBlockEntityScale)) {
40 BattleStatus* battleStatus = &gBattleStatus;
41 Actor* player = battleStatus->playerActor;
42 Entity* entity = get_entity_by_index(script->varTable[10]);
43
44 entity->scale.x = player->scalingFactor;
45 entity->scale.y = player->scalingFactor;
46 entity->scale.z = player->scalingFactor;
47 if (player->scalingFactor != 1.0) {
48 entity->pos.y -= 10.0f;
49 }
50
51 return ApiStatus_DONE2;
52}
53
55
56EvtScript N(EVS_UseItem) = {
57 SetConst(LVarA, ITEM_POW_BLOCK)
58 ExecWait(N(UseItemWithEffect))
59 Wait(10)
62 Call(N(AdjustPOWBlockEntityScale))
63 PlayEffect(EFFECT_WALKING_DUST, 2, -40, 60, 20, 0, 0, 0)
64 PlayEffect(EFFECT_WALKING_DUST, 2, -30, 65, 20, 0, 0, 0)
65 PlayEffect(EFFECT_WALKING_DUST, 2, -40, 60, 20, 0, 0, 0)
66 PlayEffect(EFFECT_WALKING_DUST, 2, -40, 55, 20, 0, 0, 0)
67 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
68 Wait(20)
69 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
70 Call(MoveBattleCamOver, 20)
71 Thread
72 Wait(15)
73 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_HIT_BLOCK)
74 Call(N(ForceTriggerPOWBlockEntity))
75 PlayEffect(EFFECT_WALKING_DUST, 2, -40, 60, 20, 0, 0, 0)
76 PlayEffect(EFFECT_WALKING_DUST, 2, -30, 65, 20, 0, 0, 0)
77 PlayEffect(EFFECT_WALKING_DUST, 2, -40, 60, 20, 0, 0, 0)
78 PlayEffect(EFFECT_WALKING_DUST, 2, -40, 55, 20, 0, 0, 0)
79 Call(StartRumble, BTL_RUMBLE_HIT_HEAVY)
80 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(1.0))
81 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(3.0))
82 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(6.0))
83 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(5.0))
84 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(4.0))
85 Call(PlaySoundAtActor, ACTOR_PLAYER, SOUND_POW_BLOCK)
86 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(3.0))
87 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(2.0))
88 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(1.0))
89 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.5))
90 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.2))
92 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
93 Add(LVar0, 30)
94 Call(SetActorSpeed, ACTOR_PLAYER, Float(4.0))
95 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Run)
96 Call(SetGoalPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
97 Call(PlayerRunToGoal, 0)
98 Wait(5)
99 Call(SetJumpAnimations, ACTOR_PLAYER, 0, ANIM_Mario1_Jump, ANIM_Mario1_Fall, ANIM_Mario1_Land)
100 Call(SetActorJumpGravity, ACTOR_PLAYER, Float(0.6))
101 Call(SetGoalPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
102 Call(PlayerHopToGoal, 20, 0, 0)
103 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
104 Call(UseBattleCamPreset, BTL_CAM_VIEW_ENEMIES)
105 Call(MoveBattleCamOver, 20)
106 Call(InitTargetIterator)
107 Label(0)
108 Call(SetGoalToTarget, ACTOR_SELF)
109 Call(ItemCheckHit, LVar0, DAMAGE_TYPE_NO_CONTACT, 0, LVar0, 0)
111 Goto(1)
112 EndIf
113 Call(GetItemPower, ITEM_POW_BLOCK, LVar3, LVar4)
114 Call(ApplyShrinkFromOwner, LVar3)
115 Call(SetDamageSource, DMG_SRC_POW_BLOCK)
117 Label(1)
118 Call(ChooseNextTarget, ITER_NEXT, LVar0)
120 Goto(0)
121 EndIf
122 PlayEffect(EFFECT_WALKING_DUST, 2, -70, 60, 20, 0, 0, 0)
123 PlayEffect(EFFECT_WALKING_DUST, 2, -60, 65, 20, 0, 0, 0)
124 PlayEffect(EFFECT_WALKING_DUST, 2, -70, 60, 20, 0, 0, 0)
125 PlayEffect(EFFECT_WALKING_DUST, 2, -70, 55, 20, 0, 0, 0)
126 Call(N(DeletePOWBlockEntity))
127 Wait(30)
128 ExecWait(N(PlayerGoHome))
129 Return
130 End
131};
f32 scalingFactor
Bytecode EvtScript[]
EntityBlueprint Entity_PowBlock
Definition Block.c:799
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ ITER_NO_MORE
Definition enums.h:2030
@ ITER_NEXT
Definition enums.h:2025
@ PS_FLAG_JUMPING
Definition enums.h:3035
@ HIT_RESULT_MISS
Definition enums.h:1956
@ BTL_CAM_DEFAULT
Definition enums.h:4824
@ BTL_CAM_VIEW_ENEMIES
Definition enums.h:4825
@ DMG_SRC_POW_BLOCK
Definition enums.h:2010
@ SOUND_HIT_BLOCK
Definition enums.h:768
@ SOUND_POW_BLOCK
Definition enums.h:1353
@ BTL_RUMBLE_HIT_HEAVY
Definition enums.h:4256
@ ENTITY_FLAG_PENDING_INSTANCE_DELETE
Definition enums.h:2642
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_SELF
Definition enums.h:2084
@ CAM_BATTLE
Definition enums.h:1801
@ DAMAGE_TYPE_POW
Definition enums.h:2861
@ DAMAGE_TYPE_IGNORE_DEFENSE
Definition enums.h:2877
@ DAMAGE_TYPE_NO_CONTACT
Definition enums.h:2878
@ DAMAGE_TYPE_MULTIPLE_POPUPS
Definition enums.h:2879
#define ApiStatus_DONE2
Definition evt.h:118
#define MAKE_ENTITY_END
Definition evt.h:107
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
void update_entities(void)
Definition entity.c:82
ApiStatus ShakeCam(Evt *script, b32 isInitialCall)
ApiStatus MakeEntity(Evt *script, b32 isInitialCall)
Creates an entity.
ApiStatus GetItemPower(Evt *script, b32 isInitialCall)
#define Ref(sym)
Address/pointer constant.
Definition macros.h:60
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:365
#define IfNe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR != RVAR.
Definition macros.h:272
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define Add(VAR, INT_VALUE)
Definition macros.h:376
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:152
#define Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#define Float(DOUBLE)
Definition macros.h:51
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
Definition macros.h:227
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:475
#define Thread
Marks the start of a thread block.
Definition macros.h:544
#define EndThread
Marks the end of a thread block.
Definition macros.h:547
#define LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define LVarA
Definition macros.h:158
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define PlayEffect(args...)
Definition macros.h:807
#define IfEq(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR == RVAR.
Definition macros.h:269
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define LVar4
Definition macros.h:152
#define LVar3
Definition macros.h:151
#define LVar0
Definition macros.h:148
#define SetConst(VAR, CONST)
Sets the given variable to a given value, skipping the evt_get_variable call.
Definition macros.h:370
#define Return
Kills the current EVT thread.
Definition macros.h:217
struct Actor * playerActor
Vec3f scale
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
BattleStatus gBattleStatus
Definition battle.c:11
PlayerStatus gPlayerStatus
Definition 77480.c:39