29 0.04, 0.04, 0.08, 0.16, 0.21, 0.4, 0.6, 0.72, 0.84, 0.92, 0.96, 0.96, 1.0,
32API_CALLABLE(MovePlayerTowardBlock) {
35 playerStatus->
pos.
x += (script->varTable[0] - playerStatus->
pos.
x) / 2;
36 playerStatus->
pos.
z += (script->varTable[2] - playerStatus->
pos.
z) / 2;
41API_CALLABLE(UpdatePushBlockMotion) {
47 script->functionTemp[0] = 0;
48 script->varTable[0] = playerStatus->
pos.
x;
49 script->varTable[1] = playerStatus->
pos.
y;
50 script->varTable[2] = playerStatus->
pos.
z;
51 script->varTable[3] = entity->
pos.
x;
52 script->varTable[4] = entity->
pos.
y;
53 script->varTable[5] = entity->
pos.
z;
54 script->varTable[9] = entity->
rot.
x;
55 script->varTable[12] = entity->
rot.
z;
59 playerStatus->
pos.
x = script->varTable[0] + (script->varTable[6] * moveRatio *
BLOCK_GRID_SIZE);
60 playerStatus->
pos.
y = script->varTable[1] + (script->varTable[7] * moveRatio *
BLOCK_GRID_SIZE);
61 playerStatus->
pos.
z = script->varTable[2] + (script->varTable[8] * moveRatio *
BLOCK_GRID_SIZE);
66 if (script->functionTemp[0] < 12) {
67 entity->
rot.
z = script->varTable[12] + (script->varTable[6] * moveRatio * -90.0f);
68 entity->
rot.
x = script->varTable[9] + (script->varTable[8] * moveRatio * 90.0f);
73 entity->
rot.
z = entity->
rot.
x = 0.0f;
80 script->functionTemp[0]++;
87API_CALLABLE(FinishPushBlockMotion) {
90 f32 hitX, hitY, hitZ, hitDepth;
95 script->functionTemp[0] = 0;
96 script->varTable[0] = block->
pos.
y;
100 hitY = block->
pos.
y + 5.0f;
104 script->functionTemp[1] = hitDepth;
106 if (hasCollision && hitDepth <= 6.0f) {
111 if (grid->dropCallback != NULL) {
112 if (grid->dropCallback(block, script)) {
122 script->functionTemp[0]++;
133API_CALLABLE(FetchPushedBlockProperties) {
136 s32 gridCenterX, gridCenterY, gridCenterZ;
137 s32 xThing, yThing, zThing;
138 s32 entityX, entityY, entityZ;
152 xThing -= gridCenterX;
153 yThing -= gridCenterY;
154 zThing -= gridCenterZ;
175 yThing += gridCenterY;
178 script->varTable[0] = xThing;
179 script->varTable[1] = yThing;
180 script->varTable[2] = zThing;
182 script->varTable[3] = entityX = entity->
pos.
x;
183 script->varTable[4] = entityY = entity->
pos.
y;
184 script->varTable[5] = entityZ = entity->
pos.
z;
194 if (deltaX != 0 && deltaZ != 0) {
198 script->varTable[6] = deltaX;
199 script->varTable[7] = 0;
200 script->varTable[8] = deltaZ;
205 if (deltaX == 0 && deltaZ == 0) {
206 script->varTable[9] = 2;
210 if (cellX < grid->numCellsX && cellX >= 0
211 && cellZ < grid->numCellsZ && cellZ >= 0
215 script->varTable[9] = 0;
217 script->varTable[9] = 1;
222API_CALLABLE(ClearPushedBlockFromGrid) {
230 in = ip + script->varTable[6];
231 jn = jp + script->varTable[8];
239API_CALLABLE(CanPlayerPushBlock) {
249 script->varTable[13] = TRUE;
251 script->varTable[13] = FALSE;
257API_CALLABLE(CheckPlayerActionState) {
258 Bytecode* args = script->ptrReadPos;
266API_CALLABLE(IsEventForSourceRunning) {
267 Bytecode* args = script->ptrReadPos;
271 s32 foundScript = FALSE;
277 if (iterScript != NULL) {
292 Call(FetchPushedBlockProperties)
295 Call(MovePlayerTowardBlock)
315 Call(CanPlayerPushBlock)
327 Call(MovePlayerTowardBlock)
333 Call(ClearPushedBlockFromGrid)
336 Call(UpdatePushBlockMotion)
337 Call(FinishPushBlockMotion)
353API_CALLABLE(CreatePushBlockGrid) {
371 if (inputGridData == NULL) {
372 for (i = 0; i < sizeNx*sizeNz; i++) {
373 blockGrid->
cells[i] = 0;
376 dataToCopy = inputGridData;
377 for (i = 0; i < sizeNx*sizeNz; i++) {
378 blockGrid->
cells[i] = dataToCopy[i];
387 blockGrid->dropCallback = NULL;
392API_CALLABLE(SetPushBlock) {
393 Bytecode* args = script->ptrReadPos;
403 cellIndex = gridX + (gridZ * blockGrid->
numCellsX);
405 blockGrid->
cells[cellIndex] = occupant;
413 script->varTable[0] = blockEntityID;
419API_CALLABLE(FillPushBlockX) {
420 Bytecode* args = script->ptrReadPos;
432 for (gridZ = startZ; gridZ <= endZ; gridZ++) {
433 cellIndex = gridX + (gridZ * blockGrid->
numCellsX);
435 blockGrid->
cells[cellIndex] = occupant;
443 script->varTable[0] = blockEntityID;
450API_CALLABLE(FillPushBlockZ) {
451 Bytecode* args = script->ptrReadPos;
463 for (gridX = startX; gridX <= endX; gridX++) {
464 cellIndex = gridX + (gridZ * blockGrid->
numCellsX);
467 blockGrid->
cells[cellIndex] = occupant;
475 script->varTable[0] = blockEntityID;
482API_CALLABLE(GetPushBlock) {
483 Bytecode* args = script->ptrReadPos;
487 s32 outVar = *args++;
492 if (gridX >= blockGrid->
numCellsX || gridX < 0 || gridZ >= blockGrid->
numCellsZ || gridZ < 0) {
496 cellIndex = gridX + (gridZ * blockGrid->
numCellsX);
502API_CALLABLE(GetGridIndexFromPos) {
503 Bytecode* args = script->ptrReadPos;
526API_CALLABLE(SetPushBlockFallEffect) {
527 Bytecode* args = script->ptrReadPos;
s32(* PushBlockFallCallback)(Entity *block, Evt *script)
#define general_heap_malloc
#define npc_raycast_down_sides
#define ASSERT(condition)
EntityBlueprint Entity_PushBlock
@ PUSH_GRID_OUT_OF_BOUNDS
@ ACTION_STATE_PUSHING_BLOCK
Entity * get_entity_by_index(s32 index)
s32 evt_get_variable(Evt *script, Bytecode var)
Evt * get_script_by_index(s32 index)
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
f32 evt_get_float_variable(Evt *script, Bytecode var)
s32 create_entity(EntityBlueprint *bp,...)
Trigger * bind_trigger_1(EvtScript *script, s32 flags, s32 triggerFlagIndex, s32 triggerVar0, s32 triggerVar1, s32 priority)
f32 PushBlockMovePositions[]
PushBlockGrid * wPushBlockGrids[8]
EvtScript EVS_PushWall_PushBlock
ApiStatus PlaySound(Evt *script, b32 isInitialCall)
ApiStatus GetPlayerActionState(Evt *script, b32 isInitialCall)
ApiStatus FacePlayerTowardPoint(Evt *script, b32 isInitialCall)
ApiStatus SetPlayerActionState(Evt *script, b32 isInitialCall)
ApiStatus DisablePlayerPhysics(Evt *script, b32 isInitialCall)
Disables player physics if disable is TRUE, enables it if FALSE.
#define Ref(sym)
Address/pointer constant.
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
#define IfNe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR != RVAR.
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
#define Add(VAR, INT_VALUE)
#define COLLISION_WITH_ENTITY_BIT
#define Goto(LABEL_ID)
Moves execution to the given label.
#define IfLt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR < RVAR.
#define EVT_ENTITY_ID_BIT
An entity index.
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
#define EndIf
Marks the end of an if statement or an else block.
#define Thread
Marks the start of a thread block.
#define EndThread
Marks the end of a thread block.
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
#define IfEq(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR == RVAR.
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
#define Return
Kills the current EVT thread.
CollisionStatus gCollisionStatus
PlayerStatus gPlayerStatus