Bring over some player documentation from decomp (#3380)

* Document static variables

* Document enums and structs

* Document some functions

* Document more functions

* actionParam to itemAction and fix build

* Document some local variables and a define

* General cleanup

* Use PlayerMeleeWeaponAnimation enum when appropiate

* Document some function parameters and local variables

* Document some of player struct
This commit is contained in:
Pepe20129 2023-11-26 17:54:54 +01:00 committed by GitHub
parent d0d1d9c487
commit 5b81964ea5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 1916 additions and 1562 deletions

View File

@ -494,8 +494,8 @@ typedef struct {
#define PLAYER_STATE3_RESTORE_NAYRUS_LOVE (1 << 6) // Set by ocarina effects actors when destroyed to signal Nayru's Love may be restored (see `ACTOROVL_ALLOC_ABSOLUTE`)
#define PLAYER_STATE3_HOOKSHOT_TRAVELLING (1 << 7) //Travelling to target
typedef void (*PlayerFunc674)(struct Player*, struct PlayState*);
typedef s32 (*PlayerFunc82C)(struct Player*, struct PlayState*);
typedef void (*PlayerActionFunc)(struct Player*, struct PlayState*);
typedef s32 (*UpperActionFunc)(struct Player*, struct PlayState*);
typedef void (*PlayerFuncA74)(struct PlayState*, struct Player*);
typedef struct Player {
@ -512,7 +512,7 @@ typedef struct Player {
/* 0x0155 */ char unk_155[0x003];
/* 0x0158 */ u8 modelGroup;
/* 0x0159 */ u8 nextModelGroup;
/* 0x015A */ s8 unk_15A;
/* 0x015A */ s8 itemChangeType;
/* 0x015B */ u8 modelAnimType;
/* 0x015C */ u8 leftHandType;
/* 0x015D */ u8 rightHandType;
@ -548,11 +548,11 @@ typedef struct Player {
/* 0x043C */ s8 mountSide;
/* 0x043D */ char unk_43D[0x003];
/* 0x0440 */ Actor* rideActor;
/* 0x0444 */ u8 csMode;
/* 0x0445 */ u8 prevCsMode;
/* 0x0446 */ u8 unk_446;
/* 0x0444 */ u8 csAction;
/* 0x0445 */ u8 prevCsAction;
/* 0x0446 */ u8 cueId;
/* 0x0447 */ u8 unk_447;
/* 0x0448 */ Actor* unk_448;
/* 0x0448 */ Actor* csActor;
/* 0x044C */ char unk_44C[0x004];
/* 0x0450 */ Vec3f unk_450;
/* 0x045C */ Vec3f unk_45C;
@ -567,7 +567,7 @@ typedef struct Player {
/* 0x0668 */ char unk_668[0x004];
/* 0x066C */ s32 unk_66C;
/* 0x0670 */ s32 meleeWeaponEffectIndex;
/* 0x0674 */ PlayerFunc674 func_674;
/* 0x0674 */ PlayerActionFunc actionFunc;
/* 0x0678 */ PlayerAgeProperties* ageProperties;
/* 0x067C */ u32 stateFlags1;
/* 0x0680 */ u32 stateFlags2;
@ -581,7 +581,7 @@ typedef struct Player {
/* 0x0698 */ f32 targetActorDistance;
/* 0x069C */ char unk_69C[0x004];
/* 0x06A0 */ f32 unk_6A0;
/* 0x06A4 */ f32 unk_6A4;
/* 0x06A4 */ f32 closestSecretDistSq;
/* 0x06A8 */ Actor* unk_6A8;
/* 0x06AC */ s8 unk_6AC;
/* 0x06AD */ u8 unk_6AD;
@ -596,18 +596,18 @@ typedef struct Player {
/* 0x06C0 */ s16 unk_6C0;
/* 0x06C2 */ s16 unk_6C2;
/* 0x06C4 */ f32 unk_6C4;
/* 0x06C8 */ SkelAnime skelAnime2;
/* 0x070C */ Vec3s jointTable2[PLAYER_LIMB_BUF_COUNT];
/* 0x079C */ Vec3s morphTable2[PLAYER_LIMB_BUF_COUNT];
/* 0x082C */ PlayerFunc82C func_82C;
/* 0x0830 */ f32 unk_830;
/* 0x06C8 */ SkelAnime upperSkelAnime;
/* 0x070C */ Vec3s upperJointTable[PLAYER_LIMB_BUF_COUNT];
/* 0x079C */ Vec3s upperMorphTable[PLAYER_LIMB_BUF_COUNT];
/* 0x082C */ UpperActionFunc upperActionFunc;
/* 0x0830 */ f32 upperAnimBlendWeight;
/* 0x0834 */ s16 unk_834;
/* 0x0836 */ s8 unk_836;
/* 0x0837 */ u8 unk_837;
/* 0x0838 */ f32 linearVelocity;
/* 0x083C */ s16 currentYaw;
/* 0x083E */ s16 targetYaw;
/* 0x0840 */ u16 unk_840;
/* 0x0840 */ u16 underwaterTimer;
/* 0x0842 */ s8 meleeWeaponAnimation;
/* 0x0843 */ s8 meleeWeaponState;
/* 0x0844 */ s8 unk_844;
@ -631,8 +631,8 @@ typedef struct Player {
/* 0x087C */ s16 unk_87C;
/* 0x087E */ s16 unk_87E;
/* 0x0880 */ f32 unk_880;
/* 0x0884 */ f32 wallHeight; // height used to determine whether link can climb or grab a ledge at the top
/* 0x0888 */ f32 wallDistance; // distance to the colliding wall plane
/* 0x0884 */ f32 yDistToLedge; // y distance to ground above an interact wall. LEDGE_DIST_MAX if no ground is found
/* 0x0888 */ f32 distToInteractWall; // distance to the colliding wall plane
/* 0x088C */ u8 unk_88C;
/* 0x088D */ u8 unk_88D;
/* 0x088E */ u8 unk_88E;
@ -643,17 +643,17 @@ typedef struct Player {
/* 0x0893 */ u8 hoverBootsTimer;
/* 0x0894 */ s16 fallStartHeight; // last truncated Y position before falling
/* 0x0896 */ s16 fallDistance; // truncated Y distance the player has fallen so far (positive is down)
/* 0x0898 */ s16 unk_898;
/* 0x089A */ s16 unk_89A;
/* 0x0898 */ s16 floorPitch; // angle of the floor slope in the direction of current world yaw (positive for ascending slope)
/* 0x089A */ s16 floorPitchAlt; // the calculation for this value is bugged and doesn't represent anything meaningful
/* 0x089C */ s16 unk_89C;
/* 0x089E */ u16 unk_89E;
/* 0x089E */ u16 floorSfxOffset;
/* 0x08A0 */ u8 unk_8A0;
/* 0x08A1 */ u8 unk_8A1;
/* 0x08A2 */ s16 unk_8A2;
/* 0x08A4 */ f32 unk_8A4;
/* 0x08A8 */ f32 unk_8A8;
/* 0x08AC */ f32 windSpeed; // Pushing player, examples include water currents, floor conveyors, climbing sloped surfaces // Upstream TODO: pushedSpeed
/* 0x08B0 */ s16 windDirection; // Yaw direction of player being pushed // Upstream TODO: pushedYaw
/* 0x08AC */ f32 pushedSpeed; // Pushing player, examples include water currents, floor conveyors, climbing sloped surfaces
/* 0x08B0 */ s16 pushedYaw; // Yaw direction of player being pushed
/* 0x08B4 */ WeaponInfo meleeWeaponInfo[3];
/* 0x0908 */ Vec3f bodyPartsPos[PLAYER_BODYPART_MAX];
/* 0x09E0 */ MtxF mf_9E0;

View File

@ -1573,7 +1573,7 @@ void DrawPlayerTab() {
ImGui::InputScalar("Y Velocity", ImGuiDataType_Float, &player->actor.velocity.y);
UIWidgets::InsertHelpHoverText("Link's speed along the Y plane. Caps at -20");
ImGui::InputScalar("Wall Height", ImGuiDataType_Float, &player->wallHeight);
ImGui::InputScalar("Wall Height", ImGuiDataType_Float, &player->yDistToLedge);
UIWidgets::InsertHelpHoverText("Height used to determine whether Link can climb or grab a ledge at the top");
ImGui::InputScalar("Invincibility Timer", ImGuiDataType_S8, &player->invincibilityTimer);

View File

@ -520,7 +520,7 @@ void GameInteractor::RawAction::SetRandomWind(bool active) {
if (active) {
GameInteractor::State::RandomWindActive = 1;
if (GameInteractor::State::RandomWindSecondsSinceLastDirectionChange == 0) {
player->windDirection = (rand() % 49152) - 32767;
player->pushedYaw = (rand() % 49152) - 32767;
GameInteractor::State::RandomWindSecondsSinceLastDirectionChange = 5;
} else {
GameInteractor::State::RandomWindSecondsSinceLastDirectionChange--;
@ -528,8 +528,8 @@ void GameInteractor::RawAction::SetRandomWind(bool active) {
} else {
GameInteractor::State::RandomWindActive = 0;
GameInteractor::State::RandomWindSecondsSinceLastDirectionChange = 0;
player->windSpeed = 0.0f;
player->windDirection = 0.0f;
player->pushedSpeed = 0.0f;
player->pushedYaw = 0.0f;
}
}

View File

@ -1426,27 +1426,27 @@ void Actor_MountHorse(PlayState* play, Player* player, Actor* horse) {
}
s32 func_8002DEEC(Player* player) {
return (player->stateFlags1 & 0x20000080) || (player->csMode != 0);
return (player->stateFlags1 & 0x20000080) || (player->csAction != 0);
}
void func_8002DF18(PlayState* play, Player* player) {
func_8006DC68(play, player);
}
s32 func_8002DF38(PlayState* play, Actor* actor, u8 csMode) {
s32 func_8002DF38(PlayState* play, Actor* actor, u8 csAction) {
Player* player = GET_PLAYER(play);
player->csMode = csMode;
player->unk_448 = actor;
player->csAction = csAction;
player->csActor = actor;
player->doorBgCamIndex = 0;
return true;
}
s32 func_8002DF54(PlayState* play, Actor* actor, u8 csMode) {
s32 func_8002DF54(PlayState* play, Actor* actor, u8 csAction) {
Player* player = GET_PLAYER(play);
func_8002DF38(play, actor, csMode);
func_8002DF38(play, actor, csAction);
player->doorBgCamIndex = 1;
return true;
@ -2121,8 +2121,8 @@ void func_8002F5C4(Actor* actorA, Actor* actorB, PlayState* play) {
void func_8002F5F0(Actor* actor, PlayState* play) {
Player* player = GET_PLAYER(play);
if (actor->xyzDistToPlayerSq < player->unk_6A4) {
player->unk_6A4 = actor->xyzDistToPlayerSq;
if (actor->xyzDistToPlayerSq < player->closestSecretDistSq) {
player->closestSecretDistSq = actor->xyzDistToPlayerSq;
}
}

View File

@ -4521,7 +4521,7 @@ s32 Camera_Subj4(Camera* camera) {
if ((anim->unk_28 < temp_f16) && !anim->unk_2E) {
player = camera->player;
anim->unk_2E = true;
func_800F4010(&player->actor.projectedPos, player->unk_89E + 0x8B0, 4.0f);
func_800F4010(&player->actor.projectedPos, player->floorSfxOffset + 0x8B0, 4.0f);
} else if (anim->unk_28 > temp_f16) {
anim->unk_2E = false;
}
@ -7732,7 +7732,7 @@ void Camera_Finish(Camera* camera) {
player->actor.freezeTimer = 0;
player->stateFlags1 &= ~0x20000000;
if (player->csMode != 0) {
if (player->csAction != 0) {
func_8002DF54(camera->play, &player->actor, 7);
osSyncPrintf("camera: player demo end!!\n");
}

View File

@ -573,7 +573,7 @@ uint8_t Player_IsCustomLinkModel() {
}
s32 Player_InBlockingCsMode(PlayState* play, Player* this) {
return (this->stateFlags1 & 0x20000080) || (this->csMode != 0) || (play->transitionTrigger == TRANS_TRIGGER_START) ||
return (this->stateFlags1 & 0x20000080) || (this->csAction != 0) || (play->transitionTrigger == TRANS_TRIGGER_START) ||
(this->stateFlags1 & 1) || (this->stateFlags3 & 0x80) ||
((gSaveContext.magicState != MAGIC_STATE_IDLE) && (Player_ActionToMagicSpell(this, this->itemAction) >= 0));
}
@ -668,7 +668,7 @@ void func_8008EC70(Player* this) {
}
void Player_SetEquipmentData(PlayState* play, Player* this) {
if (this->csMode != 0x56) {
if (this->csAction != 0x56) {
this->currentShield = SHIELD_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD));
this->currentTunic = TUNIC_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC));
this->currentBoots = BOOTS_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_BOOTS));
@ -893,8 +893,8 @@ s32 Player_GetEnvironmentalHazard(PlayState* play) {
if (play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) { // Room is hot
var = 0;
} else if ((this->unk_840 > 80) &&
((this->currentBoots == PLAYER_BOOTS_IRON) || (this->unk_840 >= 300))) { // Deep underwater
} else if ((this->underwaterTimer > 80) &&
((this->currentBoots == PLAYER_BOOTS_IRON) || (this->underwaterTimer >= 300))) { // Deep underwater
var = ((this->currentBoots == PLAYER_BOOTS_IRON) && (this->actor.bgCheckFlags & 1)) ? 1 : 3;
} else if (this->stateFlags1 & 0x8000000) { // Swimming
var = 2;

View File

@ -438,8 +438,8 @@ void func_808809E4(BgHakaTrap* this, PlayState* play, s16 arg2) {
if ((fabsf(sp18.x) < 70.0f) && (fabsf(sp18.y) < 100.0f) && (sp18.z < 500.0f) &&
(GET_PLAYER(play)->currentBoots != PLAYER_BOOTS_IRON)) {
player->windSpeed = ((500.0f - sp18.z) * 0.06f + 5.0f) * arg2 * (1.0f / 0x3A00) * (2.0f / 3.0f);
player->windDirection = this->dyna.actor.shape.rot.y;
player->pushedSpeed = ((500.0f - sp18.z) * 0.06f + 5.0f) * arg2 * (1.0f / 0x3A00) * (2.0f / 3.0f);
player->pushedYaw = this->dyna.actor.shape.rot.y;
}
}

View File

@ -970,7 +970,7 @@ void BossDodongo_Update(Actor* thisx, PlayState* play2) {
magmaScale = ((s16)(Rand_ZeroOne() * 50)) - 50;
}
if (player2->csMode >= 10) {
if (player2->csAction >= 10) {
phi_s0_3 = -1;
}

View File

@ -854,7 +854,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) {
if (&this->actor == player->actor.parent) {
player->unk_850 = 0x65;
player->actor.parent = NULL;
player->csMode = 0;
player->csAction = 0;
if (this->timers[0] == 0) {
func_8002F6D4(play, &this->actor, 20.0f, this->actor.shape.rot.y + 0x8000, 10.0f, 0);
}
@ -884,7 +884,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) {
if (&this->actor == player->actor.parent) {
player->unk_850 = 0x65;
player->actor.parent = NULL;
player->csMode = 0;
player->csAction = 0;
}
Math_ApproachF(&this->tentRippleSize, 0.15f, 0.5f, 0.01);
if (this->meltIndex < 41) {
@ -1806,7 +1806,7 @@ void BossMo_CoreCollisionCheck(BossMo* this, PlayState* play) {
if (player->actor.parent != NULL) {
player->unk_850 = 0x65;
player->actor.parent = NULL;
player->csMode = 0;
player->csAction = 0;
}
} else {
this->actor.colChkInfo.health = 1;
@ -1825,7 +1825,7 @@ void BossMo_CoreCollisionCheck(BossMo* this, PlayState* play) {
if (player->actor.parent == &sMorphaTent1->actor) {
player->unk_850 = 0x65;
player->actor.parent = NULL;
player->csMode = 0;
player->csAction = 0;
}
}
this->work[MO_TENT_ACTION_STATE] = MO_CORE_STUNNED;

View File

@ -248,7 +248,7 @@ void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, PlayState* play) {
while ((this->curNumSpawn < this->maxCurSpawns && this->totalNumSpawn < this->maxTotalSpawns) ||
(CVarGetInteger("gRandomizedEnemies", 0) && enemyCount < 15)) {
if (play->sceneNum == SCENE_HYRULE_FIELD) {
if ((player->unk_89E == 0) || (player->actor.floorBgId != BGCHECK_SCENE) ||
if ((player->floorSfxOffset == 0) || (player->actor.floorBgId != BGCHECK_SCENE) ||
!(player->actor.bgCheckFlags & 1) || (player->stateFlags1 & 0x08000000)) {
this->fieldSpawnTimer = 60;

View File

@ -21,7 +21,7 @@ void EnPartner_Draw(Actor* thisx, PlayState* play);
void EnPartner_SpawnSparkles(EnPartner* this, PlayState* play, s32 sparkleLife);
void func_808328EC(Player* this, u16 sfxId);
void func_808429B4(PlayState* play, s32 speed, s32 y, s32 countdown);
void Player_RequestQuake(PlayState* play, s32 speed, s32 y, s32 countdown);
s32 spawn_boomerang_ivan(EnPartner* this, PlayState* play);
static InitChainEntry sInitChain[] = {
@ -278,7 +278,7 @@ void UseHammer(Actor* thisx, PlayState* play, u8 started) {
static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f };
Vec3f shockwavePos = this->actor.world.pos;
func_808429B4(play, 27767, 7, 20);
Player_RequestQuake(play, 27767, 7, 20);
Player_PlaySfx(&this->actor, NA_SE_IT_HAMMER_HIT);
EffectSsBlast_SpawnWhiteShockwave(play, &shockwavePos, &zeroVec, &zeroVec);

View File

@ -164,8 +164,8 @@ void func_80AFBE8C(EnSiofuki* this, PlayState* play) {
Math_ApproachF(&this->appliedSpeed, this->targetAppliedSpeed, 1.0f, 0.1f);
}
player->windDirection = this->appliedYaw;
player->windSpeed = this->appliedSpeed;
player->pushedYaw = this->appliedYaw;
player->pushedSpeed = this->appliedSpeed;
}
} else {
if (this->applySpeed) {

View File

@ -92,11 +92,11 @@ void EnStream_SuckPlayer(EnStream* this, PlayState* play) {
if (func_80B0B81C(&this->actor.world.pos, &player->actor.world.pos, &posDifference, this->actor.scale.y) != 0) {
xzDist = sqrtf(SQ(posDifference.x) + SQ(posDifference.z));
yDistWithOffset = player->actor.world.pos.y - (this->actor.world.pos.y - 90.0f);
player->windDirection = Math_FAtan2F(-posDifference.x, -posDifference.z) * (0x8000 / M_PI);
player->pushedYaw = Math_FAtan2F(-posDifference.x, -posDifference.z) * (0x8000 / M_PI);
if (xzDist > 3.0f) {
Math_SmoothStepToF(&player->windSpeed, 3.0f, 0.5f, xzDist, 0.0f);
Math_SmoothStepToF(&player->pushedSpeed, 3.0f, 0.5f, xzDist, 0.0f);
} else {
player->windSpeed = 0.0f;
player->pushedSpeed = 0.0f;
Math_SmoothStepToF(&player->actor.world.pos.x, this->actor.world.pos.x, 0.5f, 3.0f, 0.0f);
Math_SmoothStepToF(&player->actor.world.pos.z, this->actor.world.pos.z, 0.5f, 3.0f, 0.0f);
}

View File

@ -602,8 +602,8 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) {
// Handles Dark Link being damaged
if ((this->actor.colChkInfo.health == 0) && sDeathFlag) {
this->csMode = 0x18;
this->unk_448 = &player->actor;
this->csAction = 0x18;
this->csActor = &player->actor;
this->doorBgCamIndex = 1;
sDeathFlag = false;
}

File diff suppressed because it is too large Load Diff