Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
StarSpiritEffectFunc.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "npc.h"
3#include "effects.h"
4
5#ifndef STAR_SPIRIT_DATA_VAR
6 #error STAR_SPIRIT_DATA_VAR is not defined!
7#endif
8
9// seems to be a macro in the original based on usage
10#define EVT_SPIRIT_ADJUST_CAM(pitch) \
11 Call(GetCamDistance, CAM_DEFAULT, LVar1) \
12 Sub(LVar1, 100) \
13 Call(SetCamDistance, CAM_DEFAULT, LVar1) \
14 IfNe(pitch, 10000) \
15 Call(GetCamPitch, CAM_DEFAULT, LVar2, LVar3) \
16 Call(SetCamPitch, CAM_DEFAULT, LVar2, pitch) \
17 EndIf
18
19API_CALLABLE(N(StarSpiritEffectFunc1)) {
20 StarSpiritData* ptr = script->varTablePtr[0];
21
23
24 if (ptr->unk_44 < 2) {
25 return ApiStatus_BLOCK;
26 } else {
27 return ApiStatus_DONE2;
28 }
29}
30
31API_CALLABLE(N(StarSpiritEffectFunc2)) {
32 Bytecode* args = script->ptrReadPos;
33
34 if (isInitialCall) {
35 StarSpiritData* ptr = heap_malloc(sizeof(*ptr));
36
37 script->varTablePtr[0] = ptr;
38 evt_set_variable(NULL, STAR_SPIRIT_DATA_VAR, script->varTable[0]);
39 ptr->unk_38 = evt_get_variable(script, *args++);
40 ptr->unk_3C = evt_get_variable(script, *args++);
41 ptr->unk_0C = evt_get_float_variable(script, *args++);
42 ptr->unk_10 = evt_get_float_variable(script, *args++);
43 ptr->unk_14 = evt_get_float_variable(script, *args++);
44 ptr->unk_18 = evt_get_float_variable(script, *args++);
45 ptr->unk_1C = evt_get_float_variable(script, *args++);
46 ptr->unk_20 = evt_get_float_variable(script, *args++);
47 ptr->unk_24 = evt_get_float_variable(script, *args++);
48 ptr->unk_28 = evt_get_float_variable(script, *args++);
49 ptr->unk_50 = fx_star_spirits_energy(2, ptr->unk_0C, ptr->unk_10, ptr->unk_14, 1.0f, 0);
50 ptr->unk_4E = 0;
51 ptr->unk_48 = 0;
52 ptr->unk_4A = 0;
53 ptr->unk_44 = 0;
54 ptr->unk_46 = 0;
55 }
56
57 return ApiStatus_DONE2;
58}
59
60API_CALLABLE(N(StarSpiritEffectFunc3)) {
61 PlayerStatus* playerStatus = &gPlayerStatus;
62 StarSpiritData* ptr = script->varTablePtr[0];
63
64 switch (ptr->unk_44) {
65 case 0:
66 ptr->unk_04 = update_lerp(EASING_CUBIC_OUT, ptr->unk_10, ptr->unk_1C, ptr->unk_46, ptr->unk_3C);
67 ptr->unk_00 = update_lerp(EASING_LINEAR, ptr->unk_0C, ptr->unk_18, ptr->unk_46, ptr->unk_3C);
68 ptr->unk_08 = update_lerp(EASING_LINEAR, ptr->unk_14, ptr->unk_20, ptr->unk_46, ptr->unk_3C);
72 ptr->unk_46++;
73 if (ptr->unk_46 >= ptr->unk_3C) {
74 ptr->unk_44 = 1;
75 ptr->unk_46 = 0;
76 }
77 break;
78 case 1:
79 ptr->unk_46++;
80 if (ptr->unk_46 >= 60) {
81 ptr->unk_44 = 2;
82 ptr->unk_46 = 0;
85 }
86 break;
87 case 2:
88 ptr->unk_46++;
89 if (ptr->unk_46 >= 60) {
90 ptr->unk_54 = fx_spirit_card(1, ptr->unk_18, ptr->unk_1C, ptr->unk_20, 1.0f, 0);
91 ptr->unk_54->data.spiritCard->chapter = ptr->unk_38;
92 ptr->unk_54->data.spiritCard->unk_20 = 0;
94 ptr->unk_44 = 3;
95 ptr->unk_46 = 0;
96 ptr->unk_2C = 0.0f;
97 ptr->unk_48 = 1;
98 ptr->unk_30 = 36.0f;
99 }
100 break;
101 case 3:
102 ptr->unk_30 = update_lerp(EASING_LINEAR, 36.0f, 19.0f, ptr->unk_46, 120);
103 ptr->unk_46++;
104 if (ptr->unk_46 >= 120) {
105 ptr->unk_4C = 0;
106 ptr->unk_4A = 1;
107 ptr->unk_48 = 2;
108 ptr->unk_4E = 1;
109 ptr->unk_44 = 4;
110 ptr->unk_46 = 0;
111 ptr->unk_34 = ptr->unk_2C;
112 }
113 break;
114 case 4:
115 break;
116 }
117
118 switch (ptr->unk_4A) {
119 case 1:
120 ptr->unk_2C = update_lerp(EASING_QUADRATIC_OUT, ptr->unk_34, 1440.0f, ptr->unk_4C, 120);
121 ptr->unk_04 = update_lerp(EASING_COS_IN_OUT, ptr->unk_1C, ptr->unk_24, ptr->unk_4C, 120);
122 ptr->unk_4C++;
123 if (ptr->unk_4C >= 120) {
124 ptr->unk_4C = 270;
125 ptr->unk_4A = 2;
126 ptr->unk_4E = 2;
127 }
128 break;
129 case 2:
130 ptr->unk_04 = ptr->unk_24 + (2.0f * (sin_deg(ptr->unk_4C) + 1.0f));
131 ptr->unk_4C = clamp_angle(ptr->unk_4C + 8);
132 if (!(dist3D(playerStatus->pos.x, playerStatus->pos.y + 20.0f, playerStatus->pos.z,
133 ptr->unk_00, ptr->unk_04, ptr->unk_08) > 30.0f)) {
134 ptr->unk_4E = 3;
135 }
136 break;
137 }
138
139 switch (ptr->unk_48) {
140 case 1:
141 ptr->unk_2C = clamp_angle(ptr->unk_2C + ptr->unk_30);
142 case 2:
143 ptr->unk_54->data.spiritCard->yaw = ptr->unk_2C;
144 ptr->unk_54->data.spiritCard->pos.x = ptr->unk_18;
145 ptr->unk_54->data.spiritCard->pos.y = ptr->unk_04;
146 ptr->unk_54->data.spiritCard->pos.z = ptr->unk_20;
147 break;
148 }
149
150 return ApiStatus_BLOCK;
151}
152
153API_CALLABLE(N(StarSpiritEffectFunc4)) {
154 s32 var = evt_get_variable(script, *script->ptrReadPos);
155 StarSpiritData* ptr = script->varTablePtr[0];
156
157 return (ptr->unk_4E == var) * ApiStatus_DONE2;
158}
159
160API_CALLABLE(N(StarSpiritEffectFunc5)) {
161 Bytecode* args = script->ptrReadPos;
162
163 if (isInitialCall) {
164 StarSpiritData* ptr = heap_malloc(sizeof(*ptr));
165 script->varTablePtr[0] = ptr;
166 ptr->unk_38 = evt_get_variable(script, *args++);
167 ptr->unk_18 = evt_get_float_variable(script, *args++);
168 ptr->unk_24 = evt_get_float_variable(script, *args++);
169 ptr->unk_20 = evt_get_float_variable(script, *args++);
170 ptr->unk_28 = evt_get_float_variable(script, *args++);
171 ptr->unk_54 = fx_spirit_card(1, ptr->unk_18, ptr->unk_24, ptr->unk_20, 1.0f, 0);
172 ptr->unk_54->data.spiritCard->chapter = ptr->unk_38;
173 ptr->unk_54->data.spiritCard->unk_20 = 0;
175 ptr->unk_4C = 270;
176 }
177
178 return ApiStatus_DONE2;
179}
180
181API_CALLABLE(N(StarSpiritEffectFunc6)) {
182 PlayerStatus* playerStatus = &gPlayerStatus;
183 StarSpiritData* ptr = script->varTablePtr[0];
184
185 ptr->unk_04 = ptr->unk_24 + (2.0f * (sin_deg(ptr->unk_4C) + 1.0f));
186 ptr->unk_4C = clamp_angle(ptr->unk_4C + 8);
187 if (dist2D(playerStatus->pos.x, playerStatus->pos.z,
188 ptr->unk_18, ptr->unk_20) <= 30.0f) {
189 ptr->unk_4E = 3;
190 }
191 ptr->unk_54->data.spiritCard->pos.x = ptr->unk_18;
192 ptr->unk_54->data.spiritCard->pos.y = ptr->unk_04;
193 ptr->unk_54->data.spiritCard->pos.z = ptr->unk_20;
194
195 return ApiStatus_BLOCK;
196}
#define sin_deg
#define clamp_angle
EffectInstance * unk_54
Definition effects.h:2646
struct SpiritCardFXData * spiritCard
Definition effects.h:2587
EffectInstance * unk_50
Definition effects.h:2645
struct StarSpiritsEnergyFXData * starSpiritsEnergy
Definition effects.h:2595
EffectData data
Definition effects.h:2605
@ SHADOW_VARYING_CIRCLE
Definition enums.h:2535
@ EASING_CUBIC_OUT
Definition enums.h:515
@ EASING_COS_IN_OUT
Definition enums.h:520
@ EASING_QUADRATIC_OUT
Definition enums.h:514
@ EASING_LINEAR
Definition enums.h:510
@ SOUND_LRAW_STAR_ORB_RISING
Definition enums.h:674
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
#define ApiStatus_BLOCK
Definition evt.h:116
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
f32 update_lerp(s32 easing, f32 start, f32 end, s32 elapsed, s32 duration)
Definition 43F0.c:735
f32 dist3D(f32 ax, f32 ay, f32 az, f32 bx, f32 by, f32 bz)
Definition 43F0.c:677
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
s32 create_shadow_type(s32 type, f32 x, f32 y, f32 z)
Definition entity.c:1528
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1930
void * heap_malloc(s32 size)
Definition heap.c:34
s32 sfx_adjust_env_sound_pos(s32 soundID, s32 sourceFlags, f32 x, f32 y, f32 z)
Definition sfx.c:431
PlayerStatus gPlayerStatus
Definition 77480.c:39