From 74830ea137f66648da57e28f3da2df6b52745165 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Thu, 8 Feb 2024 13:18:36 +0800 Subject: [PATCH] Item spell cast --- src/PlayerbotAI.cpp | 7 ++----- src/strategy/actions/UseItemAction.cpp | 6 ++---- src/strategy/generic/CastTimeStrategy.cpp | 2 +- src/strategy/generic/CombatStrategy.cpp | 2 +- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 147b6ac0..f4187184 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -38,6 +38,7 @@ #include "GuildMgr.h" #include "SayAction.h" #include +#include #include std::vector PlayerbotAI::dispel_whitelist = { @@ -2441,10 +2442,6 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget) if (failWithDelay) { SetNextCheckDelay(sPlayerbotAIConfig->reactDelay); - // if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - // LOG_DEBUG("playerbots", "Spell cast fail with delay - target name: {}, spellid: {}, bot name: {}", - // target->GetName(), spellId, bot->GetName()); - // } return false; } @@ -2963,7 +2960,7 @@ bool PlayerbotAI::IsInVehicle(bool canControl, bool canCast, bool canAttack, boo void PlayerbotAI::WaitForSpellCast(Spell* spell) { SpellInfo const* spellInfo = spell->GetSpellInfo(); - uint32 castTime = spellInfo->CalcCastTime(bot, spell); + uint32 castTime = spell->GetCastTime(); // float castTime = spell->GetCastTime(); // if (spellInfo->IsChanneled()) // { diff --git a/src/strategy/actions/UseItemAction.cpp b/src/strategy/actions/UseItemAction.cpp index 3ffb7434..906cfa8b 100644 --- a/src/strategy/actions/UseItemAction.cpp +++ b/src/strategy/actions/UseItemAction.cpp @@ -230,10 +230,8 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni targetSelected = true; out << " on "<< chat->FormatItem(itemForSpell->GetTemplate()); } - - Spell* spell = new Spell(bot, spellInfo, TRIGGERED_NONE); - botAI->WaitForSpellCast(spell); - delete spell; + uint32 castTime = spellInfo->CalcCastTime(); + botAI->SetNextCheckDelay(castTime + sPlayerbotAIConfig->reactDelay); } break; diff --git a/src/strategy/generic/CastTimeStrategy.cpp b/src/strategy/generic/CastTimeStrategy.cpp index 82ba6836..23e14ca7 100644 --- a/src/strategy/generic/CastTimeStrategy.cpp +++ b/src/strategy/generic/CastTimeStrategy.cpp @@ -27,7 +27,7 @@ float CastTimeMultiplier::GetValue(Action* action) if ((spellInfo->Targets & TARGET_FLAG_DEST_LOCATION) != 0 || (spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION) != 0) return 1.0f; - uint32 castTime = spellInfo->CalcCastTime(); + uint32 castTime = spellInfo->CalcCastTime(bot); if (spellInfo->IsChanneled()) { diff --git a/src/strategy/generic/CombatStrategy.cpp b/src/strategy/generic/CombatStrategy.cpp index 10878326..483fbe00 100644 --- a/src/strategy/generic/CombatStrategy.cpp +++ b/src/strategy/generic/CombatStrategy.cpp @@ -52,7 +52,7 @@ float AvoidAoeStrategyMultiplier::GetValue(Action* action) else if (spellId && pSpellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION) return 1.0f; - uint32 castTime = pSpellInfo->CalcCastTime(); + uint32 castTime = pSpellInfo->CalcCastTime(bot); if (AI_VALUE2(bool, "has area debuff", "self target") && spellId && castTime > 0) {