Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
StarRodAppearEffect.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects.h"
3
4typedef struct StarOutlineState {
5 /* 0x00 */ EffectInstance* effect;
6 /* 0x04 */ Vec3f pos;
7 /* 0x10 */ f32 unk_10;
8 /* 0x14 */ f32 unk_14;
9 /* 0x18 */ f32 unk_18;
10 /* 0x1C */ s32 delay;
11 /* 0x20 */ s32 duration;
12 /* 0x24 */ s32 unk_24;
13 /* 0x28 */ s32 unk_28;
14 /* 0x2C */ f32 unk_2C;
15 /* 0x30 */ f32 unk_30;
16 /* 0x34 */ f32 unk_34;
17 /* 0x38 */ s32 effectEnded;
18} StarOutlineState; // size = 0x3C
19
20API_CALLABLE(N(StarRodAppearEffect)) {
21 Bytecode* args = script->ptrReadPos;
22 Actor* actor = get_actor(script->owner1.actorID);
23 s32 i;
24 s32 endedCount;
25 StarOutlineState* effectState;
26
27 if (actor == NULL) {
28 return ApiStatus_DONE2;
29 }
30
31 if (isInitialCall) {
32 f32 x = evt_get_variable(script, *args++);
33 f32 y = evt_get_variable(script, *args++);
34 f32 z = evt_get_variable(script, *args++);
35 f32 arg4 = evt_get_float_variable(script, *args++);
36 f32 arg5 = evt_get_float_variable(script, *args++);
37 effectState = heap_malloc(sizeof(StarOutlineState) * 3);
38 actor->state.functionTempPtr[0] = effectState;
39
40 for (i = 0; i < 3; effectState++, i++) {
41 effectState->pos.x = x;
42 effectState->pos.y = y;
43 effectState->pos.z = z;
44 effectState->unk_18 = arg4;
45 effectState->unk_10 = arg4;
46 effectState->unk_14 = arg5;
47 effectState->delay = 1 + i * 10;
48 effectState->duration = 40;
49 effectState->unk_24 = 255;
50 effectState->unk_28 = 255;
51 effectState->unk_2C = 0.0f;
52 effectState->unk_30 = 0.0f;
53 effectState->unk_34 = 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_18, -1);
68 effectState->effect->data.starOutline->unk_3C.x = effectState->unk_2C;
69 effectState->effect->data.starOutline->unk_3C.y = effectState->unk_30;
70 effectState->effect->data.starOutline->unk_3C.z = effectState->unk_34;
71 effectState->effect->data.starOutline->unk_00 = 0;
72 }
73 } else if (effectState->effectEnded) {
74 endedCount++;
75 } else {
76 effectState->unk_34 += 9.0f;
77 effectState->unk_18 = fabsf(effectState->unk_10 - effectState->unk_14) * effectState->duration / 40.0f + effectState->unk_14;
78
79 if (effectState->duration <= 10) {
80 effectState->unk_24 = (effectState->duration / 2 * 0.1f + 0.5f) * 255.0f;
81 effectState->unk_28 = (effectState->duration / 2 * 0.1f + 0.5f) * 255.0f;
82 }
83
84 effectState->duration--;
85
86 if (effectState->duration <= 0) {
87 remove_effect(effectState->effect);
88 effectState->effectEnded = TRUE;
89 } else {
90 effectState->effect->data.starOutline->pos.x = effectState->pos.x;
91 effectState->effect->data.starOutline->pos.y = effectState->pos.y;
92 effectState->effect->data.starOutline->pos.z = effectState->pos.z;
93 effectState->effect->data.starOutline->unk_3C.x = effectState->unk_2C;
94 effectState->effect->data.starOutline->unk_3C.y = effectState->unk_30;
95 effectState->effect->data.starOutline->unk_3C.z = effectState->unk_34;
96 effectState->effect->data.starOutline->unk_38 = effectState->unk_18;
97 effectState->effect->data.starOutline->unk_24 = effectState->unk_24;
98 effectState->effect->data.starOutline->unk_34 = effectState->unk_28;
99 }
100 }
101 }
102
103 if (endedCount >= 3) {
104 heap_free(effectState);//@bug effectState doesn't point to allocated memory
105 return ApiStatus_DONE2;
106 } else {
107 return ApiStatus_BLOCK;
108 }
109}
EffectInstance * effect
ActorState state
#define remove_effect
struct StarOutlineFXData * starOutline
Definition effects.h:2597
EffectData data
Definition effects.h:2605
#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 fabsf(f32 f)
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