summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/engine/fox_play.c213
-rw-r--r--src/engine/fox_tank.c53
-rw-r--r--src/overlays/ovl_i3/fox_aq.c101
-rw-r--r--src/port/hooks/Events.h3
-rw-r--r--src/port/hooks/list/ActionEvent.h17
-rw-r--r--src/port/mods/PortEnhancements.c13
6 files changed, 242 insertions, 158 deletions
diff --git a/src/engine/fox_play.c b/src/engine/fox_play.c
index 7e2c4096..f319b481 100644
--- a/src/engine/fox_play.c
+++ b/src/engine/fox_play.c
@@ -3145,14 +3145,19 @@ void Player_SetupTankShot(Player* player, PlayerShot* shot, PlayerShotId shotId,
void Player_TankCannon(Player* player) {
s32 i;
- for (i = 0; i < ARRAY_COUNT(gPlayerShots) - 1; i++) {
- if (gPlayerShots[i].obj.status == SHOT_FREE) {
- Player_SetupTankShot(player, &gPlayerShots[i], PLAYERSHOT_TANK, 100.0f);
- Player_PlaySfx(player->sfxSource, NA_SE_TANK_SHOT, player->num);
- player->unk_1A0 = 2;
- break;
+ CALL_CANCELLABLE_EVENT(PlayerActionPreShootEvent, player, gLaserStrength[gPlayerNum]) {
+ for (i = 0; i < ARRAY_COUNT(gPlayerShots) - 1; i++) {
+ if (gPlayerShots[i].obj.status == SHOT_FREE) {
+ Player_SetupTankShot(player, &gPlayerShots[i], PLAYERSHOT_TANK, 100.0f);
+ Player_PlaySfx(player->sfxSource, NA_SE_TANK_SHOT, player->num);
+ player->unk_1A0 = 2;
+ break;
+ }
}
}
+ if (!PlayerActionPreShootEvent_.event.cancelled){
+ CALL_EVENT(PlayerActionPostShootEvent, player, gLaserStrength[gPlayerNum]);
+ }
}
void Player_ArwingLaser(Player* player) {
@@ -3164,24 +3169,30 @@ void Player_ArwingLaser(Player* player) {
laser = LASERS_SINGLE;
}
+ CALL_EVENT(PlayerActionPreShootEvent, player, laser);
+ if (PlayerActionPreShootEvent_.event.cancelled){
+ return;
+ }
+
switch (laser) {
case LASERS_SINGLE:
for (i = 0; i < ARRAY_COUNT(gPlayerShots) - 1; i++) {
if (gPlayerShots[i].obj.status == SHOT_FREE) {
Player_SetupArwingShot(player, &gPlayerShots[i], 0.0f, 0.0f, PLAYERSHOT_SINGLE_LASER,
- 400.0f / 3.0f);
+ 400.0f / 3.0f);
Player_PlaySfx(player->sfxSource, NA_SE_ARWING_SHOT, player->num);
gMuzzleFlashScale[player->num] = 0.5f;
break;
}
}
+
break;
case LASERS_TWIN:
case LASERS_HYPER:
for (i = 0; i < ARRAY_COUNT(gPlayerShots) - 1; i++) {
if (gPlayerShots[i].obj.status == SHOT_FREE) {
Player_SetupArwingShot(player, &gPlayerShots[i], 0.0f, -10.0f, PLAYERSHOT_TWIN_LASER,
- 400.0f / 3.0f);
+ 400.0f / 3.0f);
if (laser == LASERS_TWIN) {
Player_PlaySfx(player->sfxSource, NA_SE_ARWING_TWIN_LASER, player->num);
gMuzzleFlashScale[player->num] = 0.5f;
@@ -3194,11 +3205,19 @@ void Player_ArwingLaser(Player* player) {
}
break;
}
+ CALL_EVENT(PlayerActionPostShootEvent, player, laser);
}
void Player_SmartBomb(Player* player) {
+
if ((gBombCount[player->num] != 0) && (gBombButton[player->num] & gInputPress->button) &&
(gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].obj.status == SHOT_FREE)) {
+ CALL_EVENT(PlayerActionPreBombEvent, player);
+ if (PlayerActionPreBombEvent_.event.cancelled)
+ {
+ return;
+ }
+
if (gVersusMode) {
gBombCount[player->num] = 0;
} else {
@@ -3218,6 +3237,7 @@ void Player_SmartBomb(Player* player) {
gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].unk_60 = 0;
Audio_InitBombSfx(player->num, 1);
Audio_PlayBombFlightSfx(player->num, gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].sfxSource);
+ CALL_EVENT(PlayerActionPostBombEvent, player);
}
}
@@ -3350,15 +3370,18 @@ bool Player_UpdateLockOn(Player* player) {
(gPlayerShots[14 - player->num].obj.id != PLAYERSHOT_LOCK_ON) ||
((gPlayerShots[14 - player->num].obj.id == PLAYERSHOT_LOCK_ON) &&
(gPlayerShots[14 - player->num].unk_60 != 0))) {
- if (player->form == FORM_ARWING) {
- Player_SetupArwingShot(player, &gPlayerShots[14 - player->num], 0.0f, 0.0f, PLAYERSHOT_LOCK_ON,
- 70.0f);
- } else {
- Player_SetupTankShot(player, &gPlayerShots[14 - player->num], PLAYERSHOT_LOCK_ON, 70.0f);
+ CALL_CANCELLABLE_EVENT(PlayerActionPreShootChargedEvent, player){
+ if (player->form == FORM_ARWING) {
+ Player_SetupArwingShot(player, &gPlayerShots[14 - player->num], 0.0f, 0.0f, PLAYERSHOT_LOCK_ON,
+ 70.0f);
+ } else {
+ Player_SetupTankShot(player, &gPlayerShots[14 - player->num], PLAYERSHOT_LOCK_ON, 70.0f);
+ }
+ Object_PlayerSfx(player->sfxSource, NA_SE_LOCK_ON_LASER, player->num);
+ gControllerRumbleTimers[player->num] = 5;
+ return true;
}
- Object_PlayerSfx(player->sfxSource, NA_SE_LOCK_ON_LASER, player->num);
- gControllerRumbleTimers[player->num] = 5;
- return true;
+ CALL_EVENT(PlayerActionPostShootChargedEvent, player);
}
break;
}
@@ -3369,17 +3392,20 @@ bool Player_UpdateLockOn(Player* player) {
(gPlayerShots[14 - player->num].obj.id != PLAYERSHOT_LOCK_ON) ||
((gPlayerShots[14 - player->num].obj.id == PLAYERSHOT_LOCK_ON) &&
(gPlayerShots[14 - player->num].scale > 1.0f))) {
- if (player->form == FORM_ARWING) {
- Player_SetupArwingShot(player, &gPlayerShots[14 - player->num], 0.0f, 0.0f, PLAYERSHOT_LOCK_ON,
- 70.0f);
- } else {
- Player_SetupTankShot(player, &gPlayerShots[14 - player->num], PLAYERSHOT_LOCK_ON, 70.0f);
+ CALL_CANCELLABLE_EVENT(PlayerActionPreShootChargedEvent, player){
+ if (player->form == FORM_ARWING) {
+ Player_SetupArwingShot(player, &gPlayerShots[14 - player->num], 0.0f, 0.0f, PLAYERSHOT_LOCK_ON,
+ 70.0f);
+ } else {
+ Player_SetupTankShot(player, &gPlayerShots[14 - player->num], PLAYERSHOT_LOCK_ON, 70.0f);
+ }
+ Object_PlayerSfx(player->sfxSource, NA_SE_LOCK_ON_LASER, player->num);
+ gChargeTimers[player->num] = 0;
+ gControllerRumbleTimers[player->num] = 5;
+ return true;
}
- Object_PlayerSfx(player->sfxSource, NA_SE_LOCK_ON_LASER, player->num);
- gChargeTimers[player->num] = 0;
- gControllerRumbleTimers[player->num] = 5;
- return true;
}
+ CALL_EVENT(PlayerActionPostShootChargedEvent, player);
}
gChargeTimers[player->num] = 0;
}
@@ -3401,18 +3427,21 @@ bool Player_UpdateLockOn(Player* player) {
}
if (hasBombTarget && (gBombCount[player->num] != 0) &&
(gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].obj.status == SHOT_FREE)) {
- gBombCount[player->num]--;
- if (player->form == FORM_ARWING) {
- Player_SetupArwingShot(player, &gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1], 0.0f, 0.0f,
- PLAYERSHOT_LOCK_ON, 60.0f);
- } else {
- Player_SetupTankShot(player, &gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1], PLAYERSHOT_LOCK_ON, 60.0f);
+ CALL_CANCELLABLE_EVENT(PlayerActionPreBombEvent, player){
+ gBombCount[player->num]--;
+ if (player->form == FORM_ARWING) {
+ Player_SetupArwingShot(player, &gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1], 0.0f, 0.0f,
+ PLAYERSHOT_LOCK_ON, 60.0f);
+ } else {
+ Player_SetupTankShot(player, &gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1], PLAYERSHOT_LOCK_ON, 60.0f);
+ }
+ gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].unk_48 = 30.0f;
+ gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].unk_60 = 0;
+ Audio_InitBombSfx(player->num, 1);
+ Audio_PlayBombFlightSfx(player->num, gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].sfxSource);
+ return true;
}
- gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].unk_48 = 30.0f;
- gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].unk_60 = 0;
- Audio_InitBombSfx(player->num, 1);
- Audio_PlayBombFlightSfx(player->num, gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].sfxSource);
- return true;
+ CALL_EVENT(PlayerActionPostBombEvent, player);
}
}
return false;
@@ -5136,38 +5165,40 @@ void Player_ArwingBoost(Player* player) {
}
if ((gInputHold->button & gBoostButton[player->num]) && !(gInputHold->button & gBrakeButton[player->num]) &&
(player->state != PLAYERSTATE_U_TURN) && !player->boostCooldown) {
- if (player->boostMeter == 0.0f) {
- Player_PlaySfx(player->sfxSource, NA_SE_ARWING_BOOST, player->num);
- player->unk_194 = 5.0f;
- player->unk_190 = 5.0f;
- if (gBoostButton[player->num] & gInputPress->button) {
- gLoopBoostTimers[gPlayerNum] = 5;
+ CALL_CANCELLABLE_EVENT(PlayerActionBoostEvent, player) {
+ if (player->boostMeter == 0.0f) {
+ Player_PlaySfx(player->sfxSource, NA_SE_ARWING_BOOST, player->num);
+ player->unk_194 = 5.0f;
+ player->unk_190 = 5.0f;
+ if (gBoostButton[player->num] & gInputPress->button) {
+ gLoopBoostTimers[gPlayerNum] = 5;
+ }
}
+ if (gLevelType == LEVELTYPE_PLANET) {
+ player->arwing.unk_28 += (35.0f - player->arwing.unk_28) * 0.1f;
+ Math_SmoothStepToF(&player->arwing.upperRightFlapYrot, 0.0f, 0.5f, 100.0f, 0.0f);
+ Math_SmoothStepToF(&player->arwing.bottomRightFlapYrot, 0.0f, 0.5f, 100.0f, 0.0f);
+ Math_SmoothStepToF(&player->arwing.upperLeftFlapYrot, 0.0f, 0.5f, 100.0f, 0.0f);
+ Math_SmoothStepToF(&player->arwing.bottomLeftFlapYrot, 0.0f, 0.5f, 100.0f, 0.0f);
+ }
+ player->boostMeter += sp28;
+ if (player->boostMeter > 90.0f) {
+ player->boostMeter = 90.0f;
+ player->boostCooldown = true;
+ }
+ player->contrailScale += 0.04f;
+ if (player->contrailScale > 0.6f) {
+ player->contrailScale = 0.6f;
+ }
+ player->unk_190 = 2.0f;
+ player->boostSpeed += 2.0f;
+ if (player->boostSpeed > 30.0f) {
+ player->boostSpeed = 30.0f;
+ }
+ Math_SmoothStepToF(&player->camDist, -400.0f, 0.1f, 30.0f, 0.0f);
+ player->sfx.boost = 1;
+ Math_SmoothStepToF(&D_ctx_801779A8[player->num], 50.0f, 1.0f, 10.0f, 0.0f);
}
- if (gLevelType == LEVELTYPE_PLANET) {
- player->arwing.unk_28 += (35.0f - player->arwing.unk_28) * 0.1f;
- Math_SmoothStepToF(&player->arwing.upperRightFlapYrot, 0.0f, 0.5f, 100.0f, 0.0f);
- Math_SmoothStepToF(&player->arwing.bottomRightFlapYrot, 0.0f, 0.5f, 100.0f, 0.0f);
- Math_SmoothStepToF(&player->arwing.upperLeftFlapYrot, 0.0f, 0.5f, 100.0f, 0.0f);
- Math_SmoothStepToF(&player->arwing.bottomLeftFlapYrot, 0.0f, 0.5f, 100.0f, 0.0f);
- }
- player->boostMeter += sp28;
- if (player->boostMeter > 90.0f) {
- player->boostMeter = 90.0f;
- player->boostCooldown = true;
- }
- player->contrailScale += 0.04f;
- if (player->contrailScale > 0.6f) {
- player->contrailScale = 0.6f;
- }
- player->unk_190 = 2.0f;
- player->boostSpeed += 2.0f;
- if (player->boostSpeed > 30.0f) {
- player->boostSpeed = 30.0f;
- }
- Math_SmoothStepToF(&player->camDist, -400.0f, 0.1f, 30.0f, 0.0f);
- player->sfx.boost = 1;
- Math_SmoothStepToF(&D_ctx_801779A8[player->num], 50.0f, 1.0f, 10.0f, 0.0f);
} else {
if (player->boostMeter > 0.0f) {
player->boostMeter -= sp2C;
@@ -5239,34 +5270,36 @@ void Player_ArwingBrake(Player* player) {
if ((gInputHold->button & gBrakeButton[player->num]) && !(gInputHold->button & gBoostButton[player->num]) &&
(player->state != PLAYERSTATE_U_TURN) && !player->boostCooldown) {
- if (player->boostMeter == 0.0f) {
- Player_PlaySfx(player->sfxSource, NA_SE_ARWING_BRAKE, player->num);
- if ((gLevelMode == LEVELMODE_ALL_RANGE) && (gInputPress->button & gBrakeButton[player->num])) {
- gUturnBrakeTimers[gPlayerNum] = 5;
+ CALL_CANCELLABLE_EVENT(PlayerActionBrakeEvent, player) {
+ if (player->boostMeter == 0.0f) {
+ Player_PlaySfx(player->sfxSource, NA_SE_ARWING_BRAKE, player->num);
+ if ((gLevelMode == LEVELMODE_ALL_RANGE) && (gInputPress->button & gBrakeButton[player->num])) {
+ gUturnBrakeTimers[gPlayerNum] = 5;
+ }
}
- }
- if (gLevelType == LEVELTYPE_PLANET) {
- Math_SmoothStepToF(&player->arwing.upperRightFlapYrot, 90.0f, 0.2f, 100.0f, 0.0f);
- Math_SmoothStepToF(&player->arwing.bottomRightFlapYrot, -90.0f, 0.2f, 100.0f, 0.0f);
- Math_SmoothStepToF(&player->arwing.upperLeftFlapYrot, 90.0f, 0.2f, 100.0f, 0.0f);
- Math_SmoothStepToF(&player->arwing.bottomLeftFlapYrot, -90.0f, 0.2f, 100.0f, 0.0f);
- }
- player->boostMeter += sp30;
- if (player->boostMeter > 90.0f) {
- player->boostCooldown = true;
- player->boostMeter = 90.0f;
- }
+ if (gLevelType == LEVELTYPE_PLANET) {
+ Math_SmoothStepToF(&player->arwing.upperRightFlapYrot, 90.0f, 0.2f, 100.0f, 0.0f);
+ Math_SmoothStepToF(&player->arwing.bottomRightFlapYrot, -90.0f, 0.2f, 100.0f, 0.0f);
+ Math_SmoothStepToF(&player->arwing.upperLeftFlapYrot, 90.0f, 0.2f, 100.0f, 0.0f);
+ Math_SmoothStepToF(&player->arwing.bottomLeftFlapYrot, -90.0f, 0.2f, 100.0f, 0.0f);
+ }
+ player->boostMeter += sp30;
+ if (player->boostMeter > 90.0f) {
+ player->boostCooldown = true;
+ player->boostMeter = 90.0f;
+ }
- player->unk_190 = 0.3f;
- player->boostSpeed -= 1.0f;
- if (player->boostSpeed < -20.0f) {
- player->boostSpeed = -20.0f;
- }
+ player->unk_190 = 0.3f;
+ player->boostSpeed -= 1.0f;
+ if (player->boostSpeed < -20.0f) {
+ player->boostSpeed = -20.0f;
+ }
- Math_SmoothStepToF(&player->camDist, 180.0f, 0.1f, 10.0f, 0.0f);
- player->sfx.brake = true;
- Math_SmoothStepToF(&D_ctx_801779A8[player->num], 25.0f, 1.0f, 5.0f, 0.0f);
+ Math_SmoothStepToF(&player->camDist, 180.0f, 0.1f, 10.0f, 0.0f);
+ player->sfx.brake = true;
+ Math_SmoothStepToF(&D_ctx_801779A8[player->num], 25.0f, 1.0f, 5.0f, 0.0f);
+ }
} else if (player->boostMeter > 0.0f) {
player->boostMeter -= sp34;
if (player->boostMeter <= 0.0f) {
diff --git a/src/engine/fox_tank.c b/src/engine/fox_tank.c
index 7e34633b..d2e22f22 100644
--- a/src/engine/fox_tank.c
+++ b/src/engine/fox_tank.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "assets/ast_landmaster.h"
#include "assets/ast_titania.h"
+#include "port/hooks/Events.h"
void func_tank_80047754(Player* player);
void func_tank_80047D38(Player* player, f32);
@@ -550,35 +551,39 @@ void func_tank_80045348(Player* player) {
if (player->unk_19C >= 0) {
if ((gBoostButton[player->num] & gInputHold->button) && !player->boostCooldown) {
- D_800C9F14++;
- sp2E = true;
- if (D_800C9F24 == 0.0f) {
- player->unk_190 = player->unk_194 = 4.0f;
- AUDIO_PLAY_SFX(NA_SE_TANK_DASH, player->sfxSource, 0);
- } else {
- player->unk_190 = 2.0f;
- }
- baseSpeedTarget = 25.0f;
- sp40 = -200.0f;
- sp3C = 0.2f;
- sp38 = 6.0f;
-
- D_800C9F24 += 1.0f;
- if (D_ctx_801779A8[player->num] < 25.0f) {
- D_ctx_801779A8[player->num] = 25.0f;
- }
+ CALL_CANCELLABLE_EVENT(PlayerActionBoostEvent, player) {
+ D_800C9F14++;
+ sp2E = true;
+ if (D_800C9F24 == 0.0f) {
+ player->unk_190 = player->unk_194 = 4.0f;
+ AUDIO_PLAY_SFX(NA_SE_TANK_DASH, player->sfxSource, 0);
+ } else {
+ player->unk_190 = 2.0f;
+ }
+ baseSpeedTarget = 25.0f;
+ sp40 = -200.0f;
+ sp3C = 0.2f;
+ sp38 = 6.0f;
+
+ D_800C9F24 += 1.0f;
+ if (D_ctx_801779A8[player->num] < 25.0f) {
+ D_ctx_801779A8[player->num] = 25.0f;
+ }
- Math_SmoothStepToF(&D_ctx_801779A8[player->num], 50.0f, 1.0f, 10.0f, 0.0f);
+ Math_SmoothStepToF(&D_ctx_801779A8[player->num], 50.0f, 1.0f, 10.0f, 0.0f);
+ }
} else {
D_800C9F24 = 0.0f;
}
if ((gBrakeButton[player->num] & gInputHold->button) && !player->boostCooldown && !sp2E) {
- D_800C9F14++;
- baseSpeedTarget = 5.0f;
- sp40 = 100.0f;
- sp3C = 0.2f;
- D_800C9F28 += 1.0f;
- Math_SmoothStepToF(&D_ctx_801779A8[player->num], 25.0f, 1.0f, 5.0f, 0.0f);
+ CALL_CANCELLABLE_EVENT(PlayerActionBrakeEvent, player) {
+ D_800C9F14++;
+ baseSpeedTarget = 5.0f;
+ sp40 = 100.0f;
+ sp3C = 0.2f;
+ D_800C9F28 += 1.0f;
+ Math_SmoothStepToF(&D_ctx_801779A8[player->num], 25.0f, 1.0f, 5.0f, 0.0f);
+ }
} else {
D_800C9F28 = 0.0f;
}
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;
diff --git a/src/port/hooks/Events.h b/src/port/hooks/Events.h
index 30afe9ec..3f53a7d1 100644
--- a/src/port/hooks/Events.h
+++ b/src/port/hooks/Events.h
@@ -2,4 +2,5 @@
#include "list/EngineEvent.h"
#include "list/ActorEvent.h"
-#include "list/ItemEvent.h" \ No newline at end of file
+#include "list/ItemEvent.h"
+#include "list/ActionEvent.h" \ No newline at end of file
diff --git a/src/port/hooks/list/ActionEvent.h b/src/port/hooks/list/ActionEvent.h
new file mode 100644
index 00000000..333c6453
--- /dev/null
+++ b/src/port/hooks/list/ActionEvent.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "sf64player.h"
+#include "port/hooks/impl/EventSystem.h"
+
+DEFINE_EVENT(PlayerActionBoostEvent, Player* player;);
+
+DEFINE_EVENT(PlayerActionBrakeEvent, Player* player;);
+
+DEFINE_EVENT(PlayerActionPreShootEvent, Player* player; LaserStrength laser;);
+DEFINE_EVENT(PlayerActionPostShootEvent, Player* player; LaserStrength laser;);
+
+DEFINE_EVENT(PlayerActionPreShootChargedEvent, Player* player;);
+DEFINE_EVENT(PlayerActionPostShootChargedEvent, Player* player;);
+
+DEFINE_EVENT(PlayerActionPreBombEvent, Player* player;);
+DEFINE_EVENT(PlayerActionPostBombEvent, Player* player;); \ No newline at end of file
diff --git a/src/port/mods/PortEnhancements.c b/src/port/mods/PortEnhancements.c
index b2559422..84bfba62 100644
--- a/src/port/mods/PortEnhancements.c
+++ b/src/port/mods/PortEnhancements.c
@@ -193,6 +193,19 @@ void PortEnhancements_Register() {
REGISTER_EVENT(ObjectUpdateEvent);
REGISTER_EVENT(ObjectDrawEvent);
REGISTER_EVENT(ObjectDestroyEvent);
+
+ // Register player action events
+ REGISTER_EVENT(PlayerActionBoostEvent);
+ REGISTER_EVENT(PlayerActionBrakeEvent);
+
+ REGISTER_EVENT(PlayerActionPreShootEvent);
+ REGISTER_EVENT(PlayerActionPostShootEvent);
+
+ REGISTER_EVENT(PlayerActionPreShootChargedEvent);
+ REGISTER_EVENT(PlayerActionPostShootChargedEvent);
+
+ REGISTER_EVENT(PlayerActionPreBombEvent);
+ REGISTER_EVENT(PlayerActionPostBombEvent);
}
void PortEnhancements_Exit() {