From cdbd5fb8c7b434e347111b12d69216a815feb164 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Tue, 30 May 2023 01:06:56 +0800 Subject: [PATCH] misc(druid shape shift and spell immuned) --- src/PlayerbotAI.cpp | 89 ++++++++++--------- src/strategy/druid/DruidShapeshiftActions.cpp | 2 +- 2 files changed, 46 insertions(+), 45 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 524384e8..76cac833 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -1679,44 +1679,44 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell, if (!itemTarget) { - // bool positiveSpell = spellInfo->IsPositive(); + bool positiveSpell = spellInfo->IsPositive(); // if (positiveSpell && bot->IsHostileTo(target)) // return false; // if (!positiveSpell && bot->IsFriendlyTo(target)) // return false; - // bool damage = false; - // for (uint8 i = EFFECT_0; i <= EFFECT_2; i++) - // { - // if (spellInfo->Effects[i].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) - // { - // damage = true; - // break; - // } - // } + bool damage = false; + for (uint8 i = EFFECT_0; i <= EFFECT_2; i++) + { + if (spellInfo->Effects[i].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) + { + damage = true; + break; + } + } - // if (target->IsImmunedToSpell(spellInfo)) { - // if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) { - // LOG_DEBUG("playerbots", "target is immuned to spell - target name: {}, spellid: {}, bot name: {}", - // target->GetName(), spellid, bot->GetName()); - // } - // return false; - // } + if (target->IsImmunedToSpell(spellInfo)) { + if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) { + LOG_DEBUG("playerbots", "target is immuned to spell - target name: {}, spellid: {}, bot name: {}", + target->GetName(), spellid, bot->GetName()); + } + return false; + } - // if (!damage) - // { - // for (uint8 i = EFFECT_0; i <= EFFECT_2; i++) - // { - // if (target->IsImmunedToSpellEffect(spellInfo, i)) { - // if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) { - // LOG_DEBUG("playerbots", "target is immuned to spell effect - target name: {}, spellid: {}, bot name: {}", - // target->GetName(), spellid, bot->GetName()); - // } - // return false; - // } - // } - // } + if (!damage) + { + for (uint8 i = EFFECT_0; i <= EFFECT_2; i++) + { + if (target->IsImmunedToSpellEffect(spellInfo, i)) { + if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) { + LOG_DEBUG("playerbots", "target is immuned to spell effect - target name: {}, spellid: {}, bot name: {}", + target->GetName(), spellid, bot->GetName()); + } + return false; + } + } + } if (bot != target && sServerFacade->GetDistance2d(bot, target) > sPlayerbotAIConfig->sightDistance) { if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) { @@ -2036,20 +2036,20 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget) spell->prepare(&targets); - if (spellInfo->Effects[0].Effect == SPELL_EFFECT_OPEN_LOCK || spellInfo->Effects[0].Effect == SPELL_EFFECT_SKINNING) - { - LootObject loot = *aiObjectContext->GetValue("loot target"); - if (!loot.IsLootPossible(bot)) - { - spell->cancel(); - delete spell; - if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) { - LOG_DEBUG("playerbots", "Spell cast loot - target name: {}, spellid: {}, bot name: {}", - target->GetName(), spellId, bot->GetName()); - } - return false; - } - } + // if (spellInfo->Effects[0].Effect == SPELL_EFFECT_OPEN_LOCK || spellInfo->Effects[0].Effect == SPELL_EFFECT_SKINNING) + // { + // LootObject loot = *aiObjectContext->GetValue("loot target"); + // if (!loot.IsLootPossible(bot)) + // { + // spell->cancel(); + // delete spell; + // if (!sPlayerbotAIConfig->logInGroupOnly || bot->GetGroup()) { + // LOG_DEBUG("playerbots", "Spell cast loot - target name: {}, spellid: {}, bot name: {}", + // target->GetName(), spellId, bot->GetName()); + // } + // return false; + // } + // } WaitForSpellCast(spell); if (spell->GetCastTime()) @@ -2473,6 +2473,7 @@ void PlayerbotAI::WaitForSpellCast(Spell* spell) if (spellInfo->IsChanneled()) { int32 duration = spellInfo->GetDuration(); + bot->ApplySpellMod(spellInfo->Id, SPELLMOD_DURATION, duration); if (duration > 0) castTime += duration; } diff --git a/src/strategy/druid/DruidShapeshiftActions.cpp b/src/strategy/druid/DruidShapeshiftActions.cpp index ea4934bc..08bb0e66 100644 --- a/src/strategy/druid/DruidShapeshiftActions.cpp +++ b/src/strategy/druid/DruidShapeshiftActions.cpp @@ -31,7 +31,7 @@ bool CastTravelFormAction::isUseful() bool CastCasterFormAction::isUseful() { return botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "aquatic form", - "flight form", "swift flight form", "moonkin form", "tree of life", nullptr); + "flight form", "swift flight form", "moonkin form", nullptr); } bool CastCasterFormAction::Execute(Event event)