mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
auto-format
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "Corpse.h"
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "FleeManager.h"
|
#include "FleeManager.h"
|
||||||
#include "G3D/Vector3.h"
|
#include "G3D/Vector3.h"
|
||||||
@@ -41,7 +42,6 @@
|
|||||||
#include "Unit.h"
|
#include "Unit.h"
|
||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
#include "WaypointMovementGenerator.h"
|
#include "WaypointMovementGenerator.h"
|
||||||
#include "Corpse.h"
|
|
||||||
|
|
||||||
MovementAction::MovementAction(PlayerbotAI* botAI, std::string const name) : Action(botAI, name)
|
MovementAction::MovementAction(PlayerbotAI* botAI, std::string const name) : Action(botAI, name)
|
||||||
{
|
{
|
||||||
@@ -852,15 +852,16 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
|||||||
|
|
||||||
float deltaAngle = Position::NormalizeOrientation(targetOrientation - target->GetAngle(bot));
|
float deltaAngle = Position::NormalizeOrientation(targetOrientation - target->GetAngle(bot));
|
||||||
if (deltaAngle > M_PI)
|
if (deltaAngle > M_PI)
|
||||||
deltaAngle -= 2.0f * M_PI; // -PI..PI
|
deltaAngle -= 2.0f * M_PI; // -PI..PI
|
||||||
// if target is moving forward and moving far away, predict the position
|
// if target is moving forward and moving far away, predict the position
|
||||||
bool behind = fabs(deltaAngle) > M_PI_2;
|
bool behind = fabs(deltaAngle) > M_PI_2;
|
||||||
if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD) && behind) {
|
if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD) && behind)
|
||||||
|
{
|
||||||
float predictDis = std::min(3.0f, target->GetObjectSize() * 2);
|
float predictDis = std::min(3.0f, target->GetObjectSize() * 2);
|
||||||
tx += cos(target->GetOrientation()) * predictDis;
|
tx += cos(target->GetOrientation()) * predictDis;
|
||||||
ty += sin(target->GetOrientation()) * predictDis;
|
ty += sin(target->GetOrientation()) * predictDis;
|
||||||
if (!target->GetMap()->CheckCollisionAndGetValidCoords(target, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),
|
if (!target->GetMap()->CheckCollisionAndGetValidCoords(target, target->GetPositionX(), target->GetPositionY(),
|
||||||
tx, ty, tz))
|
target->GetPositionZ(), tx, ty, tz))
|
||||||
{
|
{
|
||||||
tx = target->GetPositionX();
|
tx = target->GetPositionX();
|
||||||
ty = target->GetPositionY();
|
ty = target->GetPositionY();
|
||||||
@@ -978,9 +979,8 @@ bool MovementAction::IsMovingAllowed()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (bot->isFrozen() || bot->IsPolymorphed() || (bot->isDead() && !bot->HasPlayerFlag(PLAYER_FLAGS_GHOST)) ||
|
if (bot->isFrozen() || bot->IsPolymorphed() || (bot->isDead() && !bot->HasPlayerFlag(PLAYER_FLAGS_GHOST)) ||
|
||||||
bot->IsBeingTeleported() || bot->HasRootAura() || bot->HasSpiritOfRedemptionAura() ||
|
bot->IsBeingTeleported() || bot->HasRootAura() || bot->HasSpiritOfRedemptionAura() || bot->HasConfuseAura() ||
|
||||||
bot->HasConfuseAura() || bot->IsCharmed() || bot->HasStunAura() ||
|
bot->IsCharmed() || bot->HasStunAura() || bot->IsInFlight() || bot->HasUnitState(UNIT_STATE_LOST_CONTROL))
|
||||||
bot->IsInFlight() || bot->HasUnitState(UNIT_STATE_LOST_CONTROL))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (bot->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) != NULL_MOTION_TYPE)
|
if (bot->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) != NULL_MOTION_TYPE)
|
||||||
@@ -1012,7 +1012,8 @@ void MovementAction::UpdateMovementState()
|
|||||||
bool onGround = bot->GetPositionZ() <
|
bool onGround = bot->GetPositionZ() <
|
||||||
bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()) + 1.0f;
|
bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()) + 1.0f;
|
||||||
|
|
||||||
// Keep bot->SendMovementFlagUpdate() withing the if statements to not intefere with bot behavior on ground/(shallow) waters
|
// Keep bot->SendMovementFlagUpdate() withing the if statements to not intefere with bot behavior on
|
||||||
|
// ground/(shallow) waters
|
||||||
if (!bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) &&
|
if (!bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) &&
|
||||||
bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !onGround)
|
bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !onGround)
|
||||||
{
|
{
|
||||||
@@ -1021,7 +1022,7 @@ void MovementAction::UpdateMovementState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) &&
|
else if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) &&
|
||||||
(!bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || onGround))
|
(!bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || onGround))
|
||||||
{
|
{
|
||||||
bot->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
|
bot->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
|
||||||
bot->SendMovementFlagUpdate();
|
bot->SendMovementFlagUpdate();
|
||||||
@@ -1341,7 +1342,7 @@ float MovementAction::MoveDelay(float distance, bool backwards)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
speed = backwards ? bot->GetSpeed(MOVE_RUN_BACK) :bot->GetSpeed(MOVE_RUN);
|
speed = backwards ? bot->GetSpeed(MOVE_RUN_BACK) : bot->GetSpeed(MOVE_RUN);
|
||||||
}
|
}
|
||||||
float delay = distance / speed;
|
float delay = distance / speed;
|
||||||
return delay;
|
return delay;
|
||||||
@@ -1371,8 +1372,7 @@ void MovementAction::SetNextMovementDelay(float delayMillis)
|
|||||||
{
|
{
|
||||||
AI_VALUE(LastMovement&, "last movement")
|
AI_VALUE(LastMovement&, "last movement")
|
||||||
.Set(bot->GetMapId(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), bot->GetOrientation(),
|
.Set(bot->GetMapId(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), bot->GetOrientation(),
|
||||||
delayMillis,
|
delayMillis, MovementPriority::MOVEMENT_FORCED);
|
||||||
MovementPriority::MOVEMENT_FORCED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MovementAction::Flee(Unit* target)
|
bool MovementAction::Flee(Unit* target)
|
||||||
@@ -1586,7 +1586,8 @@ bool MovementAction::MoveAway(Unit* target, float distance, bool backwards)
|
|||||||
dz = bot->GetPositionZ();
|
dz = bot->GetPositionZ();
|
||||||
exact = false;
|
exact = false;
|
||||||
}
|
}
|
||||||
if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true, exact, MovementPriority::MOVEMENT_COMBAT, false, backwards))
|
if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true, exact, MovementPriority::MOVEMENT_COMBAT, false,
|
||||||
|
backwards))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1608,7 +1609,8 @@ bool MovementAction::MoveAway(Unit* target, float distance, bool backwards)
|
|||||||
dz = bot->GetPositionZ();
|
dz = bot->GetPositionZ();
|
||||||
exact = false;
|
exact = false;
|
||||||
}
|
}
|
||||||
if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true, exact, MovementPriority::MOVEMENT_COMBAT, false, backwards))
|
if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true, exact, MovementPriority::MOVEMENT_COMBAT, false,
|
||||||
|
backwards))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1657,7 +1659,7 @@ bool MovementAction::Move(float angle, float distance)
|
|||||||
float x = bot->GetPositionX() + cos(angle) * distance;
|
float x = bot->GetPositionX() + cos(angle) * distance;
|
||||||
float y = bot->GetPositionY() + sin(angle) * distance;
|
float y = bot->GetPositionY() + sin(angle) * distance;
|
||||||
|
|
||||||
//TODO do we need GetMapWaterOrGroundLevel() if we're using CheckCollisionAndGetValidCoords() ?
|
// TODO do we need GetMapWaterOrGroundLevel() if we're using CheckCollisionAndGetValidCoords() ?
|
||||||
float z = bot->GetMapWaterOrGroundLevel(x, y, bot->GetPositionZ());
|
float z = bot->GetMapWaterOrGroundLevel(x, y, bot->GetPositionZ());
|
||||||
if (z == -100000.0f || z == -200000.0f)
|
if (z == -100000.0f || z == -200000.0f)
|
||||||
z = bot->GetPositionZ();
|
z = bot->GetPositionZ();
|
||||||
@@ -1881,7 +1883,8 @@ bool AvoidAoeAction::AvoidAuraWithDynamicObj()
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (sPlayerbotAIConfig->aoeAvoidSpellWhitelist.find(spellInfo->Id) != sPlayerbotAIConfig->aoeAvoidSpellWhitelist.end())
|
if (sPlayerbotAIConfig->aoeAvoidSpellWhitelist.find(spellInfo->Id) !=
|
||||||
|
sPlayerbotAIConfig->aoeAvoidSpellWhitelist.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DynamicObject* dynOwner = aura->GetDynobjOwner();
|
DynamicObject* dynOwner = aura->GetDynobjOwner();
|
||||||
@@ -1946,7 +1949,8 @@ bool AvoidAoeAction::AvoidGameObjectWithDamage()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sPlayerbotAIConfig->aoeAvoidSpellWhitelist.find(spellId) != sPlayerbotAIConfig->aoeAvoidSpellWhitelist.end())
|
if (sPlayerbotAIConfig->aoeAvoidSpellWhitelist.find(spellId) !=
|
||||||
|
sPlayerbotAIConfig->aoeAvoidSpellWhitelist.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||||
@@ -1972,7 +1976,8 @@ bool AvoidAoeAction::AvoidGameObjectWithDamage()
|
|||||||
lastTellTimer = time(NULL);
|
lastTellTimer = time(NULL);
|
||||||
lastMoveTimer = getMSTime();
|
lastMoveTimer = getMSTime();
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "I'm avoiding " << name.str() << " (" << spellInfo->Id << ")" << " Radius " << radius << " - [Trap]";
|
out << "I'm avoiding " << name.str() << " (" << spellInfo->Id << ")" << " Radius " << radius
|
||||||
|
<< " - [Trap]";
|
||||||
bot->Say(out.str(), LANG_UNIVERSAL);
|
bot->Say(out.str(), LANG_UNIVERSAL);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -2015,7 +2020,8 @@ bool AvoidAoeAction::AvoidUnitWithDamageAura()
|
|||||||
sSpellMgr->GetSpellInfo(spellInfo->Effects[aurEff->GetEffIndex()].TriggerSpell);
|
sSpellMgr->GetSpellInfo(spellInfo->Effects[aurEff->GetEffIndex()].TriggerSpell);
|
||||||
if (!triggerSpellInfo)
|
if (!triggerSpellInfo)
|
||||||
continue;
|
continue;
|
||||||
if (sPlayerbotAIConfig->aoeAvoidSpellWhitelist.find(triggerSpellInfo->Id) != sPlayerbotAIConfig->aoeAvoidSpellWhitelist.end())
|
if (sPlayerbotAIConfig->aoeAvoidSpellWhitelist.find(triggerSpellInfo->Id) !=
|
||||||
|
sPlayerbotAIConfig->aoeAvoidSpellWhitelist.end())
|
||||||
return false;
|
return false;
|
||||||
for (int j = 0; j < MAX_SPELL_EFFECTS; j++)
|
for (int j = 0; j < MAX_SPELL_EFFECTS; j++)
|
||||||
{
|
{
|
||||||
@@ -2037,7 +2043,8 @@ bool AvoidAoeAction::AvoidUnitWithDamageAura()
|
|||||||
lastTellTimer = time(NULL);
|
lastTellTimer = time(NULL);
|
||||||
lastMoveTimer = getMSTime();
|
lastMoveTimer = getMSTime();
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "I'm avoiding " << name.str() << " (" << triggerSpellInfo->Id << ")" << " Radius " << radius << " - [Unit Trigger]";
|
out << "I'm avoiding " << name.str() << " (" << triggerSpellInfo->Id << ")"
|
||||||
|
<< " Radius " << radius << " - [Unit Trigger]";
|
||||||
bot->Say(out.str(), LANG_UNIVERSAL);
|
bot->Say(out.str(), LANG_UNIVERSAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2056,7 +2063,8 @@ Position MovementAction::BestPositionForMeleeToFlee(Position pos, float radius)
|
|||||||
if (currentTarget)
|
if (currentTarget)
|
||||||
{
|
{
|
||||||
// Normally, move to left or right is the best position
|
// Normally, move to left or right is the best position
|
||||||
bool isTanking = (!currentTarget->isFrozen() && !currentTarget->HasRootAura()) && (currentTarget->GetVictim() == bot);
|
bool isTanking =
|
||||||
|
(!currentTarget->isFrozen() && !currentTarget->HasRootAura()) && (currentTarget->GetVictim() == bot);
|
||||||
float angle = bot->GetAngle(currentTarget);
|
float angle = bot->GetAngle(currentTarget);
|
||||||
float angleLeft = angle + (float)M_PI / 2;
|
float angleLeft = angle + (float)M_PI / 2;
|
||||||
float angleRight = angle - (float)M_PI / 2;
|
float angleRight = angle - (float)M_PI / 2;
|
||||||
@@ -2271,8 +2279,7 @@ bool CombatFormationMoveAction::isUseful()
|
|||||||
bool CombatFormationMoveAction::Execute(Event event)
|
bool CombatFormationMoveAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
float dis = AI_VALUE(float, "disperse distance");
|
float dis = AI_VALUE(float, "disperse distance");
|
||||||
if (dis <= 0.0f ||
|
if (dis <= 0.0f || (!bot->IsInCombat() && botAI->HasStrategy("stay", BotState::BOT_STATE_NON_COMBAT)) ||
|
||||||
(!bot->IsInCombat() && botAI->HasStrategy("stay", BotState::BOT_STATE_NON_COMBAT)) ||
|
|
||||||
(bot->IsInCombat() && botAI->HasStrategy("stay", BotState::BOT_STATE_COMBAT)))
|
(bot->IsInCombat() && botAI->HasStrategy("stay", BotState::BOT_STATE_COMBAT)))
|
||||||
return false;
|
return false;
|
||||||
Player* playerToLeave = NearestGroupMember(dis);
|
Player* playerToLeave = NearestGroupMember(dis);
|
||||||
@@ -2422,7 +2429,7 @@ bool TankFaceAction::Execute(Event event)
|
|||||||
|
|
||||||
float deltaAngle = Position::NormalizeOrientation(averageAngle - target->GetAngle(bot));
|
float deltaAngle = Position::NormalizeOrientation(averageAngle - target->GetAngle(bot));
|
||||||
if (deltaAngle > M_PI)
|
if (deltaAngle > M_PI)
|
||||||
deltaAngle -= 2.0f * M_PI; // -PI..PI
|
deltaAngle -= 2.0f * M_PI; // -PI..PI
|
||||||
|
|
||||||
float tolerable = M_PI_2;
|
float tolerable = M_PI_2;
|
||||||
|
|
||||||
@@ -2433,12 +2440,13 @@ bool TankFaceAction::Execute(Event event)
|
|||||||
float goodAngle2 = Position::NormalizeOrientation(averageAngle - M_PI * 3 / 5);
|
float goodAngle2 = Position::NormalizeOrientation(averageAngle - M_PI * 3 / 5);
|
||||||
|
|
||||||
// if dist < bot->GetMeleeRange(target) / 2, target will move backward
|
// if dist < bot->GetMeleeRange(target) / 2, target will move backward
|
||||||
float dist = std::max(bot->GetExactDist(target), bot->GetMeleeRange(target) / 2) - bot->GetCombatReach() - target->GetCombatReach();
|
float dist = std::max(bot->GetExactDist(target), bot->GetMeleeRange(target) / 2) - bot->GetCombatReach() -
|
||||||
|
target->GetCombatReach();
|
||||||
std::vector<Position> availablePos;
|
std::vector<Position> availablePos;
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle1);
|
target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle1);
|
||||||
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(),
|
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||||
x, y, z))
|
bot->GetPositionZ(), x, y, z))
|
||||||
{
|
{
|
||||||
/// @todo: movement control now is a mess, prepare to rewrite
|
/// @todo: movement control now is a mess, prepare to rewrite
|
||||||
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
|
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
|
||||||
@@ -2450,8 +2458,8 @@ bool TankFaceAction::Execute(Event event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle2);
|
target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle2);
|
||||||
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(),
|
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||||
x, y, z))
|
bot->GetPositionZ(), x, y, z))
|
||||||
{
|
{
|
||||||
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
|
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
|
||||||
Position pos(x, y, z);
|
Position pos(x, y, z);
|
||||||
@@ -2464,13 +2472,17 @@ bool TankFaceAction::Execute(Event event)
|
|||||||
if (availablePos.empty())
|
if (availablePos.empty())
|
||||||
return false;
|
return false;
|
||||||
Position nearest = GetNearestPosition(availablePos);
|
Position nearest = GetNearestPosition(availablePos);
|
||||||
return MoveTo(bot->GetMapId(), nearest.GetPositionX(), nearest.GetPositionY(), nearest.GetPositionZ(), false, false, false, true, MovementPriority::MOVEMENT_COMBAT);
|
return MoveTo(bot->GetMapId(), nearest.GetPositionX(), nearest.GetPositionY(), nearest.GetPositionZ(), false, false,
|
||||||
|
false, true, MovementPriority::MOVEMENT_COMBAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RearFlankAction::isUseful()
|
bool RearFlankAction::isUseful()
|
||||||
{
|
{
|
||||||
Unit* target = AI_VALUE(Unit*, "current target");
|
Unit* target = AI_VALUE(Unit*, "current target");
|
||||||
if (!target) { return false; }
|
if (!target)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Need to double the front angle check to account for mirrored angle.
|
// Need to double the front angle check to account for mirrored angle.
|
||||||
bool inFront = target->HasInArc(2.f * minAngle, bot);
|
bool inFront = target->HasInArc(2.f * minAngle, bot);
|
||||||
@@ -2484,7 +2496,10 @@ bool RearFlankAction::isUseful()
|
|||||||
bool RearFlankAction::Execute(Event event)
|
bool RearFlankAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
Unit* target = AI_VALUE(Unit*, "current target");
|
Unit* target = AI_VALUE(Unit*, "current target");
|
||||||
if (!target) { return false; }
|
if (!target)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
float angle = frand(minAngle, maxAngle);
|
float angle = frand(minAngle, maxAngle);
|
||||||
float baseDistance = bot->GetMeleeRange(target) * 0.5f;
|
float baseDistance = bot->GetMeleeRange(target) * 0.5f;
|
||||||
@@ -2503,8 +2518,8 @@ bool RearFlankAction::Execute(Event event)
|
|||||||
destination = &rightFlank;
|
destination = &rightFlank;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MoveTo(bot->GetMapId(), destination->GetPositionX(), destination->GetPositionY(), destination->GetPositionZ(),
|
return MoveTo(bot->GetMapId(), destination->GetPositionX(), destination->GetPositionY(),
|
||||||
false, false, false, true, MovementPriority::MOVEMENT_COMBAT);
|
destination->GetPositionZ(), false, false, false, true, MovementPriority::MOVEMENT_COMBAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DisperseSetAction::Execute(Event event)
|
bool DisperseSetAction::Execute(Event event)
|
||||||
@@ -2632,9 +2647,8 @@ bool SetFacingTargetAction::isUseful() { return !AI_VALUE2(bool, "facing", "curr
|
|||||||
bool SetFacingTargetAction::isPossible()
|
bool SetFacingTargetAction::isPossible()
|
||||||
{
|
{
|
||||||
if (bot->isFrozen() || bot->IsPolymorphed() || (bot->isDead() && !bot->HasPlayerFlag(PLAYER_FLAGS_GHOST)) ||
|
if (bot->isFrozen() || bot->IsPolymorphed() || (bot->isDead() && !bot->HasPlayerFlag(PLAYER_FLAGS_GHOST)) ||
|
||||||
bot->IsBeingTeleported() || bot->HasConfuseAura() || bot->IsCharmed() ||
|
bot->IsBeingTeleported() || bot->HasConfuseAura() || bot->IsCharmed() || bot->HasStunAura() ||
|
||||||
bot->HasStunAura() || bot->IsInFlight() ||
|
bot->IsInFlight() || bot->HasUnitState(UNIT_STATE_LOST_CONTROL))
|
||||||
bot->HasUnitState(UNIT_STATE_LOST_CONTROL))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -2654,7 +2668,7 @@ bool SetBehindTargetAction::Execute(Event event)
|
|||||||
|
|
||||||
float deltaAngle = Position::NormalizeOrientation(target->GetOrientation() - target->GetAngle(bot));
|
float deltaAngle = Position::NormalizeOrientation(target->GetOrientation() - target->GetAngle(bot));
|
||||||
if (deltaAngle > M_PI)
|
if (deltaAngle > M_PI)
|
||||||
deltaAngle -= 2.0f * M_PI; // -PI..PI
|
deltaAngle -= 2.0f * M_PI; // -PI..PI
|
||||||
|
|
||||||
float tolerable = M_PI_2;
|
float tolerable = M_PI_2;
|
||||||
|
|
||||||
@@ -2664,12 +2678,13 @@ bool SetBehindTargetAction::Execute(Event event)
|
|||||||
float goodAngle1 = Position::NormalizeOrientation(target->GetOrientation() + M_PI * 3 / 5);
|
float goodAngle1 = Position::NormalizeOrientation(target->GetOrientation() + M_PI * 3 / 5);
|
||||||
float goodAngle2 = Position::NormalizeOrientation(target->GetOrientation() - M_PI * 3 / 5);
|
float goodAngle2 = Position::NormalizeOrientation(target->GetOrientation() - M_PI * 3 / 5);
|
||||||
|
|
||||||
float dist = std::max(bot->GetExactDist(target), bot->GetMeleeRange(target) / 2) - bot->GetCombatReach() - target->GetCombatReach();
|
float dist = std::max(bot->GetExactDist(target), bot->GetMeleeRange(target) / 2) - bot->GetCombatReach() -
|
||||||
|
target->GetCombatReach();
|
||||||
std::vector<Position> availablePos;
|
std::vector<Position> availablePos;
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle1);
|
target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle1);
|
||||||
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(),
|
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||||
x, y, z))
|
bot->GetPositionZ(), x, y, z))
|
||||||
{
|
{
|
||||||
/// @todo: movement control now is a mess, prepare to rewrite
|
/// @todo: movement control now is a mess, prepare to rewrite
|
||||||
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
|
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
|
||||||
@@ -2681,8 +2696,8 @@ bool SetBehindTargetAction::Execute(Event event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle2);
|
target->GetNearPoint(bot, x, y, z, 0.0f, dist, goodAngle2);
|
||||||
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(),
|
if (bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||||
x, y, z))
|
bot->GetPositionZ(), x, y, z))
|
||||||
{
|
{
|
||||||
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
|
std::list<FleeInfo>& infoList = AI_VALUE(std::list<FleeInfo>&, "recently flee info");
|
||||||
Position pos(x, y, z);
|
Position pos(x, y, z);
|
||||||
@@ -2695,7 +2710,8 @@ bool SetBehindTargetAction::Execute(Event event)
|
|||||||
if (availablePos.empty())
|
if (availablePos.empty())
|
||||||
return false;
|
return false;
|
||||||
Position nearest = GetNearestPosition(availablePos);
|
Position nearest = GetNearestPosition(availablePos);
|
||||||
return MoveTo(bot->GetMapId(), nearest.GetPositionX(), nearest.GetPositionY(), nearest.GetPositionZ(), false, false, false, true, MovementPriority::MOVEMENT_COMBAT);
|
return MoveTo(bot->GetMapId(), nearest.GetPositionX(), nearest.GetPositionY(), nearest.GetPositionZ(), false, false,
|
||||||
|
false, true, MovementPriority::MOVEMENT_COMBAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveOutOfCollisionAction::Execute(Event event)
|
bool MoveOutOfCollisionAction::Execute(Event event)
|
||||||
@@ -2766,7 +2782,7 @@ bool MoveFromGroupAction::Execute(Event event)
|
|||||||
{
|
{
|
||||||
float distance = atoi(event.getParam().c_str());
|
float distance = atoi(event.getParam().c_str());
|
||||||
if (!distance)
|
if (!distance)
|
||||||
distance = 20.0f; // flee distance from config is too small for this
|
distance = 20.0f; // flee distance from config is too small for this
|
||||||
return MoveFromGroup(distance);
|
return MoveFromGroup(distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2849,10 +2865,7 @@ bool MoveAwayFromCreatureAction::Execute(Event event)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveAwayFromCreatureAction::isPossible()
|
bool MoveAwayFromCreatureAction::isPossible() { return bot->CanFreeMove(); }
|
||||||
{
|
|
||||||
return bot->CanFreeMove();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MoveAwayFromPlayerWithDebuffAction::Execute(Event event)
|
bool MoveAwayFromPlayerWithDebuffAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
@@ -2939,7 +2952,4 @@ bool MoveAwayFromPlayerWithDebuffAction::Execute(Event event)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveAwayFromPlayerWithDebuffAction::isPossible()
|
bool MoveAwayFromPlayerWithDebuffAction::isPossible() { return bot->CanFreeMove(); }
|
||||||
{
|
|
||||||
return bot->CanFreeMove();
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user