Merge pull request #402 from liyunfan1223/dev0728

Minor fixes
This commit is contained in:
Yunfan Li
2024-07-29 01:28:39 +08:00
committed by GitHub
6 changed files with 62 additions and 28 deletions

View File

@@ -136,6 +136,9 @@ void PlayerbotFactory::Init()
continue; continue;
} }
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(gemId); ItemTemplate const* proto = sObjectMgr->GetItemTemplate(gemId);
if (proto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE) { // unique gem
continue;
}
if (!proto || !sGemPropertiesStore.LookupEntry(proto->GemProperties)) { if (!proto || !sGemPropertiesStore.LookupEntry(proto->GemProperties)) {
continue; continue;
} }
@@ -2571,7 +2574,7 @@ void PlayerbotFactory::InitMounts()
break; break;
case RACE_NIGHTELF: case RACE_NIGHTELF:
slow = { 10789, 8394, 10793 }; slow = { 10789, 8394, 10793 };
fast = { 24252, 63637, 22723 }; fast = { 23219, 23220, 63637 };
break; break;
case RACE_UNDEAD_PLAYER: case RACE_UNDEAD_PLAYER:
slow = { 17463, 17464, 17462 }; slow = { 17463, 17464, 17462 };
@@ -2858,7 +2861,29 @@ void PlayerbotFactory::InitGlyphs(bool increment)
if (!increment) { if (!increment) {
for (uint32 slotIndex = 0; slotIndex < MAX_GLYPH_SLOT_INDEX; ++slotIndex) for (uint32 slotIndex = 0; slotIndex < MAX_GLYPH_SLOT_INDEX; ++slotIndex)
{ {
bot->SetGlyph(slotIndex, 0, true); uint32 glyph = bot->GetGlyph(slotIndex);
if (GlyphPropertiesEntry const* glyphEntry = sGlyphPropertiesStore.LookupEntry(glyph))
{
bot->RemoveAurasDueToSpell(glyphEntry->SpellId);
// Removed any triggered auras
Unit::AuraMap& ownedAuras = bot->GetOwnedAuras();
for (Unit::AuraMap::iterator iter = ownedAuras.begin(); iter != ownedAuras.end();)
{
Aura* aura = iter->second;
if (SpellInfo const* triggeredByAuraSpellInfo = aura->GetTriggeredByAuraSpellInfo())
{
if (triggeredByAuraSpellInfo->Id == glyphEntry->SpellId)
{
bot->RemoveOwnedAura(iter);
continue;
}
}
++iter;
}
bot->SetGlyph(slotIndex, 0, true);
}
} }
} }
@@ -2957,6 +2982,8 @@ void PlayerbotFactory::InitGlyphs(bool increment)
if (!glyph) { if (!glyph) {
continue; continue;
} }
GlyphPropertiesEntry const* glyphEntry = sGlyphPropertiesStore.LookupEntry(glyph);
bot->CastSpell(bot, glyphEntry->SpellId, TriggerCastFlags(TRIGGERED_FULL_MASK & ~(TRIGGERED_IGNORE_SHAPESHIFT | TRIGGERED_IGNORE_CASTER_AURASTATE)));
bot->SetGlyph(realSlot, glyph, true); bot->SetGlyph(realSlot, glyph, true);
chosen.insert(glyph); chosen.insert(glyph);
} else { } else {
@@ -2990,6 +3017,8 @@ void PlayerbotFactory::InitGlyphs(bool increment)
continue; continue;
chosen.insert(id); chosen.insert(id);
GlyphPropertiesEntry const* glyphEntry = sGlyphPropertiesStore.LookupEntry(id);
bot->CastSpell(bot, glyphEntry->SpellId, TriggerCastFlags(TRIGGERED_FULL_MASK & ~(TRIGGERED_IGNORE_SHAPESHIFT | TRIGGERED_IGNORE_CASTER_AURASTATE)));
bot->SetGlyph(realSlot, id, true); bot->SetGlyph(realSlot, id, true);
found = true; found = true;

View File

@@ -2211,8 +2211,8 @@ void RandomItemMgr::BuildAmmoCache()
{ {
for (uint32 subClass = ITEM_SUBCLASS_ARROW; subClass <= ITEM_SUBCLASS_BULLET; subClass++) for (uint32 subClass = ITEM_SUBCLASS_ARROW; subClass <= ITEM_SUBCLASS_BULLET; subClass++)
{ {
QueryResult results = WorldDatabase.Query("SELECT entry, Flags FROM item_template WHERE class = {} AND subclass = {} AND RequiredLevel <= {} AND stackable = 1000 " QueryResult results = WorldDatabase.Query("SELECT entry, Flags FROM item_template WHERE class = {} AND subclass = {} AND RequiredLevel <= {} "
"ORDER BY RequiredLevel DESC", ITEM_CLASS_PROJECTILE, subClass, level); "ORDER BY stackable DESC, RequiredLevel DESC", ITEM_CLASS_PROJECTILE, subClass, level);
if (!results) if (!results)
continue; continue;
do { do {

View File

@@ -375,7 +375,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
LOG_INFO("playerbots", "Creating random bot accounts..."); LOG_INFO("playerbots", "Creating random bot accounts...");
std::vector<std::future<void>> account_creations; std::vector<std::future<void>> account_creations;
bool account_creation = false; int account_creation = 0;
for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber) for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber)
{ {
std::ostringstream out; std::ostringstream out;
@@ -389,7 +389,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
{ {
continue; continue;
} }
account_creation = true; account_creation++;
std::string password = ""; std::string password = "";
if (sPlayerbotAIConfig->randomBotRandomPassword) if (sPlayerbotAIConfig->randomBotRandomPassword)
{ {
@@ -408,6 +408,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
if (account_creation) { if (account_creation) {
/* wait for async accounts create to make character create correctly, same as account delete */ /* wait for async accounts create to make character create correctly, same as account delete */
LOG_INFO("playerbots", "Waiting for {} accounts loading into database...", account_creation);
std::this_thread::sleep_for(10ms * sPlayerbotAIConfig->randomBotAccountCount); std::this_thread::sleep_for(10ms * sPlayerbotAIConfig->randomBotAccountCount);
} }
@@ -418,7 +419,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
std::unordered_map<uint8,std::vector<std::string>> names; std::unordered_map<uint8,std::vector<std::string>> names;
std::vector<std::pair<Player*, uint32>> playerBots; std::vector<std::pair<Player*, uint32>> playerBots;
std::vector<WorldSession*> sessionBots; std::vector<WorldSession*> sessionBots;
bool bot_creation = false; int bot_creation = 0;
for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber) for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber)
{ {
std::ostringstream out; std::ostringstream out;
@@ -441,7 +442,6 @@ void RandomPlayerbotFactory::CreateRandomBots()
{ {
continue; continue;
} }
bot_creation = true;
LOG_INFO("playerbots", "Creating random bot characters for account: [{}/{}]", accountNumber + 1, sPlayerbotAIConfig->randomBotAccountCount); LOG_INFO("playerbots", "Creating random bot characters for account: [{}/{}]", accountNumber + 1, sPlayerbotAIConfig->randomBotAccountCount);
RandomPlayerbotFactory factory(accountId); RandomPlayerbotFactory factory(accountId);
@@ -462,19 +462,23 @@ void RandomPlayerbotFactory::CreateRandomBots()
continue; continue;
} }
if (cls != 10) if (cls != 10) {
if (Player* playerBot = factory.CreateRandomBot(session, cls, names)) { if (Player* playerBot = factory.CreateRandomBot(session, cls, names)) {
playerBot->SaveToDB(true, false); playerBot->SaveToDB(true, false);
sCharacterCache->AddCharacterCacheEntry(playerBot->GetGUID(), accountId, playerBot->GetName(), sCharacterCache->AddCharacterCacheEntry(playerBot->GetGUID(), accountId, playerBot->GetName(),
playerBot->getGender(), playerBot->getRace(), playerBot->getClass(), playerBot->GetLevel()); playerBot->getGender(), playerBot->getRace(), playerBot->getClass(), playerBot->GetLevel());
playerBot->CleanupsBeforeDelete(); playerBot->CleanupsBeforeDelete();
delete playerBot; delete playerBot;
bot_creation++;
} else {
LOG_ERROR("playerbots", "Fail to create character for account {}", accountId);
} }
}
} }
} }
if (bot_creation) { if (bot_creation) {
LOG_INFO("playerbots", "Waiting for {} characters loading into database...", totalCharCount); 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(10s);
} }

View File

@@ -1501,7 +1501,6 @@ void RandomPlayerbotMgr::Randomize(Player* bot)
else { else {
RandomizeFirst(bot); RandomizeFirst(bot);
} }
RandomTeleportForLevel(bot);
} }
void RandomPlayerbotMgr::IncreaseLevel(Player* bot) void RandomPlayerbotMgr::IncreaseLevel(Player* bot)
@@ -1590,6 +1589,8 @@ void RandomPlayerbotMgr::RandomizeFirst(Player* bot)
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
RandomTeleportForLevel(bot);
} }
void RandomPlayerbotMgr::RandomizeMin(Player* bot) void RandomPlayerbotMgr::RandomizeMin(Player* bot)

