mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-01 09:53:47 +00:00
Pet attack (fix shadowfiend)
This commit is contained in:
@@ -225,7 +225,7 @@ class ActionContext : public NamedObjectContext<Action>
|
||||
creators["rpg mount anim"] = &ActionContext::rpg_mount_anim;
|
||||
|
||||
creators["toggle pet spell"] = &ActionContext::toggle_pet_spell;
|
||||
|
||||
creators["pet attack"] = &ActionContext::pet_attack;
|
||||
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ class ActionContext : public NamedObjectContext<Action>
|
||||
static Action* rpg_mount_anim(PlayerbotAI* botAI) { return new RpgMountAnimAction(botAI); }
|
||||
|
||||
static Action* toggle_pet_spell(PlayerbotAI* ai) { return new TogglePetSpellAutoCastAction(ai); }
|
||||
|
||||
static Action* pet_attack(PlayerbotAI* ai) { return new PetAttackAction(ai); }
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -116,22 +116,22 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
|
||||
return false;
|
||||
}
|
||||
/* prevent pet dead immediately in group */
|
||||
if (bot->GetMap()->IsDungeon() && bot->GetGroup() && !target->IsInCombat()) {
|
||||
with_pet = false;
|
||||
}
|
||||
if (Pet* pet = bot->GetPet())
|
||||
{
|
||||
if (with_pet) {
|
||||
pet->SetReactState(REACT_DEFENSIVE);
|
||||
pet->SetTarget(target->GetGUID());
|
||||
pet->GetCharmInfo()->SetIsCommandAttack(true);
|
||||
pet->AI()->AttackStart(target);
|
||||
} else {
|
||||
pet->SetReactState(REACT_PASSIVE);
|
||||
pet->GetCharmInfo()->SetIsCommandFollow(true);
|
||||
pet->GetCharmInfo()->IsReturning();
|
||||
}
|
||||
}
|
||||
// if (bot->GetMap()->IsDungeon() && bot->GetGroup() && !target->IsInCombat()) {
|
||||
// with_pet = false;
|
||||
// }
|
||||
// if (Pet* pet = bot->GetPet())
|
||||
// {
|
||||
// if (with_pet) {
|
||||
// pet->SetReactState(REACT_DEFENSIVE);
|
||||
// pet->SetTarget(target->GetGUID());
|
||||
// pet->GetCharmInfo()->SetIsCommandAttack(true);
|
||||
// pet->AI()->AttackStart(target);
|
||||
// } else {
|
||||
// pet->SetReactState(REACT_PASSIVE);
|
||||
// pet->GetCharmInfo()->SetIsCommandFollow(true);
|
||||
// pet->GetCharmInfo()->IsReturning();
|
||||
// }
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include "GenericActions.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "Playerbots.h"
|
||||
|
||||
bool MeleeAction::isUseful()
|
||||
@@ -39,4 +40,29 @@ bool TogglePetSpellAutoCastAction::Execute(Event event) {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PetAttackAction::Execute(Event event)
|
||||
{
|
||||
Guardian* pet = bot->GetGuardianPet();
|
||||
if (!pet) {
|
||||
return false;
|
||||
}
|
||||
Unit* target = AI_VALUE(Unit*, "current target");
|
||||
if (!target) {
|
||||
return false;
|
||||
}
|
||||
// pet->SetReactState(REACT_DEFENSIVE);
|
||||
pet->ClearUnitState(UNIT_STATE_FOLLOW);
|
||||
pet->AttackStop();
|
||||
pet->SetTarget(target->GetGUID());
|
||||
|
||||
pet->GetCharmInfo()->SetIsCommandAttack(true);
|
||||
pet->GetCharmInfo()->SetIsAtStay(false);
|
||||
pet->GetCharmInfo()->SetIsFollowing(false);
|
||||
pet->GetCharmInfo()->SetIsCommandFollow(false);
|
||||
pet->GetCharmInfo()->SetIsReturning(false);
|
||||
|
||||
pet->ToCreature()->AI()->AttackStart(target);
|
||||
return true;
|
||||
}
|
||||
@@ -25,4 +25,12 @@ public:
|
||||
virtual bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class PetAttackAction: public Action
|
||||
{
|
||||
public:
|
||||
PetAttackAction(PlayerbotAI* ai): Action(ai, "pet attack") {}
|
||||
virtual bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user