From 9d1e7dff11b8cbab57aefbac0bb7cd267036a5c3 Mon Sep 17 00:00:00 2001 From: Adam Bird Date: Sun, 17 Dec 2023 16:20:08 -0500 Subject: [PATCH] fix GI effect class and chaos commands --- soh/soh/Enhancements/ChaosInteractorEffect.h | 2 +- soh/soh/Enhancements/chaos.cpp | 32 +++++++++---------- soh/soh/Enhancements/chaos_commands.h | 14 ++++---- soh/soh/Enhancements/chaos_commands_macros.h | 4 +-- .../game-interactor/GameInteractor.cpp | 2 +- .../game-interactor/GameInteractor.h | 24 +++++++------- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/soh/soh/Enhancements/ChaosInteractorEffect.h b/soh/soh/Enhancements/ChaosInteractorEffect.h index ce1da50ad11..52f0005a3cf 100644 --- a/soh/soh/Enhancements/ChaosInteractorEffect.h +++ b/soh/soh/Enhancements/ChaosInteractorEffect.h @@ -9,7 +9,7 @@ #ifdef __cplusplus namespace GameInteractionEffect { - class ModifyLinkScale: public GameInteractionEffectBase { + class ModifyLinkScale: public RemovableGameInteractionEffect, public ParameterizedGameInteractionEffect { GameInteractionEffectQueryResult CanBeApplied() override; void _Apply() override; void _Remove() override; diff --git a/soh/soh/Enhancements/chaos.cpp b/soh/soh/Enhancements/chaos.cpp index d0a8ac06bdf..a88ba1bcbc0 100644 --- a/soh/soh/Enhancements/chaos.cpp +++ b/soh/soh/Enhancements/chaos.cpp @@ -84,13 +84,13 @@ static std::map kCommands { // CMD_ONE_SHOT(0x04, PL_NONE(), { scale(&(GET_PLAYER(gPlayState)->actor), 1.5f, 1.5f, 1.5f); }), CMD_ONE_SHOT(0x04, PL_NONE(), { GameInteractor::ChaosState::CustomLinkScale *= 1.5f; }), // CMD_ONE_SHOT_INTERACTOR(0x04, new GameInteractionEffect::ModifyLinkScale(), true, - // [=](GameInteractionEffectBase* effect) { + // [=](ParameterizedGameInteractionEffect* effect) { // effect->parameters[0] = 1.5f; // }), // CMD_ONE_SHOT(0x05, PL_NONE(), { scale(&(GET_PLAYER(gPlayState)->actor), 0.66f, 0.66f, 0.66f); }), CMD_ONE_SHOT(0x05, PL_NONE(), { GameInteractor::ChaosState::CustomLinkScale *= 0.66f; }), // CMD_ONE_SHOT_INTERACTOR(0x05, new GameInteractionEffect::ModifyLinkScale(), true, - // [=](GameInteractionEffectBase* effect) { + // [=](ParameterizedGameInteractionEffect* effect) { // effect->parameters[0] = 0.66; // }), @@ -127,11 +127,11 @@ static std::map kCommands { // gSaveContext.health = s_sub(gSaveContext.health, Read(payload, 0), 16); // }), CMD_ONE_SHOT_INTERACTOR(0x0D, new GameInteractionEffect::ModifyHealth(), true, - [=](GameInteractionEffectBase* effect) { + [=](ParameterizedGameInteractionEffect* effect) { effect->parameters[0] = Read(payload, 0); }), CMD_ONE_SHOT_INTERACTOR(0x0E, new GameInteractionEffect::ModifyHealth(), true, - [=](GameInteractionEffectBase* effect) { + [=](ParameterizedGameInteractionEffect* effect) { int healthToRemove = Read(payload, 0); if (gSaveContext.health - (healthToRemove * 16) <= 0) { healthToRemove = ceil((gSaveContext.health / 16) - 1); @@ -146,11 +146,11 @@ static std::map kCommands { // gSaveContext.rupees = s_sub(gSaveContext.rupees, Read(payload, 0), 16); // }), CMD_ONE_SHOT_INTERACTOR(0x0F, new GameInteractionEffect::ModifyRupees(), true, - [=](GameInteractionEffectBase* effect) { + [=](ParameterizedGameInteractionEffect* effect) { effect->parameters[0] = Read(payload, 0); }), CMD_ONE_SHOT_INTERACTOR(0x10, new GameInteractionEffect::ModifyRupees(), true, - [=](GameInteractionEffectBase* effect) { + [=](ParameterizedGameInteractionEffect* effect) { effect->parameters[0] = -Read(payload, 0); }), @@ -226,18 +226,18 @@ static std::map kCommands { // Paper link CMD_TIMED_INTERACTOR(CMD_ID++, new GameInteractionEffect::ModifyLinkSize(), false, - [&](GameInteractionEffectBase* effect) { effect->parameters[0] = GI_LINK_SIZE_PAPER; }), + [&](ParameterizedGameInteractionEffect* effect) { effect->parameters[0] = GI_LINK_SIZE_PAPER; }), // CMD(CMD_ID++, PL_BYTES(sizeof(uint32_t)), // CR_ONE_SHOT_TIMED( // [&]() { - // GameInteractionEffectBase* effect = new GameInteractionEffect::ModifyLinkSize(); - // effect->parameters[0] = GI_LINK_SIZE_PAPER; + // RemovableGameInteractionEffect* effect = new GameInteractionEffect::ModifyLinkSize(); + // dynamic_cast(effect)->parameters[0] = GI_LINK_SIZE_PAPER; // GameInteractor::ApplyEffect(effect); // }, // [&]() { - // GameInteractionEffectBase* effect = new GameInteractionEffect::ModifyLinkSize(); - // effect->parameters[0] = GI_LINK_SIZE_PAPER; + // RemovableGameInteractionEffect* effect = new GameInteractionEffect::ModifyLinkSize(); + // dynamic_cast(effect)->parameters[0] = GI_LINK_SIZE_PAPER; // GameInteractor::RemoveEffect(effect); // })), @@ -251,12 +251,12 @@ static std::map kCommands { CMD_TIMED_BOOL_CVAR(CMD_ID++, "gPogoStick"), CMD_ONE_SHOT_CVAR(CMD_ID++, "gSunsSong"), // CMD_ONE_SHOT_INTERACTOR(CMD_ID++, new GameInteractionEffect::SetTimeOfDay(), false, - // [=](GameInteractionEffectBase* effect) { + // [=](ParameterizedGameInteractionEffect* effect) { // effect->parameters[0] = IS_DAY ? 0 : 0x8000; // }), // CMD_ONE_SHOT_CVAR(CMD_ID++, "gPressA"), CMD_ONE_SHOT_INTERACTOR(CMD_ID++, new GameInteractionEffect::PressButton(), false, - [=](GameInteractionEffectBase* effect) { + [=](ParameterizedGameInteractionEffect* effect) { effect->parameters[0] = BTN_A; }), CMD_TIMED_BOOL_CVAR(CMD_ID++, "gButtonSwap"), @@ -368,15 +368,15 @@ static std::map kCommands { []() { return LINK_IS_CHILD && !CVarGetInteger("gChaosForcedBoots", 0); }, CR_TIMED_CVAR("gChaosForcedBoots", 0, 0xF))), // CMD_TIMED_INTERACTOR(0xE2, new GameInteractionEffect::ForceEquipBoots(), false, - // [=](GameInteractionEffectBase* effect) { + // [=](ParameterizedGameInteractionEffect* effect) { // effect->parameters[0] = PLAYER_BOOTS_IRON; // }), // CMD_TIMED_INTERACTOR(0xE3, new GameInteractionEffect::ForceEquipBoots(), false, - // [=](GameInteractionEffectBase* effect) { + // [=](ParameterizedGameInteractionEffect* effect) { // effect->parameters[0] = PLAYER_BOOTS_HOVER; // }), // CMD_TIMED_INTERACTOR(0xEF, new GameInteractionEffect::ForceEquipBoots(), false, - // [=](GameInteractionEffectBase* effect) { + // [=](ParameterizedGameInteractionEffect* effect) { // effect->parameters[0] = 0xD; // F boots // }), }; diff --git a/soh/soh/Enhancements/chaos_commands.h b/soh/soh/Enhancements/chaos_commands.h index 5dd9263640a..c6e269e7b66 100644 --- a/soh/soh/Enhancements/chaos_commands.h +++ b/soh/soh/Enhancements/chaos_commands.h @@ -201,7 +201,7 @@ class OneShotBooleanCVarCommand : public OneShotCommand { class OneShotInteractorCommand : public OneShotCommand { public: - OneShotInteractorCommand(GameInteractionEffectBase* effect, std::function applyParam_f, bool bypassStart = false) + OneShotInteractorCommand(GameInteractionEffectBase* effect, std::function applyParam_f, bool bypassStart = false) : effect_(effect), applyParam_f_(applyParam_f), bypassStart_(bypassStart), @@ -214,18 +214,18 @@ class OneShotInteractorCommand : public OneShotCommand { void tryApplyParam() { if (applyParam_f_ != nullptr) { - applyParam_f_(effect_); + applyParam_f_(dynamic_cast(effect_)); } } GameInteractionEffectBase* effect_; - std::function applyParam_f_; + std::function applyParam_f_; bool bypassStart_; }; class TimedInteractorCommand : public OneShotTimedCommand { public: - TimedInteractorCommand(GameInteractionEffectBase* effect, std::function applyParam_f, uint32_t seconds, bool bypassStart = false) + TimedInteractorCommand(RemovableGameInteractionEffect* effect, std::function applyParam_f, uint32_t seconds, bool bypassStart = false) : effect_(effect), applyParam_f_(applyParam_f), bypassStart_(bypassStart), @@ -246,12 +246,12 @@ class TimedInteractorCommand : public OneShotTimedCommand { void tryApplyParam() { if (applyParam_f_ != nullptr) { - applyParam_f_(effect_); + applyParam_f_(dynamic_cast(effect_)); } } - GameInteractionEffectBase* effect_; - std::function applyParam_f_; + RemovableGameInteractionEffect* effect_; + std::function applyParam_f_; bool bypassStart_; }; diff --git a/soh/soh/Enhancements/chaos_commands_macros.h b/soh/soh/Enhancements/chaos_commands_macros.h index 24c26857969..fb3de107da8 100644 --- a/soh/soh/Enhancements/chaos_commands_macros.h +++ b/soh/soh/Enhancements/chaos_commands_macros.h @@ -93,9 +93,9 @@ #define CMD_ONE_SHOT_INTERACTOR(id, effect, bypassStart, applyParam) CMD(id, PL_BYTES(sizeof(uint32_t)), CR_ONE_SHOT_INTERACTOR(effect, applyParam, bypassStart)) #define CMD_TAKE_AMMO_INTERACTOR(id, item) CMD_ONE_SHOT_INTERACTOR(id, new GameInteractionEffect::AddOrTakeAmmo(), true, \ - [=](GameInteractionEffectBase* effect) { effect->parameters[0] = -Read(payload, 0); effect->parameters[1] = item; }) + [=](ParameterizedGameInteractionEffect* effect) { effect->parameters[0] = -Read(payload, 0); effect->parameters[1] = item; }) #define CMD_GIVE_AMMO_INTERACTOR(id, item) CMD_ONE_SHOT_INTERACTOR(id, new GameInteractionEffect::AddOrTakeAmmo(), true, \ - [=](GameInteractionEffectBase* effect) { effect->parameters[0] = Read(payload, 0); effect->parameters[1] = item; }) + [=](ParameterizedGameInteractionEffect* effect) { effect->parameters[0] = Read(payload, 0); effect->parameters[1] = item; }) #endif \ No newline at end of file diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor.cpp index 20ccb40577c..4a21bf03e46 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.cpp @@ -27,7 +27,7 @@ GameInteractionEffectQueryResult GameInteractor::CanApplyEffect(GameInteractionE return effect->CanBeApplied(); } -GameInteractionEffectQueryResult GameInteractor::CanRemoveEffect(GameInteractionEffectBase* effect) { +GameInteractionEffectQueryResult GameInteractor::CanRemoveEffect(RemovableGameInteractionEffect* effect) { return effect->CanBeRemoved(); } diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.h b/soh/soh/Enhancements/game-interactor/GameInteractor.h index f0b9afe311b..3ebae3b4109 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.h @@ -170,7 +170,7 @@ class GameInteractor { // Effects static GameInteractionEffectQueryResult CanApplyEffect(GameInteractionEffectBase* effect); - static GameInteractionEffectQueryResult CanRemoveEffect(GameInteractionEffectBase* effect); + static GameInteractionEffectQueryResult CanRemoveEffect(RemovableGameInteractionEffect* effect); static GameInteractionEffectQueryResult ApplyEffect(GameInteractionEffectBase* effect); static GameInteractionEffectQueryResult RemoveEffect(RemovableGameInteractionEffect* effect); @@ -277,6 +277,17 @@ class GameInteractor { static GameInteractionEffectQueryResult SpawnActor(uint32_t actorId, int32_t actorParams); }; + // Chaos ========================================================== + class ChaosState { + public: + static float CustomLinkScale; + static std::vector DogFollowers; + }; + + class ChaosRawAction { + public: + }; + private: #ifdef ENABLE_REMOTE_CONTROL IPaddress remoteIP; @@ -291,17 +302,6 @@ class GameInteractor { void HandleRemoteData(char payload[512]); void HandleRemoteJson(std::string payload); #endif - - // Chaos ========================================================== - class ChaosState { - public: - static float CustomLinkScale; - static std::vector DogFollowers; - }; - - class ChaosRawAction { - public: - }; }; #endif /* __cplusplus */