mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
VBify + add conditions
This commit is contained in:
parent
ba91af60de
commit
9be17be83a
4 changed files with 167 additions and 63 deletions
114
soh/soh/Enhancements/TimeSavers/CrawlSpeed.cpp
Normal file
114
soh/soh/Enhancements/TimeSavers/CrawlSpeed.cpp
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
#include <libultraship/bridge.h>
|
||||||
|
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||||
|
#include "soh/ShipInit.hpp"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "macros.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "objects/gameplay_keep/gameplay_keep.h"
|
||||||
|
extern PlayState* gPlayState;
|
||||||
|
extern void OnePointCutscene_SetCsCamPoints(Camera* camera, s16 actionParameters, s16 initTimer,
|
||||||
|
CutsceneCameraPoint* atPoints, CutsceneCameraPoint* eyePoints);
|
||||||
|
extern void Player_StartAnimMovement(PlayState* play, Player* player, s32 flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CVAR_CRAWL_SPEED_NAME CVAR_ENHANCEMENT("CrawlSpeed")
|
||||||
|
#define CVAR_CRAWL_SPEED_DEFAULT 1
|
||||||
|
#define CVAR_CRAWL_SPEED_VALUE CVarGetInteger(CVAR_CRAWL_SPEED_NAME, CVAR_CRAWL_SPEED_DEFAULT)
|
||||||
|
#define CVAR_GLITCH_AIDING_NAME CVAR_ENHANCEMENT("GlitchAidingCrawlspaces")
|
||||||
|
#define CVAR_GLITCH_AIDING_DEFAULT 0
|
||||||
|
#define CVAR_GLITCH_AIDING_VALUE CVarGetInteger(CVAR_GLITCH_AIDING_NAME, CVAR_GLITCH_AIDING_DEFAULT)
|
||||||
|
|
||||||
|
extern "C" void ExitCrawlspace(Player* player, PlayState* play) {
|
||||||
|
LinkAnimationHeader* animExit = (LinkAnimationHeader*)gPlayerAnim_link_child_tunnel_end;
|
||||||
|
LinkAnimationHeader* animEnter = (LinkAnimationHeader*)gPlayerAnim_link_child_tunnel_start;
|
||||||
|
|
||||||
|
if (player->linearVelocity > 0.0f) {
|
||||||
|
// Leaving a crawlspace forwards
|
||||||
|
player->actor.shape.rot.y = player->actor.wallYaw + 0x8000;
|
||||||
|
LinkAnimation_Change(play, &player->skelAnime, animExit, ((CVAR_CRAWL_SPEED_VALUE + 1.0f) / 2.0f), 0.0f,
|
||||||
|
Animation_GetLastFrame(animExit), ANIMMODE_ONCE, 0.0f);
|
||||||
|
Player_StartAnimMovement(play, player, 0x9D);
|
||||||
|
OnePointCutscene_Init(play, 9601, 999, NULL, MAIN_CAM);
|
||||||
|
} else {
|
||||||
|
// Leaving a crawlspace backwards
|
||||||
|
player->actor.shape.rot.y = player->actor.wallYaw;
|
||||||
|
LinkAnimation_Change(play, &player->skelAnime, animEnter, -1.0f * ((CVAR_CRAWL_SPEED_VALUE + 1.0f) / 2.0f),
|
||||||
|
Animation_GetLastFrame(animEnter), 0.0f, ANIMMODE_ONCE, 0.0f);
|
||||||
|
Player_StartAnimMovement(play, player, 0x9D);
|
||||||
|
OnePointCutscene_Init(play, 9602, 999, NULL, MAIN_CAM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void ExitCrawlspaceCS(PlayState* play, Camera* csCam, int16_t actionParameters, int16_t initTimer,
|
||||||
|
CutsceneCameraPoint* atPoints, CutsceneCameraPoint* eyePoints) {
|
||||||
|
s16 camCrawlTemp = CVAR_CRAWL_SPEED_VALUE;
|
||||||
|
s16 camCrawlTimer = initTimer / camCrawlTemp;
|
||||||
|
|
||||||
|
OnePointCutscene_SetCsCamPoints(csCam, actionParameters | 0x1000, camCrawlTimer, atPoints, eyePoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void EnterCrawlspace(Player* player, PlayState* play) {
|
||||||
|
LinkAnimationHeader* anim = (LinkAnimationHeader*)gPlayerAnim_link_child_tunnel_start;
|
||||||
|
|
||||||
|
LinkAnimation_Change(play, &player->skelAnime, anim, ((CVAR_CRAWL_SPEED_VALUE + 1.0f) / 2.0f), 0.0f,
|
||||||
|
Animation_GetLastFrame(anim), ANIMMODE_ONCE, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void IncreaseCrawlSpeed(Player* player, PlayState* play) {
|
||||||
|
Input* sControlInput = &play->state.input[0];
|
||||||
|
player->linearVelocity = sControlInput->rel.stick_y * 0.03f * CVAR_CRAWL_SPEED_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CrawlSpeed_Register() {
|
||||||
|
bool shouldRegister = CVAR_CRAWL_SPEED_VALUE > 1;
|
||||||
|
|
||||||
|
COND_VB_SHOULD(VB_CRAWL_SPEED_EXIT, shouldRegister, {
|
||||||
|
Player* player = GET_PLAYER(gPlayState);
|
||||||
|
bool worldPosition = (player->actor.world.pos.x > 950.0f) && (player->actor.world.pos.x < 1025.0f) &&
|
||||||
|
(player->actor.world.pos.z > -1510.0f) && (player->actor.world.pos.z < -1490.0f) &&
|
||||||
|
gPlayState->sceneNum == SCENE_BOTTOM_OF_THE_WELL;
|
||||||
|
bool glitchAiding = CVAR_GLITCH_AIDING_VALUE;
|
||||||
|
if (glitchAiding && worldPosition) {
|
||||||
|
*should = true;
|
||||||
|
} else {
|
||||||
|
ExitCrawlspace(player, gPlayState);
|
||||||
|
*should = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
COND_VB_SHOULD(VB_CRAWL_SPEED_EXIT_CS, shouldRegister, {
|
||||||
|
Player* player = GET_PLAYER(gPlayState);
|
||||||
|
Camera* csCam = va_arg(args, Camera*);
|
||||||
|
int16_t csId = (int16_t)va_arg(args, int);
|
||||||
|
int16_t actionParameters = (int16_t)va_arg(args, int);
|
||||||
|
int16_t initTimer = (int16_t)va_arg(args, int);
|
||||||
|
CutsceneCameraPoint* atPoints = va_arg(args, CutsceneCameraPoint*);
|
||||||
|
CutsceneCameraPoint* eyePoints = va_arg(args, CutsceneCameraPoint*);
|
||||||
|
bool worldPosition = (player->actor.world.pos.x > 950.0f) && (player->actor.world.pos.x < 1025.0f) &&
|
||||||
|
(player->actor.world.pos.z > -1510.0f) && (player->actor.world.pos.z < -1490.0f) &&
|
||||||
|
gPlayState->sceneNum == SCENE_BOTTOM_OF_THE_WELL;
|
||||||
|
bool glitchAiding = CVAR_GLITCH_AIDING_VALUE;
|
||||||
|
if (glitchAiding && worldPosition) {
|
||||||
|
*should = true;
|
||||||
|
} else {
|
||||||
|
ExitCrawlspaceCS(gPlayState, csCam, actionParameters, initTimer, atPoints, eyePoints);
|
||||||
|
*should = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
COND_VB_SHOULD(VB_CRAWL_SPEED_ENTER, shouldRegister, {
|
||||||
|
Player* player = GET_PLAYER(gPlayState);
|
||||||
|
EnterCrawlspace(player, gPlayState);
|
||||||
|
*should = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
COND_VB_SHOULD(VB_CRAWL_SPEED_INCREASE, shouldRegister, {
|
||||||
|
Player* player = GET_PLAYER(gPlayState);
|
||||||
|
IncreaseCrawlSpeed(player, gPlayState);
|
||||||
|
*should = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegisterShipInitFunc initSpeed(CrawlSpeed_Register, { CVAR_CRAWL_SPEED_NAME });
|
|
@ -294,6 +294,43 @@ typedef enum {
|
||||||
// - `*ObjKibako2`
|
// - `*ObjKibako2`
|
||||||
VB_CRATE_SETUP_DRAW,
|
VB_CRATE_SETUP_DRAW,
|
||||||
|
|
||||||
|
// #### `result`
|
||||||
|
// ```c
|
||||||
|
// true
|
||||||
|
// ```
|
||||||
|
// #### `args`
|
||||||
|
// - None
|
||||||
|
VB_CRAWL_SPEED_ENTER,
|
||||||
|
|
||||||
|
// #### `result`
|
||||||
|
// ```c
|
||||||
|
// true
|
||||||
|
// ```
|
||||||
|
// #### `args`
|
||||||
|
// - None
|
||||||
|
VB_CRAWL_SPEED_EXIT,
|
||||||
|
|
||||||
|
// #### `result`
|
||||||
|
// ```c
|
||||||
|
// true
|
||||||
|
// ```
|
||||||
|
// #### `args`
|
||||||
|
// - `*Camera`
|
||||||
|
// - 'int16_t' (csId)
|
||||||
|
// - 'int16_t' (actionParameters)
|
||||||
|
// - 'int16_t' (initTimer)
|
||||||
|
// - 'CutsceneCameraPoint*' (atPoints)
|
||||||
|
// - 'CutsceneCameraPoint*' (eyePoints)
|
||||||
|
VB_CRAWL_SPEED_EXIT_CS,
|
||||||
|
|
||||||
|
// #### `result`
|
||||||
|
// ```c
|
||||||
|
// true
|
||||||
|
// ```
|
||||||
|
// #### `args`
|
||||||
|
// - None
|
||||||
|
VB_CRAWL_SPEED_INCREASE,
|
||||||
|
|
||||||
// #### `result`
|
// #### `result`
|
||||||
// ```c
|
// ```c
|
||||||
// !Flags_GetItemGetInf(ITEMGETINF_1C)
|
// !Flags_GetItemGetInf(ITEMGETINF_1C)
|
||||||
|
|
|
@ -71,12 +71,6 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 camIdx, s16 csId, Actor* actor
|
||||||
f32 tempRand;
|
f32 tempRand;
|
||||||
Unique9OnePointCs* csInfo = ONEPOINT_CS_INFO(csCam);
|
Unique9OnePointCs* csInfo = ONEPOINT_CS_INFO(csCam);
|
||||||
|
|
||||||
// #region SOH [Enhancement]
|
|
||||||
// the default is 90, lower values necessary to prevent camera swing as animation speeds up
|
|
||||||
s16 camCrawlTemp = CVarGetInteger(CVAR_ENHANCEMENT("CrawlSpeed"), 1);
|
|
||||||
s16 camCrawlTimer = D_8012042C / camCrawlTemp;
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
switch (csId) {
|
switch (csId) {
|
||||||
case 1020:
|
case 1020:
|
||||||
if (timer < 20) {
|
if (timer < 20) {
|
||||||
|
@ -336,26 +330,19 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 camIdx, s16 csId, Actor* actor
|
||||||
case 9601:
|
case 9601:
|
||||||
Play_CameraChangeSetting(play, camIdx, CAM_SET_CS_3);
|
Play_CameraChangeSetting(play, camIdx, CAM_SET_CS_3);
|
||||||
Play_CameraChangeSetting(play, MAIN_CAM, mainCam->prevSetting);
|
Play_CameraChangeSetting(play, MAIN_CAM, mainCam->prevSetting);
|
||||||
if (CVarGetInteger(CVAR_ENHANCEMENT("CrawlSpeed"), 1) > 1) {
|
if (GameInteractor_Should(VB_CRAWL_SPEED_EXIT_CS, true, csCam, csId, D_80120430, D_8012042C, D_80120308,
|
||||||
OnePointCutscene_SetCsCamPoints(csCam, D_80120430 | 0x1000, camCrawlTimer, D_80120308, D_80120398);
|
D_80120398)) {
|
||||||
} else {
|
|
||||||
OnePointCutscene_SetCsCamPoints(csCam, D_80120430 | 0x1000, D_8012042C, D_80120308, D_80120398);
|
OnePointCutscene_SetCsCamPoints(csCam, D_80120430 | 0x1000, D_8012042C, D_80120308, D_80120398);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 9602:
|
case 9602:
|
||||||
// #region SOH [Enhancement]
|
|
||||||
if (CVarGetInteger(CVAR_ENHANCEMENT("CrawlSpeed"), 1) > 1) {
|
|
||||||
Play_CameraChangeSetting(play, camIdx, CAM_SET_CS_3);
|
|
||||||
Play_CameraChangeSetting(play, MAIN_CAM, mainCam->prevSetting);
|
|
||||||
OnePointCutscene_SetCsCamPoints(csCam, D_80120430 | 0x1000, camCrawlTimer, D_80120308, D_80120434);
|
|
||||||
break;
|
|
||||||
// #endregion
|
|
||||||
} else {
|
|
||||||
Play_CameraChangeSetting(play, camIdx, CAM_SET_CS_3);
|
Play_CameraChangeSetting(play, camIdx, CAM_SET_CS_3);
|
||||||
Play_CameraChangeSetting(play, MAIN_CAM, mainCam->prevSetting);
|
Play_CameraChangeSetting(play, MAIN_CAM, mainCam->prevSetting);
|
||||||
|
if (GameInteractor_Should(VB_CRAWL_SPEED_EXIT_CS, true, csCam, csId, D_80120430, D_8012042C, D_80120308,
|
||||||
|
D_80120434)) {
|
||||||
OnePointCutscene_SetCsCamPoints(csCam, D_80120430 | 0x1000, D_8012042C, D_80120308, D_80120434);
|
OnePointCutscene_SetCsCamPoints(csCam, D_80120430 | 0x1000, D_8012042C, D_80120308, D_80120434);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case 4175:
|
case 4175:
|
||||||
csInfo->keyFrames = D_8012147C;
|
csInfo->keyFrames = D_8012147C;
|
||||||
csInfo->keyFrameCnt = 4;
|
csInfo->keyFrameCnt = 4;
|
||||||
|
|
|
@ -7679,18 +7679,9 @@ s32 Player_TryEnteringCrawlspace(Player* this, PlayState* play, u32 interactWall
|
||||||
this->actor.world.pos.z = zVertex1 + (distToInteractWall * wallPolyNormZ);
|
this->actor.world.pos.z = zVertex1 + (distToInteractWall * wallPolyNormZ);
|
||||||
func_80832224(this);
|
func_80832224(this);
|
||||||
this->actor.prevPos = this->actor.world.pos;
|
this->actor.prevPos = this->actor.world.pos;
|
||||||
// #region SOH [Enhancement]
|
|
||||||
if (CVarGetInteger(CVAR_ENHANCEMENT("CrawlSpeed"), 1) > 1) {
|
|
||||||
// increase animation speed when entering a tunnel
|
|
||||||
LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_child_tunnel_start,
|
|
||||||
((CVarGetInteger(CVAR_ENHANCEMENT("CrawlSpeed"), 1) + 1.0f) / 2.0f), 0.0f,
|
|
||||||
Animation_GetLastFrame(&gPlayerAnim_link_child_tunnel_start), ANIMMODE_ONCE,
|
|
||||||
0.0f);
|
|
||||||
Player_StartAnimMovement(play, this, 0x9D);
|
|
||||||
// #endregion
|
|
||||||
} else {
|
|
||||||
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_start);
|
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_start);
|
||||||
Player_StartAnimMovement(play, this, 0x9D);
|
if (GameInteractor_Should(VB_CRAWL_SPEED_ENTER, true)) {
|
||||||
|
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_start);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -7773,36 +7764,16 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) {
|
||||||
if (ABS(yawToWall) > 0x4000) {
|
if (ABS(yawToWall) > 0x4000) {
|
||||||
Player_SetupAction(play, this, Player_Action_8084C81C, 0);
|
Player_SetupAction(play, this, Player_Action_8084C81C, 0);
|
||||||
|
|
||||||
|
if (GameInteractor_Should(VB_CRAWL_SPEED_EXIT, true)) {
|
||||||
if (this->linearVelocity > 0.0f) {
|
if (this->linearVelocity > 0.0f) {
|
||||||
// Leaving a crawlspace forwards
|
// Leaving a crawlspace forwards
|
||||||
this->actor.shape.rot.y = this->actor.wallYaw + 0x8000;
|
this->actor.shape.rot.y = this->actor.wallYaw + 0x8000;
|
||||||
// #region SOH [Enhancement]
|
|
||||||
if (CVarGetInteger(CVAR_ENHANCEMENT("CrawlSpeed"), 1) > 1) {
|
|
||||||
LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_child_tunnel_end,
|
|
||||||
((CVarGetInteger(CVAR_ENHANCEMENT("CrawlSpeed"), 1) + 1.0f) / 2.0f), 0.0f,
|
|
||||||
Animation_GetLastFrame(&gPlayerAnim_link_child_tunnel_end), ANIMMODE_ONCE,
|
|
||||||
0.0f);
|
|
||||||
Player_StartAnimMovement(play, this, 0x9D);
|
|
||||||
OnePointCutscene_Init(play, 9601, 999, NULL, MAIN_CAM);
|
|
||||||
// #endregion
|
|
||||||
} else {
|
|
||||||
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_end);
|
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_end);
|
||||||
Player_StartAnimMovement(play, this, 0x9D);
|
Player_StartAnimMovement(play, this, 0x9D);
|
||||||
OnePointCutscene_Init(play, 9601, 999, NULL, MAIN_CAM);
|
OnePointCutscene_Init(play, 9601, 999, NULL, MAIN_CAM);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Leaving a crawlspace backwards
|
// Leaving a crawlspace backwards
|
||||||
this->actor.shape.rot.y = this->actor.wallYaw;
|
this->actor.shape.rot.y = this->actor.wallYaw;
|
||||||
// #region SOH [Enhancement]
|
|
||||||
if (CVarGetInteger(CVAR_ENHANCEMENT("CrawlSpeed"), 1) > 1) {
|
|
||||||
LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_child_tunnel_start,
|
|
||||||
-1.0f * ((CVarGetInteger(CVAR_ENHANCEMENT("CrawlSpeed"), 1) + 1.0f) / 2.0f),
|
|
||||||
Animation_GetLastFrame(&gPlayerAnim_link_child_tunnel_start), 0.0f,
|
|
||||||
ANIMMODE_ONCE, 0.0f);
|
|
||||||
Player_StartAnimMovement(play, this, 0x9D);
|
|
||||||
OnePointCutscene_Init(play, 9602, 999, NULL, MAIN_CAM);
|
|
||||||
// #endregion
|
|
||||||
} else {
|
|
||||||
LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_child_tunnel_start, -1.0f,
|
LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_child_tunnel_start, -1.0f,
|
||||||
Animation_GetLastFrame(&gPlayerAnim_link_child_tunnel_start), 0.0f,
|
Animation_GetLastFrame(&gPlayerAnim_link_child_tunnel_start), 0.0f,
|
||||||
ANIMMODE_ONCE, 0.0f);
|
ANIMMODE_ONCE, 0.0f);
|
||||||
|
@ -13587,12 +13558,7 @@ void Player_Action_8084C760(Player* this, PlayState* play) {
|
||||||
|
|
||||||
// player speed in a tunnel
|
// player speed in a tunnel
|
||||||
if (!Player_TryLeavingCrawlspace(this, play)) {
|
if (!Player_TryLeavingCrawlspace(this, play)) {
|
||||||
// #region SOH [Enhancement]
|
if (GameInteractor_Should(VB_CRAWL_SPEED_INCREASE, true)) {
|
||||||
if (CVarGetInteger(CVAR_ENHANCEMENT("CrawlSpeed"), 1) > 1) {
|
|
||||||
this->linearVelocity =
|
|
||||||
sControlInput->rel.stick_y * 0.03f * CVarGetInteger(CVAR_ENHANCEMENT("CrawlSpeed"), 1);
|
|
||||||
// #endregion
|
|
||||||
} else {
|
|
||||||
this->linearVelocity = sControlInput->rel.stick_y * 0.03f;
|
this->linearVelocity = sControlInput->rel.stick_y * 0.03f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue