mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-21 10:30:01 +01:00
coredump fix & rpg actions
This commit is contained in:
parent
1d423e4820
commit
1c47108c23
@ -608,7 +608,7 @@ AiPlayerbot.BotCheats = "taxi"
|
|||||||
AiPlayerbot.RandomBotRandomPassword = 0
|
AiPlayerbot.RandomBotRandomPassword = 0
|
||||||
|
|
||||||
# Set RandomBotMaxLevel bots to RandomBotMinLevel or not
|
# Set RandomBotMaxLevel bots to RandomBotMinLevel or not
|
||||||
AiPlayerbot.DowngradeMaxLevelBot = 1
|
AiPlayerbot.DowngradeMaxLevelBot = 0
|
||||||
|
|
||||||
##################################################################################
|
##################################################################################
|
||||||
# #
|
# #
|
||||||
|
|||||||
@ -261,9 +261,7 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool min = minimal;
|
bool min = minimal;
|
||||||
|
|
||||||
UpdateAIInternal(elapsed, min);
|
UpdateAIInternal(elapsed, min);
|
||||||
|
|
||||||
inCombat = bot->IsInCombat();
|
inCombat = bot->IsInCombat();
|
||||||
// test fix lags because of BG
|
// test fix lags because of BG
|
||||||
if (bot && !inCombat)
|
if (bot && !inCombat)
|
||||||
@ -272,6 +270,8 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
|
|||||||
if (HasRealPlayerMaster())
|
if (HasRealPlayerMaster())
|
||||||
min = false;
|
min = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
YieldThread(min);
|
YieldThread(min);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1972,18 +1972,18 @@ bool PlayerbotAI::CanCastSpell(std::string const name, Unit* target, Item* itemT
|
|||||||
bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell, Item* itemTarget)
|
bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell, Item* itemTarget)
|
||||||
{
|
{
|
||||||
if (!spellid) {
|
if (!spellid) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) {
|
||||||
LOG_DEBUG("playerbots", "Can cast spell failed. No spellid. - spellid: {}, bot name: {}",
|
// LOG_DEBUG("playerbots", "Can cast spell failed. No spellid. - spellid: {}, bot name: {}",
|
||||||
spellid, bot->GetName());
|
// spellid, bot->GetName());
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bot->HasUnitState(UNIT_STATE_LOST_CONTROL)) {
|
if (bot->HasUnitState(UNIT_STATE_LOST_CONTROL)) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "Can cast spell failed. Unit state lost control. - spellid: {}, bot name: {}",
|
// LOG_DEBUG("playerbots", "Can cast spell failed. Unit state lost control. - spellid: {}, bot name: {}",
|
||||||
spellid, bot->GetName());
|
// spellid, bot->GetName());
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1991,19 +1991,19 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
|
|||||||
if (!target)
|
if (!target)
|
||||||
target = bot;
|
target = bot;
|
||||||
|
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup())
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup())
|
||||||
LOG_DEBUG("playerbots", "Can cast spell? - target name: {}, spellid: {}, bot name: {}",
|
// LOG_DEBUG("playerbots", "Can cast spell? - target name: {}, spellid: {}, bot name: {}",
|
||||||
target->GetName(), spellid, bot->GetName());
|
// target->GetName(), spellid, bot->GetName());
|
||||||
|
|
||||||
if (Pet* pet = bot->GetPet())
|
if (Pet* pet = bot->GetPet())
|
||||||
if (pet->HasSpell(spellid))
|
if (pet->HasSpell(spellid))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (checkHasSpell && !bot->HasSpell(spellid)) {
|
if (checkHasSpell && !bot->HasSpell(spellid)) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "Can cast spell failed. Bot not has spell. - target name: {}, spellid: {}, bot name: {}",
|
// LOG_DEBUG("playerbots", "Can cast spell failed. Bot not has spell. - target name: {}, spellid: {}, bot name: {}",
|
||||||
target->GetName(), spellid, bot->GetName());
|
// target->GetName(), spellid, bot->GetName());
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2014,28 +2014,28 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bot->HasSpellCooldown(spellid)) {
|
if (bot->HasSpellCooldown(spellid)) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "Can cast spell failed. Spell not has cooldown. - target name: {}, spellid: {}, bot name: {}",
|
// LOG_DEBUG("playerbots", "Can cast spell failed. Spell not has cooldown. - target name: {}, spellid: {}, bot name: {}",
|
||||||
target->GetName(), spellid, bot->GetName());
|
// target->GetName(), spellid, bot->GetName());
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
|
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
|
||||||
if (!spellInfo) {
|
if (!spellInfo) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "Can cast spell failed. No spellInfo. - target name: {}, spellid: {}, bot name: {}",
|
// LOG_DEBUG("playerbots", "Can cast spell failed. No spellInfo. - target name: {}, spellid: {}, bot name: {}",
|
||||||
target->GetName(), spellid, bot->GetName());
|
// target->GetName(), spellid, bot->GetName());
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 CastingTime = !spellInfo->IsChanneled() ? spellInfo->CalcCastTime(bot) : spellInfo->GetDuration();
|
uint32 CastingTime = !spellInfo->IsChanneled() ? spellInfo->CalcCastTime(bot) : spellInfo->GetDuration();
|
||||||
if (CastingTime && bot->isMoving()) {
|
if (CastingTime && bot->isMoving()) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "Casting time and bot is moving - target name: {}, spellid: {}, bot name: {}",
|
// LOG_DEBUG("playerbots", "Casting time and bot is moving - target name: {}, spellid: {}, bot name: {}",
|
||||||
target->GetName(), spellid, bot->GetName());
|
// target->GetName(), spellid, bot->GetName());
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2059,10 +2059,10 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (target->IsImmunedToSpell(spellInfo)) {
|
if (target->IsImmunedToSpell(spellInfo)) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "target is immuned to spell - target name: {}, spellid: {}, bot name: {}",
|
// LOG_DEBUG("playerbots", "target is immuned to spell - target name: {}, spellid: {}, bot name: {}",
|
||||||
target->GetName(), spellid, bot->GetName());
|
// target->GetName(), spellid, bot->GetName());
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2081,10 +2081,10 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (bot != target && sServerFacade->GetDistance2d(bot, target) > sPlayerbotAIConfig->sightDistance) {
|
if (bot != target && sServerFacade->GetDistance2d(bot, target) > sPlayerbotAIConfig->sightDistance) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "target is out of sight distance - target name: {}, spellid: {}, bot name: {}",
|
// LOG_DEBUG("playerbots", "target is out of sight distance - target name: {}, spellid: {}, bot name: {}",
|
||||||
target->GetName(), spellid, bot->GetName());
|
// target->GetName(), spellid, bot->GetName());
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2100,12 +2100,12 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
|
|||||||
SpellCastResult result = spell->CheckCast(true);
|
SpellCastResult result = spell->CheckCast(true);
|
||||||
delete spell;
|
delete spell;
|
||||||
|
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
if (result != SPELL_FAILED_NOT_READY && result != SPELL_CAST_OK) {
|
// if (result != SPELL_FAILED_NOT_READY && result != SPELL_CAST_OK) {
|
||||||
LOG_DEBUG("playerbots", "CanCastSpell - target name: {}, spellid: {}, bot name: {}, result: {}",
|
// LOG_DEBUG("playerbots", "CanCastSpell - target name: {}, spellid: {}, bot name: {}, result: {}",
|
||||||
target->GetName(), spellid, bot->GetName(), result);
|
// target->GetName(), spellid, bot->GetName(), result);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (oldSel)
|
if (oldSel)
|
||||||
bot->SetSelection(oldSel->GetGUID());
|
bot->SetSelection(oldSel->GetGUID());
|
||||||
@ -2286,10 +2286,10 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
|
|||||||
aiObjectContext->GetValue<time_t>("stay time")->Set(0);
|
aiObjectContext->GetValue<time_t>("stay time")->Set(0);
|
||||||
|
|
||||||
if (bot->IsFlying() || bot->HasUnitState(UNIT_STATE_IN_FLIGHT)) {
|
if (bot->IsFlying() || bot->HasUnitState(UNIT_STATE_IN_FLIGHT)) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "Spell cast is flying - target name: {}, spellid: {}, bot name: {}}",
|
// LOG_DEBUG("playerbots", "Spell cast is flying - target name: {}, spellid: {}, bot name: {}}",
|
||||||
target->GetName(), spellId, bot->GetName());
|
// target->GetName(), spellId, bot->GetName());
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2316,10 +2316,10 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
|
|||||||
if (failWithDelay)
|
if (failWithDelay)
|
||||||
{
|
{
|
||||||
SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
|
SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "Spell cast fail with delay - target name: {}, spellid: {}, bot name: {}",
|
// LOG_DEBUG("playerbots", "Spell cast fail with delay - target name: {}, spellid: {}, bot name: {}",
|
||||||
target->GetName(), spellId, bot->GetName());
|
// target->GetName(), spellId, bot->GetName());
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2335,10 +2335,10 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
|
|||||||
{
|
{
|
||||||
bot->GetTradeData()->SetSpell(spellId);
|
bot->GetTradeData()->SetSpell(spellId);
|
||||||
delete spell;
|
delete spell;
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "Spell cast no item - target name: {}, spellid: {}, bot name: {}",
|
// LOG_DEBUG("playerbots", "Spell cast no item - target name: {}, spellid: {}, bot name: {}",
|
||||||
target->GetName(), spellId, bot->GetName());
|
// target->GetName(), spellId, bot->GetName());
|
||||||
}
|
// }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2400,10 +2400,10 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
|
|||||||
SpellCastResult result = spell->prepare(&targets);
|
SpellCastResult result = spell->prepare(&targets);
|
||||||
|
|
||||||
if (result != SPELL_CAST_OK) {
|
if (result != SPELL_CAST_OK) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "Spell cast failed. - target name: {}, spellid: {}, bot name: {}, result: {}",
|
// LOG_DEBUG("playerbots", "Spell cast failed. - target name: {}, spellid: {}, bot name: {}, result: {}",
|
||||||
target->GetName(), spellId, bot->GetName(), result);
|
// target->GetName(), spellId, bot->GetName(), result);
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if (spellInfo->Effects[0].Effect == SPELL_EFFECT_OPEN_LOCK || spellInfo->Effects[0].Effect == SPELL_EFFECT_SKINNING)
|
// if (spellInfo->Effects[0].Effect == SPELL_EFFECT_OPEN_LOCK || spellInfo->Effects[0].Effect == SPELL_EFFECT_SKINNING)
|
||||||
|
|||||||
@ -267,14 +267,14 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
|
|
||||||
// if (bot->getLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel)
|
if (bot->getLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel)
|
||||||
// {
|
{
|
||||||
// pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_EnchantTemplate");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_EnchantTemplate");
|
||||||
// LOG_INFO("playerbots", "Initializing enchant templates...");
|
LOG_INFO("playerbots", "Initializing enchant templates...");
|
||||||
// ApplyEnchantTemplate();
|
ApplyEnchantTemplate();
|
||||||
// if (pmo)
|
if (pmo)
|
||||||
// pmo->finish();
|
pmo->finish();
|
||||||
// }
|
}
|
||||||
|
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Inventory");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Inventory");
|
||||||
LOG_INFO("playerbots", "Initializing inventory...");
|
LOG_INFO("playerbots", "Initializing inventory...");
|
||||||
@ -306,6 +306,7 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bot->RemovePet(nullptr, PET_SAVE_AS_CURRENT, true);
|
bot->RemovePet(nullptr, PET_SAVE_AS_CURRENT, true);
|
||||||
|
bot->RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true);
|
||||||
if (bot->getLevel() >= 10)
|
if (bot->getLevel() >= 10)
|
||||||
{
|
{
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Pet");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Pet");
|
||||||
@ -339,17 +340,12 @@ void PlayerbotFactory::Refresh()
|
|||||||
InitClassSpells();
|
InitClassSpells();
|
||||||
InitAvailableSpells();
|
InitAvailableSpells();
|
||||||
bot->DurabilityRepairAll(false, 1.0f, false);
|
bot->DurabilityRepairAll(false, 1.0f, false);
|
||||||
|
if (bot->isDead())
|
||||||
|
bot->ResurrectPlayer(1.0f, false);
|
||||||
uint32 money = urand(level * 1000, level * 5 * 1000);
|
uint32 money = urand(level * 1000, level * 5 * 1000);
|
||||||
if (bot->GetMoney() < money)
|
if (bot->GetMoney() < money)
|
||||||
bot->SetMoney(money);
|
bot->SetMoney(money);
|
||||||
bot->SaveToDB(false, false);
|
bot->SaveToDB(false, false);
|
||||||
|
|
||||||
// Prepare();
|
|
||||||
// InitAmmo();
|
|
||||||
// InitFood();
|
|
||||||
// InitPotions();
|
|
||||||
|
|
||||||
//bot->SaveToDB();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerbotFactory::AddConsumables()
|
void PlayerbotFactory::AddConsumables()
|
||||||
@ -1203,7 +1199,7 @@ void PlayerbotFactory::InitEquipment(bool incremental)
|
|||||||
|
|
||||||
if (slot == EQUIPMENT_SLOT_OFFHAND && bot->getClass() == CLASS_ROGUE && proto->Class != ITEM_CLASS_WEAPON)
|
if (slot == EQUIPMENT_SLOT_OFFHAND && bot->getClass() == CLASS_ROGUE && proto->Class != ITEM_CLASS_WEAPON)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
uint16 dest = 0;
|
uint16 dest = 0;
|
||||||
if (CanEquipUnseenItem(slot, dest, itemId))
|
if (CanEquipUnseenItem(slot, dest, itemId))
|
||||||
items[slot].push_back(itemId);
|
items[slot].push_back(itemId);
|
||||||
|
|||||||
@ -1166,36 +1166,38 @@ void RandomPlayerbotMgr::PrepareTeleportCache()
|
|||||||
}
|
}
|
||||||
LOG_INFO("playerbots", "{} locations for level collected.", collected_locs);
|
LOG_INFO("playerbots", "{} locations for level collected.", collected_locs);
|
||||||
|
|
||||||
LOG_INFO("playerbots", "Preparing RPG teleport caches for {} factions...", sFactionTemplateStore.GetNumRows());
|
// temporary only use locsPerLevelCache, so disable rpgLocsCacheLevel cache
|
||||||
results = WorldDatabase.Query("SELECT map, position_x, position_y, position_z, r.race, r.minl, r.maxl FROM creature c INNER JOIN playerbots_rpg_races r ON c.id1 = r.entry "
|
|
||||||
"WHERE r.race < 15");
|
|
||||||
if (results)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
Field* fields = results->Fetch();
|
|
||||||
uint16 mapId = fields[0].Get<uint16>();
|
|
||||||
float x = fields[1].Get<float>();
|
|
||||||
float y = fields[2].Get<float>();
|
|
||||||
float z = fields[3].Get<float>();
|
|
||||||
uint32 race = fields[4].Get<uint32>();
|
|
||||||
uint32 minl = fields[5].Get<uint32>();
|
|
||||||
uint32 maxl = fields[6].Get<uint32>();
|
|
||||||
|
|
||||||
for (uint32 level = 1; level < sPlayerbotAIConfig->randomBotMaxLevel + 1; level++)
|
// LOG_INFO("playerbots", "Preparing RPG teleport caches for {} factions...", sFactionTemplateStore.GetNumRows());
|
||||||
{
|
// results = WorldDatabase.Query("SELECT map, position_x, position_y, position_z, r.race, r.minl, r.maxl FROM creature c INNER JOIN playerbots_rpg_races r ON c.id1 = r.entry "
|
||||||
if (level > maxl || level < minl)
|
// "WHERE r.race < 15");
|
||||||
continue;
|
// if (results)
|
||||||
|
// {
|
||||||
|
// do
|
||||||
|
// {
|
||||||
|
// Field* fields = results->Fetch();
|
||||||
|
// uint16 mapId = fields[0].Get<uint16>();
|
||||||
|
// float x = fields[1].Get<float>();
|
||||||
|
// float y = fields[2].Get<float>();
|
||||||
|
// float z = fields[3].Get<float>();
|
||||||
|
// uint32 race = fields[4].Get<uint32>();
|
||||||
|
// uint32 minl = fields[5].Get<uint32>();
|
||||||
|
// uint32 maxl = fields[6].Get<uint32>();
|
||||||
|
|
||||||
WorldLocation loc(mapId, x, y, z, 0);
|
// for (uint32 level = 1; level < sPlayerbotAIConfig->randomBotMaxLevel + 1; level++)
|
||||||
for (uint32 r = 1; r < MAX_RACES; r++)
|
// {
|
||||||
{
|
// if (level > maxl || level < minl)
|
||||||
if (race == r || race == 0)
|
// continue;
|
||||||
rpgLocsCacheLevel[r][level].push_back(loc);
|
|
||||||
}
|
// WorldLocation loc(mapId, x, y, z, 0);
|
||||||
}
|
// for (uint32 r = 1; r < MAX_RACES; r++)
|
||||||
} while (results->NextRow());
|
// {
|
||||||
}
|
// if (race == r || race == 0)
|
||||||
|
// rpgLocsCacheLevel[r][level].push_back(loc);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } while (results->NextRow());
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot)
|
void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot)
|
||||||
@ -1341,7 +1343,6 @@ void RandomPlayerbotMgr::RandomizeFirst(Player* bot)
|
|||||||
|
|
||||||
// teleport to a random inn for bot level
|
// teleport to a random inn for bot level
|
||||||
GET_PLAYERBOT_AI(bot)->Reset(true);
|
GET_PLAYERBOT_AI(bot)->Reset(true);
|
||||||
// RandomTeleportForRpg(bot);
|
|
||||||
|
|
||||||
if (bot->GetGroup())
|
if (bot->GetGroup())
|
||||||
bot->RemoveFromGroup();
|
bot->RemoveFromGroup();
|
||||||
@ -1458,6 +1459,9 @@ void RandomPlayerbotMgr::Refresh(Player* bot)
|
|||||||
uint32 money = bot->GetMoney();
|
uint32 money = bot->GetMoney();
|
||||||
bot->SetMoney(money + 500 * sqrt(urand(1, bot->getLevel() * 5)));
|
bot->SetMoney(money + 500 * sqrt(urand(1, bot->getLevel() * 5)));
|
||||||
|
|
||||||
|
if (bot->GetGroup())
|
||||||
|
bot->RemoveFromGroup();
|
||||||
|
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
}
|
}
|
||||||
@ -1706,7 +1710,7 @@ bool RandomPlayerbotMgr::HandlePlayerbotConsoleCommand(ChatHandler* handler, cha
|
|||||||
handlers["levelup"] = handlers["level"] = &RandomPlayerbotMgr::IncreaseLevel;
|
handlers["levelup"] = handlers["level"] = &RandomPlayerbotMgr::IncreaseLevel;
|
||||||
handlers["refresh"] = &RandomPlayerbotMgr::Refresh;
|
handlers["refresh"] = &RandomPlayerbotMgr::Refresh;
|
||||||
handlers["teleport"] = &RandomPlayerbotMgr::RandomTeleportForLevel;
|
handlers["teleport"] = &RandomPlayerbotMgr::RandomTeleportForLevel;
|
||||||
handlers["rpg"] = &RandomPlayerbotMgr::RandomTeleportForRpg;
|
// handlers["rpg"] = &RandomPlayerbotMgr::RandomTeleportForRpg;
|
||||||
handlers["revive"] = &RandomPlayerbotMgr::Revive;
|
handlers["revive"] = &RandomPlayerbotMgr::Revive;
|
||||||
handlers["grind"] = &RandomPlayerbotMgr::RandomTeleport;
|
handlers["grind"] = &RandomPlayerbotMgr::RandomTeleport;
|
||||||
handlers["change_strategy"] = &RandomPlayerbotMgr::ChangeStrategy;
|
handlers["change_strategy"] = &RandomPlayerbotMgr::ChangeStrategy;
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
|
#include "Timer.h"
|
||||||
|
|
||||||
uint32 NextAction::size(NextAction** actions)
|
uint32 NextAction::size(NextAction** actions)
|
||||||
{
|
{
|
||||||
@ -101,11 +102,11 @@ Unit* Action::GetTarget()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ActionBasket::ActionBasket(ActionNode* action, float relevance, bool skipPrerequisites, Event event) :
|
ActionBasket::ActionBasket(ActionNode* action, float relevance, bool skipPrerequisites, Event event) :
|
||||||
action(action), relevance(relevance), skipPrerequisites(skipPrerequisites), event(event), created(time(nullptr))
|
action(action), relevance(relevance), skipPrerequisites(skipPrerequisites), event(event), created(getMSTime())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ActionBasket::isExpired(time_t secs)
|
bool ActionBasket::isExpired(uint32 msecs)
|
||||||
{
|
{
|
||||||
return time(nullptr) - created >= secs;
|
return getMSTime() - created >= msecs;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,14 +109,14 @@ class ActionBasket
|
|||||||
bool isSkipPrerequisites() { return skipPrerequisites; }
|
bool isSkipPrerequisites() { return skipPrerequisites; }
|
||||||
void AmendRelevance(float k) { relevance *= k; }
|
void AmendRelevance(float k) { relevance *= k; }
|
||||||
void setRelevance(float relevance) { this->relevance = relevance; }
|
void setRelevance(float relevance) { this->relevance = relevance; }
|
||||||
bool isExpired(time_t secs);
|
bool isExpired(uint32 msecs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActionNode* action;
|
ActionNode* action;
|
||||||
float relevance;
|
float relevance;
|
||||||
bool skipPrerequisites;
|
bool skipPrerequisites;
|
||||||
Event event;
|
Event event;
|
||||||
time_t created;
|
uint32 created;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -261,7 +261,7 @@ bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal)
|
|||||||
lastRelevance = 0.0f;
|
lastRelevance = 0.0f;
|
||||||
PushDefaultActions();
|
PushDefaultActions();
|
||||||
|
|
||||||
if (queue.Peek() && depth < 2)
|
if (queue.Peek() && depth < 1 && !minimal)
|
||||||
return DoNextAction(unit, depth + 1, minimal);
|
return DoNextAction(unit, depth + 1, minimal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,7 +640,7 @@ void Engine::LogAction(char const* format, ...)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Player* bot = botAI->GetBot();
|
Player* bot = botAI->GetBot();
|
||||||
if (sPlayerbotAIConfig->logInGroupOnly && !bot->GetGroup())
|
if (sPlayerbotAIConfig->logInGroupOnly && (!bot->GetGroup() || !botAI->HasRealPlayerMaster()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LOG_DEBUG("playerbots", "{} {}", bot->GetName().c_str(), buf);
|
LOG_DEBUG("playerbots", "{} {}", bot->GetName().c_str(), buf);
|
||||||
@ -677,7 +677,7 @@ void Engine::LogValues()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Player* bot = botAI->GetBot();
|
Player* bot = botAI->GetBot();
|
||||||
if (sPlayerbotAIConfig->logInGroupOnly && !bot->GetGroup())
|
if (sPlayerbotAIConfig->logInGroupOnly && (!bot->GetGroup() || !botAI->HasRealPlayerMaster()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string const text = botAI->GetAiObjectContext()->FormatValues();
|
std::string const text = botAI->GetAiObjectContext()->FormatValues();
|
||||||
|
|||||||
@ -86,7 +86,7 @@ void Queue::RemoveExpired()
|
|||||||
for (std::list<ActionBasket*>::iterator iter = actions.begin(); iter != actions.end(); iter++)
|
for (std::list<ActionBasket*>::iterator iter = actions.begin(); iter != actions.end(); iter++)
|
||||||
{
|
{
|
||||||
ActionBasket* basket = *iter;
|
ActionBasket* basket = *iter;
|
||||||
if (sPlayerbotAIConfig->expireActionTime && basket->isExpired(sPlayerbotAIConfig->expireActionTime / 1000))
|
if (sPlayerbotAIConfig->expireActionTime && basket->isExpired(sPlayerbotAIConfig->expireActionTime))
|
||||||
expired.push_back(basket);
|
expired.push_back(basket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,6 @@ void Queue::RemoveExpired()
|
|||||||
|
|
||||||
if (ActionNode* action = basket->getAction())
|
if (ActionNode* action = basket->getAction())
|
||||||
{
|
{
|
||||||
// LOG_DEBUG("playerbots", "Action {} is expired", action->getName().c_str());
|
|
||||||
delete action;
|
delete action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ class FindBuffVisitor : public IterateItemsVisitor
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
Item* itemForSpell = *GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue<Item*>("item for spell", spellId);
|
Item* itemForSpell = *GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue<Item*>("item for spell", spellId);
|
||||||
if (itemForSpell && itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
|
if (itemForSpell && itemForSpell->IsInWorld() && itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (items.find(proto->SubClass) == items.end())
|
if (items.find(proto->SubClass) == items.end())
|
||||||
|
|||||||
@ -63,10 +63,10 @@ bool CastSpellAction::Execute(Event event)
|
|||||||
bool CastSpellAction::isPossible()
|
bool CastSpellAction::isPossible()
|
||||||
{
|
{
|
||||||
if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true)) {
|
if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true)) {
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "Can cast spell failed. Vehicle. - bot name: {}",
|
// LOG_DEBUG("playerbots", "Can cast spell failed. Vehicle. - bot name: {}",
|
||||||
bot->GetName());
|
// bot->GetName());
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,10 +75,10 @@ bool CastSpellAction::isPossible()
|
|||||||
|
|
||||||
if (spell == "mount" && bot->IsInCombat())
|
if (spell == "mount" && bot->IsInCombat())
|
||||||
{
|
{
|
||||||
if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
// if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) {
|
||||||
LOG_DEBUG("playerbots", "Can cast spell failed. Mount. - bot name: {}",
|
// LOG_DEBUG("playerbots", "Can cast spell failed. Mount. - bot name: {}",
|
||||||
bot->GetName());
|
// bot->GetName());
|
||||||
}
|
// }
|
||||||
bot->Dismount();
|
bot->Dismount();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "LeaveGroupAction.h"
|
#include "LeaveGroupAction.h"
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "PlayerbotAIConfig.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
|
|
||||||
bool LeaveGroupAction::Execute(Event event)
|
bool LeaveGroupAction::Execute(Event event)
|
||||||
@ -153,5 +154,9 @@ bool LeaveFarAwayAction::isUseful()
|
|||||||
if (abs(int32(master->getLevel() - bot->getLevel())) > 4)
|
if (abs(int32(master->getLevel() - bot->getLevel())) > 4)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (bot->GetMapId() != master->GetMapId() || bot->GetDistance2d(master) >= 2 * sPlayerbotAIConfig->rpgDistance) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ void GroupStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
|||||||
{
|
{
|
||||||
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("invite nearby", 4.0f), nullptr)));
|
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("invite nearby", 4.0f), nullptr)));
|
||||||
triggers.push_back(new TriggerNode("random", NextAction::array(0, new NextAction("invite guild", 4.0f), nullptr)));
|
triggers.push_back(new TriggerNode("random", NextAction::array(0, new NextAction("invite guild", 4.0f), nullptr)));
|
||||||
triggers.push_back(new TriggerNode("seldom", NextAction::array(0, new NextAction("leave far away", 4.0f), nullptr)));
|
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("leave far away", 4.0f), nullptr)));
|
||||||
triggers.push_back(new TriggerNode("seldom", NextAction::array(0, new NextAction("reset instances", 1.0f), nullptr)));
|
triggers.push_back(new TriggerNode("seldom", NextAction::array(0, new NextAction("reset instances", 1.0f), nullptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ class SpellInfo;
|
|||||||
class ItemForSpellValue : public CalculatedValue<Item*>, public Qualified
|
class ItemForSpellValue : public CalculatedValue<Item*>, public Qualified
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ItemForSpellValue(PlayerbotAI* botAI, std::string const name = "item for spell") : CalculatedValue<Item*>(botAI, name, 20 * 1000) { }
|
ItemForSpellValue(PlayerbotAI* botAI, std::string const name = "item for spell") : CalculatedValue<Item*>(botAI, name, 1) { }
|
||||||
|
|
||||||
Item* Calculate() override;
|
Item* Calculate() override;
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ bool SpellCastUsefulValue::Calculate()
|
|||||||
qualifier == "rockbiter weapon" || qualifier == "earthliving weapon" || qualifier == "spellstone")
|
qualifier == "rockbiter weapon" || qualifier == "earthliving weapon" || qualifier == "spellstone")
|
||||||
{
|
{
|
||||||
if (Item* item = AI_VALUE2(Item*, "item for spell", spellid))
|
if (Item* item = AI_VALUE2(Item*, "item for spell", spellid))
|
||||||
if (item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
|
if (item->IsInWorld() && item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user