Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
up_and_away.c
Go to the documentation of this file.
1#include "battle/battle.h"
2#include "script_api/battle.h"
3#include "sprite/npc/BattleKalmar.h"
4#include "entity.h"
5#include "model.h"
6#include "sprite/player.h"
7
9
10#define NAMESPACE battle_move_up_and_away
11
13
14API_CALLABLE(N(DarkenBackground)) {
15 if (isInitialCall) {
19 script->functionTemp[0] = 200;
20 }
21
22 mdl_set_shroud_tint_params(0, 0, 0, script->functionTemp[0]);
23 script->functionTemp[0] += 2;
24
25 if (script->functionTemp[0] >= 254) {
26 mdl_set_shroud_tint_params(0, 0, 0, 254);
27 return ApiStatus_DONE2;
28 }
29
30 return ApiStatus_BLOCK;
31}
32
33API_CALLABLE(N(RestoreBackground)) {
34 if (isInitialCall) {
35 script->functionTemp[0] = 254;
36 }
37
38 mdl_set_shroud_tint_params(0, 0, 0, script->functionTemp[0]);
39 script->functionTemp[0] -= 5;
40
41 if (script->functionTemp[0] <= 200) {
42 mdl_set_shroud_tint_params(0, 0, 0, 200);
43
44 return ApiStatus_DONE2;
45 }
46
47 return ApiStatus_BLOCK;
48}
49
50API_CALLABLE(N(ShouldTargetBeCaptured)) {
51 Actor* targetActor = get_actor(get_actor(script->owner1.actorID)->targetActorID);
52
53 script->varTable[0] = FALSE;
54
55 if (targetActor->flags & ACTOR_FLAG_TARGET_ONLY) {
56 return ApiStatus_DONE2;
57 }
58
59 if (targetActor->flags & ACTOR_FLAG_NO_DMG_APPLY) {
60 return ApiStatus_DONE2;
61 }
62
63 if (targetActor->flags & ACTOR_FLAG_DAMAGE_IMMUNE) {
64 return ApiStatus_DONE2;
65 }
66
67 if (targetActor->actorBlueprint->upAndAwayChance != 0
68 && rand_int(100) <= targetActor->actorBlueprint->upAndAwayChance
69 ) {
70 script->varTable[0] = TRUE;
71 }
72
73 return ApiStatus_DONE2;
74}
75
76EvtScript N(EVS_UsePower) = {
77 ExecWait(N(EVS_StarPower_WishForSpirit))
78 SetConst(LVar0, ANIM_BattleKalmar_Idle)
79 ExecWait(N(EVS_StarPower_SpiritSummoned))
80 Call(SetNpcAnimation, NPC_BTL_SPIRIT, ANIM_BattleKalmar_Shout)
81 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
82 Wait(20)
83 Call(SetMotionBlurParams, 0, 0, 0, 320, 240, 128, 10)
84 Call(N(DarkenBackground))
86 PlayEffect(EFFECT_ENERGY_SHOCKWAVE, 0, 0, 20, 0, Float(1.0), 90)
87 Wait(30)
88 Thread
89 PlayEffect(EFFECT_SHIMMER_WAVE, 0, 0, 50, 0, 300, 100, 10, 40)
91 PlayEffect(EFFECT_ENERGY_SHOCKWAVE, 0, 0, 20, 0, Float(1.0), 90)
92 Wait(75)
93 Call(SetMotionBlurParams, 0, 0, 0, 320, 240, 0, 10)
94 Call(InitTargetIterator)
95 Label(0)
96 Call(SetGoalToTarget, ACTOR_SELF)
97 Call(N(ShouldTargetBeCaptured))
98 Set(LFlag0, FALSE)
99 Call(ItemCheckHit, LVar1, 0, 0, 0, 0)
101 Set(LVar0, 0)
102 Set(LFlag0, TRUE)
103 EndIf
105 CaseGt(0)
106 Call(GetOwnerTarget, LVar0, LVar1)
107 Call(DispatchEvent, LVar0, EVENT_UP_AND_AWAY)
108 Call(SetActorRotationOffset, LVar0, 0, 10, 0)
109 Thread
110 Call(GetOwnerTarget, LVarB, LVar1)
111 Wait(10)
113 Call(GetActorPos, LVarB, LVar0, LVar1, LVar2)
114 Set(LVarD, LVar0)
115 Set(LVarE, LVar1)
116 Set(LVarF, LVar2)
118 SetF(LVar0, Float(0.2))
120 Loop(4)
121 AddF(LVar0, Float(0.2))
123 Wait(1)
124 EndLoop
125 Set(LVar0, 0)
126 Loop(5)
127 Add(LVar0, 72)
129 Wait(1)
130 EndLoop
132 Set(LVar0, LVarD)
133 Set(LVar1, LVarE)
134 Set(LVar2, LVarF)
135 Set(LVar3, 0)
136 Loop(50)
139 Add(LVar1, 6)
140 Add(LVar3, 45)
141 Wait(1)
142 EndLoop
144 Thread
146 Call(GetOwnerTarget, LVarA, LVar1)
147 Call(SetActorFlagBits, LVarA, ACTOR_FLAG_NO_SHADOW, TRUE)
148 SetF(LVar0, Float(1.0))
149 Loop(18)
150 SubF(LVar0, Float(0.05))
151 Call(SetActorScale, LVarA, LVar0, LVar0, LVar0)
152 Wait(1)
153 EndLoop
154 Call(SetActorPos, LVarA, NPC_DISPOSE_LOCATION)
155 Call(GetActorPos, LVarA, LVar0, LVar1, LVar2)
156 Loop(10)
157 PlayEffect(EFFECT_SPARKLES, FX_SPARKLES_1, LVar0, LVar1, LVar2, 20, 0)
158 Add(LVar1, 30)
159 Wait(5)
160 EndLoop
161 Call(SetBattleFlagBits, BS_FLAGS1_STAR_POINTS_DROPPED, TRUE)
162 Call(RemoveActor, LVarA)
165 IfEq(LFlag0, FALSE)
167 EndIf
169 Wait(5)
170 Call(ChooseNextTarget, ITER_NEXT, LVar0)
172 Goto(0)
173 EndIf
174 Wait(70)
175 Call(N(RestoreBackground))
176 ExecWait(N(EVS_StarPower_SpiritDeparts))
177 Call(PlayerYieldTurn)
178 ExecWait(N(EVS_StarPower_EndWish))
179 Return
180 End
181};
struct ActorBlueprint * actorBlueprint
s16 targetActorID
Bytecode EvtScript[]
#define rand_int
@ FX_SPARKLES_1
Definition effects.h:235
s32 EntityModelScript[]
Definition entity.h:7
@ ENV_TINT_SHROUD
Definition enums.h:4387
@ BS_FLAGS1_STAR_POINTS_DROPPED
Definition enums.h:3593
@ BS_FLAGS1_FORCE_IMMUNE_HIT
Definition enums.h:3580
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ ITER_NO_MORE
Definition enums.h:2030
@ ITER_NEXT
Definition enums.h:2025
@ HIT_RESULT_MISS
Definition enums.h:1956
@ BTL_CAM_DEFAULT
Definition enums.h:4824
@ SUPPRESS_EVENT_ALL
Definition enums.h:2907
@ NPC_BTL_SPIRIT
Definition enums.h:2531
@ SOUND_UP_AND_AWAY_CAST
Definition enums.h:968
@ SOUND_UP_AND_AWAY_CAPTURE
Definition enums.h:1410
@ SOUND_UP_AND_AWAY_SEND_AWAY
Definition enums.h:1383
@ ACTOR_SELF
Definition enums.h:2084
@ ACTOR_FLAG_DAMAGE_IMMUNE
Definition enums.h:3333
@ ACTOR_FLAG_NO_SHADOW
Hide shadow.
Definition enums.h:3325
@ ACTOR_FLAG_TARGET_ONLY
Battle ends even if undefeated. No turn.
Definition enums.h:3334
@ ACTOR_FLAG_NO_DMG_APPLY
Damage is not applied to actor HP.
Definition enums.h:3340
@ EVENT_UP_AND_AWAY
Definition enums.h:2176
#define ApiStatus_DONE2
Definition evt.h:118
#define ApiStatus_BLOCK
Definition evt.h:116
void mdl_set_all_tint_type(s32)
Definition model.c:4521
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
void mdl_set_shroud_tint_params(u8 r, u8 g, u8 b, u8 a)
Definition model.c:3906
ApiStatus PlaySound(Evt *script, b32 isInitialCall)
ApiStatus SetMotionBlurParams(Evt *script, b32 isInitialCall)
ApiStatus CreateVirtualEntity(Evt *script, b32 isInitialCall)
ApiStatus SetNpcAnimation(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityPosition(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityScale(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityRotation(Evt *script, b32 isInitialCall)
#define Switch(LVAR)
Marks the start of a switch statement.
Definition macros.h:311
#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 AddF(VAR, FLOAT_VALUE)
Definition macros.h:383
#define LVarF
Definition macros.h:163
#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 EndLoop
Marks the end of a loop.
Definition macros.h:248
#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 CaseDefault
Marks the start of a switch case that executes unconditionally. It also marks the end of any previous...
Definition macros.h:337
#define LVarB
Definition macros.h:159
#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 SetF(VAR, FLOAT_VALUE)
Sets the given variable to a given value, but supports Floats.
Definition macros.h:373
#define LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define LFlag0
Definition macros.h:167
#define LVarA
Definition macros.h:158
#define LVarD
Definition macros.h:161
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define NPC_DISPOSE_LOCATION
Definition macros.h:158
#define SubF(VAR, FLOAT_VALUE)
Definition macros.h:384
#define PlayEffect(args...)
Definition macros.h:807
#define EndSwitch
Marks the end of a switch statement and any case.
Definition macros.h:362
#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 CaseGt(RVAR)
Marks the start of a switch case that executes only if LVAR <= RVAR. It also marks the end of any pre...
Definition macros.h:328
#define Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:245
#define LVar3
Definition macros.h:151
#define LVarE
Definition macros.h:162
#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
u8 upAndAwayChance
Definition battle.h:144
EntityModelScript EMS_StarIcon
u8 * gBackgroundTintModePtr
Definition model.c:105