Skip to content

Commit

Permalink
Additional Sail commands (HarbourMasters#4970)
Browse files Browse the repository at this point in the history
* Additional Sail Commands.

Adds "SpawnEnemyWithOffset" and "SpawnActor" to Sail Functions.

* Small Corrections

Indentation my beloved
  • Loading branch information
Xeokn authored Feb 2, 2025
1 parent ac9b8c2 commit 33d7b17
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
24 changes: 24 additions & 0 deletions soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
8 changes: 8 additions & 0 deletions soh/soh/Enhancements/game-interactor/GameInteractionEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
14 changes: 14 additions & 0 deletions soh/soh/Network/Sail/Sail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>();
effect->parameters[1] = payload["parameters"][1].get<int32_t>();
}
return effect;
} else if (name == "SpawnActor") {
auto effect = new GameInteractionEffect::SpawnActor();
if (payload.contains("parameters")) {
effect->parameters[0] = payload["parameters"][0].get<int32_t>();
effect->parameters[1] = payload["parameters"][1].get<int32_t>();
}
return effect;
} else {
SPDLOG_INFO("[Sail] Unknown effect name: {}", name);
return nullptr;
Expand Down

0 comments on commit 33d7b17

Please sign in to comment.