Skip to content

Commit

Permalink
fix GI effect class and chaos commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Archez committed Dec 23, 2023
1 parent 6ca756c commit 9d1e7df
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/ChaosInteractorEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
32 changes: 16 additions & 16 deletions soh/soh/Enhancements/chaos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ static std::map<uint8_t, CommandCreator> 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;
// }),

Expand Down Expand Up @@ -127,11 +127,11 @@ static std::map<uint8_t, CommandCreator> kCommands {
// gSaveContext.health = s_sub(gSaveContext.health, Read<uint32_t>(payload, 0), 16);
// }),
CMD_ONE_SHOT_INTERACTOR(0x0D, new GameInteractionEffect::ModifyHealth(), true,
[=](GameInteractionEffectBase* effect) {
[=](ParameterizedGameInteractionEffect* effect) {
effect->parameters[0] = Read<uint32_t>(payload, 0);
}),
CMD_ONE_SHOT_INTERACTOR(0x0E, new GameInteractionEffect::ModifyHealth(), true,
[=](GameInteractionEffectBase* effect) {
[=](ParameterizedGameInteractionEffect* effect) {
int healthToRemove = Read<uint32_t>(payload, 0);
if (gSaveContext.health - (healthToRemove * 16) <= 0) {
healthToRemove = ceil((gSaveContext.health / 16) - 1);
Expand All @@ -146,11 +146,11 @@ static std::map<uint8_t, CommandCreator> kCommands {
// gSaveContext.rupees = s_sub(gSaveContext.rupees, Read<uint32_t>(payload, 0), 16);
// }),
CMD_ONE_SHOT_INTERACTOR(0x0F, new GameInteractionEffect::ModifyRupees(), true,
[=](GameInteractionEffectBase* effect) {
[=](ParameterizedGameInteractionEffect* effect) {
effect->parameters[0] = Read<uint32_t>(payload, 0);
}),
CMD_ONE_SHOT_INTERACTOR(0x10, new GameInteractionEffect::ModifyRupees(), true,
[=](GameInteractionEffectBase* effect) {
[=](ParameterizedGameInteractionEffect* effect) {
effect->parameters[0] = -Read<uint32_t>(payload, 0);
}),

Expand Down Expand Up @@ -226,18 +226,18 @@ static std::map<uint8_t, CommandCreator> 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<ParameterizedGameInteractionEffect*>(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<ParameterizedGameInteractionEffect*>(effect)->parameters[0] = GI_LINK_SIZE_PAPER;
// GameInteractor::RemoveEffect(effect);
// })),

Expand All @@ -251,12 +251,12 @@ static std::map<uint8_t, CommandCreator> 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"),
Expand Down Expand Up @@ -368,15 +368,15 @@ static std::map<uint8_t, CommandCreator> 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
// }),
};
Expand Down
14 changes: 7 additions & 7 deletions soh/soh/Enhancements/chaos_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class OneShotBooleanCVarCommand : public OneShotCommand {

class OneShotInteractorCommand : public OneShotCommand {
public:
OneShotInteractorCommand(GameInteractionEffectBase* effect, std::function<void(GameInteractionEffectBase* effect)> applyParam_f, bool bypassStart = false)
OneShotInteractorCommand(GameInteractionEffectBase* effect, std::function<void(ParameterizedGameInteractionEffect* effect)> applyParam_f, bool bypassStart = false)
: effect_(effect),
applyParam_f_(applyParam_f),
bypassStart_(bypassStart),
Expand All @@ -214,18 +214,18 @@ class OneShotInteractorCommand : public OneShotCommand {

void tryApplyParam() {
if (applyParam_f_ != nullptr) {
applyParam_f_(effect_);
applyParam_f_(dynamic_cast<ParameterizedGameInteractionEffect*>(effect_));
}
}

GameInteractionEffectBase* effect_;
std::function<void(GameInteractionEffectBase* effect)> applyParam_f_;
std::function<void(ParameterizedGameInteractionEffect* effect)> applyParam_f_;
bool bypassStart_;
};

class TimedInteractorCommand : public OneShotTimedCommand {
public:
TimedInteractorCommand(GameInteractionEffectBase* effect, std::function<void(GameInteractionEffectBase* effect)> applyParam_f, uint32_t seconds, bool bypassStart = false)
TimedInteractorCommand(RemovableGameInteractionEffect* effect, std::function<void(ParameterizedGameInteractionEffect* effect)> applyParam_f, uint32_t seconds, bool bypassStart = false)
: effect_(effect),
applyParam_f_(applyParam_f),
bypassStart_(bypassStart),
Expand All @@ -246,12 +246,12 @@ class TimedInteractorCommand : public OneShotTimedCommand {

void tryApplyParam() {
if (applyParam_f_ != nullptr) {
applyParam_f_(effect_);
applyParam_f_(dynamic_cast<ParameterizedGameInteractionEffect*>(effect_));
}
}

GameInteractionEffectBase* effect_;
std::function<void(GameInteractionEffectBase* effect)> applyParam_f_;
RemovableGameInteractionEffect* effect_;
std::function<void(ParameterizedGameInteractionEffect* effect)> applyParam_f_;
bool bypassStart_;
};

Expand Down
4 changes: 2 additions & 2 deletions soh/soh/Enhancements/chaos_commands_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(payload, 0); effect->parameters[1] = item; })
[=](ParameterizedGameInteractionEffect* effect) { effect->parameters[0] = -Read<uint32_t>(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<uint32_t>(payload, 0); effect->parameters[1] = item; })
[=](ParameterizedGameInteractionEffect* effect) { effect->parameters[0] = Read<uint32_t>(payload, 0); effect->parameters[1] = item; })

#endif
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/game-interactor/GameInteractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GameInteractionEffectQueryResult GameInteractor::CanApplyEffect(GameInteractionE
return effect->CanBeApplied();
}

GameInteractionEffectQueryResult GameInteractor::CanRemoveEffect(GameInteractionEffectBase* effect) {
GameInteractionEffectQueryResult GameInteractor::CanRemoveEffect(RemovableGameInteractionEffect* effect) {
return effect->CanBeRemoved();
}

Expand Down
24 changes: 12 additions & 12 deletions soh/soh/Enhancements/game-interactor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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<DogFollower> DogFollowers;
};

class ChaosRawAction {
public:
};

private:
#ifdef ENABLE_REMOTE_CONTROL
IPaddress remoteIP;
Expand All @@ -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<DogFollower> DogFollowers;
};

class ChaosRawAction {
public:
};
};

#endif /* __cplusplus */
Expand Down

0 comments on commit 9d1e7df

Please sign in to comment.