Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
WhaleAnim.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "sprite/npc/Kolorado.h"
3
4Npc* N(resolve_npc)(Evt* script, s32 npcIdOrPtr) {
5 if (npcIdOrPtr == NPC_SELF) {
6 return get_npc_safe(script->owner2.npcID);
7 } else if (npcIdOrPtr >= EVT_LIMIT) {
8 return get_npc_safe(npcIdOrPtr);
9 } else {
10 return (Npc*) npcIdOrPtr;
11 }
12}
13
14API_CALLABLE(N(UnkAngleFunc001)) {
15 Bytecode* args = script->ptrReadPos;
16 s32 npcID = evt_get_variable(script, *args++);
17 s32 outX = *args++;
18 s32 outY = *args++;
19 s32 outZ = *args++;
20 Npc* npc = N(resolve_npc)(script, npcID);
21 f32 y;
22
23 if (npc == NULL) {
24 return ApiStatus_DONE2;
25 }
26
27 N(unkAngle1) += 4;
28 if (N(unkAngle1) >= 360) {
29 N(unkAngle1) -= 360;
30 }
31
32 y = npc->pos.y;
33 if (npc->curAnim == ANIM_Kolorado_Still ||
34 npc->curAnim == ANIM_Kolorado_Walk ||
35 npc->curAnim == ANIM_Kolorado_Talk ||
36 npc->curAnim == ANIM_Kolorado_HurtStill)
37 {
38 y += 2.0f * sin_deg(N(unkAngle1));
39 }
40
41 evt_set_float_variable(script, outX, npc->pos.x);
42 evt_set_float_variable(script, outY, y);
43 evt_set_float_variable(script, outZ, npc->pos.z);
44 return ApiStatus_DONE2;
45}
46
47void N(unkVtxFunc001)(Vtx* firstVertex, Vtx* copiedVertices, s32 numVertices, s32* wagPhasePtr) {
48 s32 wagPhase;
49 s32 bendPow, bendFrac;
50 s32 i, j;
51 s16* vtxPos;
52 f32 newX, newY;
53 f32 angle;
54 s32 offset;
55
56 wagPhase = *wagPhasePtr;
57 switch (get_npc_safe(NPC_Whale)->curAnim) {
58 case ANIM_Kolorado_Still:
59 case ANIM_Kolorado_Yell:
60 case ANIM_Kolorado_IdleSad:
61 case ANIM_Kolorado_Walk:
62 case ANIM_Kolorado_WalkSad:
63 case ANIM_Kolorado_Run:
64 case ANIM_Kolorado_Panic:
65 case ANIM_Kolorado_Talk:
66 case ANIM_Kolorado_TalkSad:
67 case ANIM_Kolorado_Fallen:
68 case ANIM_Kolorado_HurtStill:
69 break;
70 case ANIM_Kolorado_Idle:
71 case ANIM_Kolorado_Shout:
72 if (*wagPhasePtr < 0) {
73 wagPhase = 0;
74 *wagPhasePtr = 0;
75 }
76 break;
77 }
78
79 for (i = 0; i < numVertices; i++) {
80 vtxPos = firstVertex[i].v.ob;
81 offset = 30;
82
83 if (vtxPos[0] > 30) {
84 newX = 0.0f;
85 newY = 0.0f;
86 // determine number of bend stages to apply
87 bendPow = (vtxPos[0] - offset) / 10;
88 bendFrac = vtxPos[0] - ((bendPow * 10) + offset);
89 // apply formula once per 10 unit interval from X = 30
90 for (j = 0; j < bendPow; j++) {
91 angle = (j / 15.0f) + ((j / 40.0f) * sin_deg(wagPhase));
92 newX += cos_rad(angle) * 10.0f;
93 newY += sin_rad(angle) * 10.0f;
94 }
95 // add fractional part between current and next interval
96 angle = (j / 15.0f) + ((j / 40.0f) * sin_deg(wagPhase));
97 newX += bendFrac * cos_rad(angle);
98 newY += bendFrac * sin_rad(angle);
99
100 copiedVertices[i].v.ob[0] = newX;
101 copiedVertices[i].v.ob[1] = vtxPos[1] + newY;
102 }
103 }
104}
105
106void N(unkAngleFunc002)(void) {
107 Vtx* firstVertex;
108 Vtx* copiedVertices;
109 s32 numVertices;
110
111 mdl_get_copied_vertices(VTX_COPY_1, &firstVertex, &copiedVertices, &numVertices);
112 N(unkVtxFunc001)(firstVertex, copiedVertices, numVertices, &N(unkAngle2));
113
114 gSPDisplayList(gMainGfxPos++, mdl_get_copied_gfx(VTX_COPY_1));
115 if (N(unkAngle2) >= 0) {
116 N(unkAngle2) += 4;
117 }
118 if (N(unkAngle2) >= 360) {
119 N(unkAngle2) = -1;
120 }
121}
122
123void N(unkAngleFunc003)(void) {
124 Vtx* firstVertex;
125 Vtx* copiedVertices;
126 s32 numVertices;
127
128 mdl_get_copied_vertices(VTX_COPY_2, &firstVertex, &copiedVertices, &numVertices);
129 N(unkVtxFunc001)(firstVertex, copiedVertices, numVertices, &N(unkAngle3));
130
131 gSPDisplayList(gMainGfxPos++, mdl_get_copied_gfx(VTX_COPY_2));
132 if (N(unkAngle3) >= 0) {
133 N(unkAngle3) += 4;
134 }
135 if (N(unkAngle3) >= 360) {
136 N(unkAngle3) = -1;
137 }
138}
139
void N unkAngleFunc003(void)
void N unkVtxFunc001(Vtx *firstVertex, Vtx *copiedVertices, s32 numVertices, s32 *wagPhasePtr)
void N unkAngleFunc002(void)
Npc *N resolve_npc(Evt *script, s32 npcIdOrPtr)
#define sin_deg
@ NPC_SELF
Definition enums.h:2526
@ VTX_COPY_2
Definition enums.h:4442
@ VTX_COPY_1
Definition enums.h:4441
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
Gfx * mdl_get_copied_gfx(s32 copyIndex)
Definition model.c:4086
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
f32 evt_set_float_variable(Evt *script, Bytecode var, f32 value)
Definition evt.c:1977
f32 cos_rad(f32 x)
Definition 43F0.c:717
f32 sin_rad(f32 x)
Definition 43F0.c:713
void mdl_get_copied_vertices(s32 copyIndex, Vtx **firstVertex, Vtx **copiedVertices, s32 *numCopied)
Definition model.c:4077
Npc * get_npc_safe(s32 npcID)
Definition npc.c:1010
#define EVT_LIMIT
Definition macros.h:47
AnimID curAnim
Vec3f pos
Gfx * gMainGfxPos
Definition cam_main.c:15