mirror of
https://github.com/zeldaret/oot.git
synced 2024-12-25 14:16:11 +00:00
Player Docs: Control stick buffers (#1945)
* name vars and add enum * name some spin attack stuff * fix right and left * forward/backward * format * fix retail bss * sControlStickWorldYaw
This commit is contained in:
parent
62b97badc9
commit
7e8b9144c2
5 changed files with 84 additions and 54 deletions
|
@ -596,6 +596,14 @@ typedef enum {
|
|||
/* 4 */ PLAYER_LEDGE_CLIMB_4
|
||||
} PlayerLedgeClimbType;
|
||||
|
||||
typedef enum {
|
||||
/* -1 */ PLAYER_STICK_DIR_NONE = -1,
|
||||
/* 0 */ PLAYER_STICK_DIR_FORWARD,
|
||||
/* 1 */ PLAYER_STICK_DIR_LEFT,
|
||||
/* 2 */ PLAYER_STICK_DIR_BACKWARD,
|
||||
/* 3 */ PLAYER_STICK_DIR_RIGHT
|
||||
} PlayerStickDirection;
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ f32 ceilingCheckHeight;
|
||||
/* 0x04 */ f32 unk_04;
|
||||
|
@ -836,9 +844,9 @@ typedef struct Player {
|
|||
/* 0x0843 */ s8 meleeWeaponState;
|
||||
/* 0x0844 */ s8 unk_844;
|
||||
/* 0x0845 */ u8 unk_845;
|
||||
/* 0x0846 */ u8 unk_846;
|
||||
/* 0x0847 */ s8 unk_847[4];
|
||||
/* 0x084B */ s8 unk_84B[4];
|
||||
/* 0x0846 */ u8 controlStickDataIndex; // cycles between 0 - 3. Used to index `controlStickSpinAngles` and `controlStickDirections`
|
||||
/* 0x0847 */ s8 controlStickSpinAngles[4]; // Stores a modified version of the control stick angle for the last 4 frames. Used for checking spins.
|
||||
/* 0x084B */ s8 controlStickDirections[4]; // Stores the control stick direction (relative to shape yaw) for the last 4 frames. See `PlayerStickDirection`.
|
||||
|
||||
/* 0x084F */ union {
|
||||
s8 actionVar1;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
// For retail BSS ordering, the block number of cbf in Math3D_CylVsCylOverlapCenterDist
|
||||
// must be 0.
|
||||
#pragma increment_block_number 190
|
||||
#pragma increment_block_number 187
|
||||
|
||||
s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB,
|
||||
Vec3f* lineAClosestToB, Vec3f* lineBClosestToA);
|
||||
|
|
|
@ -433,7 +433,8 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Pl
|
|||
|
||||
unkActor = NULL;
|
||||
|
||||
if ((player->unk_664 != NULL) && (player->unk_84B[player->unk_846] == 2)) {
|
||||
if ((player->unk_664 != NULL) &&
|
||||
(player->controlStickDirections[player->controlStickDataIndex] == PLAYER_STICK_DIR_BACKWARD)) {
|
||||
targetCtx->unk_94 = NULL;
|
||||
} else {
|
||||
func_80032AF0(play, &play->actorCtx, &unkActor, player);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "terminal.h"
|
||||
|
||||
// For retail BSS ordering, the block number of sStreamSfxProjectedPos must be 0.
|
||||
#pragma increment_block_number 201
|
||||
#pragma increment_block_number 198
|
||||
|
||||
#define FLAGS ACTOR_FLAG_4
|
||||
|
||||
|
|
|
@ -508,7 +508,7 @@ static PlayerAgeProperties sAgeProperties[] = {
|
|||
static u32 sNoclipEnabled = false;
|
||||
static f32 sControlStickMagnitude = 0.0f;
|
||||
static s16 sControlStickAngle = 0;
|
||||
static s16 D_808535DC = 0;
|
||||
static s16 sControlStickWorldYaw = 0;
|
||||
static s32 sUpperBodyIsBusy = false; // see `Player_UpdateUpperBody`
|
||||
static s32 sFloorType = FLOOR_TYPE_0;
|
||||
static f32 D_808535E8 = 1.0f;
|
||||
|
@ -2031,28 +2031,28 @@ void Player_AnimReplaceNormalPlayLoopAdjusted(PlayState* play, Player* this, Lin
|
|||
}
|
||||
|
||||
void Player_ProcessControlStick(PlayState* play, Player* this) {
|
||||
s8 phi_v1;
|
||||
s8 phi_v0;
|
||||
s8 spinAngle;
|
||||
s8 direction;
|
||||
|
||||
this->prevControlStickMagnitude = sControlStickMagnitude;
|
||||
this->prevControlStickAngle = sControlStickAngle;
|
||||
|
||||
Lib_GetControlStickData(&sControlStickMagnitude, &sControlStickAngle, sControlInput);
|
||||
|
||||
D_808535DC = Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)) + sControlStickAngle;
|
||||
sControlStickWorldYaw = Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)) + sControlStickAngle;
|
||||
|
||||
this->unk_846 = (this->unk_846 + 1) % 4;
|
||||
this->controlStickDataIndex = (this->controlStickDataIndex + 1) % 4;
|
||||
|
||||
if (sControlStickMagnitude < 55.0f) {
|
||||
phi_v0 = -1;
|
||||
phi_v1 = -1;
|
||||
direction = PLAYER_STICK_DIR_NONE;
|
||||
spinAngle = -1;
|
||||
} else {
|
||||
phi_v1 = (u16)(sControlStickAngle + 0x2000) >> 9;
|
||||
phi_v0 = (u16)((s16)(D_808535DC - this->actor.shape.rot.y) + 0x2000) >> 14;
|
||||
spinAngle = (u16)(sControlStickAngle + 0x2000) >> 9;
|
||||
direction = (u16)((s16)(sControlStickWorldYaw - this->actor.shape.rot.y) + 0x2000) >> 14;
|
||||
}
|
||||
|
||||
this->unk_847[this->unk_846] = phi_v1;
|
||||
this->unk_84B[this->unk_846] = phi_v0;
|
||||
this->controlStickSpinAngles[this->controlStickDataIndex] = spinAngle;
|
||||
this->controlStickDirections[this->controlStickDataIndex] = direction;
|
||||
}
|
||||
|
||||
void func_8083328C(PlayState* play, Player* this, LinkAnimationHeader* linkAnim) {
|
||||
|
@ -3983,7 +3983,7 @@ void func_80837530(PlayState* play, Player* this, s32 arg2) {
|
|||
}
|
||||
}
|
||||
|
||||
s32 func_808375D8(Player* this) {
|
||||
s32 Player_CanSpinAttack(Player* this) {
|
||||
s8 sp3C[4];
|
||||
s8* iter;
|
||||
s8* iter2;
|
||||
|
@ -3992,32 +3992,37 @@ s32 func_808375D8(Player* this) {
|
|||
s32 i;
|
||||
|
||||
if ((this->heldItemAction == PLAYER_IA_DEKU_STICK) || Player_HoldsBrokenKnife(this)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
iter = &this->unk_847[0];
|
||||
iter = &this->controlStickSpinAngles[0];
|
||||
iter2 = &sp3C[0];
|
||||
|
||||
for (i = 0; i < 4; i++, iter++, iter2++) {
|
||||
if ((*iter2 = *iter) < 0) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
*iter2 *= 2;
|
||||
}
|
||||
|
||||
temp1 = sp3C[0] - sp3C[1];
|
||||
|
||||
if (ABS(temp1) < 10) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
iter2 = &sp3C[1];
|
||||
|
||||
for (i = 1; i < 3; i++, iter2++) {
|
||||
temp2 = *iter2 - *(iter2 + 1);
|
||||
|
||||
if ((ABS(temp2) < 10) || (temp2 * temp1 < 0)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void func_80837704(PlayState* play, Player* this) {
|
||||
|
@ -4046,6 +4051,7 @@ static s8 D_80854480[] = {
|
|||
PLAYER_MWA_RIGHT_SLASH_1H,
|
||||
PLAYER_MWA_LEFT_SLASH_1H,
|
||||
};
|
||||
|
||||
static s8 D_80854484[] = {
|
||||
PLAYER_MWA_HAMMER_FORWARD,
|
||||
PLAYER_MWA_HAMMER_SIDE,
|
||||
|
@ -4054,38 +4060,43 @@ static s8 D_80854484[] = {
|
|||
};
|
||||
|
||||
s32 func_80837818(Player* this) {
|
||||
s32 sp1C = this->unk_84B[this->unk_846];
|
||||
s32 controlStickDirection = this->controlStickDirections[this->controlStickDataIndex];
|
||||
s32 sp18;
|
||||
|
||||
if (this->heldItemAction == PLAYER_IA_HAMMER) {
|
||||
if (sp1C < 0) {
|
||||
sp1C = 0;
|
||||
if (controlStickDirection <= PLAYER_STICK_DIR_NONE) {
|
||||
controlStickDirection = PLAYER_STICK_DIR_FORWARD;
|
||||
}
|
||||
sp18 = D_80854484[sp1C];
|
||||
|
||||
sp18 = D_80854484[controlStickDirection];
|
||||
this->unk_845 = 0;
|
||||
} else {
|
||||
if (func_808375D8(this)) {
|
||||
if (Player_CanSpinAttack(this)) {
|
||||
sp18 = PLAYER_MWA_SPIN_ATTACK_1H;
|
||||
} else {
|
||||
if (sp1C < 0) {
|
||||
if (controlStickDirection <= PLAYER_STICK_DIR_NONE) {
|
||||
if (func_80833BCC(this)) {
|
||||
sp18 = PLAYER_MWA_FORWARD_SLASH_1H;
|
||||
} else {
|
||||
sp18 = PLAYER_MWA_RIGHT_SLASH_1H;
|
||||
}
|
||||
} else {
|
||||
sp18 = D_80854480[sp1C];
|
||||
sp18 = D_80854480[controlStickDirection];
|
||||
|
||||
if (sp18 == PLAYER_MWA_STAB_1H) {
|
||||
this->stateFlags2 |= PLAYER_STATE2_30;
|
||||
|
||||
if (!func_80833BCC(this)) {
|
||||
sp18 = PLAYER_MWA_FORWARD_SLASH_1H;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this->heldItemAction == PLAYER_IA_DEKU_STICK) {
|
||||
sp18 = PLAYER_MWA_FORWARD_SLASH_1H;
|
||||
}
|
||||
}
|
||||
|
||||
if (Player_HoldsTwoHandedWeapon(this)) {
|
||||
sp18++;
|
||||
}
|
||||
|
@ -5877,42 +5888,45 @@ void func_8083BC04(Player* this, PlayState* play) {
|
|||
}
|
||||
|
||||
s32 func_8083BC7C(Player* this, PlayState* play) {
|
||||
if ((this->unk_84B[this->unk_846] == 0) && (sFloorType != FLOOR_TYPE_7)) {
|
||||
if ((this->controlStickDirections[this->controlStickDataIndex] == PLAYER_STICK_DIR_FORWARD) &&
|
||||
(sFloorType != FLOOR_TYPE_7)) {
|
||||
func_8083BC04(this, play);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void func_8083BCD0(Player* this, PlayState* play, s32 arg2) {
|
||||
func_80838940(this, D_80853D4C[arg2][0], !(arg2 & 1) ? 5.8f : 3.5f, play, NA_SE_VO_LI_SWORD_N);
|
||||
void func_8083BCD0(Player* this, PlayState* play, s32 controlStickDirection) {
|
||||
func_80838940(this, D_80853D4C[controlStickDirection][0], !(controlStickDirection & 1) ? 5.8f : 3.5f, play,
|
||||
NA_SE_VO_LI_SWORD_N);
|
||||
|
||||
if (arg2) {}
|
||||
if (controlStickDirection) {}
|
||||
|
||||
this->av2.actionVar2 = 1;
|
||||
this->av1.actionVar1 = arg2;
|
||||
this->av1.actionVar1 = controlStickDirection;
|
||||
|
||||
this->yaw = this->actor.shape.rot.y + (arg2 << 0xE);
|
||||
this->speedXZ = !(arg2 & 1) ? 6.0f : 8.5f;
|
||||
this->yaw = this->actor.shape.rot.y + (controlStickDirection << 0xE);
|
||||
this->speedXZ = !(controlStickDirection & 1) ? 6.0f : 8.5f;
|
||||
|
||||
this->stateFlags2 |= PLAYER_STATE2_19;
|
||||
|
||||
Player_PlaySfx(this, ((arg2 << 0xE) == 0x8000) ? NA_SE_PL_ROLL : NA_SE_PL_SKIP);
|
||||
Player_PlaySfx(this, ((controlStickDirection << 0xE) == 0x8000) ? NA_SE_PL_ROLL : NA_SE_PL_SKIP);
|
||||
}
|
||||
|
||||
s32 Player_ActionChange_10(Player* this, PlayState* play) {
|
||||
s32 sp2C;
|
||||
s32 controlStickDirection;
|
||||
|
||||
if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) &&
|
||||
(play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (sFloorType != FLOOR_TYPE_7) &&
|
||||
(SurfaceType_GetFloorEffect(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) != FLOOR_EFFECT_1)) {
|
||||
sp2C = this->unk_84B[this->unk_846];
|
||||
controlStickDirection = this->controlStickDirections[this->controlStickDataIndex];
|
||||
|
||||
if (sp2C <= 0) {
|
||||
if (controlStickDirection <= PLAYER_STICK_DIR_FORWARD) {
|
||||
if (func_80833BCC(this)) {
|
||||
if (this->actor.category != ACTORCAT_PLAYER) {
|
||||
if (sp2C < 0) {
|
||||
if (controlStickDirection <= PLAYER_STICK_DIR_NONE) {
|
||||
func_808389E8(this, &gPlayerAnim_link_normal_jump, REG(69) / 100.0f, play);
|
||||
} else {
|
||||
func_8083BC04(this, play);
|
||||
|
@ -5924,10 +5938,12 @@ s32 Player_ActionChange_10(Player* this, PlayState* play) {
|
|||
func_8083BC04(this, play);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
func_8083BCD0(this, play, sp2C);
|
||||
func_8083BCD0(this, play, controlStickDirection);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -9011,7 +9027,8 @@ void Player_Action_8084411C(Player* this, PlayState* play) {
|
|||
if ((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) &&
|
||||
!(this->stateFlags2 & PLAYER_STATE2_19) &&
|
||||
!(this->stateFlags1 & (PLAYER_STATE1_11 | PLAYER_STATE1_27)) && (this->speedXZ > 0.0f)) {
|
||||
if ((this->yDistToLedge >= 150.0f) && (this->unk_84B[this->unk_846] == 0)) {
|
||||
if ((this->yDistToLedge >= 150.0f) &&
|
||||
(this->controlStickDirections[this->controlStickDataIndex] == PLAYER_STICK_DIR_FORWARD)) {
|
||||
func_8083EC18(this, play, sTouchedWallFlags);
|
||||
} else if ((this->ledgeClimbType >= PLAYER_LEDGE_CLIMB_2) && (this->yDistToLedge < 150.0f) &&
|
||||
(((this->actor.world.pos.y - this->actor.floorHeight) + this->yDistToLedge) >
|
||||
|
@ -9049,7 +9066,8 @@ void Player_Action_8084411C(Player* this, PlayState* play) {
|
|||
func_80833C3C(this);
|
||||
} else if (this->fallDistance <= 80) {
|
||||
anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_short_landing, this->modelAnimType);
|
||||
} else if ((this->fallDistance < 800) && (this->unk_84B[this->unk_846] == 0) &&
|
||||
} else if ((this->fallDistance < 800) &&
|
||||
(this->controlStickDirections[this->controlStickDataIndex] == PLAYER_STICK_DIR_FORWARD) &&
|
||||
!(this->stateFlags1 & PLAYER_STATE1_11)) {
|
||||
func_8083BC04(this, play);
|
||||
return;
|
||||
|
@ -9144,7 +9162,8 @@ void Player_Action_80844708(Player* this, PlayState* play) {
|
|||
Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_CURVED, play);
|
||||
|
||||
speedTarget *= 1.5f;
|
||||
if ((speedTarget < 3.0f) || (this->unk_84B[this->unk_846] != 0)) {
|
||||
if ((speedTarget < 3.0f) ||
|
||||
(this->controlStickDirections[this->controlStickDataIndex] != PLAYER_STICK_DIR_FORWARD)) {
|
||||
speedTarget = 3.0f;
|
||||
}
|
||||
|
||||
|
@ -9209,7 +9228,7 @@ s32 func_80844BE4(Player* this, PlayState* play) {
|
|||
if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) {
|
||||
s32 temp;
|
||||
|
||||
if ((this->unk_858 >= 0.85f) || func_808375D8(this)) {
|
||||
if ((this->unk_858 >= 0.85f) || Player_CanSpinAttack(this)) {
|
||||
temp = D_80854384[Player_HoldsTwoHandedWeapon(this)];
|
||||
} else {
|
||||
temp = D_80854380[Player_HoldsTwoHandedWeapon(this)];
|
||||
|
@ -9219,7 +9238,7 @@ s32 func_80844BE4(Player* this, PlayState* play) {
|
|||
func_80837AFC(this, -8);
|
||||
|
||||
this->stateFlags2 |= PLAYER_STATE2_17;
|
||||
if (this->unk_84B[this->unk_846] == 0) {
|
||||
if (this->controlStickDirections[this->controlStickDataIndex] == PLAYER_STICK_DIR_FORWARD) {
|
||||
this->stateFlags2 |= PLAYER_STATE2_30;
|
||||
}
|
||||
} else {
|
||||
|
@ -10238,7 +10257,7 @@ void Player_UpdateInterface(PlayState* play, Player* this) {
|
|||
Actor* heldActor = this->heldActor;
|
||||
Actor* interactRangeActor = this->interactRangeActor;
|
||||
s32 sp24;
|
||||
s32 sp20 = this->unk_84B[this->unk_846];
|
||||
s32 controlStickDirection = this->controlStickDirections[this->controlStickDataIndex];
|
||||
s32 sp1C = func_808332B8(this);
|
||||
s32 doAction = DO_ACTION_NONE;
|
||||
|
||||
|
@ -10315,14 +10334,16 @@ void Player_UpdateInterface(PlayState* play, Player* this) {
|
|||
doAction = DO_ACTION_DIVE;
|
||||
} else if (!sp1C && (!(this->stateFlags1 & PLAYER_STATE1_22) || func_80833BCC(this) ||
|
||||
!Player_IsChildWithHylianShield(this))) {
|
||||
if ((!(this->stateFlags1 & PLAYER_STATE1_14) && (sp20 <= 0) &&
|
||||
if ((!(this->stateFlags1 & PLAYER_STATE1_14) &&
|
||||
(controlStickDirection <= PLAYER_STICK_DIR_FORWARD) &&
|
||||
(func_8008E9C4(this) ||
|
||||
((sFloorType != FLOOR_TYPE_7) &&
|
||||
(func_80833B2C(this) || ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) &&
|
||||
!(this->stateFlags1 & PLAYER_STATE1_22) && (sp20 == 0))))))) {
|
||||
!(this->stateFlags1 & PLAYER_STATE1_22) &&
|
||||
(controlStickDirection == PLAYER_STICK_DIR_FORWARD))))))) {
|
||||
doAction = DO_ACTION_ATTACK;
|
||||
} else if ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && func_80833BCC(this) &&
|
||||
(sp20 > 0)) {
|
||||
(controlStickDirection >= PLAYER_STICK_DIR_LEFT)) {
|
||||
doAction = DO_ACTION_JUMP;
|
||||
} else if ((this->heldItemAction >= PLAYER_IA_SWORD_MASTER) ||
|
||||
((this->stateFlags2 & PLAYER_STATE2_20) &&
|
||||
|
@ -12104,7 +12125,7 @@ void Player_Action_8084BBE4(Player* this, PlayState* play) {
|
|||
|
||||
if (this->av1.actionVar1 != 0) {
|
||||
Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_LINEAR, play);
|
||||
if (this->unk_847[this->unk_846] >= 0) {
|
||||
if (this->controlStickSpinAngles[this->controlStickDataIndex] >= 0) {
|
||||
if (this->av1.actionVar1 > 0) {
|
||||
anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_fall_up, this->modelAnimType);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue