1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-29 03:34:07 +00:00

Retail Player_Update/Noclip mode + some docs (#1718)

* matched but its kinda ugly

* goto

* semi-colon to stop formatter

* some more docs

* noclip function doc

* remove noclip function from retail

* newline

* format

* reword noclip function comment a bit and fix typo

* format

* changes to doc comments

* reorganize button check
This commit is contained in:
fig02 2024-02-05 18:13:15 -05:00 committed by GitHub
parent a2945801d6
commit c240184229
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -179,7 +179,6 @@ void func_80846978(PlayState* play, Player* this);
void func_808469BC(PlayState* play, Player* this); void func_808469BC(PlayState* play, Player* this);
void func_80846A68(PlayState* play, Player* this); void func_80846A68(PlayState* play, Player* this);
void Player_UpdateCommon(Player* this, PlayState* play, Input* input); void Player_UpdateCommon(Player* this, PlayState* play, Input* input);
s32 func_8084FCAC(Player* this, PlayState* play);
void func_8084FF7C(Player* this); void func_8084FF7C(Player* this);
void Player_UpdateBunnyEars(Player* this); void Player_UpdateBunnyEars(Player* this);
void func_80851008(PlayState* play, Player* this, void* anim); void func_80851008(PlayState* play, Player* this, void* anim);
@ -493,7 +492,7 @@ static PlayerAgeProperties sAgeProperties[] = {
}, },
}; };
static u32 D_808535D0 = false; static u32 sNoclipEnabled = false;
static f32 sControlStickMagnitude = 0.0f; static f32 sControlStickMagnitude = 0.0f;
static s16 sControlStickAngle = 0; static s16 sControlStickAngle = 0;
static s16 D_808535DC = 0; static s16 D_808535DC = 0;
@ -1605,7 +1604,6 @@ static LinkAnimationHeader* D_808543D4[] = {
&gPlayerAnim_link_hook_wait, &gPlayerAnim_link_hook_wait,
}; };
// return type can't be void due to regalloc in func_8084FCAC
BAD_RETURN(s32) Player_ZeroSpeedXZ(Player* this) { BAD_RETURN(s32) Player_ZeroSpeedXZ(Player* this) {
this->actor.speed = 0.0f; this->actor.speed = 0.0f;
this->speedXZ = 0.0f; this->speedXZ = 0.0f;
@ -11301,58 +11299,74 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) {
Collider_ResetQuadAT(play, &this->shieldQuad.base); Collider_ResetQuadAT(play, &this->shieldQuad.base);
} }
static Vec3f D_80854838 = { 0.0f, 0.0f, -30.0f }; #if OOT_DEBUG
s32 Player_UpdateNoclip(Player* this, PlayState* play);
#endif
void Player_Update(Actor* thisx, PlayState* play) { void Player_Update(Actor* thisx, PlayState* play) {
static Vec3f sDogSpawnPos;
Player* this = (Player*)thisx; Player* this = (Player*)thisx;
s32 dogParams; s32 dogParams;
s32 pad; s32 pad;
Input sp44; Input input;
Actor* dog;
if (func_8084FCAC(this, play)) { #if OOT_DEBUG
if (gSaveContext.dogParams < 0) { if (!Player_UpdateNoclip(this, play)) {
if (Object_GetSlot(&play->objectCtx, OBJECT_DOG) < 0) { goto skip_update;
gSaveContext.dogParams = 0; }
} else { #endif
gSaveContext.dogParams &= 0x7FFF;
Player_GetRelativePosition(this, &this->actor.world.pos, &D_80854838, &sDogSpawnPos);
dogParams = gSaveContext.dogParams;
dog = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_DOG, sDogSpawnPos.x, sDogSpawnPos.y, sDogSpawnPos.z, if (gSaveContext.dogParams < 0) {
0, this->actor.shape.rot.y, 0, dogParams | 0x8000); static Vec3f sDogSpawnOffset = { 0.0f, 0.0f, -30.0f };
if (dog != NULL) { static Vec3f sDogSpawnPos;
dog->room = 0;
}
}
}
if ((this->interactRangeActor != NULL) && (this->interactRangeActor->update == NULL)) { if (Object_GetSlot(&play->objectCtx, OBJECT_DOG) < 0) {
this->interactRangeActor = NULL; gSaveContext.dogParams = 0;
}
if ((this->heldActor != NULL) && (this->heldActor->update == NULL)) {
Player_DetachHeldActor(play, this);
}
if (this->stateFlags1 & (PLAYER_STATE1_5 | PLAYER_STATE1_29)) {
bzero(&sp44, sizeof(sp44));
} else { } else {
sp44 = play->state.input[0]; Actor* dog;
if (this->unk_88E != 0) {
sp44.cur.button &= ~(BTN_A | BTN_B | BTN_CUP); gSaveContext.dogParams &= 0x7FFF;
sp44.press.button &= ~(BTN_A | BTN_B | BTN_CUP); Player_GetRelativePosition(this, &this->actor.world.pos, &sDogSpawnOffset, &sDogSpawnPos);
dogParams = gSaveContext.dogParams;
dog = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_DOG, sDogSpawnPos.x, sDogSpawnPos.y, sDogSpawnPos.z, 0,
this->actor.shape.rot.y, 0, dogParams | 0x8000);
if (dog != NULL) {
dog->room = 0;
} }
} }
Player_UpdateCommon(this, play, &sp44);
} }
MREG(52) = this->actor.world.pos.x; if ((this->interactRangeActor != NULL) && (this->interactRangeActor->update == NULL)) {
MREG(53) = this->actor.world.pos.y; this->interactRangeActor = NULL;
MREG(54) = this->actor.world.pos.z; }
MREG(55) = this->actor.world.rot.y;
if ((this->heldActor != NULL) && (this->heldActor->update == NULL)) {
Player_DetachHeldActor(play, this);
}
if (this->stateFlags1 & (PLAYER_STATE1_5 | PLAYER_STATE1_29)) {
bzero(&input, sizeof(input));
} else {
input = play->state.input[0];
if (this->unk_88E != 0) {
input.cur.button &= ~(BTN_A | BTN_B | BTN_CUP);
input.press.button &= ~(BTN_A | BTN_B | BTN_CUP);
}
}
Player_UpdateCommon(this, play, &input);
skip_update:;
{
s32 pad;
MREG(52) = this->actor.world.pos.x;
MREG(53) = this->actor.world.pos.y;
MREG(54) = this->actor.world.pos.z;
MREG(55) = this->actor.world.rot.y;
}
} }
typedef struct { typedef struct {
@ -13618,21 +13632,42 @@ void Player_Action_8084FBF4(Player* this, PlayState* play) {
func_8002F8F0(&this->actor, NA_SE_VO_LI_TAKEN_AWAY - SFX_FLAG + this->ageProperties->unk_92); func_8002F8F0(&this->actor, NA_SE_VO_LI_TAKEN_AWAY - SFX_FLAG + this->ageProperties->unk_92);
} }
s32 func_8084FCAC(Player* this, PlayState* play) { #if OOT_DEBUG
/**
* Updates the "Noclip" debug feature, which allows the player to fly around anywhere
* in the world and clip through any collision.
*
* Noclip can be toggled on and off with two different button combos:
* Hold L + R + A and press B
* or
* Hold L and press D-pad right
*
* To control Noclip mode:
* - Move horizontally with the 4 D-pad directions
* - Move up with B
* - Move down with A
* - Hold R to move faster
*
* With Noclip enabled, another button combination can be pressed to set all "temp clear" flags
* in the current room. To do so hold L and press D-pad left.
*
* @return true if Noclip is disabled, false if enabled
*/
s32 Player_UpdateNoclip(Player* this, PlayState* play) {
sControlInput = &play->state.input[0]; sControlInput = &play->state.input[0];
if ((CHECK_BTN_ALL(sControlInput->cur.button, BTN_A | BTN_L | BTN_R) && if ((CHECK_BTN_ALL(sControlInput->cur.button, BTN_L | BTN_R | BTN_A) &&
CHECK_BTN_ALL(sControlInput->press.button, BTN_B)) || CHECK_BTN_ALL(sControlInput->press.button, BTN_B)) ||
(CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DRIGHT))) { (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DRIGHT))) {
D_808535D0 ^= 1; sNoclipEnabled ^= 1;
if (D_808535D0) { if (sNoclipEnabled) {
Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_Z_AIM); Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_Z_AIM);
} }
} }
if (D_808535D0) { if (sNoclipEnabled) {
f32 speed; f32 speed;
if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) { if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) {
@ -13672,9 +13707,7 @@ s32 func_8084FCAC(Player* this, PlayState* play) {
Player_ZeroSpeedXZ(this); Player_ZeroSpeedXZ(this);
this->actor.gravity = 0.0f; this->actor.gravity = 0.0f;
this->actor.velocity.z = 0.0f; this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = 0.0f;
this->actor.velocity.y = 0.0f;
this->actor.velocity.x = 0.0f;
if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DLEFT)) { if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sControlInput->press.button, BTN_DLEFT)) {
Flags_SetTempClear(play, play->roomCtx.curRoom.num); Flags_SetTempClear(play, play->roomCtx.curRoom.num);
@ -13682,11 +13715,12 @@ s32 func_8084FCAC(Player* this, PlayState* play) {
Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos);
return 0; return false;
} }
return 1; return true;
} }
#endif
void func_8084FF7C(Player* this) { void func_8084FF7C(Player* this) {
this->unk_858 += this->unk_85C; this->unk_858 += this->unk_85C;