distance and reach related

This commit is contained in:
Yunfan Li
2023-05-30 17:10:22 +08:00
parent 0fa640959f
commit ffb0b260d3
3 changed files with 9 additions and 28 deletions

View File

@@ -10,27 +10,7 @@
bool ReachTargetAction::Execute(Event event) bool ReachTargetAction::Execute(Event event)
{ {
Unit* target = AI_VALUE(Unit*, GetTargetName()); return MoveTo(AI_VALUE(Unit*, GetTargetName()), distance);
if (!target)
return false;
UpdateMovementState();
float combatReach = bot->GetCombatReach() + target->GetCombatReach() + 4.0f / 3.0f;
if (distance < std::max(5.0f, combatReach))
{
// return MoveTo(target, 0.0f);
return ChaseTo(target, 0.0f, bot->GetAngle(target));
}
else
{
combatReach = bot->GetCombatReach() + target->GetCombatReach();
bool inLos = bot->IsWithinLOSInMap(target);
bool isFriend = bot->IsFriendlyTo(target);
float chaseDist = inLos ? distance : isFriend ? distance / 2 : distance;
return ChaseTo(target, chaseDist - sPlayerbotAIConfig->contactDistance, bot->GetAngle(target));
// return MoveTo(target, chaseDist - sPlayerbotAIConfig->contactDistance);
}
} }
bool ReachTargetAction::isUseful() bool ReachTargetAction::isUseful()
@@ -39,8 +19,7 @@ bool ReachTargetAction::isUseful()
if (bot->IsNonMeleeSpellCast(true)) if (bot->IsNonMeleeSpellCast(true))
return false; return false;
Unit* target = AI_VALUE(Unit*, GetTargetName()); return AI_VALUE2(float, "distance", GetTargetName()) > (distance + sPlayerbotAIConfig->contactDistance);
return target && (!bot->IsWithinDistInMap(target, distance) || (bot->IsWithinDistInMap(target, distance) && !bot->IsWithinLOSInMap(target)));
} }
std::string const ReachTargetAction::GetTargetName() std::string const ReachTargetAction::GetTargetName()
@@ -57,7 +36,7 @@ ReachSpellAction::ReachSpellAction(PlayerbotAI* botAI) : ReachTargetAction(botAI
{ {
} }
ReachPartyMemberToHealAction::ReachPartyMemberToHealAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach party member to heal", botAI->GetRange("heal")) ReachPartyMemberToHealAction::ReachPartyMemberToHealAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach party member to heal", botAI->GetRange("spell"))
{ {
} }

View File

@@ -166,7 +166,7 @@ bool PartyMemberToHealOutOfSpellRangeTrigger::IsActive()
} }
PartyMemberToHealOutOfSpellRangeTrigger::PartyMemberToHealOutOfSpellRangeTrigger(PlayerbotAI* botAI) : PartyMemberToHealOutOfSpellRangeTrigger::PartyMemberToHealOutOfSpellRangeTrigger(PlayerbotAI* botAI) :
OutOfRangeTrigger(botAI, "party member to heal out of spell range", botAI->GetRange("heal")) OutOfRangeTrigger(botAI, "party member to heal out of spell range", botAI->GetRange("spell"))
{ {
} }

View File

@@ -61,9 +61,11 @@ float DistanceValue::Calculate()
} }
else if (qualifier == "current target") else if (qualifier == "current target")
{ {
Stance* stance = AI_VALUE(Stance*, "stance"); Unit* target = AI_VALUE(Unit*, qualifier);
WorldLocation loc = stance->GetLocation(); if (!target || !target->IsInWorld())
return sServerFacade->GetDistance2d(botAI->GetBot(), loc.GetPositionX(), loc.GetPositionY()); return 0.0f;
return bot->GetDistance2d(target);
} }
else else
{ {