From 5e2497bf7e58a90d983ea0b29e0401f37f2678f6 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Wed, 7 Feb 2024 21:37:19 +0800 Subject: [PATCH] Spell cast time calculation --- src/PlayerbotAI.cpp | 8 ++++---- src/PlayerbotFactory.cpp | 17 ++++++----------- src/strategy/actions/NonCombatActions.cpp | 8 ++++---- src/strategy/actions/UseItemAction.cpp | 2 +- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 9b1afd38..147b6ac0 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -2963,8 +2963,8 @@ bool PlayerbotAI::IsInVehicle(bool canControl, bool canCast, bool canAttack, boo void PlayerbotAI::WaitForSpellCast(Spell* spell) { SpellInfo const* spellInfo = spell->GetSpellInfo(); - - float castTime = spell->GetCastTime(); + uint32 castTime = spellInfo->CalcCastTime(bot, spell); + // float castTime = spell->GetCastTime(); // if (spellInfo->IsChanneled()) // { // int32 duration = spellInfo->GetDuration(); @@ -2973,9 +2973,9 @@ void PlayerbotAI::WaitForSpellCast(Spell* spell) // castTime += duration; // } - castTime = ceil(castTime); + // castTime = ceil(castTime); - uint32 globalCooldown = CalculateGlobalCooldown(spellInfo->Id); + // uint32 globalCooldown = CalculateGlobalCooldown(spellInfo->Id); // if (castTime < globalCooldown) // castTime = globalCooldown; diff --git a/src/PlayerbotFactory.cpp b/src/PlayerbotFactory.cpp index e34133a9..b0b57660 100644 --- a/src/PlayerbotFactory.cpp +++ b/src/PlayerbotFactory.cpp @@ -2616,8 +2616,7 @@ void PlayerbotFactory::InitFood() j--; continue; } - // bot->StoreNewItemInBestSlots(itemId, urand(1, proto->GetMaxStackSize())); - bot->StoreNewItemInBestSlots(itemId, proto->GetMaxStackSize()); + StoreItem(itemId, proto->GetMaxStackSize()); } } } @@ -2662,21 +2661,17 @@ void PlayerbotFactory::InitReagents() break; case CLASS_PRIEST: if (level >= 48 && level < 60) { - items.push_back({17028, 40}); - // bot->StoreNewItemInBestSlots(17028, 40); // Wild Berries + items.push_back({17028, 40}); // Wild Berries } else if (level >= 60 && level < 80) { - items.push_back({17029, 40}); - // bot->StoreNewItemInBestSlots(17029, 40); // Wild Berries + items.push_back({17029, 40}); // Wild Berries } else if (level >= 80) { - items.push_back({44615, 40}); - // bot->StoreNewItemInBestSlots(44615, 40); // Wild Berries + items.push_back({44615, 40}); // Wild Berries } break; case CLASS_MAGE: - items.push_back({17020, 40}); + items.push_back({17020, 40}); // Arcane Powder items.push_back({17031, 40}); // portal items.push_back({17032, 40}); // portal - // bot->StoreNewItemInBestSlots(17020, 40); // Arcane Powder break; case CLASS_DRUID: if (level >= 20 && level < 30) { @@ -2715,7 +2710,7 @@ void PlayerbotFactory::InitReagents() break; } for (std::pair item : items) { - bot->StoreNewItemInBestSlots(item.first, item.second); + StoreItem(item.first, item.second); } } diff --git a/src/strategy/actions/NonCombatActions.cpp b/src/strategy/actions/NonCombatActions.cpp index d94a8adc..4bc7af6b 100644 --- a/src/strategy/actions/NonCombatActions.cpp +++ b/src/strategy/actions/NonCombatActions.cpp @@ -26,9 +26,9 @@ bool DrinkAction::Execute(Event event) if (bot->isMoving()) { - // bot->StopMoving(); + bot->StopMoving(); // botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown); - return false; + // return false; } bot->SetStandState(UNIT_STAND_STATE_SIT); botAI->InterruptSpell(); @@ -78,9 +78,9 @@ bool EatAction::Execute(Event event) if (bot->isMoving()) { - // bot->StopMoving(); + bot->StopMoving(); // botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown); - return false; + // return false; } bot->SetStandState(UNIT_STAND_STATE_SIT); diff --git a/src/strategy/actions/UseItemAction.cpp b/src/strategy/actions/UseItemAction.cpp index b17ee81e..3ffb7434 100644 --- a/src/strategy/actions/UseItemAction.cpp +++ b/src/strategy/actions/UseItemAction.cpp @@ -293,7 +293,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni if (!spellId) return false; - botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown); + // botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown); botAI->TellMasterNoFacing(out.str()); bot->GetSession()->HandleUseItemOpcode(packet); return true;