9#include "sprite/npc/BattleWatt.h"
10#include "sprite/player.h"
12#define NAMESPACE battle_partner_watt
23extern EvtScript N(EVS_Attack_ElectroDash);
35static s32 sWattEffectData_initialized;
36static s32 sWattEffectData_isBouncing;
37static s32 sWattEffectData_bouncePhase;
38static s32 sWattEffectData_isActive;
39static s32 sWattEffectData_currentEffectIndex;
48API_CALLABLE(N(WattFXUpdate)) {
53 sWattEffectData_isBouncing = TRUE;
54 sWattEffectData_bouncePhase = 0;
55 sWattEffectData_isActive = TRUE;
56 sWattEffectData_currentEffectIndex = 0;
57 sWattEffectData_effect1 = fx_static_status(0, partner->
curPos.
x, partner->
curPos.
y, partner->
curPos.
z, 1.0f, 5, 0);
59 sWattEffectData_initialized = TRUE;
62 if (!sWattEffectData_initialized) {
66 if (sWattEffectData_isBouncing) {
67 sWattEffectData_bouncePhase += 15;
68 sWattEffectData_bouncePhase =
clamp_angle(sWattEffectData_bouncePhase);
79 if (sWattEffectData_isActive) {
80 switch (sWattEffectData_currentEffectIndex) {
82 if (sWattEffectData_effect1 == NULL) {
83 sWattEffectData_effect1 = fx_static_status(0, x, y, z, 1.0f, 5, 0);
85 if (sWattEffectData_effect2 != NULL) {
87 sWattEffectData_effect2 = NULL;
94 if (sWattEffectData_effect1 != NULL) {
96 sWattEffectData_effect1 = NULL;
98 if (sWattEffectData_effect2 == NULL) {
99 sWattEffectData_effect2 = fx_static_status(1, x, y, z, 1.0f, 5, 0);
107 if (sWattEffectData_effect1 != NULL) {
109 sWattEffectData_effect1 = NULL;
111 if (sWattEffectData_effect2 != NULL) {
113 sWattEffectData_effect2 = NULL;
120API_CALLABLE(N(WattFXRemove)) {
121 sWattEffectData_initialized = FALSE;
122 if (sWattEffectData_effect1 != NULL) {
125 if (sWattEffectData_effect2 != NULL) {
132API_CALLABLE(N(WattFXBounce)) {
133 sWattEffectData_isBouncing = 1;
137API_CALLABLE(N(WattFXDisableBounce)) {
138 sWattEffectData_isBouncing = 0;
142API_CALLABLE(N(WattFXEnable)) {
143 sWattEffectData_isActive = 1;
147API_CALLABLE(N(WattFXDisable)) {
148 sWattEffectData_isActive = 0;
152API_CALLABLE(N(WattFXSetEffect)) {
153 sWattEffectData_currentEffectIndex =
evt_get_variable(script, *script->ptrReadPos);
161API_CALLABLE(N(ElectroDashFX)) {
162 Bytecode* args = script->ptrReadPos;
167 N(radialShimmer) = fx_radial_shimmer(8, x, y, z, 1.3f, 55);
172API_CALLABLE(N(ElectroDashFXDisable)) {
175 if (effect != NULL) {
178 N(radialShimmer) = NULL;
183API_CALLABLE(N(PowerShockFX)) {
184 Bytecode* args = script->ptrReadPos;
190 N(thunderboltRing) = fx_thunderbolt_ring(0, x, y, z, 1.0f, 10);
191 data = N(thunderboltRing)->data.thunderboltRing;
197API_CALLABLE(N(PowerShockDischargeFX)) {
198 Bytecode* args = script->ptrReadPos;
206 fx_bulb_glow(0, x, y, z, 1.0f, &N(bulbGlow));
209 script->functionTemp[0]--;
210 if (script->functionTemp[0] == 0) {
211 N(bulbGlow)->data.bulbGlow->timeLeft = 5;
218API_CALLABLE(N(TargetParalyzeChance)) {
232 script->varTable[0] = statusChance;
237API_CALLABLE(N(TurboChargeUnwindWatt)) {
238 Bytecode* args = script->ptrReadPos;
251 script->functionTemp[0] = 0;
254 switch (script->functionTemp[0]) {
271 script->functionTemp[1] = 10;
272 script->functionTemp[0] = 1;
282 deltaY = -partner->
state.
dist * cosTheta;
290 script->functionTemp[0] = 2;
301 deltaY = -partner->
state.
dist * cosTheta;
307 script->functionTemp[0] = 3;
316 if (partnerState->
angle > 180.0f) {
319 partner->
yaw = 180.0f;
325 if (script->functionTemp[2] == 0) {
326 player->
yaw += script->functionTemp[1];
327 script->functionTemp[1]++;
332API_CALLABLE(N(TurboChargeFX)) {
333 Bytecode* args = script->ptrReadPos;
339 N(thunderboltRing) = fx_thunderbolt_ring(0, x, y, z, 1.0f, 60);
340 data = N(thunderboltRing)->data.thunderboltRing;
346API_CALLABLE(N(ApplyTurboCharge)) {
348 s32 actionCommandResult = script->varTable[0];
350 if (actionCommandResult > 0) {
351 script->varTable[0] = 1;
353 script->varTable[0] = 0;
356 script->varTable[15] = 0;
357 script->varTable[10] = actionCommandResult;
371API_CALLABLE(N(MegaShockFX)) {
372 Bytecode* args = script->ptrReadPos;
378 script->functionTemp[0] = 0;
381 switch (script->functionTemp[0]) {
387 script->functionTemp[2] = 20;
388 script->functionTemp[3] = 10;
389 N(thunderboltRing) = fx_thunderbolt_ring(0, x, y, z, 1.0f, script->functionTemp[2] + 10);
390 N(thunderboltRing)->data.thunderboltRing->unk_30 = 3;
392 script->functionTemp[0] = 1;
395 N(thunderboltRing)->data.thunderboltRing->unk_30 =
396 ((script->functionTemp[3] * 3) + (script->functionTemp[1] * (10 - script->functionTemp[3]))) / 10;
397 if (script->functionTemp[3] != 0) {
398 script->functionTemp[3]--;
400 if (script->functionTemp[2] == 0) {
404 script->functionTemp[2]--;
410API_CALLABLE(N(AverageTargetParalyzeChance)) {
415 s32 targetActorBlueprintBaseStatusChance;
426 targetActorBlueprintBaseStatusChance = 0;
430 targetActorBlueprintBaseStatusChance = 0;
433 if (targetActorBlueprintBaseStatusChance > 0) {
434 chanceTotal += targetActorBlueprintBaseStatusChance;
440 script->varTable[0] = chanceTotal / nTargets;
442 script->varTable[0] = 0;
448s32 N(DefaultAnims)[] = {
459s32 N(DefenseTable)[] = {
465s32 N(StatusTable)[] = {
494 .posOffset = { 0, 0, 0 },
495 .targetOffset = { 10, 22 },
497 .idleAnimations = N(DefaultAnims),
498 .defenseTable = N(DefenseTable),
500 .elementImmunityFlags = 0,
501 .projectileTargetOffset = { 0, 0 },
507 .type = ACTOR_TYPE_WATT,
508 .level = ACTOR_LEVEL_WATT,
511 .partsData = N(ActorParts),
512 .initScript = &N(EVS_Init),
513 .statusTable = N(StatusTable),
516 .hurricaneChance = 0,
518 .upAndAwayChance = 0,
520 .powerBounceChance = 80,
523 .healthBarOffset = { 0, 0 },
524 .statusIconOffset = { -10, 20 },
525 .statusTextOffset = { 10, 20 },
539 Call(N(WattFXUpdate))
546 Call(CloseActionCommandInfo)
547 Call(N(WattFXDisableBounce))
548 Call(N(WattFXEnable))
549 Call(N(WattFXSetEffect), 0)
566 Call(N(WattFXBounce))
575 Call(N(WattFXDisable))
580 Call(N(WattFXEnable))
597 Call(N(WattFXBounce))
603 Call(N(WattFXBounce))
605 Call(N(WattFXRemove))
615 Call(N(WattFXDisable))
617 Call(N(WattFXEnable))
642 Call(N(WattFXEnable))
643 Call(N(WattFXSetEffect), 1)
654 Call(N(WattFXEnable))
655 Call(N(WattFXSetEffect), 1)
664 Call(N(WattFXEnable))
665 Call(N(WattFXSetEffect), 1)
674 Call(N(WattFXSetEffect), 0)
685 Call(ShowActionHud, TRUE)
690 Call(LoadStarPowerScript)
696 CaseEq(MOVE_ELECTRO_DASH1)
698 CaseEq(MOVE_ELECTRO_DASH2)
700 CaseEq(MOVE_ELECTRO_DASH3)
744 Call(N(WattFXDisable))
749 Call(N(UnkBackgroundFunc3))
775 Call(action_command_body_slam_init)
776 Call(SetupMashMeter, 1, 100, 0, 0, 0, 0)
779 Call(InitTargetIterator)
791 Call(MoveBattleCamOver, 75)
793 Call(action_command_body_slam_start, 0, 102, 3, 1)
845 Call(action_command_body_slam_start, 0, 92, 3, 1)
868 Call(action_command_body_slam_start, 0, 92, 3, 1)
902 Call(CloseActionCommandInfo)
903 Call(N(ElectroDashFXDisable))
913 Call(N(SetBackgroundAlpha), 0)
931 Call(N(WattFXEnable))
932 Call(N(WattFXBounce))
935 CaseEq(MOVE_ELECTRO_DASH1)
938 CaseEq(MOVE_ELECTRO_DASH2)
941 CaseEq(MOVE_ELECTRO_DASH3)
952 Call(PartnerYieldTurn)
969 Call(action_command_power_shock_init)
970 Call(SetupMashMeter, 1, 100, 0, 0, 0, 0)
971 Call(SetActionHudPrepareTime, 0)
979 Call(MoveBattleCamOver, 40)
980 Call(InitTargetIterator)
983 Call(N(WattFXSetEffect), 1)
988 Call(AddBattleCamDist, -100)
989 Call(MoveBattleCamOver, 80)
990 Call(N(WattFXDisable))
991 Call(N(TargetParalyzeChance))
992 Call(action_command_power_shock_start, 0, 75 *
DT - 3, 3,
LVar0)
997 Call(N(UnkBackgroundFunc3))
1027 Call(AddBattleCamDist, 100)
1028 Call(MoveBattleCamOver, 5)
1030 Call(N(PowerShockDischargeFX), 20)
1033 Call(N(SetBackgroundAlpha), 0)
1035 Call(N(SetBackgroundAlpha), 200)
1038 Call(N(SetBackgroundAlpha), 0)
1040 Call(N(WattFXEnable))
1041 Call(N(WattFXSetEffect), 0)
1067 Call(PartnerYieldTurn)
1079 ExecWait(N(EVS_ReturnHome_Success))
1090EvtScript N(EVS_TurboCharge_HealthyPlayer) = {
1092 Call(action_command_water_block_init, 1)
1093 Call(SetActionHudPrepareTime, 0)
1099 Call(SetBattleCamTarget, -125, 42, 0)
1100 Call(SetBattleCamOffsetY, 0)
1101 Call(SetBattleCamDist, 340)
1102 Call(MoveBattleCamOver, 30)
1115 Call(action_command_water_block_start, 0, 100 *
DT, 3)
1116 Call(AddBattleCamDist, -75)
1117 Call(MoveBattleCamOver, 100 *
DT)
1122 Call(N(TurboChargeUnwindWatt), 0)
1136 Call(AddBattleCamDist, 100)
1137 Call(MoveBattleCamOver, 5)
1143 Call(SetJumpAnimations,
ACTOR_PLAYER, 0, ANIM_Mario1_Jump, ANIM_Mario1_Fall, ANIM_Mario1_Land)
1145 Call(PlayerHopToGoal, 20, 0, 0)
1152 Call(MoveBattleCamOver, 10)
1155 Call(N(ApplyTurboCharge))
1169 Call(WaitForMessageBoxDone)
1175EvtScript N(EVS_TurboCharge_ImmobilePlayer) = {
1177 Call(action_command_water_block_init, 1)
1178 Call(SetActionHudPrepareTime, 0)
1182 Call(SetBattleCamTarget, -125, 42, 0)
1183 Call(SetBattleCamOffsetY, 0)
1184 Call(SetBattleCamDist, 340)
1185 Call(MoveBattleCamOver, 30)
1198 Call(action_command_water_block_start, 0, 100 *
DT, 3)
1199 Call(AddBattleCamDist, -100)
1200 Call(MoveBattleCamOver, 100 *
DT)
1205 Call(N(TurboChargeUnwindWatt), 1)
1219 Call(AddBattleCamDist, 100)
1220 Call(MoveBattleCamOver, 5)
1223 Call(MoveBattleCamOver, 10)
1226 Call(N(ApplyTurboCharge))
1240 Call(WaitForMessageBoxDone)
1249 ExecWait(N(EVS_TurboCharge_ImmobilePlayer))
1251 ExecWait(N(EVS_TurboCharge_HealthyPlayer))
1261 Call(action_command_mega_shock_init)
1262 Call(SetupMashMeter, 1, 100, 0, 0, 0, 0)
1263 Call(SetActionHudPrepareTime, 0)
1265 Call(SetBattleCamTarget, -54, 63, 10)
1266 Call(SetBattleCamOffsetY, 15)
1267 Call(SetBattleCamDist, 314)
1268 Call(MoveBattleCamOver, 30)
1276 Call(N(UnkBackgroundFunc3))
1285 Call(N(AverageTargetParalyzeChance))
1286 Call(action_command_mega_shock_start, 0, 87 *
DT, 3,
LVar0)
1294 Call(AddBattleCamDist, -100)
1295 Call(MoveBattleCamOver, 90 *
DT)
1299 Call(N(WattFXDisable))
1302 Call(N(SetBackgroundAlpha), 0)
1312 Call(InitTargetIterator)
1330 Call(SetBattleCamDist, 420)
1331 Call(SetBattleCamTarget, 6, 63, 10)
1332 Call(MoveBattleCamOver, 15)
1342 Call(N(PowerShockDischargeFX), 10)
1367 Call(N(WattFXEnable))
1368 Call(PartnerYieldTurn)
1373 ExecWait(N(EVS_ReturnHome_Success))
struct SelectableTarget targetData[24]
@ FX_SHOCK_OVERLAY_MEGA_SHOCK
struct PartnerBuffFXData * partnerBuff
struct StaticStatusFXData * staticStatus
@ FX_BUFF_DATA_TURBO_CHARGE
#define STATUS_FLAGS_IMMOBILIZED
@ FX_INSTANCE_FLAG_DISMISS
@ ACTION_COMMAND_WATER_BLOCK
@ ACTION_COMMAND_MEGA_SHOCK
@ ACTION_COMMAND_BODY_SLAM
@ ACTION_COMMAND_POWER_SHOCK
@ BS_FLAGS1_TRIGGER_EVENTS
@ BS_FLAGS1_INCLUDE_POWER_UPS
@ BTL_MSG_TURBO_CHARGE_BEGIN
@ ACTOR_PAL_ADJUST_WATT_IDLE
@ ACTOR_PAL_ADJUST_WATT_ATTACK
@ ACTOR_EVENT_FLAG_ELECTRIFIED
Player takes shock damage upon contact.
@ ACTOR_EVENT_FLAG_ILLUSORY
Player attacks pass through and miss.
@ BTL_MENU_TYPE_STAR_POWERS
@ BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER
@ BS_FLAGS2_STORED_TURBO_CHARGE_TURN
@ BS_FLAGS2_PLAYER_TURN_USED
@ BS_FLAGS2_PARTNER_TURN_USED
@ STATUS_TURN_MOD_DEFAULT
@ STATUS_TURN_MOD_PARALYZE
@ HIT_RESULT_NICE_NO_DAMAGE
@ BTL_CAM_CLOSER_PARTNER_APPROACH
@ BTL_CAM_PARTNER_MISTAKE
@ BTL_CAM_PARTNER_APPROACH
@ SUPPRESS_EVENT_SPIKY_TOP
@ SUPPRESS_EVENT_ALT_SPIKY
@ SUPPRESS_EVENT_SHOCK_CONTACT
@ SUPPRESS_EVENT_SPIKY_FRONT
@ SUPPRESS_EVENT_BURN_CONTACT
@ SOUND_WATT_MEGA_DISCHARGE
@ SOUND_WATT_MEGA_CHARGE_WAVE
@ SOUND_WATT_TURBO_CHARGE
@ ACTOR_FLAG_FLYING
Quake Hammer can't hit.
@ ACTOR_FLAG_NO_INACTIVE_ANIM
@ ACTOR_FLAG_UPSIDE_DOWN
HP bar offset below actor (e.g. Swooper when upside-down).
@ ACTOR_PART_FLAG_PRIMARY_TARGET
@ DAMAGE_TYPE_STATUS_ALWAYS_HITS
@ DAMAGE_TYPE_IGNORE_DEFENSE
@ DAMAGE_TYPE_MULTIPLE_POPUPS
s32 evt_get_variable(Evt *script, Bytecode var)
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
ActorPart * get_actor_part(Actor *actor, s32 partID)
Actor * get_actor(s32 actorID)
s32 lookup_status_chance(s32 *, s32)
EvtScript EVS_Partner_Hit
EvtScript EVS_Partner_Recover
EvtScript EVS_Partner_BurnContact
EvtScript EVS_Partner_Drop
EvtScript EVS_Partner_NoDamageHit
EvtScript EVS_Partner_ShockHit
EvtScript EVS_Partner_BurnHit
EvtScript EVS_Partner_Celebrate
EvtScript EVS_RunAwayFail
EvtScript EVS_Partner_SpikeContact
EvtScript EVS_Partner_RunAway
#define Else
Marks the end of an if statement and the start of the else block.
#define Switch(LVAR)
Marks the start of a switch statement.
#define Ref(sym)
Address/pointer constant.
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
#define AddF(VAR, FLOAT_VALUE)
#define CaseEq(RVAR)
Marks the start of a switch case that executes only if LVAR == RVAR. It also marks the end of any pre...
#define Sub(VAR, INT_VALUE)
#define SetPriority(PRIORITY)
Sets the current thread's priority. Higher-priority threads execute before lower-priority threads on ...
#define IfNe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR != RVAR.
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
#define Add(VAR, INT_VALUE)
#define EndLoop
Marks the end of a loop.
#define EndCaseGroup
Marks the end of a switch case group (CaseOrEq and/or CaseAndEq), stopping fallthrough.
#define Goto(LABEL_ID)
Moves execution to the given label.
#define NPC_DISPOSE_POS_Y
#define IfGt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR <= RVAR.
#define DMG_STATUS_ALWAYS(typeFlag, duration)
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
#define CaseOrEq(RVAR)
Marks the start of a switch case that executes only if LVAR == RVAR.
#define EndIf
Marks the end of an if statement or an else block.
#define CaseDefault
Marks the start of a switch case that executes unconditionally. It also marks the end of any previous...
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
#define BreakLoop
Breaks out of the innermost loop.
#define Thread
Marks the start of a thread block.
#define EndThread
Marks the end of a thread block.
#define KillThread(TID)
Kills a thread by its thread ID.
#define SetF(VAR, FLOAT_VALUE)
Sets the given variable to a given value, but supports Floats.
#define IfFlag(LVAR, RVAR)
Marks the beginning of an if statement that only executes if the RVAR flag is set on LVAR,...
#define ExecGetTID(EVT_SOURCE, OUTVAR)
Identical to Exec, but the newly-launched thread ID is stored in OUTVAR.
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
#define SubF(VAR, FLOAT_VALUE)
#define PlayEffect(args...)
#define EndSwitch
Marks the end of a switch statement and any case.
#define IfEq(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR == RVAR.
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
#define CaseGt(RVAR)
Marks the start of a switch case that executes only if LVAR <= RVAR. It also marks the end of any pre...
#define Loop(TIMES)
Marks the beginning of a loop.
#define SetConst(VAR, CONST)
Sets the given variable to a given value, skipping the evt_get_variable call.
#define Return
Kills the current EVT thread.
struct Actor * partnerActor
struct Actor * playerActor
struct EffectInstance * buffEffect
BattleStatus gBattleStatus