Player action hooks (#93)
Some checks failed
GenerateBuilds / generate-port-otr (push) Has been cancelled
GenerateBuilds / build-windows (push) Has been cancelled
GenerateBuilds / build-macos (push) Has been cancelled
GenerateBuilds / build-linux (push) Has been cancelled

* 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
This commit is contained in:
Kiloku 2024-12-30 01:47:42 -03:00 committed by GitHub
parent dbf9b0378f
commit ad7bc7c691
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 249 additions and 165 deletions

View File

@ -3145,14 +3145,19 @@ void Player_SetupTankShot(Player* player, PlayerShot* shot, PlayerShotId shotId,
void Player_TankCannon(Player* player) { void Player_TankCannon(Player* player) {
s32 i; s32 i;
for (i = 0; i < ARRAY_COUNT(gPlayerShots) - 1; i++) { CALL_CANCELLABLE_EVENT(PlayerActionPreShootEvent, player, gLaserStrength[gPlayerNum]) {
if (gPlayerShots[i].obj.status == SHOT_FREE) { for (i = 0; i < ARRAY_COUNT(gPlayerShots) - 1; i++) {
Player_SetupTankShot(player, &gPlayerShots[i], PLAYERSHOT_TANK, 100.0f); if (gPlayerShots[i].obj.status == SHOT_FREE) {
Player_PlaySfx(player->sfxSource, NA_SE_TANK_SHOT, player->num); Player_SetupTankShot(player, &gPlayerShots[i], PLAYERSHOT_TANK, 100.0f);
player->unk_1A0 = 2; Player_PlaySfx(player->sfxSource, NA_SE_TANK_SHOT, player->num);
break; player->unk_1A0 = 2;
break;
}
} }
} }
if (!PlayerActionPreShootEvent_.event.cancelled){
CALL_EVENT(PlayerActionPostShootEvent, player, gLaserStrength[gPlayerNum]);
}
} }
void Player_ArwingLaser(Player* player) { void Player_ArwingLaser(Player* player) {
@ -3164,24 +3169,30 @@ void Player_ArwingLaser(Player* player) {
laser = LASERS_SINGLE; laser = LASERS_SINGLE;
} }
CALL_EVENT(PlayerActionPreShootEvent, player, laser);
if (PlayerActionPreShootEvent_.event.cancelled){
return;
}
switch (laser) { switch (laser) {
case LASERS_SINGLE: case LASERS_SINGLE:
for (i = 0; i < ARRAY_COUNT(gPlayerShots) - 1; i++) { for (i = 0; i < ARRAY_COUNT(gPlayerShots) - 1; i++) {
if (gPlayerShots[i].obj.status == SHOT_FREE) { if (gPlayerShots[i].obj.status == SHOT_FREE) {
Player_SetupArwingShot(player, &gPlayerShots[i], 0.0f, 0.0f, PLAYERSHOT_SINGLE_LASER, 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); Player_PlaySfx(player->sfxSource, NA_SE_ARWING_SHOT, player->num);
gMuzzleFlashScale[player->num] = 0.5f; gMuzzleFlashScale[player->num] = 0.5f;
break; break;
} }
} }
break; break;
case LASERS_TWIN: case LASERS_TWIN:
case LASERS_HYPER: case LASERS_HYPER:
for (i = 0; i < ARRAY_COUNT(gPlayerShots) - 1; i++) { for (i = 0; i < ARRAY_COUNT(gPlayerShots) - 1; i++) {
if (gPlayerShots[i].obj.status == SHOT_FREE) { if (gPlayerShots[i].obj.status == SHOT_FREE) {
Player_SetupArwingShot(player, &gPlayerShots[i], 0.0f, -10.0f, PLAYERSHOT_TWIN_LASER, Player_SetupArwingShot(player, &gPlayerShots[i], 0.0f, -10.0f, PLAYERSHOT_TWIN_LASER,
400.0f / 3.0f); 400.0f / 3.0f);
if (laser == LASERS_TWIN) { if (laser == LASERS_TWIN) {
Player_PlaySfx(player->sfxSource, NA_SE_ARWING_TWIN_LASER, player->num); Player_PlaySfx(player->sfxSource, NA_SE_ARWING_TWIN_LASER, player->num);
gMuzzleFlashScale[player->num] = 0.5f; gMuzzleFlashScale[player->num] = 0.5f;
@ -3194,11 +3205,19 @@ void Player_ArwingLaser(Player* player) {
} }
break; break;
} }
CALL_EVENT(PlayerActionPostShootEvent, player, laser);
} }
void Player_SmartBomb(Player* player) { void Player_SmartBomb(Player* player) {
if ((gBombCount[player->num] != 0) && (gBombButton[player->num] & gInputPress->button) && if ((gBombCount[player->num] != 0) && (gBombButton[player->num] & gInputPress->button) &&
(gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].obj.status == SHOT_FREE)) { (gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].obj.status == SHOT_FREE)) {
CALL_EVENT(PlayerActionPreBombEvent, player);
if (PlayerActionPreBombEvent_.event.cancelled)
{
return;
}
if (gVersusMode) { if (gVersusMode) {
gBombCount[player->num] = 0; gBombCount[player->num] = 0;
} else { } else {
@ -3218,6 +3237,7 @@ void Player_SmartBomb(Player* player) {
gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].unk_60 = 0; gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].unk_60 = 0;
Audio_InitBombSfx(player->num, 1); Audio_InitBombSfx(player->num, 1);
Audio_PlayBombFlightSfx(player->num, gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].sfxSource); 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].obj.id == PLAYERSHOT_LOCK_ON) && ((gPlayerShots[14 - player->num].obj.id == PLAYERSHOT_LOCK_ON) &&
(gPlayerShots[14 - player->num].unk_60 != 0))) { (gPlayerShots[14 - player->num].unk_60 != 0))) {
if (player->form == FORM_ARWING) { CALL_CANCELLABLE_EVENT(PlayerActionPreShootChargedEvent, player){
Player_SetupArwingShot(player, &gPlayerShots[14 - player->num], 0.0f, 0.0f, PLAYERSHOT_LOCK_ON, if (player->form == FORM_ARWING) {
70.0f); Player_SetupArwingShot(player, &gPlayerShots[14 - player->num], 0.0f, 0.0f, PLAYERSHOT_LOCK_ON,
} else { 70.0f);
Player_SetupTankShot(player, &gPlayerShots[14 - player->num], 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); CALL_EVENT(PlayerActionPostShootChargedEvent, player);
gControllerRumbleTimers[player->num] = 5;
return true;
} }
break; 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].obj.id == PLAYERSHOT_LOCK_ON) && ((gPlayerShots[14 - player->num].obj.id == PLAYERSHOT_LOCK_ON) &&
(gPlayerShots[14 - player->num].scale > 1.0f))) { (gPlayerShots[14 - player->num].scale > 1.0f))) {
if (player->form == FORM_ARWING) { CALL_CANCELLABLE_EVENT(PlayerActionPreShootChargedEvent, player){
Player_SetupArwingShot(player, &gPlayerShots[14 - player->num], 0.0f, 0.0f, PLAYERSHOT_LOCK_ON, if (player->form == FORM_ARWING) {
70.0f); Player_SetupArwingShot(player, &gPlayerShots[14 - player->num], 0.0f, 0.0f, PLAYERSHOT_LOCK_ON,
} else { 70.0f);
Player_SetupTankShot(player, &gPlayerShots[14 - player->num], 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; gChargeTimers[player->num] = 0;
} }
@ -3401,18 +3427,21 @@ bool Player_UpdateLockOn(Player* player) {
} }
if (hasBombTarget && (gBombCount[player->num] != 0) && if (hasBombTarget && (gBombCount[player->num] != 0) &&
(gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].obj.status == SHOT_FREE)) { (gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].obj.status == SHOT_FREE)) {
gBombCount[player->num]--; CALL_CANCELLABLE_EVENT(PlayerActionPreBombEvent, player){
if (player->form == FORM_ARWING) { gBombCount[player->num]--;
Player_SetupArwingShot(player, &gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1], 0.0f, 0.0f, if (player->form == FORM_ARWING) {
PLAYERSHOT_LOCK_ON, 60.0f); Player_SetupArwingShot(player, &gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1], 0.0f, 0.0f,
} else { PLAYERSHOT_LOCK_ON, 60.0f);
Player_SetupTankShot(player, &gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1], 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; CALL_EVENT(PlayerActionPostBombEvent, player);
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;
} }
} }
return false; return false;
@ -5136,38 +5165,40 @@ void Player_ArwingBoost(Player* player) {
} }
if ((gInputHold->button & gBoostButton[player->num]) && !(gInputHold->button & gBrakeButton[player->num]) && if ((gInputHold->button & gBoostButton[player->num]) && !(gInputHold->button & gBrakeButton[player->num]) &&
(player->state != PLAYERSTATE_U_TURN) && !player->boostCooldown) { (player->state != PLAYERSTATE_U_TURN) && !player->boostCooldown) {
if (player->boostMeter == 0.0f) { CALL_CANCELLABLE_EVENT(PlayerActionBoostEvent, player) {
Player_PlaySfx(player->sfxSource, NA_SE_ARWING_BOOST, player->num); if (player->boostMeter == 0.0f) {
player->unk_194 = 5.0f; Player_PlaySfx(player->sfxSource, NA_SE_ARWING_BOOST, player->num);
player->unk_190 = 5.0f; player->unk_194 = 5.0f;
if (gBoostButton[player->num] & gInputPress->button) { player->unk_190 = 5.0f;
gLoopBoostTimers[gPlayerNum] = 5; 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 { } else {
if (player->boostMeter > 0.0f) { if (player->boostMeter > 0.0f) {
player->boostMeter -= sp2C; player->boostMeter -= sp2C;
@ -5239,34 +5270,36 @@ void Player_ArwingBrake(Player* player) {
if ((gInputHold->button & gBrakeButton[player->num]) && !(gInputHold->button & gBoostButton[player->num]) && if ((gInputHold->button & gBrakeButton[player->num]) && !(gInputHold->button & gBoostButton[player->num]) &&
(player->state != PLAYERSTATE_U_TURN) && !player->boostCooldown) { (player->state != PLAYERSTATE_U_TURN) && !player->boostCooldown) {
if (player->boostMeter == 0.0f) { CALL_CANCELLABLE_EVENT(PlayerActionBrakeEvent, player) {
Player_PlaySfx(player->sfxSource, NA_SE_ARWING_BRAKE, player->num); if (player->boostMeter == 0.0f) {
if ((gLevelMode == LEVELMODE_ALL_RANGE) && (gInputPress->button & gBrakeButton[player->num])) { Player_PlaySfx(player->sfxSource, NA_SE_ARWING_BRAKE, player->num);
gUturnBrakeTimers[gPlayerNum] = 5; if ((gLevelMode == LEVELMODE_ALL_RANGE) && (gInputPress->button & gBrakeButton[player->num])) {
gUturnBrakeTimers[gPlayerNum] = 5;
}
} }
}
if (gLevelType == LEVELTYPE_PLANET) { if (gLevelType == LEVELTYPE_PLANET) {
Math_SmoothStepToF(&player->arwing.upperRightFlapYrot, 90.0f, 0.2f, 100.0f, 0.0f); 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.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.upperLeftFlapYrot, 90.0f, 0.2f, 100.0f, 0.0f);
Math_SmoothStepToF(&player->arwing.bottomLeftFlapYrot, -90.0f, 0.2f, 100.0f, 0.0f); Math_SmoothStepToF(&player->arwing.bottomLeftFlapYrot, -90.0f, 0.2f, 100.0f, 0.0f);
} }
player->boostMeter += sp30; player->boostMeter += sp30;
if (player->boostMeter > 90.0f) { if (player->boostMeter > 90.0f) {
player->boostCooldown = true; player->boostCooldown = true;
player->boostMeter = 90.0f; player->boostMeter = 90.0f;
} }
player->unk_190 = 0.3f; player->unk_190 = 0.3f;
player->boostSpeed -= 1.0f; player->boostSpeed -= 1.0f;
if (player->boostSpeed < -20.0f) { if (player->boostSpeed < -20.0f) {
player->boostSpeed = -20.0f; player->boostSpeed = -20.0f;
} }
Math_SmoothStepToF(&player->camDist, 180.0f, 0.1f, 10.0f, 0.0f); Math_SmoothStepToF(&player->camDist, 180.0f, 0.1f, 10.0f, 0.0f);
player->sfx.brake = true; player->sfx.brake = true;
Math_SmoothStepToF(&D_ctx_801779A8[player->num], 25.0f, 1.0f, 5.0f, 0.0f); Math_SmoothStepToF(&D_ctx_801779A8[player->num], 25.0f, 1.0f, 5.0f, 0.0f);
}
} else if (player->boostMeter > 0.0f) { } else if (player->boostMeter > 0.0f) {
player->boostMeter -= sp34; player->boostMeter -= sp34;
if (player->boostMeter <= 0.0f) { if (player->boostMeter <= 0.0f) {

View File

@ -1,6 +1,7 @@
#include "global.h" #include "global.h"
#include "assets/ast_landmaster.h" #include "assets/ast_landmaster.h"
#include "assets/ast_titania.h" #include "assets/ast_titania.h"
#include "port/hooks/Events.h"
void func_tank_80047754(Player* player); void func_tank_80047754(Player* player);
void func_tank_80047D38(Player* player, f32); void func_tank_80047D38(Player* player, f32);
@ -550,35 +551,39 @@ void func_tank_80045348(Player* player) {
if (player->unk_19C >= 0) { if (player->unk_19C >= 0) {
if ((gBoostButton[player->num] & gInputHold->button) && !player->boostCooldown) { if ((gBoostButton[player->num] & gInputHold->button) && !player->boostCooldown) {
D_800C9F14++; CALL_CANCELLABLE_EVENT(PlayerActionBoostEvent, player) {
sp2E = true; D_800C9F14++;
if (D_800C9F24 == 0.0f) { sp2E = true;
player->unk_190 = player->unk_194 = 4.0f; if (D_800C9F24 == 0.0f) {
AUDIO_PLAY_SFX(NA_SE_TANK_DASH, player->sfxSource, 0); player->unk_190 = player->unk_194 = 4.0f;
} else { AUDIO_PLAY_SFX(NA_SE_TANK_DASH, player->sfxSource, 0);
player->unk_190 = 2.0f; } else {
} player->unk_190 = 2.0f;
baseSpeedTarget = 25.0f; }
sp40 = -200.0f; baseSpeedTarget = 25.0f;
sp3C = 0.2f; sp40 = -200.0f;
sp38 = 6.0f; sp3C = 0.2f;
sp38 = 6.0f;
D_800C9F24 += 1.0f; D_800C9F24 += 1.0f;
if (D_ctx_801779A8[player->num] < 25.0f) { if (D_ctx_801779A8[player->num] < 25.0f) {
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 { } else {
D_800C9F24 = 0.0f; D_800C9F24 = 0.0f;
} }
if ((gBrakeButton[player->num] & gInputHold->button) && !player->boostCooldown && !sp2E) { if ((gBrakeButton[player->num] & gInputHold->button) && !player->boostCooldown && !sp2E) {
D_800C9F14++; CALL_CANCELLABLE_EVENT(PlayerActionBrakeEvent, player) {
baseSpeedTarget = 5.0f; D_800C9F14++;
sp40 = 100.0f; baseSpeedTarget = 5.0f;
sp3C = 0.2f; sp40 = 100.0f;
D_800C9F28 += 1.0f; sp3C = 0.2f;
Math_SmoothStepToF(&D_ctx_801779A8[player->num], 25.0f, 1.0f, 5.0f, 0.0f); D_800C9F28 += 1.0f;
Math_SmoothStepToF(&D_ctx_801779A8[player->num], 25.0f, 1.0f, 5.0f, 0.0f);
}
} else { } else {
D_800C9F28 = 0.0f; D_800C9F28 = 0.0f;
} }

View File

@ -1212,6 +1212,10 @@ void Aquas_BlueMarineTorpedo(Player* player) {
for (i = 15, shot = &gPlayerShots[15]; i < ARRAY_COUNT(gPlayerShots); i++, shot++) { for (i = 15, shot = &gPlayerShots[15]; i < ARRAY_COUNT(gPlayerShots); i++, shot++) {
if (shot->obj.status == SHOT_FREE) { 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); Player_SetupArwingShot(player, shot, 0.0f, 0.0f, PLAYERSHOT_LOCK_ON, 50.0f);
AUDIO_PLAY_SFX(NA_SE_MAR_BOMB_SHOT, shot->sfxSource, 0); AUDIO_PLAY_SFX(NA_SE_MAR_BOMB_SHOT, shot->sfxSource, 0);
D_i3_801C4190[5] = i + 1; D_i3_801C4190[5] = i + 1;
@ -1219,6 +1223,7 @@ void Aquas_BlueMarineTorpedo(Player* player) {
D_i3_801C4458 = -100.0f; D_i3_801C4458 = -100.0f;
D_i3_801C445C = 0.1f; D_i3_801C445C = 0.1f;
gLight3Brightness = 1.0f; gLight3Brightness = 1.0f;
CALL_EVENT(PlayerActionPostBombEvent, player);
break; break;
} }
} }
@ -1227,17 +1232,22 @@ void Aquas_BlueMarineTorpedo(Player* player) {
void Aquas_BlueMarineLaser(Player* player) { void Aquas_BlueMarineLaser(Player* player) {
s32 i; s32 i;
for (i = 0; i < 3; i++) { CALL_CANCELLABLE_EVENT(PlayerActionPreShootEvent, player, gLaserStrength[gPlayerNum]) {
if (gPlayerShots[i].obj.status == SHOT_FREE) { for (i = 0; i < 3; i++) {
Player_SetupArwingShot(player, &gPlayerShots[i], 0.0f, -10.0f, PLAYERSHOT_SINGLE_LASER, 120.0f); if (gPlayerShots[i].obj.status == SHOT_FREE) {
if (gLaserStrength[gPlayerNum] == LASERS_SINGLE) { Player_SetupArwingShot(player, &gPlayerShots[i], 0.0f, -10.0f, PLAYERSHOT_SINGLE_LASER, 120.0f);
AUDIO_PLAY_SFX(NA_SE_MAR_SHOT, gPlayerShots[i].sfxSource, 0); if (gLaserStrength[gPlayerNum] == LASERS_SINGLE) {
} else { AUDIO_PLAY_SFX(NA_SE_MAR_SHOT, gPlayerShots[i].sfxSource, 0);
AUDIO_PLAY_SFX(NA_SE_MAR_TWIN_LASER, 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) { void Aquas_BlueMarineShoot(Player* player) {
@ -1514,29 +1524,32 @@ void Aquas_BlueMarineBoost(Player* player) {
if ((gBoostButton[player->num] & gInputHold->button) && (player->unk_230 == 0) && if ((gBoostButton[player->num] & gInputHold->button) && (player->unk_230 == 0) &&
(player->state != PLAYERSTATE_U_TURN) && (player->boostCooldown == 0)) { (player->state != PLAYERSTATE_U_TURN) && (player->boostCooldown == 0)) {
if (player->boostMeter == 0) { CALL_CANCELLABLE_EVENT(PlayerActionBoostEvent, player){
AUDIO_PLAY_SFX(NA_SE_MARINE_BOOST, player->sfxSource, 4); 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;
}
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;
Math_SmoothStepToF(&D_ctx_801779A8[0], 50.0f, 1.0f, 10.0f, 0.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);
player->sfx.boost = 1;
Math_SmoothStepToF(&D_ctx_801779A8[0], 50.0f, 1.0f, 10.0f, 0.0f);
} else { } else {
D_i3_801C41B8[27] = 0.0f; 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) && if ((gInputHold->button & gBrakeButton[player->num]) && (player->unk_230 == 0) &&
(player->state != PLAYERSTATE_U_TURN) && (player->boostCooldown == 0)) { (player->state != PLAYERSTATE_U_TURN) && (player->boostCooldown == 0)) {
if (player->boostMeter == 0) { CALL_CANCELLABLE_EVENT(PlayerActionBrakeEvent, player){
AUDIO_PLAY_SFX(NA_SE_MARINE_BRAKE, player->sfxSource, 4); 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;
}
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;
Math_SmoothStepToF(&D_ctx_801779A8[0], 25.0f, 1.0f, 5.0f, 0.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);
player->sfx.brake = true;
Math_SmoothStepToF(&D_ctx_801779A8[0], 25.0f, 1.0f, 5.0f, 0.0f);
} else { } else {
if (player->boostMeter > 0.0f) { if (player->boostMeter > 0.0f) {
player->boostMeter -= 0.5f; player->boostMeter -= 0.5f;

View File

@ -3,3 +3,4 @@
#include "list/EngineEvent.h" #include "list/EngineEvent.h"
#include "list/ActorEvent.h" #include "list/ActorEvent.h"
#include "list/ItemEvent.h" #include "list/ItemEvent.h"
#include "list/ActionEvent.h"

View File

@ -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;);

View File

@ -193,6 +193,19 @@ void PortEnhancements_Register() {
REGISTER_EVENT(ObjectUpdateEvent); REGISTER_EVENT(ObjectUpdateEvent);
REGISTER_EVENT(ObjectDrawEvent); REGISTER_EVENT(ObjectDrawEvent);
REGISTER_EVENT(ObjectDestroyEvent); 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() { void PortEnhancements_Exit() {