summaryrefslogtreecommitdiff
path: root/src/engine/fox_tank.c
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/engine/fox_tank.c
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/engine/fox_tank.c')
-rw-r--r--src/engine/fox_tank.c53
1 files changed, 29 insertions, 24 deletions
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;
}