Merge pull request #491 from liyunfan1223/dev_0825

Circle formation crash fix
This commit is contained in:
Yunfan Li 2024-08-25 19:22:09 +08:00 committed by GitHub
commit 5f298b846e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 52 additions and 29 deletions

View File

@ -538,7 +538,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
{ {
LOG_INFO("playerbots", "Waiting for {} characters loading into database...", bot_creation); LOG_INFO("playerbots", "Waiting for {} characters loading into database...", bot_creation);
/* wait for characters load into database, or characters will fail to loggin */ /* 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) for (WorldSession* session : sessionBots)

View File

@ -65,10 +65,10 @@ void AutoMaintenanceOnLevelupAction::AutoLearnSpell()
void AutoMaintenanceOnLevelupAction::LearnSpells(std::ostringstream* out) void AutoMaintenanceOnLevelupAction::LearnSpells(std::ostringstream* out)
{ {
BroadcastHelper::BroadcastLevelup(botAI, bot); BroadcastHelper::BroadcastLevelup(botAI, bot);
if (sPlayerbotAIConfig->autoLearnTrainerSpells) if (sPlayerbotAIConfig->autoLearnTrainerSpells && sRandomPlayerbotMgr->IsRandomBot(bot))
LearnTrainerSpells(out); LearnTrainerSpells(out);
if (sPlayerbotAIConfig->autoLearnQuestSpells) if (sPlayerbotAIConfig->autoLearnQuestSpells && sRandomPlayerbotMgr->IsRandomBot(bot))
LearnQuestSpells(out); LearnQuestSpells(out);
} }

View File

@ -212,6 +212,9 @@ bool LfgAcceptAction::Execute(Event event)
return true; return true;
} }
if (event.getPacket().empty())
return false;
WorldPacket p(event.getPacket()); WorldPacket p(event.getPacket());

View File

@ -15,8 +15,6 @@ bool XpGainAction::Execute(Event event)
{ {
context->GetValue<uint32>("death count")->Set(0); 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) WorldPacket p(event.getPacket()); // (8+4+1+4+8)
ObjectGuid guid; ObjectGuid guid;
@ -42,6 +40,9 @@ bool XpGainAction::Execute(Event event)
BroadcastHelper::BroadcastKill(botAI, bot, creature); BroadcastHelper::BroadcastKill(botAI, bot, creature);
} }
if (!sRandomPlayerbotMgr->IsRandomBot(bot) || sPlayerbotAIConfig->playerbotsXPrate == 1)
return true;
Unit* victim = nullptr; Unit* victim = nullptr;
if (guid) if (guid)
victim = botAI->GetUnit(guid); victim = botAI->GetUnit(guid);

View File

@ -47,15 +47,15 @@ bool FlameLeviathanVehicleAction::Execute(Event event)
if (unit->GetEntry() == 33142) // Leviathan Defense Turret if (unit->GetEntry() == 33142) // Leviathan Defense Turret
continue; continue;
if (unit->GetEntry() == 33113) // Flame Leviathan if (unit->GetEntry() == 33113) // Flame Leviathan
{
flame = unit; flame = unit;
continue;
}
if (!target || bot->GetExactDist(target) > bot->GetExactDist(unit)) if (!target || bot->GetExactDist(target) > bot->GetExactDist(unit))
{ {
target = unit; target = unit;
} }
} }
if (!target)
return false;
// Flame Leviathan is chasing me // Flame Leviathan is chasing me
if (flame && flame->GetVictim() == vehicleBase_) if (flame && flame->GetVictim() == vehicleBase_)
if (MoveAvoidChasing(flame)) if (MoveAvoidChasing(flame))
@ -65,15 +65,15 @@ bool FlameLeviathanVehicleAction::Execute(Event event)
switch (entry) switch (entry)
{ {
case NPC_SALVAGED_DEMOLISHER: case NPC_SALVAGED_DEMOLISHER:
return DemolisherAction(target); return DemolisherAction(flame ? flame : target);
case NPC_SALVAGED_DEMOLISHER_TURRET: case NPC_SALVAGED_DEMOLISHER_TURRET:
return DemolisherTurretAction(target); return DemolisherTurretAction(target ? target: flame);
case NPC_SALVAGED_SIEGE_ENGINE: case NPC_SALVAGED_SIEGE_ENGINE:
return SiegeEngineAction(flame ? flame : target); return SiegeEngineAction(flame ? flame : target);
case NPC_SALVAGED_SIEGE_ENGINE_TURRET: case NPC_SALVAGED_SIEGE_ENGINE_TURRET:
return SiegeEngineTurretAction(target); return SiegeEngineTurretAction(target ? target: flame);
case NPC_VEHICLE_CHOPPER: case NPC_VEHICLE_CHOPPER:
return ChopperAction(target); return ChopperAction(target ? target: flame);
default: default:
break; break;
} }
@ -82,6 +82,8 @@ bool FlameLeviathanVehicleAction::Execute(Event event)
bool FlameLeviathanVehicleAction::MoveAvoidChasing(Unit* target) bool FlameLeviathanVehicleAction::MoveAvoidChasing(Unit* target)
{ {
if (!target)
return false;
if (avoidChaseIdx == -1) if (avoidChaseIdx == -1)
{ {
for (int i = 0; i < corners.size(); i++) for (int i = 0; i < corners.size(); i++)
@ -106,6 +108,8 @@ bool FlameLeviathanVehicleAction::MoveAvoidChasing(Unit* target)
bool FlameLeviathanVehicleAction::DemolisherAction(Unit* target) bool FlameLeviathanVehicleAction::DemolisherAction(Unit* target)
{ {
if (!target)
return false;
Aura* bluePyrite = target->GetAura(68605); Aura* bluePyrite = target->GetAura(68605);
if (!bluePyrite || (bluePyrite->GetStackAmount() <= 6 && vehicleBase_->GetPower(POWER_ENERGY) > 25) || bluePyrite->GetDuration() <= 5000) 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) bool FlameLeviathanVehicleAction::DemolisherTurretAction(Unit* target)
{ {
int32 liquidCount = 0;
{ {
GuidVector npcs = AI_VALUE(GuidVector, "nearest npcs"); GuidVector npcs = AI_VALUE(GuidVector, "nearest npcs");
for (auto i = npcs.begin(); i != npcs.end(); i++) for (auto i = npcs.begin(); i != npcs.end(); i++)
@ -136,7 +141,12 @@ bool FlameLeviathanVehicleAction::DemolisherTurretAction(Unit* target)
Unit* unit = botAI->GetUnit(*i); Unit* unit = botAI->GetUnit(*i);
if (!unit) if (!unit)
continue; 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; uint32 spellId = 62479;
if (botAI->CanCastVehicleSpell(spellId, unit)) if (botAI->CanCastVehicleSpell(spellId, unit))
@ -148,6 +158,7 @@ bool FlameLeviathanVehicleAction::DemolisherTurretAction(Unit* target)
} }
} }
} }
if (liquidCount <= 10)
{ {
GuidVector targets = AI_VALUE(GuidVector, "possible targets"); GuidVector targets = AI_VALUE(GuidVector, "possible targets");
for (auto i = targets.begin(); i != targets.end(); i++) 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; uint32 spellId = 62634;
if (botAI->CanCastVehicleSpell(spellId, target)) if (botAI->CanCastVehicleSpell(spellId, target))
if (botAI->CastVehicleSpell(spellId, target)) if (botAI->CastVehicleSpell(spellId, target))
@ -179,6 +192,8 @@ bool FlameLeviathanVehicleAction::DemolisherTurretAction(Unit* target)
bool FlameLeviathanVehicleAction::SiegeEngineAction(Unit* target) bool FlameLeviathanVehicleAction::SiegeEngineAction(Unit* target)
{ {
if (!target)
return false;
if (target->GetCurrentSpell(CURRENT_CHANNELED_SPELL) || target->HasAura(62396)) if (target->GetCurrentSpell(CURRENT_CHANNELED_SPELL) || target->HasAura(62396))
{ {
uint32 spellId = 62522; uint32 spellId = 62522;
@ -201,6 +216,8 @@ bool FlameLeviathanVehicleAction::SiegeEngineAction(Unit* target)
bool FlameLeviathanVehicleAction::SiegeEngineTurretAction(Unit* target) bool FlameLeviathanVehicleAction::SiegeEngineTurretAction(Unit* target)
{ {
if (!target)
return false;
uint32 spellId = 62358; uint32 spellId = 62358;
if (botAI->CanCastVehicleSpell(spellId, target)) if (botAI->CanCastVehicleSpell(spellId, target))
if (botAI->CastVehicleSpell(spellId, target)) if (botAI->CastVehicleSpell(spellId, target))
@ -213,6 +230,8 @@ bool FlameLeviathanVehicleAction::SiegeEngineTurretAction(Unit* target)
bool FlameLeviathanVehicleAction::ChopperAction(Unit* target) bool FlameLeviathanVehicleAction::ChopperAction(Unit* target)
{ {
if (!target)
return false;
uint32 spellId = 62286; uint32 spellId = 62286;
if (botAI->CanCastVehicleSpell(spellId, target)) if (botAI->CanCastVehicleSpell(spellId, target))
if (botAI->CastVehicleSpell(spellId, target)) if (botAI->CastVehicleSpell(spellId, target))

View File

@ -90,7 +90,7 @@ public:
float y = master->GetPositionY() + sin(angle) * range; float y = master->GetPositionY() + sin(angle) * range;
float z = master->GetPositionZ(); float z = master->GetPositionZ();
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), 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; x = master->GetPositionX() + cos(angle) * range;
y = master->GetPositionY() + sin(angle) * range; y = master->GetPositionY() + sin(angle) * range;
@ -140,8 +140,8 @@ public:
float y = master->GetPositionY() + sin(angle) * range + dy; float y = master->GetPositionY() + sin(angle) * range + dy;
float z = master->GetPositionZ(); float z = master->GetPositionZ();
z = bot->GetMapHeight(x, y, z + 5.0f); z = bot->GetMapHeight(x, y, z + 5.0f);
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), if (!master->GetMap()->CheckCollisionAndGetValidCoords(
master->GetPositionZ(), x, y, z)) master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z))
{ {
x = master->GetPositionX() + cos(angle) * range + dx; x = master->GetPositionX() + cos(angle) * range + dx;
y = master->GetPositionY() + sin(angle) * range + dy; y = master->GetPositionY() + sin(angle) * range + dy;
@ -158,13 +158,13 @@ public:
float z = master->GetPositionZ(); float z = master->GetPositionZ();
z = bot->GetMapHeight(x, y, z + 5.0f); z = bot->GetMapHeight(x, y, z + 5.0f);
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), 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 + dx; x = master->GetPositionX() + cos(angle) * range + dx;
y = master->GetPositionY() + sin(angle) * range + dy; y = master->GetPositionY() + sin(angle) * range + dy;
z = master->GetPositionZ() + master->GetHoverHeight(); z = master->GetPositionZ() + master->GetHoverHeight();
z = master->GetMapHeight(x, y, z); z = master->GetMapHeight(x, y, z);
} }
return WorldLocation(master->GetMapId(), x, y, z); return WorldLocation(master->GetMapId(), x, y, z);
} }
@ -216,13 +216,13 @@ public:
float x = target->GetPositionX() + cos(angle) * range; float x = target->GetPositionX() + cos(angle) * range;
float y = target->GetPositionY() + sin(angle) * range; float y = target->GetPositionY() + sin(angle) * range;
float z = target->GetPositionZ(); float z = target->GetPositionZ();
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), if (!target->GetMap()->CheckCollisionAndGetValidCoords(target, target->GetPositionX(), target->GetPositionY(),
master->GetPositionZ(), x, y, z)) target->GetPositionZ(), x, y, z))
{ {
x = target->GetPositionX() + cos(angle) * range; x = target->GetPositionX() + cos(angle) * range;
y = target->GetPositionY() + sin(angle) * range; y = target->GetPositionY() + sin(angle) * range;
z = target->GetPositionZ() + target->GetHoverHeight(); z = target->GetPositionZ() + target->GetHoverHeight();
z = master->GetMapHeight(x, y, z); z = target->GetMapHeight(x, y, z);
} }
return WorldLocation(bot->GetMapId(), x, y, z); return WorldLocation(bot->GetMapId(), x, y, z);
} }
@ -383,8 +383,8 @@ public:
if (minDist) if (minDist)
{ {
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(), if (!master->GetMap()->CheckCollisionAndGetValidCoords(
master->GetPositionZ(), x, y, z)) master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z))
{ {
x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange; x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
y = master->GetPositionY() + sin(angle) * range + sin(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(), 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; x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange; y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;