6 Bytecode* ptrReadPos = script->ptrReadPos;
12 script->varTable[0xE] = 0;
19 script->varTable[0xB],
20 script->varTable[0xC],
21 script->varTable[0xD],
22 script->varTable[0xE],
26 if (script->varTable[0xE] >= script->varTable[0xF]) {
27 script->varTable[0x1] = 0;
29 script->varTable[0x1] = 1;
31 script->varTable[0xE]++;
91 s32* targetX = &script->functionTemp[0];
92 s32* targetZ = &script->functionTemp[1];
93 s32* distanceRequired = &script->functionTemp[2];
104 playerStatus->
pos.
x, playerStatus->
pos.
z,
108 if (distance < *distanceRequired) {
116 Bytecode* args = script->ptrReadPos;
119 s32* targetX = &script->functionTemp[0];
120 s32* targetZ = &script->functionTemp[1];
121 s32* distanceRequired = &script->functionTemp[2];
134 playerStatus->
pos.
x, playerStatus->
pos.
z,
139 if (distance < *distanceRequired) {
147 Bytecode* ptrReadPos = script->ptrReadPos;
150 s32* targetX = &script->functionTemp[0];
151 s32* targetZ = &script->functionTemp[1];
152 s32* distanceRequired = &script->functionTemp[2];
163 playerStatus->
pos.
x, playerStatus->
pos.
z,
167 if (distance > *distanceRequired) {
175 Bytecode* args = script->ptrReadPos;
194 s32* ready = &script->functionTemp[0];
195 s32* progress = &script->functionTemp[1];
223 s32* ready = &script->functionTemp[0];
224 s32* progress = &script->functionTemp[1];
251 Bytecode* args = script->ptrReadPos;
264 Bytecode* args = script->ptrReadPos;
285 normalizedLengths[0] = 0.0f;
286 for (i = 1; i < num; i++) {
287 f32 dx = pathPositions[i].
x - pathPositions[i-1].
x;
288 f32 dy = pathPositions[i].
y - pathPositions[i-1].
y;
289 f32 dz = pathPositions[i].
z - pathPositions[i-1].
z;
291 normalizedLengths[i] = normalizedLengths[i-1] + length;
293 for (i = 1; i < num; i++) {
294 normalizedLengths[i] /= normalizedLengths[num-1];
298 outVectors[0].
x = 0.0f;
299 outVectors[0].
y = 0.0f;
300 outVectors[0].
z = 0.0f;
301 outVectors[num-1].
x = 0.0f;
302 outVectors[num-1].
y = 0.0f;
303 outVectors[num-1].
z = 0.0f;
305 for (i = 0; i < num - 1; i++) {
306 lenBuf[i] = normalizedLengths[i+1] - normalizedLengths[i];
307 vecBuf[i+1].
x = (pathPositions[i+1].
x - pathPositions[i].
x) / lenBuf[i];
308 vecBuf[i+1].
y = (pathPositions[i+1].
y - pathPositions[i].
y) / lenBuf[i];
309 vecBuf[i+1].
z = (pathPositions[i+1].
z - pathPositions[i].
z) / lenBuf[i];
313 outVectors[1].
x = vecBuf[2].
x - vecBuf[1].
x;
314 outVectors[1].
y = vecBuf[2].
y - vecBuf[1].
y;
315 outVectors[1].
z = vecBuf[2].
z - vecBuf[1].
z;
316 vecBuf[1].
x = 2.0f * (normalizedLengths[2] - normalizedLengths[0]);
317 vecBuf[1].
y = 2.0f * (normalizedLengths[2] - normalizedLengths[0]);
318 vecBuf[1].
z = 2.0f * (normalizedLengths[2] - normalizedLengths[0]);
321 for (i = 1; i < num - 2; i++) {
322 f32 sx = lenBuf[i] / vecBuf[i].
x;
323 f32 sy = lenBuf[i] / vecBuf[i].
y;
324 f32 sz = lenBuf[i] / vecBuf[i].
z;
325 outVectors[i+1].
x = (vecBuf[i+2].
x - vecBuf[i+1].
x) - outVectors[i].x * sx;
326 outVectors[i+1].
y = (vecBuf[i+2].
y - vecBuf[i+1].
y) - outVectors[i].y * sy;
327 outVectors[i+1].
z = (vecBuf[i+2].
z - vecBuf[i+1].
z) - outVectors[i].z * sz;
328 vecBuf[i+1].
x = 2.0f * (normalizedLengths[i+2] - normalizedLengths[i]) - lenBuf[i] * sx;
329 vecBuf[i+1].
y = 2.0f * (normalizedLengths[i+2] - normalizedLengths[i]) - lenBuf[i] * sy;
330 vecBuf[i+1].
z = 2.0f * (normalizedLengths[i+2] - normalizedLengths[i]) - lenBuf[i] * sz;
334 outVectors[num-2].
x -= (lenBuf[num-2] * outVectors[num-1].
x);
335 outVectors[num-2].
y -= (lenBuf[num-2] * outVectors[num-1].
y);
336 outVectors[num-2].
z -= (lenBuf[num-2] * outVectors[num-1].
z);
338 for (i = num - 2; i > 0; i--) {
339 outVectors[i].
x = (outVectors[i].
x - (lenBuf[i] * outVectors[i+1].
x)) / vecBuf[i].
x;
340 outVectors[i].
y = (outVectors[i].
y - (lenBuf[i] * outVectors[i+1].
y)) / vecBuf[i].
y;
341 outVectors[i].
z = (outVectors[i].
z - (lenBuf[i] * outVectors[i+1].
z)) / vecBuf[i].
z;
349 s32 limit = numVectors - 1;
352 f32 ax, ay, az, bx, by, bz, dx, dy, dz;
355 for (i = 0; i < limit;) {
356 s32 temp_v1 = (i + limit) / 2;
358 if (normalizedLengths[temp_v1] < alpha) {
369 curLength = normalizedLengths[i+1] - normalizedLengths[i];
370 curProgress = alpha - normalizedLengths[i];
372 dx = (pathPoints[i+1].
x - pathPoints[i].
x) / curLength;
373 ax = (((vectors[i+1].
x - vectors[i].
x) * curProgress / curLength) + (3.0f * vectors[i].
x)) * curProgress;
374 bx = dx - (((2.0f * vectors[i].
x) + vectors[i+1].x) * curLength);
375 outPos->
x = ((ax + bx) * curProgress) + pathPoints[i].
x;
377 dy = (pathPoints[i+1].
y - pathPoints[i].
y) / curLength;
378 ay = (((vectors[i+1].
y - vectors[i].
y) * curProgress / curLength) + (3.0f * vectors[i].
y)) * curProgress;
379 by = dy - (((2.0f * vectors[i].
y) + vectors[i+1].y) * curLength);
380 outPos->
y = ((ay + by) * curProgress) + pathPoints[i].
y;
382 dz = (pathPoints[i+1].
z - pathPoints[i].
z) / curLength;
383 az = (((vectors[i+1].
z - vectors[i].
z) * curProgress / curLength) + (3.0f * vectors[i].
z)) * curProgress;
384 bz = dz - (((2.0f * vectors[i].
z) + vectors[i+1].z) * curLength);
385 outPos->
z = ((az + bz) * curProgress) + pathPoints[i].
z;
389 Bytecode* args = script->ptrReadPos;
396 script->varTablePtr[15] = path;
411 Path* path = script->varTablePtr[0xF];
442 script->varTable[0] = 1;
447 script->varTable[0] = 0;
454 Bytecode* args = script->ptrReadPos;
469 Bytecode* args = script->ptrReadPos;
476 Bytecode* args = script->ptrReadPos;
490 Bytecode* args = script->ptrReadPos;
500 Bytecode* args = script->ptrReadPos;
510 Bytecode* args = script->ptrReadPos;
523 Bytecode* args = script->ptrReadPos;
537 Bytecode* args = script->ptrReadPos;
546 Bytecode* args = script->ptrReadPos;
555 Bytecode* args = script->ptrReadPos;
564API_CALLABLE(GetLanguage) {
565 Bytecode* args = script->ptrReadPos;
void get_path_position(f32 alpha, Vec3f *outPos, s32 numVectors, f32 *normalizedLengths, Vec3f *pathPoints, Vec3f *vectors)
void load_path_data(s32 num, f32 *normalizedLengths, Vec3f *pathPositions, Vec3f *outVectors)
void set_screen_overlay_params_back(u8, f32)
s32 evt_get_variable(Evt *script, Bytecode var)
f32 update_lerp(s32 easing, f32 start, f32 end, s32 elapsed, s32 duration)
void status_bar_ignore_changes(void)
void decrement_status_bar_disabled(void)
f32 evt_set_float_variable(Evt *script, Bytecode var, f32 value)
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
void set_screen_overlay_params_front(u8, f32)
void close_status_bar(void)
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
void set_screen_overlay_center(s32, s32, s32, s32)
Npc * resolve_npc(Evt *script, s32 npcIdOrPtr)
f32 evt_get_float_variable(Evt *script, Bytecode var)
void set_time_freeze_mode(s32)
Time freeze modes: 0: none 1: NPCs move, can't be interacted with 2: NPCs don't move,...
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
void * heap_malloc(s32 size)
void status_bar_respond_to_changes(void)
void increment_status_bar_disabled(void)
void set_game_mode(s32 modeID)
ApiStatus EnableWorldStatusBar(Evt *script, b32 isInitialCall)
ApiStatus SetTimeFreezeMode(Evt *script, b32 isInitialCall)
ApiStatus ModifyGlobalOverrideFlags(Evt *script, b32 isInitialCall)
ApiStatus AddVectorPolar(Evt *script, b32 isInitialCall)
ApiStatus GetAngleToPlayer(Evt *script, b32 isInitialCall)
ApiStatus ClampAngleInt(Evt *script, b32 isInitialCall)
ApiStatus AwaitPlayerLeave(Evt *script, b32 isInitialCall)
ApiStatus GetDist2D(Evt *script, b32 isInitialCall)
ApiStatus GetAngleToNPC(Evt *script, b32 isInitialCall)
ApiStatus UpdateLerp(Evt *script, b32 isInitialCall)
ApiStatus AwaitPlayerApproach(Evt *script, b32 isInitialCall)
ApiStatus func_802D4D14(Evt *script, b32 isInitialCall)
ApiStatus ShowWorldStatusBar(Evt *script, b32 isInitialCall)
ApiStatus func_802D4CC4(Evt *script, b32 isInitialCall)
ApiStatus func_802D4BDC(Evt *script, b32 isInitialCall)
ApiStatus ClampAngleFloat(Evt *script, b32 isInitialCall)
ApiStatus SetValueByRef(Evt *script, b32 isInitialCall)
ApiStatus GetAngleBetweenNPCs(Evt *script, b32 isInitialCall)
ApiStatus IsPlayerWithin(Evt *script, b32 isInitialCall)
ApiStatus SetGameMode(Evt *script, b32 isInitialCall)
ApiStatus RandInt(Evt *script, b32 isInitialCall)
ApiStatus LoadPath(Evt *script, b32 isInitialCall)
ApiStatus func_802D4D88(Evt *script, b32 isInitialCall)
ApiStatus MakeLerp(Evt *script, b32 isInitialCall)
ApiStatus GetValueByRef(Evt *script, b32 isInitialCall)
ApiStatus GetNextPathPos(Evt *script, b32 isInitialCall)
ApiStatus func_802D4C4C(Evt *script, b32 isInitialCall)
#define FLOAT_TO_FIXED(x)
Progammatically converts f32 --> Float.
PlayerStatus gPlayerStatus