summaryrefslogtreecommitdiff
path: root/src/overlays
diff options
context:
space:
mode:
authorKiloku <mateus.sateles@protonmail.com>2024-12-30 01:47:42 -0300
committerGitHub <noreply@github.com>2024-12-29 22:47:42 -0600
commitad7bc7c6917ade37662969e3a327c72acf59a974 (patch)
tree5c7efdabf24a9b312d1d6b0e6db20a4e73958645 /src/overlays
parentdbf9b0378f1fea6232f9ee1bb64983590b6e1eba (diff)
Player action hooks (#93)hooks
* Create Player Action and Player Movement event types * Call Boost/Brake events * Change some event types * Make Boost/Brake events cancellable * Use new dynamic hooks * Use separate events for each player action * Add shoot events * Return early on cancel * Add Bomb and Charged Shot Events * Remove movement event hooks, add player param to action hooks * Fix whitespace * Register player action events
Diffstat (limited to 'src/overlays')
-rw-r--r--src/overlays/ovl_i3/fox_aq.c101
1 files changed, 58 insertions, 43 deletions
diff --git a/src/overlays/ovl_i3/fox_aq.c b/src/overlays/ovl_i3/fox_aq.c
index e8a8137a..df41cf63 100644
--- a/src/overlays/ovl_i3/fox_aq.c
+++ b/src/overlays/ovl_i3/fox_aq.c
@@ -1212,6 +1212,10 @@ void Aquas_BlueMarineTorpedo(Player* player) {
for (i = 15, shot = &gPlayerShots[15]; i < ARRAY_COUNT(gPlayerShots); i++, shot++) {
if (shot->obj.status == SHOT_FREE) {
+ CALL_EVENT(PlayerActionPreBombEvent, player)
+ if (PlayerActionPreBombEvent_.event.cancelled){
+ return;
+ }
Player_SetupArwingShot(player, shot, 0.0f, 0.0f, PLAYERSHOT_LOCK_ON, 50.0f);
AUDIO_PLAY_SFX(NA_SE_MAR_BOMB_SHOT, shot->sfxSource, 0);
D_i3_801C4190[5] = i + 1;
@@ -1219,6 +1223,7 @@ void Aquas_BlueMarineTorpedo(Player* player) {
D_i3_801C4458 = -100.0f;
D_i3_801C445C = 0.1f;
gLight3Brightness = 1.0f;
+ CALL_EVENT(PlayerActionPostBombEvent, player);
break;
}
}
@@ -1226,18 +1231,23 @@ void Aquas_BlueMarineTorpedo(Player* player) {
void Aquas_BlueMarineLaser(Player* player) {
s32 i;
-
- for (i = 0; i < 3; i++) {
- if (gPlayerShots[i].obj.status == SHOT_FREE) {
- Player_SetupArwingShot(player, &gPlayerShots[i], 0.0f, -10.0f, PLAYERSHOT_SINGLE_LASER, 120.0f);
- if (gLaserStrength[gPlayerNum] == LASERS_SINGLE) {
- AUDIO_PLAY_SFX(NA_SE_MAR_SHOT, gPlayerShots[i].sfxSource, 0);
- } else {
- AUDIO_PLAY_SFX(NA_SE_MAR_TWIN_LASER, gPlayerShots[i].sfxSource, 0);
+
+ CALL_CANCELLABLE_EVENT(PlayerActionPreShootEvent, player, gLaserStrength[gPlayerNum]) {
+ for (i = 0; i < 3; i++) {
+ if (gPlayerShots[i].obj.status == SHOT_FREE) {
+ Player_SetupArwingShot(player, &gPlayerShots[i], 0.0f, -10.0f, PLAYERSHOT_SINGLE_LASER, 120.0f);
+ if (gLaserStrength[gPlayerNum] == LASERS_SINGLE) {
+ AUDIO_PLAY_SFX(NA_SE_MAR_SHOT, gPlayerShots[i].sfxSource, 0);
+ } else {
+ AUDIO_PLAY_SFX(NA_SE_MAR_TWIN_LASER, gPlayerShots[i].sfxSource, 0);
+ }
+ break;
}
- break;
}
}
+ if (!PlayerActionPreShootEvent_.event.cancelled){
+ CALL_EVENT(PlayerActionPostShootEvent, player, gLaserStrength[gPlayerNum]);
+ }
}
void Aquas_BlueMarineShoot(Player* player) {
@@ -1514,29 +1524,32 @@ void Aquas_BlueMarineBoost(Player* player) {
if ((gBoostButton[player->num] & gInputHold->button) && (player->unk_230 == 0) &&
(player->state != PLAYERSTATE_U_TURN) && (player->boostCooldown == 0)) {
- if (player->boostMeter == 0) {
- AUDIO_PLAY_SFX(NA_SE_MARINE_BOOST, player->sfxSource, 4);
- }
+ CALL_CANCELLABLE_EVENT(PlayerActionBoostEvent, player){
+ if (player->boostMeter == 0) {
+ AUDIO_PLAY_SFX(NA_SE_MARINE_BOOST, player->sfxSource, 4);
+ }
+
- if (!CVarGetInteger("gInfiniteBoost", 0)) {
- player->boostMeter += 3.0f;
- if (player->boostMeter > 90.0f) {
- player->boostMeter = 90.0f;
- player->boostCooldown = 1;
+ if (!CVarGetInteger("gInfiniteBoost", 0)) {
+ player->boostMeter += 3.0f;
+ if (player->boostMeter > 90.0f) {
+ player->boostMeter = 90.0f;
+ player->boostCooldown = 1;
+ }
}
- }
- player->boostSpeed += 2.0f;
- if (player->boostSpeed > 10.0f) {
- player->boostSpeed = 10.0f;
- }
+ player->boostSpeed += 2.0f;
+ if (player->boostSpeed > 10.0f) {
+ player->boostSpeed = 10.0f;
+ }
- Math_SmoothStepToF(&D_i3_801C41B8[27], 10.0f, 0.1f, 2.0f, 0.00001f);
- Math_SmoothStepToF(&player->camDist, -200.0f, 0.1f, D_i3_801C41B8[27], 0.00001f);
+ Math_SmoothStepToF(&D_i3_801C41B8[27], 10.0f, 0.1f, 2.0f, 0.00001f);
+ Math_SmoothStepToF(&player->camDist, -200.0f, 0.1f, D_i3_801C41B8[27], 0.00001f);
- player->sfx.boost = 1;
+ player->sfx.boost = 1;
- Math_SmoothStepToF(&D_ctx_801779A8[0], 50.0f, 1.0f, 10.0f, 0.0f);
+ Math_SmoothStepToF(&D_ctx_801779A8[0], 50.0f, 1.0f, 10.0f, 0.0f);
+ }
} else {
D_i3_801C41B8[27] = 0.0f;
@@ -1564,29 +1577,31 @@ void Aquas_BlueMarineBrake(Player* player) {
if ((gInputHold->button & gBrakeButton[player->num]) && (player->unk_230 == 0) &&
(player->state != PLAYERSTATE_U_TURN) && (player->boostCooldown == 0)) {
- if (player->boostMeter == 0) {
- AUDIO_PLAY_SFX(NA_SE_MARINE_BRAKE, player->sfxSource, 4);
- }
+ CALL_CANCELLABLE_EVENT(PlayerActionBrakeEvent, player){
+ if (player->boostMeter == 0) {
+ AUDIO_PLAY_SFX(NA_SE_MARINE_BRAKE, player->sfxSource, 4);
+ }
- if (!CVarGetInteger("gInfiniteBoost", 0)) {
- player->boostMeter += 3.0f;
- if (player->boostMeter > 90.0f) {
- player->boostMeter = 90.0f;
- player->boostCooldown = 1;
+ if (!CVarGetInteger("gInfiniteBoost", 0)) {
+ player->boostMeter += 3.0f;
+ if (player->boostMeter > 90.0f) {
+ player->boostMeter = 90.0f;
+ player->boostCooldown = 1;
+ }
}
- }
- player->boostSpeed -= 1.0f;
- if (player->boostSpeed < -20.0f) {
- player->boostSpeed = -20.0f;
- }
+ player->boostSpeed -= 1.0f;
+ if (player->boostSpeed < -20.0f) {
+ player->boostSpeed = -20.0f;
+ }
- Math_SmoothStepToF(&D_i3_801C41B8[28], 10.0f, 1.0f, 2.0f, 0.00001f);
- Math_SmoothStepToF(&player->camDist, 180.0f, 0.1f, D_i3_801C41B8[28], 0.0f);
+ Math_SmoothStepToF(&D_i3_801C41B8[28], 10.0f, 1.0f, 2.0f, 0.00001f);
+ Math_SmoothStepToF(&player->camDist, 180.0f, 0.1f, D_i3_801C41B8[28], 0.0f);
- player->sfx.brake = true;
+ player->sfx.brake = true;
- Math_SmoothStepToF(&D_ctx_801779A8[0], 25.0f, 1.0f, 5.0f, 0.0f);
+ Math_SmoothStepToF(&D_ctx_801779A8[0], 25.0f, 1.0f, 5.0f, 0.0f);
+ }
} else {
if (player->boostMeter > 0.0f) {
player->boostMeter -= 0.5f;