Option for link's models reflect the projectile weapon he's holding (Bow/Slingshot) (#2454)

* Link's models reflect the projectile weapon he's holding

extracted logic from months-old PR

* apply bow/slingshot model changes only if 'gBowSlingShotAmmoFix' is enabled

* Apply suggestions from code review

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>

* whitespace

---------

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
This commit is contained in:
Cardboy777 2023-02-14 21:14:42 -05:00 committed by GitHub
parent 218971c4a9
commit 2241635ac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 11 deletions

View File

@ -1120,6 +1120,8 @@ s32 Player_HasMirrorShieldEquipped(PlayState* play);
s32 Player_HasMirrorShieldSetToDraw(PlayState* play);
s32 Player_ActionToMagicSpell(Player* player, s32 actionParam);
s32 Player_HoldsHookshot(Player* player);
s32 Player_HoldsBow(Player* player);
s32 Player_HoldsSlingshot(Player* player);
s32 func_8008F128(Player* player);
s32 Player_ActionToSword(s32 actionParam);
s32 Player_GetSwordHeld(Player* player);

View File

@ -380,13 +380,23 @@ void Player_SetModelsForHoldingShield(Player* this) {
}
void Player_SetModels(Player* this, s32 modelGroup) {
// Left hand
this->leftHandType = gPlayerModelTypes[modelGroup][1];
this->leftHandDLists = &sPlayerDListGroups[this->leftHandType][gSaveContext.linkAge];
// Right hand
this->rightHandType = gPlayerModelTypes[modelGroup][2];
this->sheathType = gPlayerModelTypes[modelGroup][3];
this->rightHandDLists = &sPlayerDListGroups[this->rightHandType][gSaveContext.linkAge];
this->leftHandDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][1]][gSaveContext.linkAge];
this->rightHandDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][2]][gSaveContext.linkAge];
this->sheathDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][3]][gSaveContext.linkAge];
if (CVarGetInteger("gBowSlingShotAmmoFix", 0) && this->rightHandType == 11) { // If holding Bow/Slingshot
this->rightHandDLists = &sPlayerDListGroups[this->rightHandType][Player_HoldsSlingshot(this)];
}
// Sheath
this->sheathType = gPlayerModelTypes[modelGroup][3];
this->sheathDLists = &sPlayerDListGroups[this->sheathType][gSaveContext.linkAge];
// Waist
this->waistDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][4]][gSaveContext.linkAge];
Player_SetModelsForHoldingShield(this);
@ -539,6 +549,22 @@ s32 Player_HoldsHookshot(Player* this) {
return (this->heldItemAction == PLAYER_IA_HOOKSHOT) || (this->heldItemAction == PLAYER_IA_LONGSHOT);
}
s32 Player_HoldsBow(Player* this) {
switch(this->heldItemAction){
case PLAYER_IA_BOW:
case PLAYER_IA_BOW_FIRE:
case PLAYER_IA_BOW_ICE:
case PLAYER_IA_BOW_LIGHT:
return true;
default:
return false;
}
}
s32 Player_HoldsSlingshot(Player* this) {
return this->heldItemAction == PLAYER_IA_SLINGSHOT;
}
s32 func_8008F128(Player* this) {
return Player_HoldsHookshot(this) && (this->heldActor == NULL);
}
@ -1067,14 +1093,26 @@ s32 func_800902F0(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s
} else if (limbIndex == PLAYER_LIMB_L_FOREARM) {
*dList = sArmOutDLs[gSaveContext.linkAge];
} else if (limbIndex == PLAYER_LIMB_L_HAND) {
*dList = sHandOutDLs[gSaveContext.linkAge];
s32 handOutDlIndex = gSaveContext.linkAge;
if (CVarGetInteger("gBowSlingShotAmmoFix", 0) && LINK_IS_ADULT && Player_HoldsSlingshot(this)) {
handOutDlIndex = 1;
}
*dList = sHandOutDLs[handOutDlIndex];
} else if (limbIndex == PLAYER_LIMB_R_SHOULDER) {
*dList = sRightShoulderNearDLs[gSaveContext.linkAge];
} else if (limbIndex == PLAYER_LIMB_R_FOREARM) {
*dList = D_80125F30[gSaveContext.linkAge];
} else if (limbIndex == PLAYER_LIMB_R_HAND) {
s32 firstPersonWeaponIndex = gSaveContext.linkAge;
if (CVarGetInteger("gBowSlingShotAmmoFix", 0)) {
if (Player_HoldsBow(this)) {
firstPersonWeaponIndex = 0;
} else if (Player_HoldsSlingshot(this)) {
firstPersonWeaponIndex = 1;
}
}
*dList = Player_HoldsHookshot(this) ? gLinkAdultRightHandHoldingHookshotFarDL
: sHoldingFirstPersonWeaponDLs[gSaveContext.linkAge];
: sHoldingFirstPersonWeaponDLs[firstPersonWeaponIndex];
} else {
*dList = NULL;
}
@ -1447,7 +1485,11 @@ void func_80090D20(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void
if (this->rightHandType == 0xFF) {
Matrix_Get(&this->shieldMf);
} else if ((this->rightHandType == 11) || (this->rightHandType == 12)) {
BowStringData* stringData = &sBowStringData[gSaveContext.linkAge];
s32 stringModelToUse = gSaveContext.linkAge;
if(CVarGetInteger("gBowSlingShotAmmoFix", 0)){
stringModelToUse = Player_HoldsSlingshot(this);
}
BowStringData* stringData = &sBowStringData[stringModelToUse];
OPEN_DISPS(play->state.gfxCtx);

View File

@ -4920,11 +4920,13 @@ s32 func_8083AD4C(PlayState* play, Player* this) {
if (this->unk_6AD == 2) {
if (func_8002DD6C(this)) {
if (LINK_IS_ADULT) {
cameraMode = CAM_MODE_BOWARROW;
} else {
cameraMode = CAM_MODE_SLINGSHOT;
bool shouldUseBowCamera = LINK_IS_ADULT;
if(CVarGetInteger("gBowSlingShotAmmoFix", 0)){
shouldUseBowCamera = this->heldItemAction != PLAYER_IA_SLINGSHOT;
}
cameraMode = shouldUseBowCamera ? CAM_MODE_BOWARROW : CAM_MODE_SLINGSHOT;
} else {
cameraMode = CAM_MODE_BOOMERANG;
}