forked from HarbourMasters/2ship2harkinian
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RemoteBombchu enhancement, steering math needs some work
- Loading branch information
1 parent
26012da
commit 1b379e5
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include <libultraship/bridge.h> | ||
#include "2s2h/GameInteractor/GameInteractor.h" | ||
#include "2s2h/ShipInit.hpp" | ||
|
||
extern "C" { | ||
#include "variables.h" | ||
#include "src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h" | ||
|
||
void EnBomChu_Move(EnBomChu*, PlayState*); | ||
void EnBomChu_Explode(EnBomChu*, PlayState*); | ||
} | ||
|
||
#define CVAR_NAME "gEnhancements.PlayerActions.RemoteBombchu" | ||
#define CVAR CVarGetInteger(CVAR_NAME, 0) | ||
|
||
static bool focused = false; | ||
static EnBomChu* activeBombchu = nullptr; | ||
|
||
void RegisterRemoteBombchu() { | ||
COND_ID_HOOK(OnActorInit, ACTOR_EN_BOM_CHU, CVAR, [](Actor* actor) { | ||
activeBombchu = (EnBomChu*)actor; | ||
}); | ||
|
||
COND_ID_HOOK(OnActorDestroy, ACTOR_EN_BOM_CHU, CVAR, [](Actor* actor) { | ||
Player* player = GET_PLAYER(gPlayState); | ||
|
||
if (actor == (Actor*)activeBombchu) { | ||
activeBombchu = nullptr; | ||
|
||
if (focused) { | ||
Camera_SetFocalActor(Play_GetCamera(gPlayState, player->subCamId), &player->actor); | ||
player->stateFlags1 &= ~PLAYER_STATE1_20; | ||
focused = false; | ||
} | ||
} | ||
}); | ||
|
||
COND_ID_HOOK(OnActorUpdate, ACTOR_EN_BOM_CHU, CVAR, [](Actor* actor) { | ||
if (actor != (Actor*)activeBombchu) { | ||
return; | ||
} | ||
|
||
Player* player = GET_PLAYER(gPlayState); | ||
Input* input = &gPlayState->state.input[0]; | ||
|
||
if (activeBombchu->actionFunc == EnBomChu_Move) { | ||
if (!focused) { | ||
Camera_SetFocalActor(Play_GetCamera(gPlayState, CutsceneManager_GetCurrentSubCamId(actor->csId)), actor); | ||
player->stateFlags1 |= PLAYER_STATE1_20; | ||
focused = true; | ||
} | ||
|
||
f32 turnRate = 1500.0f; | ||
f32 stickX = input->cur.stick_x; | ||
if (fabsf(stickX) > 10.0f) { | ||
f32 turnAngle = turnRate * (stickX / 85.0f); | ||
// TODO: This works on flat ground, but not when the chu starts going up or down slopes/walls | ||
activeBombchu->actor.shape.rot.y -= turnAngle; | ||
activeBombchu->actor.world.rot.y -= turnAngle; | ||
} | ||
|
||
if (input->press.button & BTN_B) { | ||
EnBomChu_Explode(activeBombchu, gPlayState); | ||
} | ||
|
||
if (input->press.button & BTN_A) { | ||
activeBombchu = nullptr; | ||
Camera_SetFocalActor(Play_GetCamera(gPlayState, player->subCamId), &player->actor); | ||
player->stateFlags1 &= ~PLAYER_STATE1_20; | ||
focused = false; | ||
} | ||
} | ||
}); | ||
} | ||
|
||
static RegisterShipInitFunc initFunc(RegisterRemoteBombchu, { CVAR_NAME }); |