mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-27 15:36:22 +00:00
[Attack target] Crash fix
This commit is contained in:
@@ -179,9 +179,9 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
LOG_INFO("playerbots", "Preparing to {} randomize...", (incremental ? "incremental" : "full"));
|
LOG_DEBUG("playerbots", "Preparing to {} randomize...", (incremental ? "incremental" : "full"));
|
||||||
Prepare();
|
Prepare();
|
||||||
LOG_INFO("playerbots", "Resetting player...");
|
LOG_DEBUG("playerbots", "Resetting player...");
|
||||||
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reset");
|
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reset");
|
||||||
bot->resetTalents(true);
|
bot->resetTalents(true);
|
||||||
// bot->SaveToDB(false, false);
|
// bot->SaveToDB(false, false);
|
||||||
@@ -221,14 +221,14 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells1");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells1");
|
||||||
LOG_INFO("playerbots", "Initializing spells (step 1)...");
|
LOG_DEBUG("playerbots", "Initializing spells (step 1)...");
|
||||||
// bot->LearnDefaultSkills();
|
// bot->LearnDefaultSkills();
|
||||||
InitClassSpells();
|
InitClassSpells();
|
||||||
InitAvailableSpells();
|
InitAvailableSpells();
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
LOG_INFO("playerbots", "Initializing skills (step 1)...");
|
LOG_DEBUG("playerbots", "Initializing skills (step 1)...");
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Skills1");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Skills1");
|
||||||
InitSkills();
|
InitSkills();
|
||||||
InitSpecialSpells();
|
InitSpecialSpells();
|
||||||
@@ -238,7 +238,7 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Talents");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Talents");
|
||||||
LOG_INFO("playerbots", "Initializing talents...");
|
LOG_DEBUG("playerbots", "Initializing talents...");
|
||||||
if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) {
|
if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) {
|
||||||
InitTalentsTree();
|
InitTalentsTree();
|
||||||
}
|
}
|
||||||
@@ -252,13 +252,13 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells2");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells2");
|
||||||
LOG_INFO("playerbots", "Initializing spells (step 2)...");
|
LOG_DEBUG("playerbots", "Initializing spells (step 2)...");
|
||||||
InitAvailableSpells();
|
InitAvailableSpells();
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Mounts");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Mounts");
|
||||||
LOG_INFO("playerbots", "Initializing mounts...");
|
LOG_DEBUG("playerbots", "Initializing mounts...");
|
||||||
InitMounts();
|
InitMounts();
|
||||||
bot->SaveToDB(false, false);
|
bot->SaveToDB(false, false);
|
||||||
if (pmo)
|
if (pmo)
|
||||||
@@ -271,7 +271,7 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Equip");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Equip");
|
||||||
LOG_INFO("playerbots", "Initializing equipmemt...");
|
LOG_DEBUG("playerbots", "Initializing equipmemt...");
|
||||||
if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) {
|
if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) {
|
||||||
InitEquipment(incremental);
|
InitEquipment(incremental);
|
||||||
}
|
}
|
||||||
@@ -289,38 +289,38 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Bags");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Bags");
|
||||||
LOG_INFO("playerbots", "Initializing bags...");
|
LOG_DEBUG("playerbots", "Initializing bags...");
|
||||||
InitBags();
|
InitBags();
|
||||||
// bot->SaveToDB(false, false);
|
// bot->SaveToDB(false, false);
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Ammo");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Ammo");
|
||||||
LOG_INFO("playerbots", "Initializing ammo...");
|
LOG_DEBUG("playerbots", "Initializing ammo...");
|
||||||
InitAmmo();
|
InitAmmo();
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Food");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Food");
|
||||||
LOG_INFO("playerbots", "Initializing food...");
|
LOG_DEBUG("playerbots", "Initializing food...");
|
||||||
InitFood();
|
InitFood();
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Potions");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Potions");
|
||||||
LOG_INFO("playerbots", "Initializing potions...");
|
LOG_DEBUG("playerbots", "Initializing potions...");
|
||||||
InitPotions();
|
InitPotions();
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reagents");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reagents");
|
||||||
LOG_INFO("playerbots", "Initializing reagents...");
|
LOG_DEBUG("playerbots", "Initializing reagents...");
|
||||||
InitReagents();
|
InitReagents();
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_EqSets");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_EqSets");
|
||||||
LOG_INFO("playerbots", "Initializing second equipment set...");
|
LOG_DEBUG("playerbots", "Initializing second equipment set...");
|
||||||
// InitSecondEquipmentSet();
|
// InitSecondEquipmentSet();
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
@@ -337,18 +337,18 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Inventory");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Inventory");
|
||||||
LOG_INFO("playerbots", "Initializing inventory...");
|
LOG_DEBUG("playerbots", "Initializing inventory...");
|
||||||
// InitInventory();
|
// InitInventory();
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Consumable");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Consumable");
|
||||||
LOG_INFO("playerbots", "Initializing consumables...");
|
LOG_DEBUG("playerbots", "Initializing consumables...");
|
||||||
AddConsumables();
|
AddConsumables();
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
LOG_INFO("playerbots", "Initializing glyphs...");
|
LOG_DEBUG("playerbots", "Initializing glyphs...");
|
||||||
bot->SaveToDB(false, false);
|
bot->SaveToDB(false, false);
|
||||||
InitGlyphs();
|
InitGlyphs();
|
||||||
|
|
||||||
@@ -385,12 +385,12 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Save");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Save");
|
||||||
LOG_INFO("playerbots", "Saving to DB...");
|
LOG_DEBUG("playerbots", "Saving to DB...");
|
||||||
bot->SetMoney(urand(level * 100000, level * 5 * 100000));
|
bot->SetMoney(urand(level * 100000, level * 5 * 100000));
|
||||||
bot->SetHealth(bot->GetMaxHealth());
|
bot->SetHealth(bot->GetMaxHealth());
|
||||||
bot->SetPower(POWER_MANA, bot->GetMaxPower(POWER_MANA));
|
bot->SetPower(POWER_MANA, bot->GetMaxPower(POWER_MANA));
|
||||||
bot->SaveToDB(false, false);
|
bot->SaveToDB(false, false);
|
||||||
LOG_INFO("playerbots", "Done.");
|
LOG_INFO("playerbots", "Initialization Done.");
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ GuidVector AttackersValue::Calculate()
|
|||||||
if (Group* group = bot->GetGroup())
|
if (Group* group = bot->GetGroup())
|
||||||
AddAttackersOf(group, targets);
|
AddAttackersOf(group, targets);
|
||||||
|
|
||||||
// prioritize target
|
// prioritized target
|
||||||
GuidVector prioritizedTargets = AI_VALUE(GuidVector, "prioritized targets");
|
GuidVector prioritizedTargets = AI_VALUE(GuidVector, "prioritized targets");
|
||||||
for (ObjectGuid target : prioritizedTargets) {
|
for (ObjectGuid target : prioritizedTargets) {
|
||||||
Unit* unit = botAI->GetUnit(target);
|
Unit* unit = botAI->GetUnit(target);
|
||||||
@@ -31,10 +31,12 @@ GuidVector AttackersValue::Calculate()
|
|||||||
targets.insert(unit);
|
targets.insert(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ObjectGuid skullGuid = bot->GetGroup()->GetTargetIcon(4);
|
if (Group* group = bot->GetGroup()) {
|
||||||
Unit* skullTarget = botAI->GetUnit(skullGuid);
|
ObjectGuid skullGuid = group->GetTargetIcon(4);
|
||||||
if (skullTarget) {
|
Unit* skullTarget = botAI->GetUnit(skullGuid);
|
||||||
targets.insert(skullTarget);
|
if (skullTarget) {
|
||||||
|
targets.insert(skullTarget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveNonThreating(targets);
|
RemoveNonThreating(targets);
|
||||||
|
|||||||
Reference in New Issue
Block a user