Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
DripVolumes.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "model.h"
3
4#ifndef DROPLET_MODEL
5#error DROPLET_MODEL must be defined for DripVolumes
6#define DROPLET_MODEL 0
7#endif
8
9API_CALLABLE(N(CheckDripCollisionWithActors)) {
10 BattleStatus* battleStatus = &gBattleStatus;
11 Bytecode* args = script->ptrReadPos;
13 f32 xDiff, yDiff, zDiff, temp;
14 Actor* actor;
15 s32 i;
16
17 script->varTable[2] = 0;
18
19 actor = battleStatus->playerActor;
20 if (actor != NULL) {
21 xDiff = actor->curPos.x - model->center.x;
22 yDiff = actor->curPos.y + actor->size.y - 1.5f - model->center.y;
23 zDiff = actor->curPos.z - model->center.z;
24 temp = sqrtf(SQ(xDiff) + SQ(zDiff));
25
26 if (yDiff > 0.0f && yDiff < actor->size.y && temp < actor->size.x * 0.5f) {
27 script->varTable[2] = 1;
28 return ApiStatus_DONE2;
29 }
30 }
31
32 actor = battleStatus->partnerActor;
33 if (actor != NULL) {
34 xDiff = actor->curPos.x - model->center.x;
35 yDiff = actor->curPos.y + actor->size.y - 1.5f - model->center.y;
36 zDiff = actor->curPos.z - model->center.z;
37 temp = sqrtf(SQ(xDiff) + SQ(zDiff));
38
39 if (yDiff > 0.0f && yDiff < actor->size.y && temp < actor->size.x * 0.5f) {
40 script->varTable[2] = 1;
41 return ApiStatus_DONE2;
42 }
43 }
44
45 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
46 ActorPart* part;
47
48 actor = battleStatus->enemyActors[i];
49
50 if (actor != NULL && !(actor->flags & ACTOR_FLAG_INVISIBLE)) {
51 xDiff = actor->curPos.x - model->center.x;
52 yDiff = actor->curPos.y + actor->size.y - 1.5f - model->center.y;
53 zDiff = actor->curPos.z - model->center.z;
54 temp = sqrtf(SQ(xDiff) + SQ(zDiff));
55
56 if (yDiff > 0.0f && yDiff < actor->size.y && temp < actor->size.x * 0.5f) {
57 script->varTable[2] = 1;
58 return ApiStatus_DONE2;
59 }
60
61 for (part = actor->partsTable; part != NULL; part = part->nextPart) {
62 if (!(part->flags & ACTOR_PART_FLAG_INVISIBLE)) {
64 xDiff = part->curPos.x - model->center.x;
65 yDiff = part->curPos.y + part->size.y - 1.5f - model->center.y;
66 zDiff = part->curPos.z - model->center.z;
67 temp = sqrtf(SQ(xDiff) + SQ(zDiff));
68
69 if (yDiff > 0.0f && yDiff < part->size.y && temp < part->size.x * 0.5f) {
70 script->varTable[2] = 1;
71 return ApiStatus_DONE2;
72 }
73 }
74 }
75 }
76 }
77 }
78 return ApiStatus_DONE2;
79}
80
81EvtScript N(EVS_UpdateDripSplash) = {
82 Set(LVar1, ArrayVar(5))
83 Add(LVar1, 1)
84 Set(LVar2, ArrayVar(0))
85 Set(LVar3, ArrayVar(1))
86 Set(LVar4, ArrayVar(5))
87 Add(LVar4, 2)
88 Set(LVar5, ArrayVar(0))
89 Set(LVar6, ArrayVar(1))
90 Set(LVar7, ArrayVar(5))
91 Add(LVar7, 3)
92 Set(LVar8, ArrayVar(0))
93 Set(LVar9, ArrayVar(1))
94 Set(LVarA, ArrayVar(5))
95 Add(LVarA, 4)
96 Set(LVarB, ArrayVar(0))
97 Set(LVarC, ArrayVar(1))
98 Call(EnableModel, LVar1, TRUE)
99 Call(EnableModel, LVar4, TRUE)
100 Call(EnableModel, LVar7, TRUE)
101 Call(EnableModel, LVarA, TRUE)
102 Loop(5)
103 Add(LVar0, 1)
104 Add(LVar2, 1)
105 Add(LVar3, 1)
107 Call(ScaleModel, LVar1, Float(0.5), Float(0.5), Float(0.5))
108 Add(LVar5, -1)
109 Add(LVar6, 1)
111 Call(ScaleModel, LVar4, Float(0.5), Float(0.5), Float(0.5))
112 Add(LVar8, 1)
113 Add(LVar9, -1)
115 Call(ScaleModel, LVar7, Float(0.5), Float(0.5), Float(0.5))
116 Add(LVarB, -1)
117 Add(LVarC, -1)
119 Call(ScaleModel, LVarA, Float(0.5), Float(0.5), Float(0.5))
120 Wait(1)
121 EndLoop
122 Loop(5)
123 Add(LVar0, -1)
124 Add(LVar2, 1)
125 Add(LVar3, 1)
127 Call(ScaleModel, LVar1, Float(0.5), Float(0.5), Float(0.5))
128 Add(LVar5, -1)
129 Add(LVar6, 1)
131 Call(ScaleModel, LVar4, Float(0.5), Float(0.5), Float(0.5))
132 Add(LVar8, 1)
133 Add(LVar9, -1)
135 Call(ScaleModel, LVar7, Float(0.5), Float(0.5), Float(0.5))
136 Add(LVarB, -1)
137 Add(LVarC, -1)
139 Call(ScaleModel, LVarA, Float(0.5), Float(0.5), Float(0.5))
140 Wait(1)
141 EndLoop
142 Call(EnableModel, LVar1, FALSE)
143 Call(EnableModel, LVar4, FALSE)
144 Call(EnableModel, LVar7, FALSE)
145 Call(EnableModel, LVarA, FALSE)
146 Return
147 End
148};
149
150EvtScript N(EVS_UpdateDripVolume) = {
151 SetGroup(0)
153 Set(LVar5, ArrayVar(5))
154 Loop(5)
157 Add(LVar5, 1)
158 EndLoop
159 Label(0)
160 Call(RandInt, 200, LVar0)
161 Add(LVar0, 50)
162 Wait(LVar0)
163 Call(EnableModel, ArrayVar(5), TRUE)
165 Label(1)
168 Wait(1)
169 Call(N(CheckDripCollisionWithActors), ArrayVar(5))
170 IfEq(LVar2, 1)
171 Goto(10)
172 EndIf
173 IfEq(LVar1, 1)
174 Goto(1)
175 EndIf
176 Label(10)
177 Call(EnableModel, ArrayVar(5), FALSE)
178 ExecWait(N(EVS_UpdateDripSplash))
179 Goto(0)
180 Return
181 End
182};
183
184EvtScript N(EVS_CreateDripVolumes) = {
188 Loop(LVar1)
192 Loop(LVar9)
197 Set(LVarD, LVar2)
198 Set(LVarE, LVar3)
199 Add(LVarD, LVarB)
200 Add(LVarE, LVarC)
201 Set(ArrayVar(0), LVarD)
202 Set(ArrayVar(1), LVarE)
203 Set(ArrayVar(2), LVar6)
204 Set(ArrayVar(3), LVar7)
205 Set(ArrayVar(4), LVar8)
206 Set(ArrayVar(5), LVarF)
208 Exec(N(EVS_UpdateDripVolume))
210 Add(LVarF, 5)
211 EndLoop
212 EndLoop
214 Return
215 End
216};
217
218typedef struct DripVolume {
219 /* 0x00 */ Vec2i minPos;
220 /* 0x08 */ Vec2i maxPos;
221 /* 0x10 */ s32 startY;
222 /* 0x14 */ s32 endY;
223 /* 0x18 */ s32 duration;
224 /* 0x1C */ s32 density;
225} DripVolume;
226
227typedef struct DripVolumeList {
228 /* 0x00 */ s32 count;
229 /* 0x04 */ DripVolume volumes[VLA];
230} DripVolumeList; // size = variable
#define DROPLET_MODEL
DripVolume volumes[VLA]
struct ActorPart * partsTable
Vec2bu size
Vec3f curPos
Bytecode EvtScript[]
struct ActorPart * nextPart
#define sqrtf
@ EASING_QUADRATIC_IN
Definition enums.h:511
@ ACTOR_FLAG_INVISIBLE
Actor is not rendered.
Definition enums.h:3324
@ ACTOR_PART_FLAG_USE_ABSOLUTE_POSITION
Definition enums.h:3361
@ ACTOR_PART_FLAG_INVISIBLE
Definition enums.h:3350
#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 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3397
struct Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3315
Vec3f center
Definition model.h:69
Definition model.h:59
ApiStatus EnableModel(Evt *script, b32 isInitialCall)
Enables or disables the given model.
ApiStatus TranslateModel(Evt *script, b32 isInitialCall)
Translates the given model's position.
ApiStatus UpdateLerp(Evt *script, b32 isInitialCall)
ApiStatus ScaleModel(Evt *script, b32 isInitialCall)
Scales the model the given amount along the selected axis.
ApiStatus RandInt(Evt *script, b32 isInitialCall)
ApiStatus MakeLerp(Evt *script, b32 isInitialCall)
ApiStatus CloneModel(Evt *script, b32 isInitialCall)
Clones the given model.
#define ArrayVar(INDEX)
User Word.
Definition macros.h:122
#define VLA
Definition macros.h:516
#define LVar6
Definition macros.h:154
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:365
#define EndChildThread
Marks the end of a child thread block.
Definition macros.h:563
#define LVarF
Definition macros.h:163
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define UseBuf(INT_PTR)
Loads a s32 pointer for use with subsequent EVT_BUF_READ commands.
Definition macros.h:389
#define Add(VAR, INT_VALUE)
Definition macros.h:376
#define EndLoop
Marks the end of a loop.
Definition macros.h:248
#define BufRead4(VAR1, VAR2, VAR3, VAR4)
Consumes the next four s32s from the buffer and stores them in the given variables.
Definition macros.h:401
#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 BufRead1(VAR)
Consumes the next s32 from the buffer and stores it in the given variable.
Definition macros.h:392
#define Float(DOUBLE)
Definition macros.h:51
#define BufRead3(VAR1, VAR2, VAR3)
Consumes the next three s32s from the buffer and stores them in the given variables.
Definition macros.h:398
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
Definition macros.h:227
#define MallocArray(SIZE, OUT_PTR_VAR)
Allocates a new array of the given size for use with ArrayVar(INDEX).
Definition macros.h:433
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define LVar5
Definition macros.h:153
#define LVarB
Definition macros.h:159
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:475
#define LVar7
Definition macros.h:155
#define UseArray(INT_PTR)
Loads an s32 array pointer into the current thread for use with ArrayVar(INDEX).
Definition macros.h:425
#define LVar8
Definition macros.h:156
#define LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define LVarA
Definition macros.h:158
#define LVarD
Definition macros.h:161
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define SetGroup(GROUP)
Sets the current thread's group. Group value meanings are currently not known.
Definition macros.h:519
#define LVar9
Definition macros.h:157
#define SQ(x)
Definition macros.h:166
#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 ChildThread
Marks the start of a child thread block.
Definition macros.h:560
#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 LVarE
Definition macros.h:162
#define LVar0
Definition macros.h:148
#define Exec(EVT_SOURCE)
Launches a new thread.
Definition macros.h:455
#define Return
Kills the current EVT thread.
Definition macros.h:217
#define CLONED_MODEL(idx)
Definition map.h:18
struct Actor * partnerActor
struct Actor * playerActor
struct Actor * enemyActors[24]
BattleStatus gBattleStatus
Definition battle.c:11