papermario/src/code_F5750.c

460 lines
13 KiB
C
Raw Normal View History

2020-09-26 03:51:54 +02:00
#include "common.h"
ApiStatus HidePlayerShadow(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 hideShadow = get_variable(script, *args++);
if (hideShadow) {
disable_player_shadow();
} else {
enable_player_shadow();
}
return ApiStatus_DONE2;
}
ApiStatus DisablePlayerPhysics(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 disable = get_variable(script, *args++);
if (disable) {
disable_player_static_collisions();
} else {
enable_player_static_collisions();
}
return ApiStatus_DONE2;
}
ApiStatus DisablePlayerInput(ScriptInstance* script, s32 isInitialCall) {
PlayerStatus* playerStatus = &gPlayerStatus;
Bytecode* args = script->ptrReadPos;
s32 enable = get_variable(script, *args++);
if (enable) {
disable_player_input();
func_800EF628();
func_800E97B8();
func_800E984C();
if (playerStatus->actionState == ActionState_SPIN) {
playerStatus->animFlags |= 0x40000;
}
D_8009A650[0] |= 0x40;
} else {
enable_player_input();
func_800EF600();
func_800E01DC();
D_8009A650[0] &= ~0x40;
func_800E983C();
}
return ApiStatus_DONE2;
}
ApiStatus SetPlayerPos(ScriptInstance* script, s32 isInitialCall) {
PlayerStatus* playerStatus = &gPlayerStatus;
Bytecode* args = script->ptrReadPos;
f32 x = get_variable(script, *args++);
f32 y = get_variable(script, *args++);
f32 z = get_variable(script, *args++);
2020-10-08 21:03:58 +02:00
gPlayerNpcPtr->pos.x = x;
gPlayerNpcPtr->pos.y = y;
gPlayerNpcPtr->pos.z = z;
playerStatus->position.x = gPlayerNpcPtr->pos.x;
playerStatus->position.y = gPlayerNpcPtr->pos.y;
playerStatus->position.z = gPlayerNpcPtr->pos.z;
2020-09-26 03:51:54 +02:00
return ApiStatus_DONE2;
}
2020-10-08 23:45:26 +02:00
ApiStatus SetPlayerCollisionSize(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 height = get_variable(script, *args++);
s32 radius = get_variable(script, *args);
Npc* player = gPlayerNpcPtr;
PlayerStatus* playerStatus = &gPlayerStatus;
player->collisionHeight = height;
player->collisionRadius = radius;
2020-10-09 20:26:17 +02:00
2020-10-08 23:45:26 +02:00
playerStatus->colliderHeight = player->collisionHeight;
playerStatus->colliderDiameter = player->collisionRadius;
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
2020-09-28 02:17:51 +02:00
ApiStatus SetPlayerSpeed(ScriptInstance* script, s32 isInitialCall) {
gPlayerNpcPtr->moveSpeed = get_float_variable(script, *script->ptrReadPos);
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
2020-09-28 02:17:51 +02:00
ApiStatus SetPlayerJumpscale(ScriptInstance* script, s32 isInitialCall) {
gPlayerNpcPtr->jumpScale = get_float_variable(script, *script->ptrReadPos);
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
2020-10-08 21:03:58 +02:00
#ifdef NON_MATCHING
ApiStatus SetPlayerAnimation(ScriptInstance* script, s32 isInitialCall) {
2020-10-08 23:45:26 +02:00
Bytecode* args = script->ptrReadPos;
PlayerAnim animation;
animation = get_variable(script, *args);
2020-10-08 21:03:58 +02:00
gPlayerNpcPtr->currentAnim = animation;
gPlayerAnimation = animation;
if (animation == 0x80003) {
exec_ShakeCam1(0, 0, 2);
}
return ApiStatus_DONE2;
}
#else
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_F5750", SetPlayerAnimation, ScriptInstance* script, s32 isInitialCall);
2020-10-08 21:03:58 +02:00
#endif
2020-09-26 03:51:54 +02:00
2020-09-28 02:17:51 +02:00
ApiStatus SetPlayerActionState(ScriptInstance* script, s32 isInitialCall) {
set_action_state(get_variable(script, *script->ptrReadPos));
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
2020-09-28 02:17:51 +02:00
ApiStatus SetPlayerAnimationSpeed(ScriptInstance* script, s32 isInitialCall) {
gPlayerNpcPtr->animationSpeed = get_float_variable(script, *script->ptrReadPos);
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
2020-10-29 17:08:00 +01:00
ApiStatus PlayerMoveTo(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
PlayerStatus* playerStatus = PLAYER_STATUS;
if (isInitialCall) {
2020-10-30 00:23:22 +01:00
f32 targetX = get_variable(script, *args++);
f32 targetZ = get_variable(script, *args++);
f32 moveSpeed;
2020-10-29 17:08:00 +01:00
script->functionTemp[0].s = get_variable(script, *args++);
2020-10-30 00:23:22 +01:00
playerStatus->targetYaw = atan2(playerStatus->position.x, playerStatus->position.z, targetX, targetZ);
2020-10-29 17:08:00 +01:00
if (script->functionTemp[0].s == 0) {
2020-10-30 00:23:22 +01:00
script->functionTemp[0].s = dist2D(playerStatus->position.x, playerStatus->position.z, targetX,
targetZ) / gPlayerNpcPtr->moveSpeed;
2020-10-29 17:08:00 +01:00
moveSpeed = gPlayerNpcPtr->moveSpeed;
} else {
2020-10-30 00:23:22 +01:00
moveSpeed = dist2D(playerStatus->position.x, playerStatus->position.z, targetX, targetZ) / script->functionTemp[0].s;
2020-10-29 17:08:00 +01:00
}
move_player(script->functionTemp[0].s, playerStatus->targetYaw, moveSpeed);
}
2020-10-30 00:23:22 +01:00
// functionTemp 0 is the time left
2020-10-29 17:08:00 +01:00
script->functionTemp[0].s--;
return script->functionTemp[0].s < 0;
}
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_F5750", func_802D1270);
INCLUDE_ASM(s32, "code_F5750", func_802D1380);
INCLUDE_ASM(s32, "code_F5750", player_jump);
void PlayerJump(ScriptInstance* script, s32 isInitialCall) {
player_jump(script, isInitialCall, 0);
}
void PlayerJump1(ScriptInstance* script, s32 isInitialCall) {
player_jump(script, isInitialCall, 1);
}
void PlayerJump2(ScriptInstance* script, s32 isInitialCall) {
player_jump(script, isInitialCall, 2);
}
2020-10-29 20:56:58 +01:00
ApiStatus InterpPlayerYaw(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
PlayerStatus* playerStatus = PLAYER_STATUS;
2020-10-30 00:23:22 +01:00
f32* initialYaw = &script->functionTemp[1].f;
f32* deltaYaw = &script->functionTemp[2].f;
s32* time = &script->functionTemp[3].s;
2020-10-29 20:56:58 +01:00
if (isInitialCall) {
Npc** player = &gPlayerNpcPtr;
(*player)->yaw = playerStatus->targetYaw;
2020-10-30 00:23:22 +01:00
*initialYaw = (*player)->yaw;
*deltaYaw = get_float_variable(script, *args++) - *initialYaw;
*time = get_variable(script, *args++);
2020-10-29 20:56:58 +01:00
(*player)->duration = 0;
2020-10-30 00:23:22 +01:00
if (*deltaYaw < -180.0f) {
*deltaYaw += 360.0f;
2020-10-29 20:56:58 +01:00
}
2020-10-30 00:23:22 +01:00
if (*deltaYaw > 180.0f) {
*deltaYaw -= 360.0f;
2020-10-29 20:56:58 +01:00
}
}
2020-10-30 00:23:22 +01:00
if (*time > 0) {
2020-10-29 20:56:58 +01:00
Npc** player = &gPlayerNpcPtr;
(*player)->duration++;
2020-10-30 00:23:22 +01:00
(*player)->yaw = *initialYaw + ((*deltaYaw * (*player)->duration) / *time);
2020-10-29 20:56:58 +01:00
(*player)->yaw = clamp_angle((*player)->yaw);
playerStatus->targetYaw = (*player)->yaw;
2020-10-30 00:23:22 +01:00
return !((*player)->duration < *time);
2020-10-29 20:56:58 +01:00
} else {
Npc** player = &gPlayerNpcPtr;
2020-10-30 00:23:22 +01:00
(*player)->yaw += *deltaYaw;
(*player)->yaw = clamp_angle((*player)->yaw);
2020-10-29 20:56:58 +01:00
playerStatus->targetYaw = (*player)->yaw;
2020-10-30 00:23:22 +01:00
2020-10-29 20:56:58 +01:00
return ApiStatus_DONE2;
}
}
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_F5750", PlayerFaceNpc, ScriptInstance* script, s32 isInitialCall);
2020-09-28 02:17:51 +02:00
ApiStatus GetPlayerTargetYaw(ScriptInstance* script, s32 isInitialCall) {
set_variable(script, *script->ptrReadPos, gPlayerStatus.targetYaw);
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
2020-10-08 23:45:26 +02:00
ApiStatus SetPlayerFlagBits(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
PlayerStatus* playerStatus = &gPlayerStatus;
PlayerStatus* playerStatus2 = &gPlayerStatus;
Bytecode bits = *args++;
Bytecode a1 = *args;
if (get_variable(script, a1)) {
playerStatus->flags |= bits;
} else {
playerStatus2->flags &= ~bits;
}
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
ApiStatus GetPlayerActionState(ScriptInstance* script, s32 isInitialCall) {
Bytecode outVar = *script->ptrReadPos;
set_variable(script, outVar, gPlayerActionState);
return ApiStatus_DONE2;
}
ApiStatus GetPlayerPos(ScriptInstance* script, s32 isInitialCall) {
PlayerStatus* playerStatus = &gPlayerStatus;
Bytecode* args = script->ptrReadPos;
Bytecode outVar1 = *args++;
Bytecode outVar2 = *args++;
Bytecode outVar3 = *args++;
set_variable(script, outVar1, playerStatus->position.x);
set_variable(script, outVar2, playerStatus->position.y);
set_variable(script, outVar3, playerStatus->position.z);
return ApiStatus_DONE2;
}
ApiStatus GetPlayerAnimation(ScriptInstance* script, s32 isInitialCall) {
Bytecode outVar = *script->ptrReadPos;
set_variable(script, outVar, gPlayerAnimation);
return ApiStatus_DONE2;
}
ApiStatus FullyRestoreHPandFP(ScriptInstance* script, s32 isInitialCall) {
PlayerData* playerData = &gPlayerData;
playerData->curHP = playerData->curMaxHP;
playerData->curFP = playerData->curMaxFP;
return ApiStatus_DONE2;
}
2020-10-08 21:03:58 +02:00
ApiStatus FullyRestoreSP(ScriptInstance* script, s32 isInitialCall) {
PlayerData* playerData = &gPlayerData;
2020-09-26 03:51:54 +02:00
2020-10-08 21:03:58 +02:00
playerData->specialBarsFilled = playerData->maxStarPower * 256;
return ApiStatus_DONE2;
}
ApiStatus EnablePartner(ScriptInstance* script, s32 isInitialCall) {
s32 partnerIdx = get_variable(script, *script->ptrReadPos) - 1;
PartnerData* partner = &gPlayerData.partners[partnerIdx];
partner->enabled = TRUE;
return ApiStatus_DONE2;
}
ApiStatus DisablePartner(ScriptInstance* script, s32 isInitialCall) {
s32 partnerIdx = get_variable(script, *script->ptrReadPos) - 1;
PartnerData* partner = &gPlayerData.partners[partnerIdx];
2020-09-26 03:51:54 +02:00
2020-10-08 21:03:58 +02:00
partner->enabled = FALSE;
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_F5750", UseEntryHeading);
INCLUDE_ASM(s32, "code_F5750", func_802D2148);
INCLUDE_ASM(s32, "code_F5750", UseExitHeading);
INCLUDE_ASM(s32, "code_F5750", func_802D23F8);
INCLUDE_ASM(s32, "code_F5750", func_802D244C);
INCLUDE_ASM(s32, "code_F5750", func_802D2484);
2020-10-29 17:08:00 +01:00
ApiStatus func_802D249C(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 val = 0;
if (gCollisionStatus.currentFloor >= 0) {
val = func_802D23F8() != 0;
}
set_variable(script, *args, val);
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
2020-10-28 07:42:14 +01:00
ApiStatus func_802D24F4(ScriptInstance* script, s32 isInitialCall) {
2020-10-28 20:11:05 +01:00
return (gPlayerStatus.moveFrames == 0) * ApiStatus_DONE2;
2020-10-28 07:42:14 +01:00
}
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_F5750", func_802D2508);
INCLUDE_ASM(s32, "code_F5750", func_802D2520);
INCLUDE_ASM(s32, "code_F5750", func_802D286C);
INCLUDE_ASM(s32, "code_F5750", func_802D2884);
2020-10-08 21:03:58 +02:00
ApiStatus DisablePulseStone(ScriptInstance* script, s32 isInitialCall) {
PlayerStatus* playerStatus = &gPlayerStatus;
PlayerStatus* playerStatus2 = &gPlayerStatus;
2020-09-26 03:51:54 +02:00
2020-10-08 21:03:58 +02:00
if (get_variable(script, *script->ptrReadPos)) {
playerStatus->animFlags &= ~0x80;
} else {
playerStatus2->animFlags |= 0x80;
}
return ApiStatus_DONE2;
}
ApiStatus GetCurrentPartner(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
Bytecode a0 = *args;
PlayerData* playerData = &gPlayerData;
s32 currentPartner = 0;
if (D_8010EBB0[0] != 0) {
currentPartner = playerData->currentPartner;
}
set_variable(script, a0, currentPartner);
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_F5750", func_802D2B50);
INCLUDE_ASM(s32, "code_F5750", func_802D2B6C);
2020-10-08 23:45:26 +02:00
ApiStatus Disable8bitMario(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
PlayerStatus* playerStatus = &gPlayerStatus;
PlayerStatus* playerStatus2 = &gPlayerStatus;
if (get_variable(script, *args)) {
playerStatus->colliderHeight = 37;
playerStatus->colliderDiameter = 26;
playerStatus->animFlags &= ~0x4000;
} else {
playerStatus2->colliderHeight = 19;
playerStatus2->colliderDiameter = 26;
playerStatus2->animFlags |= 0x44004;
}
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_F5750", func_802D2C14);
INCLUDE_ASM(s32, "code_F5750", func_802D2C40);
2020-10-08 21:03:58 +02:00
ApiStatus PlaySoundAtPlayer(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 var = get_variable(script, *args++);
s32 var2 = get_variable(script, *args++);
play_sound_at_player(var, var2);
return 2;
}
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_F5750", func_802D2D30);
INCLUDE_ASM(s32, "code_F5750", func_802D2ED4);
INCLUDE_ASM(s32, "code_F5750", func_802D2F34);
INCLUDE_ASM(s32, "code_F5750", func_802D2FCC);
INCLUDE_ASM(s32, "code_F5750", func_802D3028);
INCLUDE_ASM(s32, "code_F5750", func_802D31E0);
INCLUDE_ASM(s32, "code_F5750", func_802D3398);
INCLUDE_ASM(s32, "code_F5750", func_802D33D4);
INCLUDE_ASM(s32, "code_F5750", func_802D3474);
INCLUDE_ASM(s32, "code_F5750", func_802D354C);
INCLUDE_ASM(s32, "code_F5750", func_802D3624);
INCLUDE_ASM(s32, "code_F5750", func_802D3674);
INCLUDE_ASM(s32, "code_F5750", func_802D36E0);
INCLUDE_ASM(s32, "code_F5750", func_802D378C);
INCLUDE_ASM(s32, "code_F5750", func_802D3840);
INCLUDE_ASM(s32, "code_F5750", func_802D38EC);
INCLUDE_ASM(s32, "code_F5750", func_802D3998);
INCLUDE_ASM(s32, "code_F5750", func_802D39FC);
INCLUDE_ASM(s32, "code_F5750", func_802D3A60);
INCLUDE_ASM(s32, "code_F5750", func_802D3C58);
INCLUDE_ASM(s32, "code_F5750", func_802D3EB8);
INCLUDE_ASM(s32, "code_F5750", func_802D3F74);
INCLUDE_ASM(s32, "code_F5750", func_802D3FC8);
INCLUDE_ASM(s32, "code_F5750", func_802D4050);
INCLUDE_ASM(s32, "code_F5750", func_802D4164);
INCLUDE_ASM(s32, "code_F5750", func_802D417C);
INCLUDE_ASM(s32, "code_F5750", func_802D420C);
INCLUDE_ASM(s32, "code_F5750", func_802D42AC);
INCLUDE_ASM(s32, "code_F5750", func_802D4364);
INCLUDE_ASM(s32, "code_F5750", func_802D43AC);
INCLUDE_ASM(s32, "code_F5750", func_802D43D0);
INCLUDE_ASM(s32, "code_F5750", func_802D43F4);
INCLUDE_ASM(s32, "code_F5750", func_802D4434);
INCLUDE_ASM(s32, "code_F5750", func_802D4488);
INCLUDE_ASM(s32, "code_F5750", func_802D4560);