var target = TargetSelector.GetTarget(Q.Range, TargetSelector.DamageType.Magical); if (target != null && Q.IsReady()) { var prediction = Q.GetPrediction(target); if (prediction.Hitchance >= HitChance.High) { Q.Cast(prediction.CastPosition); } }
var target = TargetSelector.GetTarget(W.Range, TargetSelector.DamageType.Magical); if (target != null && W.IsReady()) { W.CastIfHitchanceEquals(target, HitChance.Medium); }In this example, the script checks if the W spell is ready and there is an enemy target in range. If both conditions are met, the script tries to cast the spell at the target's current position using medium hitchance. If the hitchance is lower than medium, the spell will not be cast. Overall, the LeagueSharp.Common package library is used for creating custom scripts for League of Legends. The Spell CastIfHitchanceEquals method is one of the many methods provided by this library to help scripters interact with the game.