Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
ghost_watt.inc.c
Go to the documentation of this file.
1#include "battle/battle.h"
2#include "script_api/battle.h"
3#include "sprite/npc/BattleWatt.h"
4#include "effects.h"
5
6#define NAMESPACE A(watt_clone)
7
8extern EvtScript N(EVS_Init);
9extern EvtScript N(EVS_Idle);
10extern EvtScript N(EVS_TakeTurn);
12
13s32 N(DefaultAnims)[] = {
24};
25
26s32 N(DefenseTable)[] = {
28 ELEMENT_SHOCK, 99,
30};
31
32s32 N(StatusTable)[] = {
55};
56
58 {
60 .index = PRT_MAIN,
61 .posOffset = { 0, 0, 0 },
62 .targetOffset = { -1, 20 },
63 .opacity = 255,
64 .idleAnimations = N(DefaultAnims),
65 .defenseTable = N(DefenseTable),
66 .eventFlags = ACTOR_EVENT_FLAG_ELECTRIFIED,
67 .elementImmunityFlags = 0,
68 .projectileTargetOffset = { 0, -8 },
69 },
70 {
72 .index = PRT_TARGET,
73 .posOffset = { 0, 50, 0 },
74 .targetOffset = { -1, -30 },
75 .opacity = 255,
76 .idleAnimations = NULL,
77 .defenseTable = N(DefenseTable),
78 .eventFlags = ACTOR_EVENT_FLAG_ELECTRIFIED,
79 .elementImmunityFlags = 0,
80 .projectileTargetOffset = { 0, -8 },
81 },
82};
83
84ActorBlueprint NAMESPACE = {
85 .flags = ACTOR_FLAG_FLYING,
88 .maxHP = 15,
89 .partCount = ARRAY_COUNT(N(ActorParts)),
90 .partsData = N(ActorParts),
91 .initScript = &N(EVS_Init),
92 .statusTable = N(StatusTable),
93 .escapeChance = 50,
94 .airLiftChance = 80,
95 .hurricaneChance = 70,
96 .spookChance = 50,
97 .upAndAwayChance = 95,
98 .spinSmashReq = 0,
99 .powerBounceChance = 90,
100 .coinReward = 2,
101 .size = { 34, 28 },
102 .healthBarOffset = { 0, 0 },
103 .statusIconOffset = { -10, 20 },
104 .statusTextOffset = { 10, 20 },
105};
106
107EvtScript N(EVS_Init) = {
111 Return
112 End
113};
114
115API_CALLABLE(N(WattFXUpdate)) {
116 Actor* actor = get_actor(script->owner1.enemyID);
117 ActorState* state = &actor->state;
119 f32 x, y, z;
120
121 if (isInitialCall) {
123 actor->state.varTablePtr[2] = wattEffectData;
124 wattEffectData->isBouncing = TRUE;
125 wattEffectData->bouncePhase = 0;
126 wattEffectData->isActive = TRUE;
127 wattEffectData->currentEffectIndex = 0;
128 wattEffectData->effect1 = fx_static_status(0, actor->curPos.x, actor->curPos.y, actor->curPos.z, (actor->debuff != STATUS_KEY_SHRINK) ? 1.0f : 0.4f, 5, 0);
129 wattEffectData->effect2 = fx_static_status(1, actor->curPos.x, NPC_DISPOSE_POS_Y, actor->curPos.z, (actor->debuff != STATUS_KEY_SHRINK) ? 1.0f : 0.4f, 5, 0);
130 wattEffectData->initialized = TRUE;
131 wattEffectData->debuff = actor->debuff;
132 }
133
134 wattEffectData = state->varTablePtr[2];
135 if (wattEffectData->initialized) {
136 if (wattEffectData->isBouncing && actor->debuff != STATUS_KEY_STOP) {
137 wattEffectData->bouncePhase += 15;
138 wattEffectData->bouncePhase = clamp_angle(wattEffectData->bouncePhase);
139 }
140 actor->verticalRenderOffset = sin_rad(DEG_TO_RAD(wattEffectData->bouncePhase)) * 3.0f;
141
142 x = actor->curPos.x + actor->headOffset.x;
143 y = actor->curPos.y + actor->headOffset.y + actor->verticalRenderOffset + (actor->debuff != STATUS_KEY_SHRINK ? 12.0 : 4.800000000000001); // 4.8 doesn't match
144 z = actor->curPos.z + actor->headOffset.z;
145 if (wattEffectData->isActive) {
146 switch (wattEffectData->currentEffectIndex) {
147 case 0:
148 if (wattEffectData->effect1 == NULL) {
149 wattEffectData->effect1 = fx_static_status(0, x, y, z, (actor->debuff != STATUS_KEY_SHRINK) ? 1.0f : 0.4f, 5, 0);
150 }
151
152 if (wattEffectData->effect2 != NULL) {
153 wattEffectData->effect2->flags |= FX_INSTANCE_FLAG_DISMISS;
154 wattEffectData->effect2 = NULL;
155 }
156 wattEffectData->effect1->data.staticStatus->pos.x = x;
157 wattEffectData->effect1->data.staticStatus->pos.y = y;
158 wattEffectData->effect1->data.staticStatus->pos.z = z;
159 break;
160 case 1:
161 if (wattEffectData->effect1 != NULL) {
162 wattEffectData->effect1->flags |= FX_INSTANCE_FLAG_DISMISS;
163 wattEffectData->effect1 = NULL;
164 }
165 if (wattEffectData->effect2 == NULL) {
166 wattEffectData->effect2 = fx_static_status(1, x, y, z, (actor->debuff != STATUS_KEY_SHRINK) ? 1.0f : 0.4f, 5, 0);
167
168 }
169 wattEffectData->effect2->data.staticStatus->pos.x = x;
170 wattEffectData->effect2->data.staticStatus->pos.y = y;
171 wattEffectData->effect2->data.staticStatus->pos.z = z;
172 break;
173 }
174 } else {
175 if (wattEffectData->effect1 != NULL) {
176 wattEffectData->effect1->flags |= FX_INSTANCE_FLAG_DISMISS;
177 wattEffectData->effect1 = NULL;
178 }
179 if (wattEffectData->effect2 != NULL) {
180 wattEffectData->effect2->flags |= FX_INSTANCE_FLAG_DISMISS;
181 wattEffectData->effect2 = NULL;
182 }
183 }
184 if (wattEffectData->debuff != actor->debuff && wattEffectData->isActive) {
185 if (wattEffectData->effect1 != NULL) {
186 wattEffectData->effect1->flags |= FX_INSTANCE_FLAG_DISMISS;
187 wattEffectData->effect1 = NULL;
188 }
189 if (wattEffectData->effect2 != NULL) {
190 wattEffectData->effect2->flags |= FX_INSTANCE_FLAG_DISMISS;
191 wattEffectData->effect2 = NULL;
192 }
193 }
194 wattEffectData->debuff = actor->debuff;
195 return ApiStatus_BLOCK;
196 }
197 return ApiStatus_DONE2;
198}
199
200EvtScript N(EVS_Idle) = {
201 SetPriority(99)
203 Return
204 End
205};
206
207API_CALLABLE(N(WattFXRemove)) {
208 WattEffectData* wattEffectData = get_actor(script->owner1.enemyID)->state.varTablePtr[2];
209
210 wattEffectData->initialized = FALSE;
211
212 if (wattEffectData->effect1 != NULL) {
213 wattEffectData->effect1->flags |= FX_INSTANCE_FLAG_DISMISS;
214 }
215
216 if (wattEffectData->effect2 != NULL) {
217 wattEffectData->effect2->flags |= FX_INSTANCE_FLAG_DISMISS;
218 }
219
220 return ApiStatus_DONE2;
221}
222
223API_CALLABLE(N(WattFXSetBouncing)) {
224 Bytecode* args = script->ptrReadPos;
225 WattEffectData* wattEffectData = get_actor(script->owner1.enemyID)->state.varTablePtr[2];
226
227 wattEffectData->isBouncing = evt_get_variable(script, *args++);
228 return ApiStatus_DONE2;
229}
230
231API_CALLABLE(N(WattFXSetActive)) {
232 Bytecode* args = script->ptrReadPos;
233 WattEffectData* wattEffectData = get_actor(script->owner1.enemyID)->state.varTablePtr[2];
234
235 wattEffectData->isActive = evt_get_variable(script, *args++);
236 return ApiStatus_DONE2;
237}
238
239API_CALLABLE(N(WattFXSetEffect)) {
240 Bytecode* args = script->ptrReadPos;
241 WattEffectData* wattEffectData = get_actor(script->owner1.enemyID)->state.varTablePtr[2];
242
243 wattEffectData->currentEffectIndex = evt_get_variable(script, *args++);
244 return ApiStatus_DONE2;
245}
246
250 Call(N(WattFXSetActive), 1)
251 Call(N(WattFXSetEffect), 0)
275 Return
289 Return
303 Wait(10)
307 Return
317 Return
326 Return
331 Return
332 End
333};
334
335#include "common/UnkBackgroundFunc3.inc.c"
336
338
351 Call(N(WattFXSetEffect), 1)
352 Call(AddGoalPos, ACTOR_SELF, 15, -10, 5)
355 Call(N(WattFXSetEffect), 0)
356 Wait(5)
358 Call(AddGoalPos, ACTOR_SELF, 25, 20, 0)
367 Set(LVarA, LVar0)
368 Thread
369 Wait(5)
373 Call(AddGoalPos, ACTOR_SELF, -40, 10, 0)
377 EndIf
378 Call(N(WattFXSetActive), 1)
380 Wait(20)
388 Return
391 Call(N(WattFXSetActive), 0)
392 Set(LVarA, 40)
400 Add(LVar1, 4)
402 Else
404 Add(LVar1, 12)
406 EndIf
408 Set(LVar9, 0)
410 Loop(LVarA)
411 Add(LVar9, 3)
412 IfGt(LVar9, 200)
413 Set(LVar9, 200)
414 EndIf
416 Wait(1)
417 EndLoop
422 Thread
423 Wait(2)
429 Wait(2)
430#if VERSION_JP
432#else
434#endif
436 Wait(2)
437#if VERSION_JP
439#else
441#endif
443 Wait(2)
444#if VERSION_JP
446#else
448#endif
454 Call(N(WattFXSetActive), 1)
456 Call(AddGoalPos, ACTOR_SELF, 25, 10, 0)
458 Wait(15)
467 Return
468 End
469};
470
BSS s32 PopupMenu_SelectedIndex
s8 verticalRenderOffset
Vec3s headOffset
ActorState state
Vec3f curPos
Bytecode EvtScript[]
#define clamp_angle
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ BTL_CAM_XADJ_AVG
Definition enums.h:4899
@ BTL_CAM_XADJ_NONE
Definition enums.h:4898
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3574
@ BS_FLAGS1_INCLUDE_POWER_UPS
Definition enums.h:3570
@ ELEMENT_END
Definition enums.h:2114
@ ELEMENT_SHOCK
Definition enums.h:2125
@ ELEMENT_NORMAL
Definition enums.h:2115
@ ACTOR_PAL_ADJUST_WATT_IDLE
Definition enums.h:2248
@ ACTOR_EVENT_FLAG_ELECTRIFIED
Player takes shock damage upon contact.
Definition enums.h:3375
@ STATUS_KEY_PARALYZE
Definition enums.h:2201
@ STATUS_TURN_MOD_DEFAULT
Definition enums.h:2227
@ STATUS_TURN_MOD_PARALYZE
Definition enums.h:2234
@ STATUS_KEY_FROZEN
Definition enums.h:2203
@ STATUS_TURN_MOD_SLEEP
Definition enums.h:2228
@ STATUS_TURN_MOD_DIZZY
Definition enums.h:2232
@ STATUS_KEY_STATIC
Definition enums.h:2207
@ STATUS_END
Definition enums.h:2196
@ STATUS_TURN_MOD_POISON
Definition enums.h:2233
@ STATUS_KEY_FEAR
Definition enums.h:2199
@ STATUS_TURN_MOD_STOP
Definition enums.h:2237
@ STATUS_KEY_SLEEP
Definition enums.h:2202
@ STATUS_KEY_STONE
Definition enums.h:2208
@ STATUS_KEY_STOP
Definition enums.h:2204
@ STATUS_TURN_MOD_FROZEN
Definition enums.h:2230
@ STATUS_KEY_SHRINK
Definition enums.h:2206
@ STATUS_KEY_DIZZY
Definition enums.h:2200
@ STATUS_KEY_POISON
Definition enums.h:2205
@ STATUS_TURN_MOD_STATIC
Definition enums.h:2229
@ STATUS_TURN_MOD_FEAR
Definition enums.h:2231
@ STATUS_KEY_NORMAL
Definition enums.h:2197
@ STATUS_TURN_MOD_SHRINK
Definition enums.h:2235
@ STATUS_KEY_DEFAULT
Definition enums.h:2198
@ HIT_RESULT_NO_DAMAGE
Definition enums.h:1952
@ HIT_RESULT_HIT
Definition enums.h:1950
@ HIT_RESULT_LUCKY
Definition enums.h:1955
@ HIT_RESULT_MISS
Definition enums.h:1956
@ BTL_CAM_DEFAULT
Definition enums.h:4823
@ BTL_CAM_REPOSITION
Definition enums.h:4840
@ SUPPRESS_EVENT_ALL
Definition enums.h:2907
@ EASING_COS_IN_OUT
Definition enums.h:520
@ EASING_QUADRATIC_OUT
Definition enums.h:514
@ PARTNER_RANK_NORMAL
Definition enums.h:2018
@ PARTNER_RANK_SUPER
Definition enums.h:2019
@ PARTNER_RANK_ULTRA
Definition enums.h:2020
@ STATUS_FLAG_SHRINK
Definition enums.h:2819
@ SOUND_WATT_CHARGE
Definition enums.h:1000
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_SELF
Definition enums.h:2084
@ ACTOR_FLAG_FLYING
Quake Hammer can't hit.
Definition enums.h:3329
@ BTL_CAM_YADJ_NONE
Definition enums.h:4905
@ BTL_CAM_YADJ_TARGET
Definition enums.h:4904
@ EVENT_HIT
Definition enums.h:2132
@ EVENT_SCARE_AWAY
Definition enums.h:2174
@ EVENT_BURN_HIT
Definition enums.h:2136
@ EVENT_IMMUNE
Definition enums.h:2146
@ EVENT_BURN_DEATH
Definition enums.h:2157
@ EVENT_ZERO_DAMAGE
Definition enums.h:2144
@ EVENT_SPIN_SMASH_HIT
Definition enums.h:2133
@ EVENT_SPIN_SMASH_DEATH
Definition enums.h:2154
@ EVENT_HIT_COMBO
Definition enums.h:2131
@ EVENT_AIR_LIFT_FAILED
Definition enums.h:2152
@ EVENT_BEGIN_AIR_LIFT
Definition enums.h:2175
@ EVENT_DEATH
Definition enums.h:2153
@ EVENT_RECOVER_STATUS
Definition enums.h:2167
@ EVENT_BLOW_AWAY
Definition enums.h:2143
@ ACTOR_PART_FLAG_PRIMARY_TARGET
Definition enums.h:3362
@ ACTOR_PART_FLAG_SKIP_MOVEMENT_ALLOC
Definition enums.h:3366
@ ACTOR_PART_FLAG_NO_TARGET
Cannot be targeted.
Definition enums.h:3360
@ ACTOR_PART_FLAG_INVISIBLE
Definition enums.h:3350
@ DAMAGE_TYPE_IGNORE_DEFENSE
Definition enums.h:2877
@ DAMAGE_TYPE_SHOCK
Definition enums.h:2856
@ DAMAGE_TYPE_TRIGGER_LUCKY
Definition enums.h:2881
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
#define ApiStatus_BLOCK
Definition evt.h:116
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1689
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
f32 sin_rad(f32 x)
Definition 43F0.c:712
void * heap_malloc(s32 size)
Definition heap.c:34
EvtScript EVS_Enemy_ScareAway
EvtScript EVS_Enemy_Hit
EvtScript EVS_Enemy_Death
EvtScript EVS_Enemy_SpinSmashHit
EvtScript EVS_Enemy_AirLift
EvtScript EVS_Enemy_BlowAway
EvtScript EVS_Enemy_Recover
EvtScript EVS_Enemy_BurnHit
EvtScript EVS_Enemy_NoDamageHit
#define Else
Marks the end of an if statement and the start of the else block.
Definition macros.h:295
#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 CaseEq(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:319
#define SetPriority(PRIORITY)
Sets the current thread's priority. Higher-priority threads execute before lower-priority threads on ...
Definition macros.h:513
#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 EndCaseGroup
Marks the end of a switch case group (CaseOrEq and/or CaseAndEq), stopping fallthrough.
Definition macros.h:352
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define NPC_DISPOSE_POS_Y
Definition macros.h:164
#define IfGt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR <= RVAR.
Definition macros.h:278
#define Float(DOUBLE)
Definition macros.h:51
#define CaseOrEq(RVAR)
Marks the start of a switch case that executes only if LVAR == RVAR.
Definition macros.h:341
#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 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 IfFlag(LVAR, RVAR)
Marks the beginning of an if statement that only executes if the RVAR flag is set on LVAR,...
Definition macros.h:288
#define LVar2
Definition macros.h:150
#define DEG_TO_RAD(deg)
Definition macros.h:138
#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 LVar9
Definition macros.h:157
#define A(sym)
Definition macros.h:36
#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 Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:245
#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
#define ACTOR_BY_POS(_name, _pos, _priority, args...)
Definition battle.h:230
FormationRow Formation[]
Definition battle.h:167