Skip to content

Commit

Permalink
add can't jump/hammer effects
Browse files Browse the repository at this point in the history
  • Loading branch information
JCog committed Sep 23, 2024
1 parent 841bfab commit 5e6fede
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/battle/btl_states_menus.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "hud_element.h"
#include "battle/action_cmd.h"
#include "sprite/player.h"
#include "chaos.h"

#include "sprite/npc/Goompa.h"
#include "sprite/npc/BattleGoombario.h"
Expand Down Expand Up @@ -2392,7 +2393,7 @@ void btl_state_update_player_menu(void) {
BattleMenu_OptionEnabled[entryIdx] = FALSE;
battle_menu_isMessageDisabled[entryIdx] = BTL_MSG_NO_JUMP_TARGET;
}
if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_JUMP)) {
if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_JUMP) || chaosStatus.cantJump) {
BattleMenu_HudScripts[entryIdx] = battle_menu_JumpHudScripts[0].disabled;
BattleMenu_OptionEnabled[entryIdx] = FALSE;
battle_menu_isMessageDisabled[entryIdx] = BTL_MSG_CANT_SELECT_NOW;
Expand All @@ -2418,7 +2419,7 @@ void btl_state_update_player_menu(void) {
BattleMenu_OptionEnabled[entryIdx] = FALSE;
battle_menu_isMessageDisabled[entryIdx] = BTL_MSG_NO_HAMMER_TARGET;
}
if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_SMASH)) {
if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_SMASH) || chaosStatus.cantHammer) {
BattleMenu_HudScripts[entryIdx] = battle_menu_HammerHudScripts[0].disabled;
BattleMenu_OptionEnabled[entryIdx] = FALSE;
battle_menu_isMessageDisabled[entryIdx] = BTL_MSG_CANT_SELECT_NOW;
Expand Down
2 changes: 2 additions & 0 deletions src/chaos.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ typedef struct ChaosStatus {
enum Buttons buttonMap[9];
b8 randomButton;
b8 rememberThis;
b8 cantJump;
b8 cantHammer;
} ChaosStatus;

extern ChaosStatus chaosStatus;
Expand Down
30 changes: 27 additions & 3 deletions src/chaos_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ static void randomButton(ChaosEffectData*);
static void rememberThis(ChaosEffectData*);
static void shuffleUpgrades(ChaosEffectData*);
static void spawnJunk(ChaosEffectData* effect);
static void preventJump(ChaosEffectData* effect);
static void preventHammer(ChaosEffectData* effect);

ChaosEffectData effectData[] = {
#if CHAOS_DEBUG
Expand Down Expand Up @@ -130,6 +132,8 @@ ChaosEffectData effectData[] = {
{"Remember This?", FALSE, 0, 0, rememberThis, NULL, canRememberThis},
{"Shuffle Upgrades", FALSE, 0, 0, shuffleUpgrades, NULL, canShuffleUpgrades},
{"Spawn Junk", FALSE, 0, 0, spawnJunk, NULL, canSpawnItem},
{"Can't Jump", FALSE, 0, 60, preventJump, preventJump, NULL},
{"Can't Hammer", FALSE, 0, 60, preventHammer, preventHammer, NULL},
};

const u8 totalEffectCount = ARRAY_COUNT(effectData);
Expand Down Expand Up @@ -209,8 +213,10 @@ void handleTimers() {
static b8 isMovePossible(u8 moveId, MoveData *move) {
if ((move->category == MOVE_TYPE_STAR_POWER && move->costFP > gPlayerData.starPower / 0x100)
|| (move->category != MOVE_TYPE_STAR_POWER && move->costFP > gPlayerData.curFP)
|| (move->category == MOVE_TYPE_JUMP && (gPlayerData.bootsLevel < 0 || gBattleStatus.jumpLossTurns > 0))
|| (move->category == MOVE_TYPE_HAMMER && (gPlayerData.hammerLevel < 0 || gBattleStatus.hammerLossTurns > 0)))
|| (move->category == MOVE_TYPE_JUMP
&& (gPlayerData.bootsLevel < 0 || gBattleStatus.jumpLossTurns > 0 || chaosStatus.cantJump))
|| (move->category == MOVE_TYPE_HAMMER
&& (gPlayerData.hammerLevel < 0 || gBattleStatus.hammerLossTurns > 0 || chaosStatus.cantHammer)))
{
return FALSE;
}
Expand Down Expand Up @@ -1243,5 +1249,23 @@ static void shuffleUpgrades(ChaosEffectData *effect) {
static void spawnJunk(ChaosEffectData *effect) {
enum ItemIDs junkItems[] = {ITEM_MYSTERY, ITEM_PEBBLE, ITEM_DRIED_SHROOM, ITEM_DUSTY_HAMMER, ITEM_MISTAKE};
make_item_entity(junkItems[rand_int(ARRAY_COUNT(junkItems) - 1)], gPlayerStatus.pos.x, gPlayerStatus.pos.y + 19.0f,
gPlayerStatus.pos.z, ITEM_SPAWN_MODE_FALL, 0, 0, 0);
gPlayerStatus.pos.z, ITEM_SPAWN_MODE_FALL, 0, 0, 0);
}

static void preventJump(ChaosEffectData *effect) {
chaosStatus.cantJump = !chaosStatus.cantJump;
if (gGameStatus.isBattle && gBattleState == BATTLE_STATE_PLAYER_MENU) {
// TODO: make this more robust
clear_windows();
gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_CREATE_MAIN_MENU;
}
}

static void preventHammer(ChaosEffectData *effect) {
chaosStatus.cantHammer = !chaosStatus.cantHammer;
if (gGameStatus.isBattle && gBattleState == BATTLE_STATE_PLAYER_MENU) {
// TODO: make this more robust
clear_windows();
gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_CREATE_MAIN_MENU;
}
}
6 changes: 6 additions & 0 deletions src/world/action/hammer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "effects.h"
#include "sprite.h"
#include "sprite/player.h"
#include "chaos.h"

enum {
SUBSTATE_HAMMER_0 = 0,
Expand Down Expand Up @@ -271,6 +272,11 @@ void action_update_hammer(void) {
HammerHit->unk_14 = 0;
}

if (chaosStatus.cantHammer && HammerHit->timer == 2) {
set_action_state(ACTION_STATE_IDLE);
return;
}

playerStatus->flags &= ~PS_FLAG_HAMMER_CHECK;
if (HammerHit->timer < 3 && (playerStatus->flags & PS_FLAG_ENTERING_BATTLE)) {
// This is probably to stop Mario from triggering multiple battles at once by hammering while one is starting.
Expand Down
7 changes: 6 additions & 1 deletion src/world/action/jump.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "common.h"
#include "sprite/player.h"
#include "chaos.h"

extern f32 JumpedOnSwitchX;
extern f32 JumpedOnSwitchZ;
Expand All @@ -23,7 +24,11 @@ void initialize_jump(void) {
playerStatus->jumpFromPos.z = playerStatus->pos.z;
playerStatus->jumpFromHeight = playerStatus->pos.y;

phys_init_integrator_for_current_state();
if (chaosStatus.cantJump) {
gravity_use_fall_parms();
} else {
phys_init_integrator_for_current_state();
}

if (playerStatus->animFlags & PA_FLAG_8BIT_MARIO) {
anim = ANIM_MarioW3_8bit_Jump;
Expand Down

0 comments on commit 5e6fede

Please sign in to comment.