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);
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) {
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) {
39};
40
41s32 N(DefaultAnims)[] = {
52};
53
54s32 N(FlailingAnims)[] = {
57};
58
59s32 N(RunAnims)[] = {
62};
63
64s32 N(DefenseTable)[] = {
67};
68
69s32 N(StatusTable)[] = {
92};
93
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) = {
138 Return
139 End
140};
141
151 EndIf
153 Return
154 End
155};
156
157EvtScript N(EVS_Idle) = {
158 Return
159 End
160};
161
166 Return
167 End
168};
169
184 SetConst(LVar2, -1)
189 SetConst(LVar2, -1)
194 Return
206 Return
223 Return
235 Wait(10)
239 Return
249 Return
258 Return
263 Return
264 End
265};
266
275 Wait(20)
281 Set(LVarA, LVar0)
285 Call(AddGoalPos, ACTOR_SELF, -100, 0, 0)
290 EndIf
291 Wait(10)
296 Wait(15)
305 Return
312 Call(AddGoalPos, ACTOR_SELF, Float(4.0), Float(-6.0), 0)
313 Else
314 Call(AddGoalPos, ACTOR_SELF, 10, -15, 0)
315 EndIf
318 Wait(2)
329 Add(LVar0, 30)
332 Add(LVar0, 20)
335 Wait(10)
342 Return
343 End
344};
345
352
357 Wait(30)
363 Thread
365 Add(LVar1, 3)
366 Add(LVar2, 5)
367 Loop(3)
369 Wait(3)
370 EndLoop
372 Wait(5)
386 Wait(30)
389 IfGt(LVarC, 0)
390 Set(LVarC, 0)
400 EndIf
409 Return
410 End
411};
412
414 Set(LVar9, LVar0)
421 Add(LVar2, 10)
422 Add(LVar3, 10)
432 Thread
434 Add(LVar1, 3)
435 Add(LVar2, 5)
436 Loop(3)
438 Wait(3)
439 EndLoop
441 Wait(5)
455 Wait(15)
459 Add(LVarB, 30)
460 Set(LVarC, 0)
463 Add(LVarB, 20)
466 Add(LVarB, 10)
469 Wait(20)
471 Call(SetActorYaw, LVarA, 180)
489 Return
490 End
491};
492
495 Set(LVarA, LVar0)
496 Set(LVarB, LVar1)
497 Set(LVarC, LVar2)
499 Call(SetActorScale, ACTOR_SELF, Float(1.0), Float(1.0), Float(1.0))
503 Add(LVar0, 15)
504 Add(LVar1, 10)
509 Set(LVar0, LVarA)
510 Set(LVar1, LVarB)
513 Thread
515 Set(LVar0, 0)
516 Loop(15)
517 Add(LVar0, -48)
519 Wait(1)
520 EndLoop
524 Add(LVar0, 60)
525 Set(LVar1, 0)
529 Add(LVar0, 20)
532 Add(LVar0, 10)
535 Return
536 End
537};
538
540
549#define NAMESPACE A(duplighost)
550
551API_CALLABLE(N(GetPartnerAndLevel)) {
552 Bytecode* args = script->ptrReadPos;
553
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
601 Wait(15)
607 Add(LVar1, 8)
608 SetF(LVar3, Float(0.4))
609 Else
610 Add(LVar1, 20)
611 SetF(LVar3, Float(1.0))
612 EndIf
615 Call(MakeLerp, 0, 200, 20, EASING_LINEAR)
616 Label(0)
619 Wait(1)
620 IfEq(LVar1, 1)
621 Goto(0)
622 EndIf
623 Wait(10)
644 Set(LVarA, LVar0)
648 Thread
650 Add(LVar1, 3)
651 Add(LVar2, 5)
652 Loop(3)
654 Wait(3)
655 EndLoop
657 Wait(5)
669 Wait(20)
672 Thread
673 Call(MakeLerp, 200, 0, 20, EASING_LINEAR)
674 Label(1)
677 Wait(1)
678 IfEq(LVar1, 1)
679 Goto(1)
680 EndIf
684 CaseEq(8)
689 Wait(10)
690 CaseOrEq(6)
691 CaseOrEq(9)
692 CaseOrEq(4)
703 Wait(20)
710 Return
711 End
712};
713
718 Call(RandInt, 1000, LVar0)
719 IfLt(LVar0, 600)
722 // first time partner is copied, set battle flag and proceed
727 Else
728 // partner has been copied before, try to avoid copying the same one
733 Else
735 EndIf
736 EndIf
737 Else
739 EndIf
741 // do nothing, currently in disguise
746 Return
747 End
748};
BSS s32 PopupMenu_SelectedIndex
PartnerData partners[12]
Bytecode EvtScript[]
#define WATT(x)
@ BTL_CAM_XADJ_AVG
Definition enums.h:4899
@ ACTOR_SOUND_JUMP
Definition enums.h:2036
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3574
@ BS_FLAGS1_INCLUDE_POWER_UPS
Definition enums.h:3570
@ 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:4823
@ BTL_CAM_ACTOR
Definition enums.h:4835
@ BTL_CAM_ENEMY_APPROACH
Definition enums.h:4884
@ EASING_LINEAR
Definition enums.h:510
@ IDLE_SCRIPT_ENABLE
Definition enums.h:6407
@ IDLE_SCRIPT_DISABLE
Definition enums.h:6406
@ 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: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_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:1689
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1846
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:162
#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