Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
coconut.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 "sprite/player.h"
6#include "include_asset.h"
7
8#define NAMESPACE battle_item_coconut
9
12
13static s32 _pad = 0;
14
15#include "battle/move/item/coconut.png.h"
16INCLUDE_IMG("battle/move/item/coconut.png", battle_item_coconut_png);
17INCLUDE_PAL("battle/move/item/coconut.pal", battle_item_coconut_pal);
18
20Vtx N(model)[] = {
21 { .v = {{ -16, -16, 0 }, FALSE, { 0, 0 }, { 0, 0, 0, 255 }}},
22 { .v = {{ 15, -16, 0 }, FALSE, { 1024, 0 }, { 0, 0, 0, 255 }}},
23 { .v = {{ 15, 15, 0 }, FALSE, { 1024, 1024 }, { 0, 0, 0, 255 }}},
24 { .v = {{ -16, 15, 0 }, FALSE, { 0, 1024 }, { 0, 0, 0, 255 }}},
25};
26
27Gfx N(displayList)[] = {
28 gsDPPipeSync(),
29 gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
30 gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
31 gsDPSetTexturePersp(G_TP_PERSP),
32 gsDPSetTextureDetail(G_TD_CLAMP),
33 gsDPSetTextureLOD(G_TL_TILE),
34 gsDPSetTextureLUT(G_TT_NONE),
35 gsDPSetTextureFilter(G_TF_AVERAGE),
36 gsDPSetTextureConvert(G_TC_FILT),
37 gsDPSetTextureLUT(G_TT_RGBA16),
38 gsDPLoadTLUT_pal16(0, battle_item_coconut_pal),
39 gsDPLoadTextureTile_4b(battle_item_coconut_png, G_IM_FMT_CI, battle_item_coconut_png_width, battle_item_coconut_png_height, 0, 0, battle_item_coconut_png_width - 1, battle_item_coconut_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),
40 gsSPClearGeometryMode(G_LIGHTING),
41 gsSPClearGeometryMode(G_SHADING_SMOOTH),
42 gsSPVertex(&N(model), ARRAY_COUNT(N(model)), 0),
43 gsSP1Triangle(0, 1, 2, 0),
44 gsSP1Triangle(0, 2, 3, 0),
45 gsDPPipeSync(),
46 gsSPEndDisplayList(),
47};
48
49EntityModelScript N(modelCommandList) = STANDARD_ENTITY_MODEL_SCRIPT(N(displayList), RENDER_MODE_ALPHATEST);
50
51EvtScript N(EVS_UseItem) = {
52 SetConst(LVarA, ITEM_COCONUT)
53 ExecWait(N(UseItemWithEffect))
54 Call(UseBattleCamPreset, BTL_CAM_VIEW_ENEMIES)
55 Call(MoveBattleCamOver, 15)
56 Call(SetAnimation, ACTOR_PLAYER, 0, ANIM_Mario1_Throw)
58 Wait(3)
59 Call(CreateVirtualEntity, LVarA, Ref(N(modelCommandList)))
60 SetF(LVar0, Float(1.0))
61 Call(MultiplyByActorScale, LVar0)
63 Call(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2)
64 Set(LVar3, 20)
65 Set(LVar4, 42)
66 Set(LVar5, 5)
67 Call(MultiplyVec3ByActorScale, LVar3, LVar4, LVar5)
72 Call(InitTargetIterator)
73 Call(SetGoalToTarget, ACTOR_SELF)
74 Call(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2)
75 Thread
76 Set(LVar0, 0)
77 Loop(18)
78 Add(LVar0, -60)
80 Wait(1)
84 Add(LVar2, 5)
86 Call(GetItemPower, ITEM_COCONUT, LVar3, LVar4)
87 Call(ApplyShrinkFromOwner, LVar3)
89 Add(LVar0, 60)
90 Add(LVar1, 0)
93 ExecWait(N(PlayerGoHome))
94 Return
95 End
96};
Bytecode EvtScript[]
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_THROW
Definition enums.h:1311
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_SELF
Definition enums.h:2084
@ DAMAGE_TYPE_IGNORE_DEFENSE
Definition enums.h:2877
@ DAMAGE_TYPE_NO_CONTACT
Definition enums.h:2878
#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 GetItemPower(Evt *script, b32 isInitialCall)
ApiStatus VirtualEntityJumpTo(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityRotation(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 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 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 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