Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
duplighost.inc.c
Go to the documentation of this file.
1#include "battle/battle.h"
2#include "script_api/battle.h"
3#include "effects.h"
4#include "sprite/npc/Duplighost.h"
5
6#define NAMESPACE A(duplighost)
7
8// scripts in duplighost.c call two functions defined in ghost_watt.c for adjusting the background fade
9// this macro is used to highlight those instances
10#define WATT(x) A( watt_clone_##x )
11
12extern EvtScript N(EVS_Init);
13extern EvtScript N(EVS_Idle);
14extern EvtScript N(EVS_TakeTurn);
15extern EvtScript N(EVS_HandleEvent);
16extern EvtScript N(EVS_HandlePhase);
17
18enum N(ActorPartIDs) {
19 PRT_MAIN = 1,
20 PRT_TARGET = 2,
21 PRT_SPINY = 3,
22 PRT_ZERO = 0,
23};
24
25enum N(ActorVars) {
26 AVAR_Copy_ParentActorID = 0,
27 AVAR_Copy_PartnerLevel = 1,
28 AVAR_Kooper_Toppled = 3,
29 AVAR_Kooper_ToppleTurns = 4,
30 AVAR_State = 8,
31 AVAL_State_ReadyToCopy = 0, // will copy partner next turn
32 AVAL_State_CopiedPartner = 1, // currently transformed
33 AVAL_State_ReadyToTackle = 2, // will use flying tackle next turn
34 AVAL_State_WaitToTackle = 3, // do nothing this turn and tackle next turn (unused)
35};
36
37enum N(ActorParams) {
38 DMG_FLYING_LEAP = 4,
39};
40
41s32 N(DefaultAnims)[] = {
42 STATUS_KEY_NORMAL, ANIM_Duplighost_Anim02,
43 STATUS_KEY_STONE, ANIM_Duplighost_Anim00,
44 STATUS_KEY_SLEEP, ANIM_Duplighost_Anim0D,
45 STATUS_KEY_POISON, ANIM_Duplighost_Anim02,
46 STATUS_KEY_STOP, ANIM_Duplighost_Anim00,
47 STATUS_KEY_STATIC, ANIM_Duplighost_Anim02,
48 STATUS_KEY_PARALYZE, ANIM_Duplighost_Anim00,
49 STATUS_KEY_DIZZY, ANIM_Duplighost_Anim0E,
50 STATUS_KEY_FEAR, ANIM_Duplighost_Anim0E,
52};
53
54s32 N(FlailingAnims)[] = {
55 STATUS_KEY_NORMAL, ANIM_Duplighost_Anim0A,
57};
58
59s32 N(RunAnims)[] = {
60 STATUS_KEY_NORMAL, ANIM_Duplighost_Anim04,
62};
63
64s32 N(DefenseTable)[] = {
67};
68
69s32 N(StatusTable)[] = {
92};
93
94ActorPartBlueprint N(ActorParts)[] = {
95 {
97 .index = PRT_MAIN,
98 .posOffset = { 0, 0, 0 },
99 .targetOffset = { -5, 25 },
100 .opacity = 255,
101 .idleAnimations = N(DefaultAnims),
102 .defenseTable = N(DefenseTable),
103 .eventFlags = 0,
104 .elementImmunityFlags = 0,
105 .projectileTargetOffset = { -2, -10 },
106 },
107};
108
109ActorBlueprint NAMESPACE = {
110 .flags = 0,
111 .type = ACTOR_TYPE_DUPLIGHOST,
112 .level = ACTOR_LEVEL_DUPLIGHOST,
113 .maxHP = 15,
114 .partCount = ARRAY_COUNT(N(ActorParts)),
115 .partsData = N(ActorParts),
116 .initScript = &N(EVS_Init),
117 .statusTable = N(StatusTable),
118 .escapeChance = 50,
119 .airLiftChance = 80,
120 .hurricaneChance = 70,
121 .spookChance = 50,
122 .upAndAwayChance = 95,
123 .spinSmashReq = 0,
124 .powerBounceChance = 90,
125 .coinReward = 2,
126 .size = { 36, 36 },
127 .healthBarOffset = { 0, 0 },
128 .statusIconOffset = { -10, 20 },
129 .statusTextOffset = { 10, 20 },
130};
131
132EvtScript N(EVS_Init) = {
133 Call(BindTakeTurn, ACTOR_SELF, Ref(N(EVS_TakeTurn)))
134 Call(BindIdle, ACTOR_SELF, Ref(N(EVS_Idle)))
135 Call(BindHandleEvent, ACTOR_SELF, Ref(N(EVS_HandleEvent)))
136 Call(BindHandlePhase, ACTOR_SELF, Ref(N(EVS_HandlePhase)))
137 Call(SetActorVar, ACTOR_SELF, AVAR_State, AVAL_State_ReadyToCopy)
138 Return
139 End
140};
141
142EvtScript N(EVS_HandlePhase) = {
143 Call(GetBattlePhase, LVar0)
148 Call(GetActorVar, ACTOR_SELF, AVAR_State, LVar0)
149 IfEq(LVar0, AVAL_State_WaitToTackle)
150 Call(SetActorVar, ACTOR_SELF, AVAR_State, AVAL_State_ReadyToTackle)
151 EndIf
153 Return
154 End
155};
156
157EvtScript N(EVS_Idle) = {
158 Return
159 End
160};
161
162EvtScript N(EVS_ReturnHome) = {
163 SetConst(LVar0, PRT_MAIN)
164 SetConst(LVar1, ANIM_Duplighost_Anim04)
166 Return
167 End
168};
169
170EvtScript N(EVS_HandleEvent) = {
171 Call(UseIdleAnimation, ACTOR_SELF, FALSE)
172 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE)
173 Call(GetLastEvent, ACTOR_SELF, LVar0)
177 SetConst(LVar0, PRT_MAIN)
178 SetConst(LVar1, ANIM_Duplighost_Anim0A)
182 SetConst(LVar0, PRT_MAIN)
183 SetConst(LVar1, ANIM_Duplighost_Anim0C)
184 SetConst(LVar2, -1)
187 SetConst(LVar0, PRT_MAIN)
188 SetConst(LVar1, ANIM_Duplighost_Anim0C)
189 SetConst(LVar2, -1)
191 SetConst(LVar0, PRT_MAIN)
192 SetConst(LVar1, ANIM_Duplighost_Anim0C)
194 Return
196 SetConst(LVar0, PRT_MAIN)
197 SetConst(LVar1, ANIM_Duplighost_Anim0A)
200 SetConst(LVar0, PRT_MAIN)
201 SetConst(LVar1, ANIM_Duplighost_Anim0A)
203 SetConst(LVar0, PRT_MAIN)
204 SetConst(LVar1, ANIM_Duplighost_Anim0A)
206 Return
208 Call(ResetAllActorSounds, ACTOR_SELF)
209 SetConst(LVar0, PRT_MAIN)
210 SetConst(LVar1, ANIM_Duplighost_Anim0A)
212 SetConst(LVar0, PRT_MAIN)
213 SetConst(LVar1, ANIM_Duplighost_Anim0A)
215 ExecWait(N(EVS_ReturnHome))
217 SetConst(LVar0, PRT_MAIN)
218 SetConst(LVar1, ANIM_Duplighost_Anim0A)
220 SetConst(LVar0, PRT_MAIN)
221 SetConst(LVar1, ANIM_Duplighost_Anim0A)
223 Return
227 SetConst(LVar0, PRT_MAIN)
228 SetConst(LVar1, ANIM_Duplighost_Anim02)
232 SetConst(LVar0, PRT_MAIN)
233 SetConst(LVar1, ANIM_Duplighost_Anim0A)
235 Wait(10)
236 SetConst(LVar0, PRT_MAIN)
237 SetConst(LVar1, ANIM_Duplighost_Anim0A)
239 Return
241 SetConst(LVar0, PRT_MAIN)
242 SetConst(LVar1, ANIM_Duplighost_Anim02)
245 SetConst(LVar0, PRT_MAIN)
246 SetConst(LVar1, ANIM_Duplighost_Anim04)
247 SetConst(LVar2, ANIM_Duplighost_Anim0A)
249 Return
251 SetConst(LVar0, PRT_MAIN)
252 SetConst(LVar1, ANIM_Duplighost_Anim04)
255 SetConst(LVar0, PRT_MAIN)
256 SetConst(LVar1, ANIM_Duplighost_Anim0A)
258 Return
261 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE)
262 Call(UseIdleAnimation, ACTOR_SELF, TRUE)
263 Return
264 End
265};
266
267EvtScript N(EVS_Attack_FlyingTackle) = {
268 Call(UseIdleAnimation, ACTOR_SELF, FALSE)
269 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE)
270 Call(SetTargetActor, ACTOR_SELF, ACTOR_PLAYER)
271 Call(UseBattleCamPreset, BTL_CAM_ENEMY_APPROACH)
272 Call(BattleCamTargetActor, ACTOR_SELF)
273 Call(SetBattleCamTargetingModes, BTL_CAM_YADJ_TARGET, BTL_CAM_XADJ_AVG, FALSE)
274 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_Duplighost_Anim07)
275 Wait(20)
277 Call(EnemyTestTarget, ACTOR_SELF, LVar0, 0, 0, 1, BS_FLAGS1_INCLUDE_POWER_UPS)
281 Set(LVarA, LVar0)
282 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
283 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_Duplighost_Anim08)
284 Call(SetGoalToTarget, ACTOR_SELF)
285 Call(AddGoalPos, ACTOR_SELF, -100, 0, 0)
286 Call(SetActorJumpGravity, ACTOR_SELF, Float(0.3))
287 Call(JumpToGoal, ACTOR_SELF, 17, FALSE, TRUE, FALSE)
289 Call(EnemyTestTarget, ACTOR_SELF, LVar0, DAMAGE_TYPE_TRIGGER_LUCKY, 0, 0, 0)
290 EndIf
291 Wait(10)
292 Call(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
293 Call(SetActorPos, ACTOR_SELF, LVar0, 0, LVar2)
294 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_Duplighost_Anim02)
295 Call(ResetActorSounds, ACTOR_SELF, ACTOR_SOUND_JUMP)
296 Wait(15)
297 Call(YieldTurn)
298 Call(SetActorYaw, ACTOR_SELF, 180)
299 Call(AddActorDecoration, ACTOR_SELF, PRT_MAIN, 0, ACTOR_DECORATION_SWEAT)
300 ExecWait(N(EVS_ReturnHome))
301 Call(RemoveActorDecoration, ACTOR_SELF, PRT_MAIN, 0)
302 Call(SetActorYaw, ACTOR_SELF, 0)
303 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE)
304 Call(UseIdleAnimation, ACTOR_SELF, TRUE)
305 Return
308 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_Duplighost_Anim08)
309 Call(SetGoalToTarget, ACTOR_SELF)
310 Call(GetStatusFlags, ACTOR_SELF, LVarA)
312 Call(AddGoalPos, ACTOR_SELF, Float(4.0), Float(-6.0), 0)
313 Else
314 Call(AddGoalPos, ACTOR_SELF, 10, -15, 0)
315 EndIf
316 Call(SetActorJumpGravity, ACTOR_SELF, Float(0.3))
317 Call(JumpToGoal, ACTOR_SELF, 12, FALSE, TRUE, FALSE)
318 Wait(2)
319 Call(SetGoalToTarget, ACTOR_SELF)
320 Call(EnemyDamageTarget, ACTOR_SELF, LVar0, 0, 0, 0, DMG_FLYING_LEAP, BS_FLAGS1_TRIGGER_EVENTS)
324 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
325 Call(ResetActorSounds, ACTOR_SELF, ACTOR_SOUND_JUMP)
326 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_Duplighost_Anim09)
327 Call(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
328 Call(SetActorJumpGravity, ACTOR_SELF, Float(0.5))
329 Add(LVar0, 30)
330 Call(SetGoalPos, ACTOR_SELF, LVar0, 0, LVar2)
331 Call(JumpToGoal, ACTOR_SELF, 20, FALSE, TRUE, FALSE)
332 Add(LVar0, 20)
333 Call(SetGoalPos, ACTOR_SELF, LVar0, 0, LVar2)
334 Call(JumpToGoal, ACTOR_SELF, 10, FALSE, TRUE, FALSE)
335 Wait(10)
336 Call(YieldTurn)
337 ExecWait(N(EVS_ReturnHome))
340 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE)
341 Call(UseIdleAnimation, ACTOR_SELF, TRUE)
342 Return
343 End
344};
345
346EvtScript A(EVS_Duplighost_OnDeath) = {
347 Call(GetActorVar, ACTOR_SELF, AVAR_Copy_ParentActorID, LVar0)
348 Call(RemoveActor, LVar0)
349 Return
350 End
351};
352
353EvtScript A(EVS_Duplighost_OnHitElectric) = {
354 Call(UseIdleAnimation, ACTOR_SELF, FALSE)
355 Call(HideHealthBar, ACTOR_SELF)
356 Call(SetAnimation, ACTOR_SELF, LVar0, LVar1)
357 Wait(30)
358 Call(GetActorVar, ACTOR_SELF, AVAR_Copy_ParentActorID, LVarA)
359 Call(UseIdleAnimation, LVarA, FALSE)
360 Call(HideHealthBar, LVarA)
361 Call(CopyStatusEffects, ACTOR_SELF, LVarA)
362 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_SMOKE_BURST)
363 Thread
364 Call(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
365 Add(LVar1, 3)
366 Add(LVar2, 5)
367 Loop(3)
368 PlayEffect(EFFECT_BIG_SMOKE_PUFF, LVar0, LVar1, LVar2, 0, 0, 0, 0, 0)
369 Wait(3)
370 EndLoop
372 Wait(5)
373 Call(GetActorHP, ACTOR_SELF, LVarB)
374 Call(SetEnemyHP, LVarA, LVarB)
375 Call(CopyBuffs, ACTOR_SELF, LVarA)
376 Call(GetActorPos, ACTOR_SELF, LVarB, LVarC, LVarD)
377 Call(SetActorPos, LVarA, LVarB, LVarC, LVarD)
378 Call(SetPartFlagBits, LVarA, 1, ACTOR_PART_FLAG_PRIMARY_TARGET, TRUE)
380 Call(SetActorFlagBits, LVarA, ACTOR_FLAG_NO_SHADOW | ACTOR_FLAG_NO_DMG_APPLY, FALSE)
381 Call(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_NO_SHADOW, TRUE)
382 Call(SetActorVar, LVarA, AVAR_State, AVAL_State_ReadyToTackle)
383 Call(SetPartFlagBits, ACTOR_SELF, LVar0, ACTOR_PART_FLAG_INVISIBLE, TRUE)
384 Call(SetIdleAnimations, LVarA, PRT_MAIN, Ref(N(FlailingAnims)))
385 Call(SetAnimation, LVarA, 1, ANIM_Duplighost_Anim0A)
386 Wait(30)
387 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
388 Call(GetActorPos, LVarA, LVarB, LVarC, LVarD)
389 IfGt(LVarC, 0)
390 Set(LVarC, 0)
391 Call(SetActorJumpGravity, LVarA, Float(0.5))
392 Call(SetActorSounds, LVarA, ACTOR_SOUND_JUMP, SOUND_FALL_QUICK, 0)
393 Call(SetGoalPos, LVarA, LVarB, LVarC, LVarD)
394 Call(JumpToGoal, LVarA, 15, FALSE, TRUE, FALSE)
395 Call(ResetActorSounds, LVarA, ACTOR_SOUND_JUMP)
396 Call(SetGoalPos, LVarA, LVarB, LVarC, LVarD)
397 Call(JumpToGoal, LVarA, 10, FALSE, TRUE, FALSE)
398 Call(SetGoalPos, LVarA, LVarB, LVarC, LVarD)
399 Call(JumpToGoal, LVarA, 5, FALSE, TRUE, FALSE)
400 EndIf
401 Call(ForceHomePos, LVarA, LVarB, LVarC, LVarD)
402 Call(HPBarToHome, LVarA)
403 Call(SetIdleAnimations, LVarA, PRT_MAIN, Ref(N(DefaultAnims)))
404 Call(SetAnimation, LVarA, 1, ANIM_Duplighost_Anim02)
406 Call(ForceHomePos, ACTOR_SELF, NPC_DISPOSE_LOCATION)
407 Call(HPBarToHome, ACTOR_SELF)
408 Call(RemoveActor, ACTOR_SELF)
409 Return
410 End
411};
412
413EvtScript A(EVS_Duplighost_OnShockHit) = {
414 Set(LVar9, LVar0)
415 Call(UseIdleAnimation, ACTOR_SELF, FALSE)
416 Call(HideHealthBar, ACTOR_SELF)
417 Call(SetAnimation, ACTOR_SELF, LVar0, LVar1)
418 Call(SetActorRotation, ACTOR_SELF, 0, 0, 0)
419 Call(SetActorDispOffset, ACTOR_SELF, 0, 0, 0)
420 Call(GetActorPos, ACTOR_SELF, LVar2, LVar3, LVar4)
421 Add(LVar2, 10)
422 Add(LVar3, 10)
423 Call(SetActorJumpGravity, ACTOR_SELF, Float(1.0))
424 Call(SetGoalPos, ACTOR_SELF, LVar2, LVar3, LVar4)
425 Call(JumpToGoal, ACTOR_SELF, 5, FALSE, TRUE, FALSE)
427 Call(GetActorVar, ACTOR_SELF, AVAR_Copy_ParentActorID, LVarA)
428 Call(UseIdleAnimation, LVarA, FALSE)
429 Call(HideHealthBar, LVarA)
430 Call(CopyStatusEffects, ACTOR_SELF, LVarA)
431 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_SMOKE_BURST)
432 Thread
433 Call(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
434 Add(LVar1, 3)
435 Add(LVar2, 5)
436 Loop(3)
437 PlayEffect(EFFECT_BIG_SMOKE_PUFF, LVar0, LVar1, LVar2, 0, 0, 0, 0, 0)
438 Wait(3)
439 EndLoop
441 Wait(5)
442 Call(GetActorHP, ACTOR_SELF, LVarB)
443 Call(SetEnemyHP, LVarA, LVarB)
444 Call(CopyBuffs, ACTOR_SELF, LVarA)
445 Call(GetActorPos, ACTOR_SELF, LVarB, LVarC, LVarD)
446 Call(SetActorPos, LVarA, LVarB, LVarC, LVarD)
447 Call(SetPartFlagBits, LVarA, 1, ACTOR_PART_FLAG_PRIMARY_TARGET, TRUE)
449 Call(SetActorFlagBits, LVarA, ACTOR_FLAG_NO_SHADOW | ACTOR_FLAG_NO_DMG_APPLY, FALSE)
450 Call(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_NO_SHADOW, TRUE)
451 Call(SetActorVar, LVarA, AVAR_State, AVAL_State_WaitToTackle)
452 Call(SetPartFlagBits, ACTOR_SELF, LVar9, ACTOR_PART_FLAG_INVISIBLE, TRUE)
453 Call(SetIdleAnimations, LVarA, PRT_MAIN, Ref(N(FlailingAnims)))
454 Call(SetAnimation, LVarA, 1, ANIM_Duplighost_Anim0A)
455 Wait(15)
456 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
457 Call(SetActorJumpGravity, LVarA, Float(0.5))
458 Call(GetActorPos, LVarA, LVarB, LVarC, LVarD)
459 Add(LVarB, 30)
460 Set(LVarC, 0)
461 Call(SetGoalPos, LVarA, LVarB, LVarC, LVarD)
462 Call(JumpToGoal, LVarA, 15, FALSE, TRUE, FALSE)
463 Add(LVarB, 20)
464 Call(SetGoalPos, LVarA, LVarB, LVarC, LVarD)
465 Call(JumpToGoal, LVarA, 10, FALSE, TRUE, FALSE)
466 Add(LVarB, 10)
467 Call(SetGoalPos, LVarA, LVarB, LVarC, LVarD)
468 Call(JumpToGoal, LVarA, 5, FALSE, TRUE, FALSE)
469 Wait(20)
470 Call(AddActorDecoration, LVarA, 1, 0, ACTOR_DECORATION_SWEAT)
471 Call(SetActorYaw, LVarA, 180)
472 Call(SetIdleAnimations, LVarA, PRT_MAIN, Ref(N(RunAnims)))
473 Call(SetAnimation, LVarA, 1, ANIM_Duplighost_Anim04)
474 Call(SetActorSpeed, LVarA, Float(8.0))
475 Call(SetGoalToHome, ACTOR_SELF)
476 Call(GetGoalPos, ACTOR_SELF, LVarB, LVarC, LVarD)
477 Call(SetGoalPos, LVarA, LVarB, 0, LVarD)
478 Call(RunToGoal, LVarA, 0, FALSE)
479 Call(SetAnimation, LVarA, 1, ANIM_Duplighost_Anim02)
480 Call(SetActorYaw, LVarA, 0)
481 Call(RemoveActorDecoration, LVarA, 1, 0)
482 Call(SetIdleAnimations, LVarA, PRT_MAIN, Ref(N(DefaultAnims)))
483 Call(ForceHomePos, LVarA, LVarB, 0, LVarD)
484 Call(HPBarToHome, LVarA)
486 Call(ForceHomePos, ACTOR_SELF, NPC_DISPOSE_LOCATION)
487 Call(HPBarToHome, ACTOR_SELF)
488 Call(RemoveActor, ACTOR_SELF)
489 Return
490 End
491};
492
493EvtScript A(EVS_Duplighost_OnShockDeath) = {
494 Call(HideHealthBar, ACTOR_SELF)
495 Set(LVarA, LVar0)
496 Set(LVarB, LVar1)
497 Set(LVarC, LVar2)
498 Call(SetActorRotation, ACTOR_SELF, 0, 0, 0)
499 Call(SetActorScale, ACTOR_SELF, Float(1.0), Float(1.0), Float(1.0))
500 Call(SetActorDispOffset, ACTOR_SELF, 0, 0, 0)
501 Call(SetAnimation, ACTOR_SELF, LVarA, LVarB)
502 Call(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
503 Add(LVar0, 15)
504 Add(LVar1, 10)
505 Call(SetActorJumpGravity, ACTOR_SELF, Float(0.1))
506 Call(SetAnimation, ACTOR_SELF, LVarA, LVarB)
507 Call(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
508 Call(JumpToGoal, ACTOR_SELF, 5, FALSE, FALSE, FALSE)
509 Set(LVar0, LVarA)
510 Set(LVar1, LVarB)
512 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
513 Thread
514 Call(SetActorRotationOffset, ACTOR_SELF, 0, LVarC, 0)
515 Set(LVar0, 0)
516 Loop(15)
517 Add(LVar0, -48)
518 Call(SetActorRotation, ACTOR_SELF, 0, 0, LVar0)
519 Wait(1)
520 EndLoop
521 Call(SetActorRotationOffset, ACTOR_SELF, 0, 0, 0)
523 Call(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
524 Add(LVar0, 60)
525 Set(LVar1, 0)
526 Call(SetActorJumpGravity, ACTOR_SELF, Float(1.4))
527 Call(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
528 Call(JumpToGoal, ACTOR_SELF, 15, FALSE, TRUE, FALSE)
529 Add(LVar0, 20)
530 Call(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
531 Call(JumpToGoal, ACTOR_SELF, 10, FALSE, TRUE, FALSE)
532 Add(LVar0, 10)
533 Call(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
534 Call(JumpToGoal, ACTOR_SELF, 4, FALSE, TRUE, FALSE)
535 Return
536 End
537};
538
539Vec3i A(DuplighostSummonPos) = { NPC_DISPOSE_LOCATION };
540
549#define NAMESPACE A(duplighost)
550
551API_CALLABLE(N(GetPartnerAndLevel)) {
552 Bytecode* args = script->ptrReadPos;
553
554 evt_set_variable(script, *args++, gPlayerData.curPartner);
556 return ApiStatus_DONE2;
557}
558
559API_CALLABLE(N(AdjustFormationPriority)) {
560 s32 partnerID = evt_get_variable(script, *script->ptrReadPos);
561 Actor* actor = get_actor(script->owner1.actorID);
562 FormationRow* formation = NULL;
563
564 switch (partnerID) {
566 formation = A(GoombarioCloneFormation);
567 break;
568 case PARTNER_KOOPER:
569 formation = A(KooperCloneFormation);
570 break;
571 case PARTNER_BOMBETTE:
572 formation = A(BombetteCloneFormation);
573 break;
575 formation = A(ParakarryCloneFormation);
576 break;
577 case PARTNER_BOW:
578 formation = A(BowCloneFormation);
579 break;
580 case PARTNER_WATT:
581 formation = A(WattCloneFormation);
582 break;
583 case PARTNER_SUSHIE:
584 formation = A(SushieCloneFormation);
585 break;
587 formation = A(LakilesterCloneFormation);
588 break;
589 }
590
591 formation->priority = actor->turnPriority;
592
593 return ApiStatus_DONE2;
594}
595
596EvtScript N(EVS_CopyPartner) = {
597 Call(UseIdleAnimation, ACTOR_SELF, FALSE)
598 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE)
599 Call(UseBattleCamPreset, BTL_CAM_ACTOR)
600 Call(BattleCamTargetActor, ACTOR_SELF)
601 Wait(15)
602 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_GHOST_TRANSFORM)
603 Call(SetAnimation, ACTOR_SELF, PRT_MAIN, ANIM_Duplighost_Anim06)
604 Call(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
605 Call(GetStatusFlags, ACTOR_SELF, LVarA)
607 Add(LVar1, 8)
608 SetF(LVar3, Float(0.4))
609 Else
610 Add(LVar1, 20)
611 SetF(LVar3, Float(1.0))
612 EndIf
613 PlayEffect(EFFECT_GATHER_ENERGY_PINK, 1, LVar0, LVar1, LVar2, LVar3, 40, 0)
614 Call(WATT(UnkBackgroundFunc3))
615 Call(MakeLerp, 0, 200, 20, EASING_LINEAR)
616 Label(0)
618 Call(WATT(SetBackgroundAlpha), LVar0)
619 Wait(1)
620 IfEq(LVar1, 1)
621 Goto(0)
622 EndIf
623 Wait(10)
624 Call(N(GetPartnerAndLevel), LVar5, LVar6)
625 Call(N(AdjustFormationPriority), LVar5)
628 Call(SummonEnemy, Ref(A(GoombarioCloneFormation)), FALSE)
630 Call(SummonEnemy, Ref(A(KooperCloneFormation)), FALSE)
632 Call(SummonEnemy, Ref(A(BombetteCloneFormation)), FALSE)
634 Call(SummonEnemy, Ref(A(ParakarryCloneFormation)), FALSE)
636 Call(SummonEnemy, Ref(A(BowCloneFormation)), FALSE)
638 Call(SummonEnemy, Ref(A(WattCloneFormation)), FALSE)
640 Call(SummonEnemy, Ref(A(SushieCloneFormation)), FALSE)
642 Call(SummonEnemy, Ref(A(LakilesterCloneFormation)), FALSE)
644 Set(LVarA, LVar0)
645 Call(CopyStatusEffects, ACTOR_SELF, LVarA)
646 Call(SetBattleVar, BTL_VAR_LastCopiedPartner, LVar5)
647 Call(PlaySoundAtActor, ACTOR_SELF, SOUND_SMOKE_BURST)
648 Thread
649 Call(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
650 Add(LVar1, 3)
651 Add(LVar2, 5)
652 Loop(3)
653 PlayEffect(EFFECT_BIG_SMOKE_PUFF, LVar0, LVar1, LVar2, 0, 0, 0, 0, 0)
654 Wait(3)
655 EndLoop
657 Wait(5)
658 Call(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2)
659 Call(SetActorPos, LVarA, LVar0, LVar1, LVar2)
660 Call(SetPartFlagBits, ACTOR_SELF, PRT_MAIN, ACTOR_PART_FLAG_INVISIBLE | ACTOR_PART_FLAG_NO_TARGET, TRUE)
661 Call(SetPartFlagBits, ACTOR_SELF, PRT_MAIN, ACTOR_PART_FLAG_PRIMARY_TARGET, FALSE)
663 Call(GetActorHP, ACTOR_SELF, LVar0)
664 Call(SetEnemyHP, LVarA, LVar0)
665 Call(CopyBuffs, ACTOR_SELF, LVarA)
666 Call(GetOwnerID, LVar0)
667 Call(SetActorVar, LVarA, AVAR_Copy_ParentActorID, LVar0)
668 Call(SetActorVar, LVarA, AVAR_Copy_PartnerLevel, LVar6)
669 Wait(20)
670 Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
671 Call(MoveBattleCamOver, 20)
672 Thread
673 Call(MakeLerp, 200, 0, 20, EASING_LINEAR)
674 Label(1)
676 Call(WATT(SetBackgroundAlpha), LVar0)
677 Wait(1)
678 IfEq(LVar1, 1)
679 Goto(1)
680 EndIf
682 Call(SetActorSounds, LVarA, ACTOR_SOUND_JUMP, SOUND_NONE, 0)
684 CaseEq(8)
685 Call(GetActorPos, LVarA, LVar0, LVar1, LVar2)
686 Call(SetActorJumpGravity, LVarA, Float(0.01))
687 Call(SetGoalPos, LVarA, LVar0, 10, LVar2)
688 Call(JumpToGoal, LVarA, 10, FALSE, FALSE, FALSE)
689 Wait(10)
690 CaseOrEq(6)
691 CaseOrEq(9)
692 CaseOrEq(4)
693 Call(GetActorPos, LVarA, LVar0, LVar1, LVar2)
694 Call(SetActorJumpGravity, LVarA, Float(0.01))
695 Call(SetGoalPos, LVarA, LVar0, 30, LVar2)
696 Call(JumpToGoal, LVarA, 20, FALSE, FALSE, FALSE)
699 Call(GetActorPos, LVarA, LVar0, LVar1, LVar2)
700 Call(ForceHomePos, LVarA, LVar0, LVar1, LVar2)
701 Call(HPBarToHome, LVarA)
702 Call(ResetActorSounds, LVarA, ACTOR_SOUND_JUMP)
703 Wait(20)
705 Call(ForceHomePos, ACTOR_SELF, NPC_DISPOSE_LOCATION)
706 Call(HPBarToHome, ACTOR_SELF)
707 Call(SetActorVar, ACTOR_SELF, AVAR_State, AVAL_State_CopiedPartner)
708 Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE)
709 Call(UseIdleAnimation, ACTOR_SELF, TRUE)
710 Return
711 End
712};
713
714EvtScript N(EVS_TakeTurn) = {
715 Call(GetActorVar, ACTOR_SELF, AVAR_State, LVar0)
717 CaseEq(AVAL_State_ReadyToCopy)
718 Call(RandInt, 1000, LVar0)
719 IfLt(LVar0, 600)
722 // first time partner is copied, set battle flag and proceed
726 ExecWait(N(EVS_CopyPartner))
727 Else
728 // partner has been copied before, try to avoid copying the same one
729 Call(GetBattleVar, BTL_VAR_LastCopiedPartner, LVar0)
730 Call(N(GetPartnerAndLevel), LVar1, LVar2)
732 ExecWait(N(EVS_CopyPartner))
733 Else
734 ExecWait(N(EVS_Attack_FlyingTackle))
735 EndIf
736 EndIf
737 Else
738 ExecWait(N(EVS_Attack_FlyingTackle))
739 EndIf
740 CaseEq(AVAL_State_CopiedPartner)
741 // do nothing, currently in disguise
742 CaseEq(AVAL_State_ReadyToTackle)
743 ExecWait(N(EVS_Attack_FlyingTackle))
744 CaseEq(AVAL_State_WaitToTackle)
746 Return
747 End
748};
749
750
751
PartnerData partners[12]
Bytecode EvtScript[]
#define WATT(x)
@ BTL_CAM_XADJ_AVG
Definition enums.h:4900
@ ACTOR_SOUND_JUMP
Definition enums.h:2036
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ BS_FLAGS1_INCLUDE_POWER_UPS
Definition enums.h:3571
@ ELEMENT_END
Definition enums.h:2114
@ ELEMENT_NORMAL
Definition enums.h:2115
@ ACTOR_DECORATION_SWEAT
Definition enums.h:2045
@ PHASE_ENEMY_BEGIN
Definition enums.h:2068
@ PHASE_PLAYER_BEGIN
Definition enums.h:2066
@ PHASE_ENEMY_END
Definition enums.h:2067
@ 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:4824
@ BTL_CAM_ACTOR
Definition enums.h:4836
@ BTL_CAM_ENEMY_APPROACH
Definition enums.h:4885
@ EASING_LINEAR
Definition enums.h:510
@ IDLE_SCRIPT_ENABLE
Definition enums.h:6408
@ IDLE_SCRIPT_DISABLE
Definition enums.h:6407
@ STATUS_FLAG_SHRINK
Definition enums.h:2819
@ SOUND_NONE
Definition enums.h:547
@ SOUND_FALL_QUICK
Definition enums.h:1090
@ SOUND_GHOST_TRANSFORM
Definition enums.h:1472
@ SOUND_SMOKE_BURST
Definition enums.h:1039
@ SOUND_DUPLIGHOST_LEAP
Definition enums.h:1037
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_SELF
Definition enums.h:2084
@ ACTOR_FLAG_NO_SHADOW
Hide shadow.
Definition enums.h:3325
@ ACTOR_FLAG_NO_DMG_APPLY
Damage is not applied to actor HP.
Definition enums.h:3340
@ PARTNER_BOMBETTE
Definition enums.h:2888
@ PARTNER_LAKILESTER
Definition enums.h:2893
@ PARTNER_WATT
Definition enums.h:2891
@ PARTNER_BOW
Definition enums.h:2894
@ PARTNER_SUSHIE
Definition enums.h:2892
@ PARTNER_PARAKARRY
Definition enums.h:2889
@ PARTNER_KOOPER
Definition enums.h:2887
@ PARTNER_GOOMBARIO
Definition enums.h:2886
@ BTL_CAM_YADJ_TARGET
Definition enums.h:4905
@ 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_SHOCK_DEATH
Definition enums.h:2159
@ 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_SHOCK_HIT
Definition enums.h:2165
@ 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_NO_TARGET
Cannot be targeted.
Definition enums.h:3360
@ ACTOR_PART_FLAG_INVISIBLE
Definition enums.h:3350
@ DAMAGE_TYPE_TRIGGER_LUCKY
Definition enums.h:2881
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
EvtScript EVS_Enemy_ReturnHome
EvtScript EVS_Enemy_Knockback
EvtScript EVS_Enemy_ScareAway
EvtScript EVS_Enemy_Hit
EvtScript EVS_Enemy_Death
EvtScript EVS_Enemy_SpinSmashHit
EvtScript EVS_Enemy_ShockHit
EvtScript EVS_Enemy_AirLift
EvtScript EVS_Enemy_BlowAway
EvtScript EVS_Enemy_Recover
EvtScript EVS_Enemy_BurnHit
EvtScript EVS_Enemy_NoDamageHit
ApiStatus UpdateLerp(Evt *script, b32 isInitialCall)
ApiStatus RandInt(Evt *script, b32 isInitialCall)
ApiStatus MakeLerp(Evt *script, b32 isInitialCall)
#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 LVar6
Definition macros.h:154
#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 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 Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#define LVarC
Definition macros.h:160
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define IfGt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR <= RVAR.
Definition macros.h:278
#define IfLt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR < RVAR.
Definition macros.h:275
#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 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 LVar5
Definition macros.h:153
#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 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 LVar1
Definition macros.h:149
#define LVarA
Definition macros.h:158
#define IfNotFlag(LVAR, RVAR)
Marks the beginning of an if statement that only executes if the RVAR flag is unset on LVAR,...
Definition macros.h:292
#define LVarD
Definition macros.h:161
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define LVar9
Definition macros.h:157
#define NPC_DISPOSE_LOCATION
Definition macros.h:158
#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 BitwiseOrConst(VAR, CONST)
VAR |= CONST, but CONST is treated as-is rather than dereferenced with evt_get_variable.
Definition macros.h:445
#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
s32 priority
Actors with higher priority values take their turn first.
Definition battle.h:160
@ BTL_VAR_DuplighostCopyFlags
Definition battle.h:81
@ BTL_VAR_LastCopiedPartner
Definition battle.h:91
@ BTL_VAL_Duplighost_HasCopied
Definition battle.h:82
PlayerData gPlayerData
Definition 77480.c:40