Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
StarRodPowerUpEffect.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects.h"
3
4typedef struct StarOutlineState2 {
5 /* 0x00 */ EffectInstance* effect;
6 /* 0x04 */ Vec3f pos;
7 /* 0x10 */ f32 unk_10;
8 /* 0x14 */ s32 delay;
9 /* 0x18 */ s32 duration;
10 /* 0x1C */ s32 unk_1C;
11 /* 0x20 */ s32 unk_20;
12 /* 0x24 */ f32 unk_24;
13 /* 0x38 */ f32 unk_28;
14 /* 0x2C */ f32 unk_2C;
15 /* 0x30 */ s32 effectEnded;
16} StarOutlineState2; // size = 0x34
17
18API_CALLABLE(N(StarRodPowerUpEffect)) {
19 Bytecode* args = script->ptrReadPos;
20 Actor* actor = get_actor(script->owner1.actorID);
21 s32 i;
22 s32 endedCount;
23 StarOutlineState2* effectState;
24
25 if (actor == NULL) {
26 return ApiStatus_DONE2;
27 }
28
29 if (isInitialCall) {
30 f32 x = evt_get_variable(script, *args++);
31 f32 y = evt_get_variable(script, *args++);
32 f32 z = evt_get_variable(script, *args++);
33 f32 arg4 = evt_get_float_variable(script, *args++);
34
35 if (actor->debuff == STATUS_KEY_SHRINK) {
36 arg4 *= 0.4;
37 }
38
39 effectState = heap_malloc(sizeof(StarOutlineState2) * 3);
40 actor->state.functionTempPtr[0] = effectState;
41
42 for (i = 0; i < 3; effectState++, i++) {
43 effectState->pos.x = x;
44 effectState->pos.y = y;
45 effectState->pos.z = z;
46 effectState->unk_10 = arg4;
47 effectState->delay = 1 + i * 16;
48 effectState->duration = 50;
49 effectState->unk_1C = 255;
50 effectState->unk_20 = 255;
51 effectState->unk_24 = 90.0f;
52 effectState->unk_28 = 0.0f;
53 effectState->unk_2C = 0.0f;
54 effectState->effectEnded = FALSE;
55 }
56 return ApiStatus_BLOCK;
57 }
58
59 effectState = actor->state.functionTempPtr[0];
60 endedCount = 0;
61
62 for (i = 0; i < 3; effectState++, i++) {
63 if (effectState->delay > 0) {
64 effectState->delay--;
65 if (effectState->delay <= 0) {
66 effectState->effect = fx_star_outline(0, effectState->pos.x, effectState->pos.y, effectState->pos.z,
67 effectState->unk_10, -1);
68 effectState->effect->data.starOutline->unk_3C.x = effectState->unk_24;
69 effectState->effect->data.starOutline->unk_3C.y = effectState->unk_28;
70 effectState->effect->data.starOutline->unk_3C.z = effectState->unk_2C;
71 }
72 } else if (effectState->effectEnded) {
73 endedCount++;
74 } else {
75#ifdef BOWSER_LARGE
76 if (actor->debuff != STATUS_KEY_SHRINK) {
77 if (effectState->pos.y < 60.0) {
78 effectState->pos.y += 4.5;
79 } else if (effectState->pos.y < 90.0) {
80 effectState->pos.y += 3.6000001430511475;
81 } else if (effectState->pos.y < 120.0) {
82 effectState->pos.y += 2.400000035762787;
83 } else {
84 effectState->pos.y += 1.5;
85 }
86 } else {
87 if (effectState->pos.y < 24.0) {
88 effectState->pos.y += 1.8;
89 } else if (effectState->pos.y < 36.0) {
90 effectState->pos.y += 1.440000057220459;
91 } else if (effectState->pos.y < 48.0) {
92 effectState->pos.y += 0.9600000143051148;
93 } else {
94 effectState->pos.y += 0.6000000000000001;
95 }
96 }
97#else
98 if (actor->debuff != STATUS_KEY_SHRINK) {
99 if (effectState->pos.y < 40.0) {
100 effectState->pos.y += 3.0;
101 } else if (effectState->pos.y < 60.0) {
102 effectState->pos.y += 2.400000095367431640625;
103 } else if (effectState->pos.y < 80.0) {
104 effectState->pos.y += 1.60000002384185791015625;
105 } else {
106 effectState->pos.y += 1.0;
107 }
108 } else {
109 if (effectState->pos.y < 16.0) {
110 effectState->pos.y += 1.20000000000000017763568394003;
111 } else if (effectState->pos.y < 24.0) {
112 effectState->pos.y += 0.96000003814697265625;
113 } else if (effectState->pos.y < 32.0) {
114 effectState->pos.y += 0.640000009536743186266960492503;
115 } else {
116 effectState->pos.y += 0.4;
117 }
118 }
119#endif
120 effectState->unk_28 += 18.0f;
121
122 if (effectState->duration <= 16) {
123 effectState->unk_1C = effectState->duration * 255 / 16;
124 effectState->unk_20 = effectState->duration * 255 / 16;
125 }
126
127 effectState->effect->data.starOutline->pos.x = effectState->pos.x;
128 effectState->effect->data.starOutline->pos.y = effectState->pos.y;
129 effectState->effect->data.starOutline->pos.z = effectState->pos.z;
130 effectState->effect->data.starOutline->unk_3C.x = effectState->unk_24;
131 effectState->effect->data.starOutline->unk_3C.y = effectState->unk_28;
132 effectState->effect->data.starOutline->unk_3C.z = effectState->unk_2C;
133 effectState->effect->data.starOutline->unk_38 = effectState->unk_10;
134 effectState->effect->data.starOutline->unk_24 = effectState->unk_1C;
135 effectState->effect->data.starOutline->unk_34 = effectState->unk_20;
136
137 effectState->duration--;
138
139 if (effectState->duration <= 0) {
140 remove_effect(effectState->effect);
141 effectState->effectEnded = TRUE;
142 }
143 }
144 }
145
146 if (endedCount >= 3) {
147 heap_free(effectState);//@bug effectState doesn't point to allocated memory
148 return ApiStatus_DONE2;
149 } else {
150 return ApiStatus_BLOCK;
151 }
152}
ActorState state
#define remove_effect
struct StarOutlineFXData * starOutline
Definition effects.h:2597
EffectData data
Definition effects.h:2605
@ STATUS_KEY_SHRINK
Definition enums.h:2206
#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
s32 heap_free(void *ptr)
Definition heap.c:42
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1930
void * heap_malloc(s32 size)
Definition heap.c:34