Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
sleepy_sheep.c
Go to the documentation of this file.
1#include "common.h"
2#include "script_api/battle.h"
3#include "entity.h"
4#include "ld_addrs.h"
5#include "effects.h"
6#include "sprite/player.h"
7#include "include_asset.h"
8
9#define NAMESPACE battle_item_sleepy_sheep
10
12
14void virtual_entity_set_pos(s32, s32, s32, s32);
17
18extern s32 D_802A3E88_7214D8[];
20extern f32 D_802A3F00_721550[];
21
22BSS s32 D_802A3F54; // unused?
24BSS s32 D_802A3F80[2]; // unused?
26
27API_CALLABLE(N(func_802A123C_71E88C)) {
29 s32 entityID;
30 f32 x, y, z;
31 s32 cond;
32 s32 i;
33
34 if (isInitialCall) {
35 script->functionTemp[0] = 0;
36 }
37
38 switch (script->functionTemp[0]) {
39 case 0:
40 posPtr->x = -200.0f;
41 posPtr->z = 10.0f;
42 for (i = 0; i < ARRAY_COUNT(D_802A3F58); i++) {
44 x = D_802A3E88_7214D8[i * 3] + posPtr->x;
45 y = D_802A3E88_7214D8[i * 3 + 1];
46 z = D_802A3E88_7214D8[i * 3 + 2] + posPtr->z;
49 }
50 script->functionTemp[1] = (gGameStatusPtr->frameCounter % 10) & 0xFFFF;
51 script->functionTemp[0] = 1;
52 break;
53 case 1:
54 posPtr->x += 6.0f;
55 cond = FALSE;
56 if (!((gGameStatusPtr->frameCounter % 3) & 0xFFFF)) {
57 script->functionTemp[1] = (script->functionTemp[1] + 1) % 10;
58 }
59
60 for (i = 0; i < ARRAY_COUNT(D_802A3F58); i++) {
62 x = D_802A3E88_7214D8[i * 3] + posPtr->x;
63 y = D_802A3E88_7214D8[i * 3 + 1];
64 z = D_802A3E88_7214D8[i * 3 + 2] + posPtr->z;
66 if (!cond && script->functionTemp[1] == i && !((gGameStatusPtr->frameCounter % 5) & 0xFFFF)) {
67 if (x > 0.0f) {
68 y = x;
69 if (x > 100.0f) {
70 y = x - 50.0f;
71 }
72 y = rand_int(y);
73 }
74
75 if (x > 40.0f) {
76 x = -(x - 40.0f);
77 }
78 fx_landing_dust(3, x, y, z, 0.0f);
79 cond = TRUE;
80 }
81 }
83 s32 randIdx = rand_int(9);
84
85 x = D_802A3E88_7214D8[randIdx * 3] + posPtr->x;
86 y = D_802A3E88_7214D8[randIdx * 3 + 1];
87 z = D_802A3E88_7214D8[randIdx * 3 + 2] + posPtr->z;
88
89 fx_landing_dust(2, x, y, z, 0.0f);
90 }
91 if (posPtr->x >= 320.0f) {
92 script->functionTemp[0] = 2;
93 }
94 break;
95 case 2:
96 for (i = 0; i < ARRAY_COUNT(D_802A3F58); i++) {
98 }
99 return ApiStatus_DONE2;
100 }
101 return ApiStatus_BLOCK;
102}
103
104API_CALLABLE(N(func_802A1740_71ED90)) {
106 Actor* player = battleStatus->playerActor;
107 s32 i;
108
109 if (isInitialCall) {
110 script->functionTemp[0] = 0;
111 script->functionTemp[1] = 90;
112 }
113
114 for (i = 0; i < player->targetListLength; i++) {
115 s8 targetIdx = player->targetIndexList[i];
117 Actor* targetActor = get_actor(target->actorID);
119
120 if (targetActor->transparentStatus == 0 && !(targetPart->eventFlags & ACTOR_EVENT_FLAG_ILLUSORY)) {
121 targetActor->yaw += 33.0f;
123 }
124 }
125
126 if (script->functionTemp[1] != 0) {
127 script->functionTemp[1]--;
128 return ApiStatus_BLOCK;
129 }
130
131 return ApiStatus_DONE2;
132}
133
134API_CALLABLE(N(func_802A1848_71EE98)) {
136 Actor* player = battleStatus->playerActor;
137 s32 i;
138 s32 cond;
139
140 if (isInitialCall) {
141 script->functionTemp[0] = 0;
142 }
143
144 cond = FALSE;
145
146 for (i = 0; i < player->targetListLength; i++) {
147 s8 targetIdx = player->targetIndexList[i];
149 Actor* targetActor = get_actor(target->actorID);
150
151 if (targetActor != NULL) {
153 if ((targetActor->transparentStatus == 0) && !(targetPart->eventFlags & ACTOR_EVENT_FLAG_ILLUSORY)) {
154 if (targetActor->yaw < 360.0f) {
155 targetActor->yaw += 33.0f;
156 if (targetActor->yaw >= 360.0f) {
157 targetActor->yaw = 360.0f;
158 }
159 cond = TRUE;
160 }
161 }
162 }
163 }
164
165 if (!cond) {
166 return ApiStatus_DONE2;
167 }
168 return ApiStatus_BLOCK;
169}
170
172
173static s32 _pad = 0;
174
175#include "battle/move/item/sleepy_sheep1.png.h"
176INCLUDE_IMG("battle/move/item/sleepy_sheep1.png", battle_item_sleepy_sheep1_png);
177INCLUDE_PAL("battle/move/item/sleepy_sheep1.pal", battle_item_sleepy_sheep1_pal);
178
179#include "battle/move/item/sleepy_sheep2.png.h"
180INCLUDE_IMG("battle/move/item/sleepy_sheep2.png", battle_item_sleepy_sheep2_png);
181INCLUDE_PAL("battle/move/item/sleepy_sheep2.pal", battle_item_sleepy_sheep2_pal);
182
183#include "battle/move/item/sleepy_sheep3.png.h"
184INCLUDE_IMG("battle/move/item/sleepy_sheep3.png", battle_item_sleepy_sheep3_png);
185INCLUDE_PAL("battle/move/item/sleepy_sheep3.pal", battle_item_sleepy_sheep3_pal);
186
187Vtx N(model)[] = {
188 { .v = {{ -28, 0, 0 }, FALSE, { 0, 1536 }, { 0, 0, 0, 255 }}},
189 { .v = {{ 27, 0, 0 }, FALSE, { 1792, 1536 }, { 0, 0, 0, 255 }}},
190 { .v = {{ 27, 47, 0 }, FALSE, { 1792, 0 }, { 0, 0, 0, 255 }}},
191 { .v = {{ -28, 47, 0 }, FALSE, { 0, 0 }, { 0, 0, 0, 255 }}},
192};
193
194Gfx N(frame1_displayList)[] = {
195 gsDPPipeSync(),
196 gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
209 gsSPVertex(N(model), ARRAY_COUNT(N(model)), 0),
210 gsSP1Triangle(0, 1, 2, 0),
211 gsSP1Triangle(0, 2, 3, 0),
212 gsDPPipeSync(),
214};
215
216Gfx N(frame2_displayList)[] = {
217 gsDPPipeSync(),
218 gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
231 gsSPVertex(N(model), ARRAY_COUNT(N(model)), 0),
232 gsSP1Triangle(0, 1, 2, 0),
233 gsSP1Triangle(0, 2, 3, 0),
234 gsDPPipeSync(),
236};
237
238Gfx N(frame3_displayList)[] = {
239 gsDPPipeSync(),
240 gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
253 gsSPVertex(N(model), ARRAY_COUNT(N(model)), 0),
254 gsSP1Triangle(0, 1, 2, 0),
255 gsSP1Triangle(0, 2, 3, 0),
256 gsDPPipeSync(),
258};
259
267 ems_End
268};
269
277 ems_End
278};
279
287 ems_End
288};
289
294 Call(SetBattleCamTarget, -67, -15, -5)
298 Thread
300 Loop(7)
302 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.5))
303 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(1.5))
304 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.5))
305 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.2))
306 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.5))
307 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(2.0))
308 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(1.5))
309 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(1.0))
310 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.5))
311 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.25))
312 Wait(2)
313 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.5))
314 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(1.5))
315 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.5))
316 Call(ShakeCam, CAM_BATTLE, 0, 2, Float(0.2))
317 EndLoop
319 Wait(20)
322 Add(LVar1, 32)
324 Wait(30)
326 Wait(1)
328 Wait(1)
330 Wait(1)
332 Wait(1)
334 Wait(1)
336 Thread
340 Thread
341 Wait(40)
347 Wait(8)
352 Call(PlayerHopToGoal, 15, 0, 0)
353 Thread
354 Wait(5)
356 Wait(1)
358 Wait(1)
360 Wait(1)
362 Wait(1)
364 Wait(1)
367 Wait(40)
369 Set(LVar7, -200)
370 Set(LVar8, 0)
371 Set(LVar9, 0)
373 Call(SetVirtualEntityScale, LVarA, Float(0.711), Float(0.711), Float(0.711))
379 Sub(LVar0, 60)
384 Thread
386 Call(SetActorScale, ACTOR_PLAYER, Float(1.2), Float(0.9), Float(1.0))
387 Wait(1)
388 Call(SetActorScale, ACTOR_PLAYER, Float(1.3), Float(0.8), Float(1.0))
389 Wait(3)
390 Call(SetActorScale, ACTOR_PLAYER, Float(1.2), Float(0.9), Float(1.0))
391 Wait(1)
392 Call(SetActorScale, ACTOR_PLAYER, Float(1.0), Float(1.0), Float(1.0))
395 Wait(2)
398 Add(LVar0, 60)
402 Add(LVar0, 20)
405 Add(LVar0, 10)
408 Wait(5)
409 Thread
411 Add(LVar0, 270)
415 Wait(30)
419 Label(0)
423 Goto(1)
424 EndIf
428 Label(1)
429 Wait(5)
432 Goto(0)
433 EndIf
434 Wait(30)
436 Return
437 End
438};
439
441 0, 0, 0,
442 -30, 0, -50,
443 -27, 0, 30,
444 -70, 0, -5,
445 -105, 0, 30,
446 -110, 0, -50,
447 -145, 0, -5,
448 -170, 0, -50,
449 -190, 0, -30,
450 -210, 0, -10,
451};
452
453f32 D_802A3F00_721550[] = { 1.0f, 1.0f, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.75f, 0.75f };
454
BSS s32 PopupMenu_SelectedIndex
struct SelectableTarget targetData[24]
s8 targetIndexList[24]
Bytecode EvtScript[]
s8 targetListLength
#define rand_int
#define clamp_angle
s32 EntityModelScript[]
Definition entity.h:7
#define ems_Restart
Definition entity.h:49
#define ems_SetRenderMode(mode)
Definition entity.h:51
#define ems_End
Definition entity.h:47
#define ems_Draw(dlist, holdTime)
Definition entity.h:48
@ EMOTE_QUESTION
Definition enums.h:497
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3574
@ ITER_NO_MORE
Definition enums.h:2030
@ ITER_NEXT
Definition enums.h:2025
@ ACTOR_EVENT_FLAG_ILLUSORY
Player attacks pass through and miss.
Definition enums.h:3374
@ HIT_RESULT_MISS
Definition enums.h:1956
@ BTL_CAM_DEFAULT
Definition enums.h:4823
@ BTL_CAM_REPOSITION
Definition enums.h:4840
@ BTL_CAM_VIEW_ENEMIES
Definition enums.h:4824
@ EMOTER_POS
Definition enums.h:506
@ STATUS_FLAG_SLEEP
Definition enums.h:2812
@ SOUND_HIT_BLOCK
Definition enums.h:768
@ SOUND_SHEEP_STAMPEDE
Definition enums.h:1172
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
@ BTL_RUMBLE_HIT_MIN
Definition enums.h:4253
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_SELF
Definition enums.h:2084
@ CAM_BATTLE
Definition enums.h:1801
@ DAMAGE_TYPE_STATUS_ALWAYS_HITS
Definition enums.h:2880
@ DAMAGE_TYPE_NO_CONTACT
Definition enums.h:2878
#define ApiStatus_DONE2
Definition evt.h:118
#define ApiStatus_BLOCK
Definition evt.h:116
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:1191
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
#define INCLUDE_PAL(FILENAME, SYMBOLNAME)
#define INCLUDE_IMG(FILENAME, SYMBOLNAME)
ApiStatus CreateVirtualEntity(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityMoveSpeed(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityPosition(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityJumpGravity(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityScale(Evt *script, b32 isInitialCall)
ApiStatus ShakeCam(Evt *script, b32 isInitialCall)
ApiStatus ShowEmote(Evt *script, b32 isInitialCall)
ApiStatus DeleteVirtualEntity(Evt *script, b32 isInitialCall)
ApiStatus GetItemPower(Evt *script, b32 isInitialCall)
ApiStatus VirtualEntityJumpTo(Evt *script, b32 isInitialCall)
ApiStatus VirtualEntityMoveTo(Evt *script, b32 isInitialCall)
#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 IfNe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR != RVAR.
Definition macros.h:272
#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 Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#define BSS
Definition macros.h:7
#define ARRAY_COUNT(arr)
Definition macros.h:40
#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 EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define ExecWait(EVT_SOURCE)
Launches a new child thread.
Definition macros.h:475
#define LVar7
Definition macros.h:155
#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 LVar8
Definition macros.h:156
#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 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
BSS Vec3f D_802A3F88
BSS s32 D_802A3F54
BSS s32 D_802A3F80[2]
BSS s32 D_802A3F58[10]
EntityModelScript * D_802A3F28_721578[10]
void virtual_entity_set_pos(s32, s32, s32, s32)
s32 virtual_entity_create(EntityModelScript *)
f32 D_802A3F00_721550[]
void virtual_entity_delete_by_index(s32)
void virtual_entity_set_scale(s32, f32, f32, f32)
s32 D_802A3E88_7214D8[]
GameStatus * gGameStatusPtr
Definition main_loop.c:32
BattleStatus gBattleStatus
Definition battle.c:11