facing to & reach party member to resurrect

This commit is contained in:
Yunfan Li
2023-09-14 23:29:09 +08:00
parent 0343ac5714
commit a24e60f03d
14 changed files with 60 additions and 20 deletions

View File

@@ -504,7 +504,7 @@ AiPlayerbot.TooCloseDistance = 5.0
AiPlayerbot.MeleeDistance = 0.01
AiPlayerbot.FollowDistance = 1.5
AiPlayerbot.WhisperDistance = 6000.0
AiPlayerbot.ContactDistance = 0.01
AiPlayerbot.ContactDistance = 0.45
AiPlayerbot.AoeRadius = 10
AiPlayerbot.RpgDistance = 200
AiPlayerbot.AggroDistance = 22

View File

@@ -85,6 +85,7 @@ class ActionContext : public NamedObjectContext<Action>
creators["reach spell"] = &ActionContext::ReachSpell;
creators["reach melee"] = &ActionContext::ReachMelee;
creators["reach party member to heal"] = &ActionContext::reach_party_member_to_heal;
creators["reach party member to resurrect"] = &ActionContext::reach_party_member_to_resurrect;
creators["flee"] = &ActionContext::flee;
creators["flee with pet"] = &ActionContext::flee_with_pet;
creators["gift of the naaru"] = &ActionContext::gift_of_the_naaru;
@@ -259,6 +260,7 @@ class ActionContext : public NamedObjectContext<Action>
static Action* ReachSpell(PlayerbotAI* botAI) { return new ReachSpellAction(botAI); }
static Action* ReachMelee(PlayerbotAI* botAI) { return new ReachMeleeAction(botAI); }
static Action* reach_party_member_to_heal(PlayerbotAI* botAI) { return new ReachPartyMemberToHealAction(botAI); }
static Action* reach_party_member_to_resurrect(PlayerbotAI* botAI) { return new ReachPartyMemberToResurrectAction(botAI); }
static Action* flee(PlayerbotAI* botAI) { return new FleeAction(botAI); }
static Action* flee_with_pet(PlayerbotAI* botAI) { return new FleeWithPetAction(botAI); }
static Action* gift_of_the_naaru(PlayerbotAI* botAI) { return new CastGiftOfTheNaaruAction(botAI); }

View File

@@ -102,6 +102,10 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
context->GetValue<Unit*>("current target")->Set(target);
context->GetValue<LootObjectStack*>("available loot")->Get()->Add(guid);
/* prevent pet dead immediately in group */
if (bot->GetGroup() && !target->IsInCombat()) {
with_pet = false;
}
if (Pet* pet = bot->GetPet())
{
if (with_pet) {
@@ -118,8 +122,10 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
}
}
if (IsMovingAllowed() && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target))
bot->SetFacingToObject(target);
if (IsMovingAllowed() && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target)) {
sServerFacade->SetFacingTo(bot, target);
}
// bot->SetFacingToObject(target);
bool attacked = bot->Attack(target, true);
botAI->ChangeEngine(BOT_STATE_COMBAT);

View File

@@ -7,6 +7,7 @@
#include "Event.h"
#include "ItemUsageValue.h"
#include "Playerbots.h"
#include "ServerFacade.h"
uint32 FindLastSeparator(std::string const text, std::string const sep)
{
@@ -99,7 +100,7 @@ bool CastCustomSpellAction::Execute(Event event)
if (target != bot && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target, sPlayerbotAIConfig->sightDistance))
{
bot->SetFacingToObject(target);
sServerFacade->SetFacingTo(bot, target);
botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
msg << "cast " << text;

View File

@@ -153,7 +153,7 @@ bool CastEnchantItemAction::isPossible()
CastHealingSpellAction::CastHealingSpellAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount) : CastAuraSpellAction(botAI, spell, true), estAmount(estAmount)
{
range = botAI->GetRange("spell");
range = botAI->GetRange("heal");
}
bool CastHealingSpellAction::isUseful()
@@ -168,7 +168,7 @@ bool CastAoeHealSpellAction::isUseful()
CastCureSpellAction::CastCureSpellAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell)
{
range = botAI->GetRange("spell");
range = botAI->GetRange("heal");
}
Value<Unit*>* CurePartyMemberAction::GetTargetValue()

View File

@@ -6,6 +6,8 @@
#define _PLAYERBOT_GENERICSPELLACTIONS_H
#include "Action.h"
#include "PlayerbotAI.h"
#include "PlayerbotAIConfig.h"
#include "Value.h"
class PlayerbotAI;
@@ -150,9 +152,14 @@ class HealPartyMemberAction : public CastHealingSpellAction, public PartyMemberA
class ResurrectPartyMemberAction : public CastSpellAction
{
public:
ResurrectPartyMemberAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) { }
ResurrectPartyMemberAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) {
}
std::string const GetTargetName() override { return "party member to resurrect"; }
NextAction** getPrerequisites() override
{
return NextAction::merge( NextAction::array(0, new NextAction("reach party member to resurrect"), NULL), Action::getPrerequisites());
}
};
class CurePartyMemberAction : public CastSpellAction, public PartyMemberActionNameSupport

