Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
thunder_bolt.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "effects.h"
4#include "model.h"
5#include "sprite/player.h"
6
7#define NAMESPACE battle_item_thunder_bolt
8
10
11API_CALLABLE(N(SpawnLightningFX)) {
12 Actor* enemyTarget = get_actor(script->owner1.enemyID);
13 Actor* actor = get_actor(enemyTarget->targetActorID);
14 f32 posY, posX, posZ;
15 s32 scaleX, scaleY;
16
17 if (actor != NULL) {
19
20 posX = actor->curPos.x;
21 posY = actor->curPos.y + (actor->size.y / 10);
22 posZ = actor->curPos.z;
23
24 scaleX = (actor->size.x + (actor->size.x >> 2)) * actor->scalingFactor;
25 scaleY = (actor->size.y - 2) * actor->scalingFactor;
26
27 if (actor->flags & ACTOR_FLAG_HALF_HEIGHT) {
28 posY -= actor->size.y / 2;
29 }
30
31 fx_lightning(rand_int(2) + 3, posX, posY, posZ, scaleX, scaleY);
32
33 return ApiStatus_DONE2;
34 }
35
36 return ApiStatus_DONE2;
37}
38
41
43
44EvtScript N(EVS_UseItem) = {
45 SetConst(LVarA, ITEM_THUNDER_BOLT)
46 ExecWait(N(UseItemWithEffect))
47 Thread
48 Wait(5)
49 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
50 Call(MoveBattleCamOver, 20)
54 Wait(10)
55 Call(InitTargetIterator)
56 Call(SetGoalToTarget, ACTOR_SELF)
57 Call(ItemCheckHit, LVar0, DAMAGE_TYPE_NO_CONTACT, 0, LVar0, 0)
59 Goto(1)
60 EndIf
61 Call(N(SpawnLightningFX))
62 Wait(5)
64 Call(ShakeCam, CAM_BATTLE, 0, 5, Float(1.0))
65 Call(GetItemPower, ITEM_THUNDER_RAGE, LVar0, LVar1)
67 Label(1)
68 Wait(5)
69 Call(UseBattleCamPreset, BTL_CAM_VIEW_ENEMIES)
70 Call(MoveBattleCamOver, 20)
71 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Idle)
72 Wait(30)
74 ExecWait(N(PlayerGoHome))
75 Return
76 End
77};
f32 scalingFactor
s16 targetActorID
Vec2bu size
Vec3f curPos
Bytecode EvtScript[]
#define rand_int
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ HIT_RESULT_MISS
Definition enums.h:1956
@ BTL_CAM_DEFAULT
Definition enums.h:4824
@ BTL_CAM_VIEW_ENEMIES
Definition enums.h:4825
@ SOUND_THUNDER_BOLT
Definition enums.h:1173
@ SOUND_LIGHTNING_STRIKE
Definition enums.h:1174
@ BTL_RUMBLE_PLAYER_EXTREME
Definition enums.h:4262
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_SELF
Definition enums.h:2084
@ ACTOR_FLAG_HALF_HEIGHT
Definition enums.h:3335
@ CAM_BATTLE
Definition enums.h:1801
@ DAMAGE_TYPE_IGNORE_DEFENSE
Definition enums.h:2877
@ DAMAGE_TYPE_SHOCK
Definition enums.h:2856
@ DAMAGE_TYPE_NO_CONTACT
Definition enums.h:2878
@ DAMAGE_TYPE_MULTIPLE_POPUPS
Definition enums.h:2879
#define ApiStatus_DONE2
Definition evt.h:118
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
ApiStatus PlaySound(Evt *script, b32 isInitialCall)
ApiStatus FadeBackgroundLighten(Evt *script, b32 isInitialCall)
ApiStatus FadeBackgroundDarken(Evt *script, b32 isInitialCall)
ApiStatus ShakeCam(Evt *script, b32 isInitialCall)
ApiStatus GetItemPower(Evt *script, b32 isInitialCall)
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#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 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 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 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