View File

@@ -164,15 +164,15 @@ bool SummonAction::SummonUsingNpcs(Player* summoner, Player* player)
bool SummonAction::Teleport(Player* summoner, Player* player) bool SummonAction::Teleport(Player* summoner, Player* player)
{ {
Player* master = GetMaster(); Player* master = GetMaster();
if (master->GetMap() && master->GetMap()->IsDungeon()) { // if (master->GetMap() && master->GetMap()->IsDungeon()) {
InstanceMap* map = master->GetMap()->ToInstanceMap(); // InstanceMap* map = master->GetMap()->ToInstanceMap();
if (map) { // if (map) {
if (map->CannotEnter(player) == Map::CANNOT_ENTER_MAX_PLAYERS) { // if (map->CannotEnter(player, true) == Map::CANNOT_ENTER_MAX_PLAYERS) {
botAI->TellError("I can not enter this dungeon"); // botAI->TellError("I can not enter this dungeon");
return false; // return false;
} // }
} // }
} // }
if (!summoner->IsBeingTeleported() && !player->IsBeingTeleported()) if (!summoner->IsBeingTeleported() && !player->IsBeingTeleported())
{ {
float followAngle = GetFollowAngle(); float followAngle = GetFollowAngle();

View File

@@ -72,11 +72,11 @@ UnholyDKStrategy::UnholyDKStrategy(PlayerbotAI* botAI) : GenericDKStrategy(botAI
NextAction** UnholyDKStrategy::getDefaultActions() NextAction** UnholyDKStrategy::getDefaultActions()
{ {
return NextAction::array(0, return NextAction::array(0,
new NextAction("death and decay", ACTION_DEFAULT + 1.0f), new NextAction("death and decay", ACTION_DEFAULT + 0.5f),
new NextAction("scourge strike", ACTION_DEFAULT + 0.8f), new NextAction("horn of winter", ACTION_DEFAULT + 0.4f),
new NextAction("horn of winter", ACTION_DEFAULT + 0.6f), new NextAction("summon gargoyle", ACTION_DEFAULT + 0.3f),
new NextAction("summon gargoyle", ACTION_DEFAULT + 0.4f),
new NextAction("death coil", ACTION_DEFAULT + 0.2f), new NextAction("death coil", ACTION_DEFAULT + 0.2f),
new NextAction("scourge strike", ACTION_NORMAL + 0.1f),
new NextAction("melee", ACTION_DEFAULT), new NextAction("melee", ACTION_DEFAULT),
nullptr); nullptr);
} }
@@ -91,8 +91,8 @@ void UnholyDKStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
triggers.push_back(new TriggerNode("no desolation", NextAction::array(0, new NextAction("blood strike", ACTION_HIGH + 4), nullptr))); triggers.push_back(new TriggerNode("no desolation", NextAction::array(0, new NextAction("blood strike", ACTION_HIGH + 4), nullptr)));
triggers.push_back(new TriggerNode("death and decay cooldown", triggers.push_back(new TriggerNode("death and decay cooldown",
NextAction::array(0, NextAction::array(0,
new NextAction("ghoul frenzy", ACTION_DEFAULT + 5.0f), new NextAction("ghoul frenzy", ACTION_NORMAL + 5.0f),
new NextAction("scourge strike", ACTION_DEFAULT + 4.0f), new NextAction("scourge strike", ACTION_NORMAL + 4.0f),
new NextAction("blood boil", ACTION_NORMAL + 3.0f), new NextAction("blood boil", ACTION_NORMAL + 3.0f),
new NextAction("icy touch", ACTION_NORMAL + 2.0f), new NextAction("icy touch", ACTION_NORMAL + 2.0f),
new NextAction("plague strike", ACTION_NORMAL + 1.0f), new NextAction("plague strike", ACTION_NORMAL + 1.0f),