hookify additional reticles (#6278)
This commit is contained in:
@@ -1127,6 +1127,7 @@ Player* Player_UnsetMask(PlayState* play);
|
||||
s32 Player_HasMirrorShieldEquipped(PlayState* play);
|
||||
s32 Player_HasMirrorShieldSetToDraw(PlayState* play);
|
||||
s32 Player_ActionToMagicSpell(Player* player, s32 actionParam);
|
||||
void Player_DrawHookshotReticle(PlayState* play, Player* player, f32 hookshotRange);
|
||||
s32 Player_HoldsHookshot(Player* player);
|
||||
s32 Player_HoldsBow(Player* player);
|
||||
s32 Player_HoldsSlingshot(Player* player);
|
||||
|
||||
74
soh/soh/Enhancements/Items/AdditionalReticles.cpp
Normal file
74
soh/soh/Enhancements/Items/AdditionalReticles.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
||||
#include "soh/ShipInit.hpp"
|
||||
|
||||
extern "C" {
|
||||
extern PlayState* gPlayState;
|
||||
extern SaveContext gSaveContext;
|
||||
#include "macros.h"
|
||||
#include "functions.h"
|
||||
}
|
||||
|
||||
#define CVAR_BOW_RETICLE_NAME CVAR_ENHANCEMENT("BowReticle")
|
||||
#define CVAR_BOW_RETICLE_DEFAULT 0
|
||||
#define CVAR_BOW_RETICLE_VALUE CVarGetInteger(CVAR_BOW_RETICLE_NAME, CVAR_BOW_RETICLE_DEFAULT)
|
||||
|
||||
#define CVAR_BOOMERANG_RETICLE_NAME CVAR_ENHANCEMENT("BoomerangReticle")
|
||||
#define CVAR_BOOMERANG_RETICLE_DEFAULT 0
|
||||
#define CVAR_BOOMERANG_RETICLE_VALUE CVarGetInteger(CVAR_BOOMERANG_RETICLE_NAME, CVAR_BOOMERANG_RETICLE_DEFAULT)
|
||||
|
||||
// OTRTODO: Figure out why this value works/what this value should be
|
||||
// This was originally obtained by working down from FLT_MAX until the math
|
||||
// started working out properly
|
||||
#define RETICLE_MAX 3.402823466e+12f
|
||||
|
||||
const Vec3s BoomerangViewAdult = { -31200, -9200, 17000 };
|
||||
const Vec3s BoomerangViewChild = { -31200, -8700, 17000 };
|
||||
|
||||
s32 Player_HoldsBoomerang(Player* player) {
|
||||
return player->heldItemAction == PLAYER_IA_BOOMERANG;
|
||||
}
|
||||
|
||||
s32 Player_AimsBoomerang(Player* player) {
|
||||
return Player_HoldsBoomerang(player) && (player->unk_834 != 0);
|
||||
}
|
||||
|
||||
void RegisterAdditionalReticles() {
|
||||
bool shouldRegister = CVAR_BOW_RETICLE_VALUE || CVAR_BOOMERANG_RETICLE_VALUE;
|
||||
|
||||
COND_VB_SHOULD(VB_DRAW_ADDITIONAL_RETICLES, shouldRegister, {
|
||||
Player* player = GET_PLAYER(gPlayState);
|
||||
Actor* heldActor = player->heldActor;
|
||||
if (CVAR_BOW_RETICLE_VALUE &&
|
||||
((player->heldItemAction >= PLAYER_IA_BOW && player->heldItemAction <= PLAYER_IA_BOW_LIGHT) ||
|
||||
player->heldItemAction == PLAYER_IA_SLINGSHOT)) {
|
||||
if (heldActor != NULL) {
|
||||
MtxF sp44;
|
||||
s32 pad;
|
||||
|
||||
Matrix_RotateZYX(0, -15216, -17496, MTXMODE_APPLY);
|
||||
Matrix_Get(&sp44);
|
||||
|
||||
if (func_8002DD78(player) != 0) {
|
||||
Matrix_Translate(500.0f, 300.0f, 0.0f, MTXMODE_APPLY);
|
||||
Player_DrawHookshotReticle(gPlayState, player, RETICLE_MAX);
|
||||
}
|
||||
}
|
||||
} else if (CVAR_BOOMERANG_RETICLE_VALUE && player->heldItemAction == PLAYER_IA_BOOMERANG) {
|
||||
if (Player_HoldsBoomerang(player)) {
|
||||
if (LINK_IS_ADULT) {
|
||||
Matrix_RotateZYX(BoomerangViewAdult.x, BoomerangViewAdult.y, BoomerangViewAdult.z, MTXMODE_APPLY);
|
||||
} else {
|
||||
Matrix_RotateZYX(BoomerangViewChild.x, BoomerangViewChild.y, BoomerangViewChild.z, MTXMODE_APPLY);
|
||||
}
|
||||
|
||||
if (Player_AimsBoomerang(player)) {
|
||||
Matrix_Translate(500.0f, 300.0f, 0.0f, MTXMODE_APPLY);
|
||||
Player_DrawHookshotReticle(gPlayState, player, RETICLE_MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static RegisterShipInitFunc initFunc(RegisterAdditionalReticles,
|
||||
{ CVAR_ENHANCEMENT("BowReticle"), CVAR_ENHANCEMENT("BoomerangReticle") });
|
||||
@@ -522,6 +522,14 @@ typedef enum {
|
||||
// Opt: s32
|
||||
VB_HEISHI2_ACCEPT_ITEM_AS_ZELDAS_LETTER,
|
||||
|
||||
// #### `result`
|
||||
// ```c
|
||||
// true
|
||||
// ```
|
||||
// #### `args`
|
||||
// - None
|
||||
VB_DRAW_ADDITIONAL_RETICLES,
|
||||
|
||||
// #### `result`
|
||||
// In `Interface_DrawAmmoCount`:
|
||||
// ```c
|
||||
|
||||
@@ -845,16 +845,6 @@ s32 Player_HoldsSlingshot(Player* this) {
|
||||
return this->heldItemAction == PLAYER_IA_SLINGSHOT;
|
||||
}
|
||||
|
||||
// #region SOH [Enhancement]
|
||||
s32 Player_HoldsBoomerang(Player* this) {
|
||||
return this->heldItemAction == PLAYER_IA_BOOMERANG;
|
||||
}
|
||||
|
||||
s32 Player_AimsBoomerang(Player* this) {
|
||||
return Player_HoldsBoomerang(this) && (this->unk_834 != 0);
|
||||
}
|
||||
// #endregion
|
||||
|
||||
s32 func_8008F128(Player* this) {
|
||||
return Player_HoldsHookshot(this) && (this->heldActor == NULL);
|
||||
}
|
||||
@@ -1781,17 +1771,9 @@ Vec3f sLeftRightFootLimbModelFootPos[] = {
|
||||
{ 200.0f, 200.0f, 0.0f },
|
||||
};
|
||||
|
||||
// OTRTODO: Figure out why this value works/what this value should be
|
||||
// This was originally obtained by working down from FLT_MAX until the math
|
||||
// started working out properly
|
||||
#define RETICLE_MAX 3.402823466e+12f
|
||||
|
||||
void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) {
|
||||
Player* this = (Player*)thisx;
|
||||
|
||||
const Vec3s BoomerangViewAdult = { -31200, -9200, 17000 };
|
||||
const Vec3s BoomerangViewChild = { -31200, -8700, 17000 };
|
||||
|
||||
if (*dList != NULL) {
|
||||
Matrix_MultVec3f(&sZeroVec, D_80160000);
|
||||
}
|
||||
@@ -1933,7 +1915,8 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve
|
||||
}
|
||||
|
||||
if (this->actor.scale.y >= 0.0f) {
|
||||
if ((this->heldItemAction == PLAYER_IA_HOOKSHOT) || (this->heldItemAction == PLAYER_IA_LONGSHOT)) {
|
||||
if (GameInteractor_Should(VB_DRAW_ADDITIONAL_RETICLES, (this->heldItemAction == PLAYER_IA_HOOKSHOT) ||
|
||||
(this->heldItemAction == PLAYER_IA_LONGSHOT))) {
|
||||
Matrix_MultVec3f(&D_80126184, &this->unk_3C8);
|
||||
|
||||
if (heldActor != NULL) {
|
||||
@@ -1954,41 +1937,6 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve
|
||||
CVarGetFloat(CVAR_CHEAT("HookshotReachMultiplier"), 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
// #region SOH [Enhancement]
|
||||
} else if (CVarGetInteger(CVAR_ENHANCEMENT("BowReticle"), 0) &&
|
||||
((this->heldItemAction == PLAYER_IA_BOW_FIRE) || (this->heldItemAction == PLAYER_IA_BOW_ICE) ||
|
||||
(this->heldItemAction == PLAYER_IA_BOW_LIGHT) || (this->heldItemAction == PLAYER_IA_BOW) ||
|
||||
(this->heldItemAction == PLAYER_IA_SLINGSHOT))) {
|
||||
if (heldActor != NULL) {
|
||||
MtxF sp44;
|
||||
s32 pad;
|
||||
|
||||
Matrix_RotateZYX(0, -15216, -17496, MTXMODE_APPLY);
|
||||
Matrix_Get(&sp44);
|
||||
|
||||
if (func_8002DD78(this) != 0) {
|
||||
Matrix_Translate(500.0f, 300.0f, 0.0f, MTXMODE_APPLY);
|
||||
Player_DrawHookshotReticle(play, this, RETICLE_MAX);
|
||||
}
|
||||
}
|
||||
} else if (CVarGetInteger(CVAR_ENHANCEMENT("BoomerangReticle"), 0) &&
|
||||
(this->heldItemAction == PLAYER_IA_BOOMERANG)) {
|
||||
if (Player_HoldsBoomerang(this)) {
|
||||
if (LINK_IS_ADULT) {
|
||||
Matrix_RotateZYX(BoomerangViewAdult.x, BoomerangViewAdult.y, BoomerangViewAdult.z,
|
||||
MTXMODE_APPLY);
|
||||
} else {
|
||||
Matrix_RotateZYX(BoomerangViewChild.x, BoomerangViewChild.y, BoomerangViewChild.z,
|
||||
MTXMODE_APPLY);
|
||||
}
|
||||
|
||||
if (Player_AimsBoomerang(this)) {
|
||||
Matrix_Translate(500.0f, 300.0f, 0.0f, MTXMODE_APPLY);
|
||||
Player_DrawHookshotReticle(play, this, RETICLE_MAX);
|
||||
}
|
||||
}
|
||||
// #endregion
|
||||
}
|
||||
|
||||
if ((this->unk_862 != 0) || ((func_8002DD6C(this) == 0) && (heldActor != NULL))) {
|
||||
|
||||
Reference in New Issue
Block a user