SpellCastResult DoCheckCast() { Guardian pet = GetCaster().ToPlayer().GetGuardianPet(); if (pet == null || !pet.IsPet() || !pet.IsAlive()) { return(SpellCastResult.NoPet); } // Do a mini Spell::CheckCasterAuras on the pet, no other way of doing this SpellCastResult result = SpellCastResult.SpellCastOk; UnitFlags unitflag = (UnitFlags)pet.GetUInt32Value(UnitFields.Flags); if (!pet.GetCharmerGUID().IsEmpty()) { result = SpellCastResult.Charmed; } else if (unitflag.HasAnyFlag(UnitFlags.Stunned)) { result = SpellCastResult.Stunned; } else if (unitflag.HasAnyFlag(UnitFlags.Fleeing)) { result = SpellCastResult.Fleeing; } else if (unitflag.HasAnyFlag(UnitFlags.Confused)) { result = SpellCastResult.Confused; } if (result != SpellCastResult.SpellCastOk) { return(result); } Unit target = GetExplTargetUnit(); if (!target) { return(SpellCastResult.BadTargets); } if (!pet.IsWithinLOSInMap(target)) { return(SpellCastResult.LineOfSight); } return(SpellCastResult.SpellCastOk); }