View File

@@ -26,8 +26,8 @@ bool DrinkAction::Execute(Event event)
if (bot->isMoving())
{
bot->StopMoving();
botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
// bot->StopMoving();
// botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
return false;
}
bot->SetStandState(UNIT_STAND_STATE_SIT);
@@ -78,8 +78,8 @@ bool EatAction::Execute(Event event)
if (bot->isMoving())
{
bot->StopMoving();
botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
// bot->StopMoving();
// botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
return false;
}

View File

@@ -45,3 +45,12 @@ std::string const ReachPartyMemberToHealAction::GetTargetName()
{
return "party member to heal";
}
ReachPartyMemberToResurrectAction::ReachPartyMemberToResurrectAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach party member to resurrect", botAI->GetRange("spell"))
{
}
std::string const ReachPartyMemberToResurrectAction::GetTargetName()
{
return "party member to resurrect";
}

View File

@@ -54,4 +54,13 @@ class ReachPartyMemberToHealAction : public ReachTargetAction
std::string const GetTargetName() override;
};
class ReachPartyMemberToResurrectAction : public ReachTargetAction
{
public:
ReachPartyMemberToResurrectAction(PlayerbotAI* botAI);
std::string const GetTargetName() override;
};
#endif

View File

@@ -74,6 +74,12 @@ bool SummonAction::Execute(Event event)
if (!master)
return false;
if (Pet* pet = bot->GetPet()) {
pet->SetReactState(REACT_PASSIVE);
pet->GetCharmInfo()->SetIsCommandFollow(true);
pet->GetCharmInfo()->IsReturning();
}
if (master->GetSession()->GetSecurity() >= SEC_PLAYER)
return Teleport(master, bot);

View File

@@ -100,5 +100,5 @@ void FrostDKStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
void FrostDKAoeStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
{
triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("howling blast", ACTION_NORMAL + 4), nullptr)));
triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("howling blast", ACTION_HIGH + 4), nullptr)));
}

View File

@@ -48,5 +48,5 @@ NextAction** CastRebirthAction::getPrerequisites()
bool CastRebirthAction::isUseful()
{
return AI_VALUE2(float, "distance", GetTargetName()) <= sPlayerbotAIConfig->spellDistance;
return CastSpellAction::isUseful() && AI_VALUE2(float, "distance", GetTargetName()) <= sPlayerbotAIConfig->spellDistance;
}

View File

@@ -234,19 +234,19 @@ class NoDrinkTrigger : public Trigger
class LightAoeTrigger : public AoeTrigger
{
public:
LightAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 2, 10.0f) { }
LightAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 2, 8.0f) { }
};
class MediumAoeTrigger : public AoeTrigger
{
public:
MediumAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 3, 10.0f) { }
MediumAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 3, 8.0f) { }
};
class HighAoeTrigger : public AoeTrigger
{
public:
HighAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 4, 10.0f) { }
HighAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 4, 8.0f) { }
};
class BuffTrigger : public SpellTrigger
@@ -523,7 +523,7 @@ class TankAssistTrigger : public NoAttackersTrigger
class IsBehindTargetTrigger : public Trigger
{
public:
IsBehindTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI) { }
IsBehindTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "behind target") { }
bool IsActive() override;
};
@@ -531,7 +531,7 @@ class IsBehindTargetTrigger : public Trigger
class IsNotBehindTargetTrigger : public Trigger
{
public:
IsNotBehindTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI) { }
IsNotBehindTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "is not behind target") { }
bool IsActive() override;
};
@@ -539,7 +539,7 @@ class IsNotBehindTargetTrigger : public Trigger
class IsNotFacingTargetTrigger : public Trigger
{
public:
IsNotFacingTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI) { }
IsNotFacingTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "not facing target") { }
bool IsActive() override;
};

View File

@@ -107,7 +107,7 @@ class TargetCriticalHealthTrigger : public TargetLowHealthTrigger
class PartyMemberDeadTrigger : public Trigger
{
public:
PartyMemberDeadTrigger(PlayerbotAI* botAI) : Trigger(botAI, "resurrect", 3) { }
PartyMemberDeadTrigger(PlayerbotAI* botAI) : Trigger(botAI, "resurrect", 1 * 1000) { }
std::string const GetTargetName() override { return "party member to resurrect"; }
bool IsActive() override;