mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
check bot and target world-state before spell creation and before prepare
This commit is contained in:
@@ -3402,8 +3402,14 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Spell* spell = new Spell(bot, spellInfo, TRIGGERED_NONE);
|
// early bot/target world-state check before spell creationg a spell, after pet
|
||||||
|
if (!bot->IsInWorld() || bot->IsDuringRemoveFromWorld() ||
|
||||||
|
(target && (!target->IsInWorld() || target->IsDuringRemoveFromWorld())))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Spell* spell = new Spell(bot, spellInfo, TRIGGERED_NONE);
|
||||||
SpellCastTargets targets;
|
SpellCastTargets targets;
|
||||||
if (spellInfo->Effects[0].Effect != SPELL_EFFECT_OPEN_LOCK &&
|
if (spellInfo->Effects[0].Effect != SPELL_EFFECT_OPEN_LOCK &&
|
||||||
(spellInfo->Targets & TARGET_FLAG_ITEM || spellInfo->Targets & TARGET_FLAG_GAMEOBJECT_ITEM))
|
(spellInfo->Targets & TARGET_FLAG_ITEM || spellInfo->Targets & TARGET_FLAG_GAMEOBJECT_ITEM))
|
||||||
@@ -3491,6 +3497,15 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
|
|||||||
// if (spellSuccess != SPELL_CAST_OK)
|
// if (spellSuccess != SPELL_CAST_OK)
|
||||||
// return false;
|
// return false;
|
||||||
|
|
||||||
|
|
||||||
|
// check bot/target world-state just before preparing the actual spel
|
||||||
|
Unit* unitTarget = targets.GetUnitTarget();
|
||||||
|
if (!bot->IsInWorld() || bot->IsDuringRemoveFromWorld() ||
|
||||||
|
(unitTarget && (!unitTarget->IsInWorld() || unitTarget->IsDuringRemoveFromWorld())))
|
||||||
|
{
|
||||||
|
delete spell;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
SpellCastResult result = spell->prepare(&targets);
|
SpellCastResult result = spell->prepare(&targets);
|
||||||
|
|
||||||
if (result != SPELL_CAST_OK)
|
if (result != SPELL_CAST_OK)
|
||||||
|
|||||||
Reference in New Issue
Block a user