Set data for executing attacks.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
583bde3768
commit
aa356d74d7
|
@ -62,8 +62,12 @@ void TurnHandler::ExecuteAttackChoice(AttackTurnChoice *choice) {
|
||||||
//TODO: Change attack
|
//TODO: Change attack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Resolve all targets
|
||||||
|
auto target = choice->GetUser()->GetBattle()->GetTarget(choice->GetTarget());
|
||||||
|
std::vector<Creature*> targets = {target};
|
||||||
|
|
||||||
//TODO: Set ExecutingAttack data
|
//TODO: Set ExecutingAttack data
|
||||||
auto attack = new ExecutingAttack();
|
auto attack = new ExecutingAttack(targets, 1, choice->GetUser(), choice->GetAttack(), choice->GetAttackScript());
|
||||||
bool prevented = false;
|
bool prevented = false;
|
||||||
HOOK(PreventAttack, attack, attack, prevented);
|
HOOK(PreventAttack, attack, attack, prevented);
|
||||||
if (prevented){
|
if (prevented){
|
||||||
|
|
|
@ -67,6 +67,16 @@ namespace CreatureLib::Battling {
|
||||||
LearnedAttack* _attack;
|
LearnedAttack* _attack;
|
||||||
Script* _script;
|
Script* _script;
|
||||||
public:
|
public:
|
||||||
|
ExecutingAttack(const std::vector<Creature*>& targets, uint8_t numberHits, Creature* user, LearnedAttack* attack,
|
||||||
|
Script* script)
|
||||||
|
: _user(user), _attack(attack), _script(script)
|
||||||
|
{
|
||||||
|
_targets.reserve(targets.size());
|
||||||
|
for (auto target: targets){
|
||||||
|
_targets.insert({target, TargetData(numberHits)});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~ExecutingAttack() = default;
|
virtual ~ExecutingAttack() = default;
|
||||||
|
|
||||||
TargetData& GetAttackDataForTarget(Creature* creature){
|
TargetData& GetAttackDataForTarget(Creature* creature){
|
||||||
|
|
|
@ -31,6 +31,10 @@ namespace CreatureLib::Battling{
|
||||||
return _target;
|
return _target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Script* GetAttackScript(){
|
||||||
|
return _attackScript;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void GetActiveScripts(std::vector<ScriptWrapper> &scripts) override {
|
void GetActiveScripts(std::vector<ScriptWrapper> &scripts) override {
|
||||||
scripts.emplace_back(&_attackScript);
|
scripts.emplace_back(&_attackScript);
|
||||||
|
|
Loading…
Reference in New Issue