mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-13 09:07:19 +00:00
Merge pull request #491 from liyunfan1223/dev_0825
Circle formation crash fix
This commit is contained in:
@@ -538,7 +538,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
|
||||
{
|
||||
LOG_INFO("playerbots", "Waiting for {} characters loading into database...", bot_creation);
|
||||
/* wait for characters load into database, or characters will fail to loggin */
|
||||
std::this_thread::sleep_for(10s);
|
||||
std::this_thread::sleep_for(5s + bot_creation * 5ms);
|
||||
}
|
||||
|
||||
for (WorldSession* session : sessionBots)
|
||||
|
||||
@@ -65,10 +65,10 @@ void AutoMaintenanceOnLevelupAction::AutoLearnSpell()
|
||||
void AutoMaintenanceOnLevelupAction::LearnSpells(std::ostringstream* out)
|
||||
{
|
||||
BroadcastHelper::BroadcastLevelup(botAI, bot);
|
||||
if (sPlayerbotAIConfig->autoLearnTrainerSpells)
|
||||
if (sPlayerbotAIConfig->autoLearnTrainerSpells && sRandomPlayerbotMgr->IsRandomBot(bot))
|
||||
LearnTrainerSpells(out);
|
||||
|
||||
if (sPlayerbotAIConfig->autoLearnQuestSpells)
|
||||
if (sPlayerbotAIConfig->autoLearnQuestSpells && sRandomPlayerbotMgr->IsRandomBot(bot))
|
||||
LearnQuestSpells(out);
|
||||
}
|
||||
|
||||
|
||||
@@ -212,6 +212,9 @@ bool LfgAcceptAction::Execute(Event event)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.getPacket().empty())
|
||||
return false;
|
||||
|
||||
WorldPacket p(event.getPacket());
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ bool XpGainAction::Execute(Event event)
|
||||
{
|
||||
context->GetValue<uint32>("death count")->Set(0);
|
||||
|
||||
if (!sRandomPlayerbotMgr->IsRandomBot(bot) || sPlayerbotAIConfig->playerbotsXPrate == 1)
|
||||
return true;
|
||||
|
||||
WorldPacket p(event.getPacket()); // (8+4+1+4+8)
|
||||
ObjectGuid guid;
|
||||
@@ -42,6 +40,9 @@ bool XpGainAction::Execute(Event event)
|
||||
BroadcastHelper::BroadcastKill(botAI, bot, creature);
|
||||
}
|
||||
|
||||
if (!sRandomPlayerbotMgr->IsRandomBot(bot) || sPlayerbotAIConfig->playerbotsXPrate == 1)
|
||||
return true;
|
||||
|
||||
Unit* victim = nullptr;
|
||||
if (guid)
|
||||
victim = botAI->GetUnit(guid);
|
||||
|
||||
@@ -47,15 +47,15 @@ bool FlameLeviathanVehicleAction::Execute(Event event)
|
||||
if (unit->GetEntry() == 33142) // Leviathan Defense Turret
|
||||
continue;
|
||||
if (unit->GetEntry() == 33113) // Flame Leviathan
|
||||
{
|
||||
flame = unit;
|
||||
continue;
|
||||
}
|
||||
if (!target || bot->GetExactDist(target) > bot->GetExactDist(unit))
|
||||
{
|
||||
target = unit;
|
||||
}
|
||||
}
|
||||
if (!target)
|
||||
return false;
|
||||
|
||||
// Flame Leviathan is chasing me
|
||||
if (flame && flame->GetVictim() == vehicleBase_)
|
||||
if (MoveAvoidChasing(flame))
|
||||
@@ -65,15 +65,15 @@ bool FlameLeviathanVehicleAction::Execute(Event event)
|
||||
switch (entry)
|
||||
{
|
||||
case NPC_SALVAGED_DEMOLISHER:
|
||||
return DemolisherAction(target);
|
||||
return DemolisherAction(flame ? flame : target);
|
||||
case NPC_SALVAGED_DEMOLISHER_TURRET:
|
||||
return DemolisherTurretAction(target);
|
||||
return DemolisherTurretAction(target ? target: flame);
|
||||
case NPC_SALVAGED_SIEGE_ENGINE:
|
||||
return SiegeEngineAction(flame ? flame : target);
|
||||
case NPC_SALVAGED_SIEGE_ENGINE_TURRET:
|
||||
return SiegeEngineTurretAction(target);
|
||||
return SiegeEngineTurretAction(target ? target: flame);
|
||||
case NPC_VEHICLE_CHOPPER:
|
||||
return ChopperAction(target);
|
||||
return ChopperAction(target ? target: flame);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -82,6 +82,8 @@ bool FlameLeviathanVehicleAction::Execute(Event event)
|
||||
|
||||
bool FlameLeviathanVehicleAction::MoveAvoidChasing(Unit* target)
|
||||
{
|
||||
if (!target)
|
||||
return false;
|
||||
if (avoidChaseIdx == -1)
|
||||
{
|
||||
for (int i = 0; i < corners.size(); i++)
|
||||
@@ -106,6 +108,8 @@ bool FlameLeviathanVehicleAction::MoveAvoidChasing(Unit* target)
|
||||
|
||||
bool FlameLeviathanVehicleAction::DemolisherAction(Unit* target)
|
||||
{
|
||||
if (!target)
|
||||
return false;
|
||||
Aura* bluePyrite = target->GetAura(68605);
|
||||
if (!bluePyrite || (bluePyrite->GetStackAmount() <= 6 && vehicleBase_->GetPower(POWER_ENERGY) > 25) || bluePyrite->GetDuration() <= 5000)
|
||||
{
|
||||
@@ -129,6 +133,7 @@ bool FlameLeviathanVehicleAction::DemolisherAction(Unit* target)
|
||||
|
||||
bool FlameLeviathanVehicleAction::DemolisherTurretAction(Unit* target)
|
||||
{
|
||||
int32 liquidCount = 0;
|
||||
{
|
||||
GuidVector npcs = AI_VALUE(GuidVector, "nearest npcs");
|
||||
for (auto i = npcs.begin(); i != npcs.end(); i++)
|
||||
@@ -136,7 +141,12 @@ bool FlameLeviathanVehicleAction::DemolisherTurretAction(Unit* target)
|
||||
Unit* unit = botAI->GetUnit(*i);
|
||||
if (!unit)
|
||||
continue;
|
||||
if (unit->GetEntry() == 33189 && vehicleBase_->GetPower(POWER_ENERGY) <= 25) // Liquid Pyrite
|
||||
if (unit->GetEntry() != 33189)
|
||||
continue;
|
||||
if (unit->GetDistance(bot) >= 49.0f)
|
||||
continue;
|
||||
++liquidCount;
|
||||
if (vehicleBase_->GetPower(POWER_ENERGY) <= 25) // Liquid Pyrite
|
||||
{
|
||||
uint32 spellId = 62479;
|
||||
if (botAI->CanCastVehicleSpell(spellId, unit))
|
||||
@@ -148,6 +158,7 @@ bool FlameLeviathanVehicleAction::DemolisherTurretAction(Unit* target)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (liquidCount <= 10)
|
||||
{
|
||||
GuidVector targets = AI_VALUE(GuidVector, "possible targets");
|
||||
for (auto i = targets.begin(); i != targets.end(); i++)
|
||||
@@ -167,6 +178,8 @@ bool FlameLeviathanVehicleAction::DemolisherTurretAction(Unit* target)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!target)
|
||||
return false;
|
||||
uint32 spellId = 62634;
|
||||
if (botAI->CanCastVehicleSpell(spellId, target))
|
||||
if (botAI->CastVehicleSpell(spellId, target))
|
||||
@@ -179,6 +192,8 @@ bool FlameLeviathanVehicleAction::DemolisherTurretAction(Unit* target)
|
||||
|
||||
bool FlameLeviathanVehicleAction::SiegeEngineAction(Unit* target)
|
||||
{
|
||||
if (!target)
|
||||
return false;
|
||||
if (target->GetCurrentSpell(CURRENT_CHANNELED_SPELL) || target->HasAura(62396))
|
||||
{
|
||||
uint32 spellId = 62522;
|
||||
@@ -201,6 +216,8 @@ bool FlameLeviathanVehicleAction::SiegeEngineAction(Unit* target)
|
||||
|
||||
bool FlameLeviathanVehicleAction::SiegeEngineTurretAction(Unit* target)
|
||||
{
|
||||
if (!target)
|
||||
return false;
|
||||
uint32 spellId = 62358;
|
||||
if (botAI->CanCastVehicleSpell(spellId, target))
|
||||
if (botAI->CastVehicleSpell(spellId, target))
|
||||
@@ -213,6 +230,8 @@ bool FlameLeviathanVehicleAction::SiegeEngineTurretAction(Unit* target)
|
||||
|
||||
bool FlameLeviathanVehicleAction::ChopperAction(Unit* target)
|
||||
{
|
||||
if (!target)
|
||||
return false;
|
||||
uint32 spellId = 62286;
|
||||
if (botAI->CanCastVehicleSpell(spellId, target))
|
||||
if (botAI->CastVehicleSpell(spellId, target))
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
float y = master->GetPositionY() + sin(angle) * range;
|
||||
float z = master->GetPositionZ();
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||
master->GetPositionZ(), x, y, z))
|
||||
master->GetPositionZ(), x, y, z))
|
||||
{
|
||||
x = master->GetPositionX() + cos(angle) * range;
|
||||
y = master->GetPositionY() + sin(angle) * range;
|
||||
@@ -140,8 +140,8 @@ public:
|
||||
float y = master->GetPositionY() + sin(angle) * range + dy;
|
||||
float z = master->GetPositionZ();
|
||||
z = bot->GetMapHeight(x, y, z + 5.0f);
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||
master->GetPositionZ(), x, y, z))
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
|
||||
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z))
|
||||
{
|
||||
x = master->GetPositionX() + cos(angle) * range + dx;
|
||||
y = master->GetPositionY() + sin(angle) * range + dy;
|
||||
@@ -158,13 +158,13 @@ public:
|
||||
float z = master->GetPositionZ();
|
||||
z = bot->GetMapHeight(x, y, z + 5.0f);
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||
master->GetPositionZ(), x, y, z))
|
||||
{
|
||||
x = master->GetPositionX() + cos(angle) * range + dx;
|
||||
y = master->GetPositionY() + sin(angle) * range + dy;
|
||||
z = master->GetPositionZ() + master->GetHoverHeight();
|
||||
z = master->GetMapHeight(x, y, z);
|
||||
}
|
||||
master->GetPositionZ(), x, y, z))
|
||||
{
|
||||
x = master->GetPositionX() + cos(angle) * range + dx;
|
||||
y = master->GetPositionY() + sin(angle) * range + dy;
|
||||
z = master->GetPositionZ() + master->GetHoverHeight();
|
||||
z = master->GetMapHeight(x, y, z);
|
||||
}
|
||||
return WorldLocation(master->GetMapId(), x, y, z);
|
||||
}
|
||||
|
||||
@@ -216,13 +216,13 @@ public:
|
||||
float x = target->GetPositionX() + cos(angle) * range;
|
||||
float y = target->GetPositionY() + sin(angle) * range;
|
||||
float z = target->GetPositionZ();
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||
master->GetPositionZ(), x, y, z))
|
||||
if (!target->GetMap()->CheckCollisionAndGetValidCoords(target, target->GetPositionX(), target->GetPositionY(),
|
||||
target->GetPositionZ(), x, y, z))
|
||||
{
|
||||
x = target->GetPositionX() + cos(angle) * range;
|
||||
y = target->GetPositionY() + sin(angle) * range;
|
||||
z = target->GetPositionZ() + target->GetHoverHeight();
|
||||
z = master->GetMapHeight(x, y, z);
|
||||
z = target->GetMapHeight(x, y, z);
|
||||
}
|
||||
return WorldLocation(bot->GetMapId(), x, y, z);
|
||||
}
|
||||
@@ -383,8 +383,8 @@ public:
|
||||
|
||||
if (minDist)
|
||||
{
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||
master->GetPositionZ(), x, y, z))
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
|
||||
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z))
|
||||
{
|
||||
x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
|
||||
y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
|
||||
@@ -398,7 +398,7 @@ public:
|
||||
}
|
||||
|
||||
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
|
||||
master->GetPositionZ(), x, y, z))
|
||||
master->GetPositionZ(), x, y, z))
|
||||
{
|
||||
x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
|
||||
y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
|
||||
|
||||
Reference in New Issue
Block a user