mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-14 15:53:45 +00:00
Merge pull request #487 from liyunfan1223/flame_leviathan
Flame leviathan strategy (normal mode)
This commit is contained in:
@@ -139,6 +139,9 @@ std::vector<std::pair<uint32, std::string>> ListSpellsAction::GetSpellList(std::
|
||||
{
|
||||
if (itr->second->State == PLAYERSPELL_REMOVED || !itr->second->Active)
|
||||
continue;
|
||||
|
||||
if (!(itr->second->specMask & bot->GetActiveSpecMask()))
|
||||
continue;
|
||||
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
|
||||
if (!spellInfo)
|
||||
|
||||
@@ -197,6 +197,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
{
|
||||
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(bot);
|
||||
Unit* vehicleBase = vehicle->GetBase();
|
||||
generatePath = vehicleBase->CanFly();
|
||||
if (!vehicleBase || !seat || !seat->CanControl()) // is passenger and cant move anyway
|
||||
return false;
|
||||
|
||||
@@ -815,7 +816,6 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
||||
|
||||
if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD)) // target is moving forward, predict the position
|
||||
{
|
||||
|
||||
float needToGo = bot->GetExactDist(target) - distance;
|
||||
float timeToGo = MoveDelay(abs(needToGo)) + sPlayerbotAIConfig->reactDelay / 1000.0f;
|
||||
float targetMoveDist = timeToGo * target->GetSpeed(MOVE_RUN);
|
||||
@@ -848,7 +848,8 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
||||
return false;
|
||||
path.ShortenPathUntilDist(G3D::Vector3(tx, ty, tz), distance);
|
||||
G3D::Vector3 endPos = path.GetPath().back();
|
||||
return MoveTo(target->GetMapId(), endPos.x, endPos.y, endPos.z, false, false, false, false, MovementPriority::MOVEMENT_COMBAT);
|
||||
return MoveTo(target->GetMapId(), endPos.x, endPos.y, endPos.z, false, false, false, false,
|
||||
MovementPriority::MOVEMENT_COMBAT);
|
||||
}
|
||||
|
||||
float MovementAction::GetFollowAngle()
|
||||
@@ -881,9 +882,9 @@ bool MovementAction::IsMovingAllowed(Unit* target)
|
||||
if (bot->GetMapId() != target->GetMapId())
|
||||
return false;
|
||||
|
||||
float distance = sServerFacade->GetDistance2d(bot, target);
|
||||
if (!bot->InBattleground() && distance > sPlayerbotAIConfig->reactDistance)
|
||||
return false;
|
||||
// float distance = sServerFacade->GetDistance2d(bot, target);
|
||||
// if (!bot->InBattleground() && distance > sPlayerbotAIConfig->reactDistance)
|
||||
// return false;
|
||||
|
||||
return IsMovingAllowed();
|
||||
}
|
||||
@@ -893,9 +894,10 @@ bool MovementAction::IsMovingAllowed(uint32 mapId, float x, float y, float z)
|
||||
// removed sqrt as means distance limit was effectively 22500 (ReactDistance<63>)
|
||||
// leaving it commented incase we find ReactDistance limit causes problems
|
||||
// float distance = sqrt(bot->GetDistance(x, y, z));
|
||||
float distance = bot->GetDistance(x, y, z);
|
||||
if (!bot->InBattleground() && distance > sPlayerbotAIConfig->reactDistance)
|
||||
return false;
|
||||
|
||||
// Remove react distance limit
|
||||
// if (!bot->InBattleground())
|
||||
// return false;
|
||||
|
||||
return IsMovingAllowed();
|
||||
}
|
||||
@@ -1514,7 +1516,7 @@ bool MovementAction::MoveAway(Unit* target)
|
||||
float dz = bot->GetPositionZ();
|
||||
bool exact = true;
|
||||
if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||
bot->GetPositionZ(), dx, dy, dz))
|
||||
bot->GetPositionZ(), dx, dy, dz))
|
||||
{
|
||||
// disable prediction if position is invalid
|
||||
dx = bot->GetPositionX() + cos(angle) * sPlayerbotAIConfig->fleeDistance;
|
||||
@@ -1536,7 +1538,7 @@ bool MovementAction::MoveAway(Unit* target)
|
||||
dy = bot->GetPositionY() + sin(angle) * sPlayerbotAIConfig->fleeDistance;
|
||||
dz = bot->GetPositionZ();
|
||||
if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||
bot->GetPositionZ(), dx, dy, dz))
|
||||
bot->GetPositionZ(), dx, dy, dz))
|
||||
{
|
||||
// disable prediction if position is invalid
|
||||
dx = bot->GetPositionX() + cos(angle) * sPlayerbotAIConfig->fleeDistance;
|
||||
@@ -2401,7 +2403,8 @@ bool MoveInsideAction::Execute(Event event) { return MoveInside(bot->GetMapId(),
|
||||
bool RotateAroundTheCenterPointAction::Execute(Event event)
|
||||
{
|
||||
uint32 next_point = GetCurrWaypoint();
|
||||
if (MoveTo(bot->GetMapId(), waypoints[next_point].first, waypoints[next_point].second, bot->GetPositionZ(), false, false, false, false, MovementPriority::MOVEMENT_COMBAT))
|
||||
if (MoveTo(bot->GetMapId(), waypoints[next_point].first, waypoints[next_point].second, bot->GetPositionZ(), false,
|
||||
false, false, false, MovementPriority::MOVEMENT_COMBAT))
|
||||
{
|
||||
call_counters += 1;
|
||||
return true;
|
||||
|
||||
@@ -319,7 +319,6 @@ bool SpiritHealerAction::Execute(Event event)
|
||||
PlayerbotChatHandler ch(bot);
|
||||
bot->ResurrectPlayer(0.5f);
|
||||
bot->SpawnCorpseBones();
|
||||
bot->SaveToDB(false, false);
|
||||
context->GetValue<Unit*>("current target")->Set(nullptr);
|
||||
bot->SetTarget();
|
||||
botAI->TellMaster("Hello");
|
||||
|
||||
@@ -175,6 +175,12 @@ bool SummonAction::Teleport(Player* summoner, Player* player)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (player->GetVehicle())
|
||||
{
|
||||
botAI->TellError("You cannot summon me while I'm on a vehicle");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!summoner->IsBeingTeleported() && !player->IsBeingTeleported())
|
||||
{
|
||||
float followAngle = GetFollowAngle();
|
||||
@@ -222,6 +228,7 @@ bool SummonAction::Teleport(Player* summoner, Player* player)
|
||||
}
|
||||
|
||||
player->GetMotionMaster()->Clear();
|
||||
AI_VALUE(LastMovement&, "last movement").clear();
|
||||
player->TeleportTo(mapId, x, y, z, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,11 @@
|
||||
|
||||
#include "BattlegroundIC.h"
|
||||
#include "ItemVisitors.h"
|
||||
#include "ObjectDefines.h"
|
||||
#include "Playerbots.h"
|
||||
#include "QuestValues.h"
|
||||
#include "ServerFacade.h"
|
||||
#include "Unit.h"
|
||||
#include "Vehicle.h"
|
||||
|
||||
// TODO methods to enter/exit vehicle should be added to BGTactics or MovementAction (so that we can better control
|
||||
@@ -20,6 +23,21 @@ bool EnterVehicleAction::Execute(Event event)
|
||||
// do not switch vehicles yet
|
||||
if (bot->GetVehicle())
|
||||
return false;
|
||||
|
||||
Player* master = botAI->GetMaster();
|
||||
// Triggered by a chat command
|
||||
if (event.getOwner() && master && master->GetTarget())
|
||||
{
|
||||
Unit* vehicleBase = botAI->GetUnit(master->GetTarget());
|
||||
if (!vehicleBase)
|
||||
return false;
|
||||
Vehicle* veh = vehicleBase->GetVehicleKit();
|
||||
if (vehicleBase->IsVehicle() && veh && veh->GetAvailableSeatCount())
|
||||
{
|
||||
return EnterVehicle(vehicleBase, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
GuidVector npcs = AI_VALUE(GuidVector, "nearest vehicles");
|
||||
for (GuidVector::iterator i = npcs.begin(); i != npcs.end(); i++)
|
||||
@@ -27,6 +45,9 @@ bool EnterVehicleAction::Execute(Event event)
|
||||
Unit* vehicleBase = botAI->GetUnit(*i);
|
||||
if (!vehicleBase)
|
||||
continue;
|
||||
|
||||
if (vehicleBase->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE))
|
||||
continue;
|
||||
|
||||
// dont let them get in the cannons as they'll stay forever and do nothing useful
|
||||
// dont let them in catapult they cant use them at all
|
||||
@@ -44,27 +65,36 @@ bool EnterVehicleAction::Execute(Event event)
|
||||
if (vehicleBase->GetVehicleKit()->IsVehicleInUse())
|
||||
continue;
|
||||
|
||||
float dist = sServerFacade->GetDistance2d(bot, vehicleBase);
|
||||
if (dist > 40.0f)
|
||||
continue;
|
||||
|
||||
if (dist > INTERACTION_DISTANCE)
|
||||
return MoveTo(vehicleBase);
|
||||
|
||||
bot->EnterVehicle(vehicleBase);
|
||||
|
||||
if (!bot->IsOnVehicle(vehicleBase))
|
||||
return false;
|
||||
|
||||
// dismount because bots can enter vehicle on mount
|
||||
WorldPacket emptyPacket;
|
||||
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
|
||||
return true;
|
||||
if (EnterVehicle(vehicleBase, true))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EnterVehicleAction::EnterVehicle(Unit* vehicleBase, bool moveIfFar)
|
||||
{
|
||||
float dist = sServerFacade->GetDistance2d(bot, vehicleBase);
|
||||
if (dist > 40.0f)
|
||||
return false;
|
||||
|
||||
if (dist > INTERACTION_DISTANCE && !moveIfFar)
|
||||
return false;
|
||||
|
||||
if (dist > INTERACTION_DISTANCE)
|
||||
return MoveTo(vehicleBase);
|
||||
// Use HandleSpellClick instead of Unit::EnterVehicle to handle special vehicle script (ulduar)
|
||||
vehicleBase->HandleSpellClick(bot);
|
||||
|
||||
if (!bot->IsOnVehicle(vehicleBase))
|
||||
return false;
|
||||
|
||||
// dismount because bots can enter vehicle on mount
|
||||
WorldPacket emptyPacket;
|
||||
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LeaveVehicleAction::Execute(Event event)
|
||||
{
|
||||
Vehicle* myVehicle = bot->GetVehicle();
|
||||
|
||||
@@ -17,6 +17,8 @@ public:
|
||||
EnterVehicleAction(PlayerbotAI* botAI, std::string const& name = "enter vehicle") : MovementAction(botAI, name) {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
protected:
|
||||
bool EnterVehicle(Unit* vehicleBase, bool moveIfFar);
|
||||
};
|
||||
|
||||
class LeaveVehicleAction : public MovementAction
|
||||
|
||||
Reference in New Issue
Block a user