From 568592f18899e28bc8097ba2d099cc13121ebc4f Mon Sep 17 00:00:00 2001 From: Yunfan Li <56597220+liyunfan1223@users.noreply.github.com> Date: Mon, 13 Jan 2025 01:03:27 +0800 Subject: [PATCH] Minor fixes to spell and mount init (#863) * Make summon imp non-temporary * Remove horse mount from troll * Set facing to during spell casting * Allow rpg status command * Init unarmed skill and fix skill clear * Cast delay after interrupt spell --- src/PlayerbotAI.cpp | 18 +++++++++++++----- src/RandomPlayerbotMgr.cpp | 2 +- src/factory/PlayerbotFactory.cpp | 9 +++++---- src/strategy/rpg/NewRpgAction.cpp | 5 ++++- src/strategy/rpg/NewRpgAction.h | 2 +- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index f33c450c..8037b40c 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -328,13 +328,14 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) if (currentSpell && currentSpell->GetSpellInfo() && currentSpell->getState() == SPELL_STATE_PREPARING) { const SpellInfo* spellInfo = currentSpell->GetSpellInfo(); - + Unit* spellTarget = currentSpell->m_targets.GetUnitTarget(); // interrupt if target is dead - if (currentSpell->m_targets.GetUnitTarget() && !currentSpell->m_targets.GetUnitTarget()->IsAlive() && + if (spellTarget && !spellTarget->IsAlive() && !spellInfo->IsAllowingDeadTarget()) { InterruptSpell(); - SetNextCheckDelay(sPlayerbotAIConfig->reactDelay); + YieldThread(GetReactDelay()); + return; } bool isHeal = false; @@ -357,10 +358,16 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) } } // interrupt if target ally has full health (heal by other member) - if (isHeal && isSingleTarget && currentSpell->m_targets.GetUnitTarget() && currentSpell->m_targets.GetUnitTarget()->IsFullHealth()) + if (isHeal && isSingleTarget && spellTarget && spellTarget->IsFullHealth()) { InterruptSpell(); - SetNextCheckDelay(sPlayerbotAIConfig->reactDelay); + YieldThread(GetReactDelay()); + return; + } + + if (spellTarget && !bot->HasInArc(CAST_ANGLE_IN_FRONT, spellTarget) && (spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT)) + { + sServerFacade->SetFacingTo(bot, spellTarget); } // wait for spell cast @@ -817,6 +824,7 @@ bool PlayerbotAI::IsAllowedCommand(std::string const text) unsecuredCommands.insert("sendmail"); unsecuredCommands.insert("invite"); unsecuredCommands.insert("leave"); + unsecuredCommands.insert("rpg status"); } for (std::set::iterator i = unsecuredCommands.begin(); i != unsecuredCommands.end(); ++i) diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 1722cab4..f8e53659 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -1510,7 +1510,7 @@ void RandomPlayerbotMgr::PrepareTeleportCache() } LOG_INFO("playerbots", ">> {} locations for level collected.", collected_locs); - LOG_INFO("playerbots", "Preparing innkeepers locations for level collected..."); + LOG_INFO("playerbots", "Preparing innkeepers locations for level..."); if (sPlayerbotAIConfig->enableNewRpgStrategy) { results = WorldDatabase.Query( diff --git a/src/factory/PlayerbotFactory.cpp b/src/factory/PlayerbotFactory.cpp index 64d93bd8..436a58b2 100644 --- a/src/factory/PlayerbotFactory.cpp +++ b/src/factory/PlayerbotFactory.cpp @@ -2185,6 +2185,7 @@ void PlayerbotFactory::InitSkills() uint32 skillLevel = bot->GetLevel() < 40 ? 0 : 1; uint32 dualWieldLevel = bot->GetLevel() < 20 ? 0 : 1; SetRandomSkill(SKILL_DEFENSE); + SetRandomSkill(SKILL_UNARMED); switch (bot->getClass()) { case CLASS_DRUID: @@ -2328,8 +2329,8 @@ void PlayerbotFactory::SetRandomSkill(uint16 id) uint16 step = bot->GetSkillValue(id) ? bot->GetSkillStep(id) : 1; - if (!bot->HasSkill(id) || value > curValue) - bot->SetSkill(id, step, value, maxValue); + // if (!bot->HasSkill(id) || value > curValue) + bot->SetSkill(id, step, value, maxValue); } void PlayerbotFactory::InitAvailableSpells() @@ -2475,7 +2476,7 @@ void PlayerbotFactory::InitClassSpells() case CLASS_WARLOCK: bot->learnSpell(687, true); bot->learnSpell(686, true); - bot->learnSpell(688, true); // summon imp + bot->learnSpell(688, false); // summon imp if (level >= 10) { bot->learnSpell(697, false); // summon voidwalker @@ -2867,7 +2868,7 @@ void PlayerbotFactory::InitMounts() fast = {23225, 23223, 23222}; break; case RACE_TROLL: - slow = {10796, 10799, 8395, 472}; + slow = {10796, 10799, 8395}; fast = {23241, 23242, 23243}; break; case RACE_DRAENEI: diff --git a/src/strategy/rpg/NewRpgAction.cpp b/src/strategy/rpg/NewRpgAction.cpp index 478f56fb..30068c17 100644 --- a/src/strategy/rpg/NewRpgAction.cpp +++ b/src/strategy/rpg/NewRpgAction.cpp @@ -18,8 +18,11 @@ bool TellRpgStatusAction::Execute(Event event) { + Player* owner = event.getOwner(); + if (!owner) + return false; std::string out = botAI->rpgInfo.ToString(); - botAI->TellMasterNoFacing(out); + bot->Whisper(out.c_str(), LANG_UNIVERSAL, owner); return true; } diff --git a/src/strategy/rpg/NewRpgAction.h b/src/strategy/rpg/NewRpgAction.h index 8e590e7a..058822be 100644 --- a/src/strategy/rpg/NewRpgAction.h +++ b/src/strategy/rpg/NewRpgAction.h @@ -24,7 +24,7 @@ protected: // const int32 setGrindInterval = 5 * 60 * 1000; // const int32 setNpcInterval = 1 * 60 * 1000; const int32 statusNearNpcDuration = 5 * 60 * 1000; - const int32 statusNearRandomDuration = 2 * 60 * 1000; + const int32 statusNearRandomDuration = 5 * 60 * 1000; const int32 statusRestDuration = 30 * 1000; WorldPosition SelectRandomGrindPos(); WorldPosition SelectRandomInnKeeperPos();