Support overriding attacks through script hooks.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -37,15 +37,17 @@ namespace CreatureLib::Battling {
|
||||
std::unique_ptr<HitData[]> _hits;
|
||||
ArbUt::BorrowedPtr<Creature> _user;
|
||||
ArbUt::BorrowedPtr<LearnedAttack> _attack;
|
||||
ArbUt::BorrowedPtr<const Library::AttackData> _useAttack;
|
||||
std::unique_ptr<BattleScript> _script = nullptr;
|
||||
ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>> _targets;
|
||||
|
||||
public:
|
||||
ExecutingAttack(const ArbUt::List<ArbUt::OptionalBorrowedPtr<Creature>>& targets, uint8_t numberHits,
|
||||
ArbUt::BorrowedPtr<Creature> user, const ArbUt::BorrowedPtr<LearnedAttack>& attack,
|
||||
const ArbUt::BorrowedPtr<const Library::AttackData>& useAttack,
|
||||
const std::unique_ptr<BattleScript>& script)
|
||||
: _numberHits(numberHits), _hits(std::make_unique<HitData[]>(targets.Count() * numberHits)), _user(user),
|
||||
_attack(attack), _targets(targets) {
|
||||
_attack(attack), _useAttack(useAttack), _targets(targets) {
|
||||
// Take ownership of the script of the attack choice, and give attack choice our initial nullptr.
|
||||
_script.swap(const_cast<std::unique_ptr<BattleScript>&>(script));
|
||||
}
|
||||
@@ -98,6 +100,7 @@ namespace CreatureLib::Battling {
|
||||
inline const ArbUt::BorrowedPtr<Creature>& GetUser() noexcept { return _user; }
|
||||
|
||||
inline const ArbUt::BorrowedPtr<LearnedAttack>& GetAttack() noexcept { return _attack; }
|
||||
inline const ArbUt::BorrowedPtr<const Library::AttackData>& GetUseAttack() noexcept { return _useAttack; }
|
||||
size_t ScriptCount() const override { return _user->ScriptCount() + 1; }
|
||||
|
||||
inline ArbUt::BorrowedPtr<BattleScript> GetScript() const noexcept { return _script; }
|
||||
|
||||
Reference in New Issue
Block a user