Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
insecticide_herb.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "effects.h"
4#include "entity.h"
5#include "ld_addrs.h"
6#include "sprite/player.h"
7#include "include_asset.h"
8
9#define NAMESPACE battle_item_insecticide_herb
10
12
13API_CALLABLE(N(func_802A123C_72A98C)) {
14 BattleStatus* battleStatus = &gBattleStatus;
15 Actor* enemy = get_actor(script->owner1.enemyID);
16 Actor* target = get_actor(enemy->targetActorID);
17
18 script->varTable[9] = target->actorType == 49;
19
20 return ApiStatus_DONE2;
21}
22
23API_CALLABLE(N(func_802A1280_72A9D0)) {
24 Actor* enemy = get_actor(script->owner1.enemyID);
25 Actor* target;
26
28 target = get_actor(enemy->targetActorID);
30
31 return ApiStatus_DONE2;
32}
33
34API_CALLABLE(N(func_802A12E0_72AA30)) {
35 Bytecode* args = script->ptrReadPos;
36 f32 a = evt_get_variable(script, *args++);
37 f32 b = evt_get_variable(script, *args++);
38 f32 c = evt_get_variable(script, *args++);
39 EffectInstance* effect;
40
41 a += rand_int(20) - 10;
42 b += rand_int(10) - 5;
43
44 effect = fx_cold_breath(0, a, b, c, 1.0f, 30);
45
46 effect->data.coldBreath->primCol.r = 244;
47 effect->data.coldBreath->primCol.g = 244;
48 effect->data.coldBreath->primCol.b = 220;
49 effect->data.coldBreath->envCol.r = 210;
50 effect->data.coldBreath->envCol.g = 210;
51 effect->data.coldBreath->envCol.b = 190;
52
53 return ApiStatus_DONE2;
54}
55
57
58static s32 _pad = 0; // XXX
59
60#include "battle/move/item/insecticide_herb.png.h"
61INCLUDE_IMG("battle/move/item/insecticide_herb.png", battle_item_insecticide_herb_png);
62INCLUDE_PAL("battle/move/item/insecticide_herb.pal", battle_item_insecticide_herb_pal);
63
64Vtx N(model)[] = {
65 { .v = { .ob = {-16, -16, 0}, FALSE, .tc = {0, 0}, .cn = {0, 0, 0, 255} } },
66 { .v = { .ob = {15, -16, 0}, FALSE, .tc = {1024, 0}, .cn = {0, 0, 0, 255} } },
67 { .v = { .ob = {15, 15, 0}, FALSE, .tc = {1024, 1024}, .cn = {0, 0, 0, 255} } },
68 { .v = { .ob = {-16, 15, 0}, FALSE, .tc = {0, 1024}, .cn = {0, 0, 0, 255} } },
69};
70
71Gfx N(displayList)[] = {
72 gsDPPipeSync(),
73 gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
74 gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
75 gsDPSetTexturePersp(G_TP_PERSP),
76 gsDPSetTextureDetail(G_TD_CLAMP),
77 gsDPSetTextureLOD(G_TL_TILE),
78 gsDPSetTextureLUT(G_TT_NONE),
79 gsDPSetTextureFilter(G_TF_AVERAGE),
80 gsDPSetTextureConvert(G_TC_FILT),
81 gsDPSetTextureLUT(G_TT_RGBA16),
82 gsDPLoadTLUT_pal16(0, battle_item_insecticide_herb_pal),
83 gsDPLoadTextureTile_4b(battle_item_insecticide_herb_png, G_IM_FMT_CI, battle_item_insecticide_herb_png_width, battle_item_insecticide_herb_png_height, 0, 0, battle_item_insecticide_herb_png_width - 1, battle_item_insecticide_herb_png_height - 1, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD),
84 gsSPClearGeometryMode(G_LIGHTING),
85 gsSPClearGeometryMode(G_SHADING_SMOOTH),
86 gsSPVertex(N(model), ARRAY_COUNT(N(model)), 0),
87 gsSP1Triangle(0, 1, 2, 0),
88 gsSP1Triangle(0, 2, 3, 0),
89 gsDPPipeSync(),
90 gsSPEndDisplayList(),
91};
92
93EntityModelScript N(modelCommandList) = STANDARD_ENTITY_MODEL_SCRIPT(N(displayList), RENDER_MODE_ALPHATEST);
94
95
96EvtScript N(EVS_UseItem) = {
97 SetConst(LVarA, ITEM_INSECTICIDE_HERB)
98 ExecWait(N(UseItemWithEffect))
99 Call(UseBattleCamPreset, BTL_CAM_VIEW_ENEMIES)
100 Call(MoveBattleCamOver, 15)
101 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Throw)
103 Wait(3)
104 Call(CreateVirtualEntity, LVarA, Ref(N(modelCommandList)))
105 SetF(LVar0, Float(1.0))
106 Call(MultiplyByActorScale, LVar0)
108 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
109 Set(LVar3, 20)
110 Set(LVar4, 42)
111 Set(LVar5, 5)
112 Call(MultiplyVec3ByActorScale, LVar3, LVar4, LVar5)
113 Add(LVar0, LVar3)
114 Add(LVar1, LVar4)
115 Add(LVar2, LVar5)
117 Call(InitTargetIterator)
118 Call(SetGoalToTarget, ACTOR_SELF)
119 Call(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
120 Thread
121 Set(LVar0, 0)
122 Loop(18)
123 Add(LVar0, -60)
125 Wait(1)
126 EndLoop
129 Add(LVar2, 5)
131 PlayEffect(EFFECT_WALKING_DUST, 3, LVar0, LVar1, LVar2, 0, 0, 0)
132 Sub(LVar0, 10)
133 PlayEffect(EFFECT_WALKING_DUST, 3, LVar0, LVar1, LVar2, 0, 0, 0)
134 Add(LVar0, 20)
135 PlayEffect(EFFECT_WALKING_DUST, 3, LVar0, LVar1, LVar2, 0, 0, 0)
136 Thread
137 Call(N(func_802A12E0_72AA30), LVar0, LVar1, LVar2)
138 Wait(3)
139 Call(N(func_802A12E0_72AA30), LVar0, LVar1, LVar2)
140 Wait(3)
141 Call(N(func_802A12E0_72AA30), LVar0, LVar1, LVar2)
143 Call(InitTargetIterator)
144 Call(SetGoalToTarget, ACTOR_SELF)
145 Call(N(func_802A123C_72A98C))
147 IfEq(LVar9, 0)
148 Call(ItemDamageEnemy, LVar0, 0, 0, 0, BS_FLAGS1_TRIGGER_EVENTS)
149 Else
150 Call(InitTargetIterator)
151 Call(SetGoalToTarget, ACTOR_SELF)
152 Call(N(func_802A1280_72A9D0))
153 EndIf
154 ExecWait(N(PlayerGoHome))
155 Return
156 End
157};
ActorState state
s16 targetActorID
Bytecode EvtScript[]
#define sfx_play_sound_at_position
#define rand_int
struct ColdBreathFXData * coldBreath
Definition effects.h:2575
Color4i primCol
Definition effects.h:1990
EffectData data
Definition effects.h:2605
s32 EntityModelScript[]
Definition entity.h:7
#define STANDARD_ENTITY_MODEL_SCRIPT(gfx, renderMode)
Definition entity.h:56
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3575
@ BTL_CAM_VIEW_ENEMIES
Definition enums.h:4825
@ SOUND_DAMAGE_STARS
Definition enums.h:950
@ SOUND_THROW
Definition enums.h:1311
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_SELF
Definition enums.h:2084
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ EVENT_SCARE_AWAY
Definition enums.h:2174
#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
void dispatch_event_actor(Actor *, s32)
Definition 1A5830.c:103
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
#define INCLUDE_PAL(FILENAME, SYMBOLNAME)
#define INCLUDE_IMG(FILENAME, SYMBOLNAME)
ApiStatus PlaySound(Evt *script, b32 isInitialCall)
ApiStatus CreateVirtualEntity(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityPosition(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityJumpGravity(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityScale(Evt *script, b32 isInitialCall)
ApiStatus DeleteVirtualEntity(Evt *script, b32 isInitialCall)
ApiStatus VirtualEntityJumpTo(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityRotation(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 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 Sub(VAR, INT_VALUE)
Definition macros.h:377
#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 ARRAY_COUNT(arr)
Definition macros.h:40
#define Float(DOUBLE)
Definition macros.h:51
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define LVar5
Definition macros.h:153
#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 LVar2
Definition macros.h:150
#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 PlayEffect(args...)
Definition macros.h:807
#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 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
BattleStatus gBattleStatus
Definition battle.c:11