SpellCastTargets targets; if(mage->IsPlayer()) { targets.ReadForCaster(mage, SPELL_TARGET_SINGLE_ENEMY); enemy->CastSpell(spellID, SpellCastTargets); }
SpellCastTargets targets; if(paladin->IsPlayer()) { targets.ReadForCaster(partyMember, SPELL_TARGET_SINGLE_FRIENDLY); partyMember->CastSpell(spellID, SpellCastTargets); }In both examples, the SpellCastTargets object is created to determine the valid targets for the spell cast. The ReadForCaster function is then used to read the targets based on the caster's properties. The resulting targets are then used to cast the spell on the appropriate target. The package library for this example is the World of Warcraft API, which is used for creating addons for the popular MMORPG.