From f0b596fabda51bc059815a426940cf3f465a5cc7 Mon Sep 17 00:00:00 2001 From: Xeokn <74164454+Xeokn@users.noreply.github.com> Date: Thu, 30 Jan 2025 00:44:39 +1000 Subject: [PATCH] Additional Sail Commands. Adds "SpawnEnemyWithOffset" and "SpawnActor" to Sail Functions. --- .../game-interactor/GameInteractionEffect.cpp | 24 +++++++++++++++++++ .../game-interactor/GameInteractionEffect.h | 8 +++++++ soh/soh/Network/Sail/Sail.cpp | 14 +++++++++++ 3 files changed, 46 insertions(+) diff --git a/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp b/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp index a0469d0c3..5e2685e3d 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp @@ -640,4 +640,28 @@ namespace GameInteractionEffect { void SlipperyFloor::_Remove() { GameInteractor::State::SlipperyFloorActive = 0; } + + // MARK: - SpawnEnemyWithOffset + GameInteractionEffectQueryResult SpawnEnemyWithOffset::CanBeApplied() { + if (!GameInteractor::IsSaveLoaded()) { + return GameInteractionEffectQueryResult::TemporarilyNotPossible; + } + return GameInteractor::RawAction::SpawnEnemyWithOffset(parameters[0], parameters[1]); + } + + void SpawnEnemyWithOffset::_Apply() { + GameInteractor::RawAction::SpawnEnemyWithOffset(parameters[0], parameters[1]); + } + + // MARK: - SpawnActor + GameInteractionEffectQueryResult SpawnActor::CanBeApplied() { + if (!GameInteractor::IsSaveLoaded()) { + return GameInteractionEffectQueryResult::TemporarilyNotPossible; + } + return GameInteractor::RawAction::SpawnActor(parameters[0], parameters[1]); + } + + void SpawnActor::_Apply() { + GameInteractor::RawAction::SpawnActor(parameters[0], parameters[1]); + } } diff --git a/soh/soh/Enhancements/game-interactor/GameInteractionEffect.h b/soh/soh/Enhancements/game-interactor/GameInteractionEffect.h index 5e28024b6..855b549ee 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractionEffect.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractionEffect.h @@ -262,6 +262,14 @@ namespace GameInteractionEffect { void _Apply() override; void _Remove() override; }; + class SpawnEnemyWithOffset: public GameInteractionEffectBase, public ParameterizedGameInteractionEffect { + GameInteractionEffectQueryResult CanBeApplied() override; + void _Apply() override; + }; + class SpawnActor: public GameInteractionEffectBase, public ParameterizedGameInteractionEffect { + GameInteractionEffectQueryResult CanBeApplied() override; + void _Apply() override; + }; } #endif /* __cplusplus */ diff --git a/soh/soh/Network/Sail/Sail.cpp b/soh/soh/Network/Sail/Sail.cpp index 1c27e1d72..f9ae7b313 100644 --- a/soh/soh/Network/Sail/Sail.cpp +++ b/soh/soh/Network/Sail/Sail.cpp @@ -320,6 +320,20 @@ GameInteractionEffectBase* Sail::EffectFromJson(nlohmann::json payload) { return new GameInteractionEffect::PlayerInvincibility(); } else if (name == "SlipperyFloor") { return new GameInteractionEffect::SlipperyFloor(); + } else if (name == "SpawnEnemyWithOffset") { + auto effect = new GameInteractionEffect::SpawnEnemyWithOffset(); + if (payload.contains("parameters")) { + effect->parameters[0] = payload["parameters"][0].get(); + effect->parameters[1] = payload["parameters"][1].get(); + } + return effect; + } else if (name == "SpawnActor") { + auto effect = new GameInteractionEffect::SpawnActor(); + if (payload.contains("parameters")) { + effect->parameters[0] = payload["parameters"][0].get(); + effect->parameters[1] = payload["parameters"][1].get(); + } + return effect; } else { SPDLOG_INFO("[Sail] Unknown effect name: {}", name); return nullptr;