public bool IsInRange(Vector2 point, float otherRange = -1) { return(RangeCheckFrom.DistanceSquared(point) < (otherRange < 0 ? RangeSqr : otherRange *otherRange)); }
/// <summary> /// Returns if the Vector2 is in range of the spell. /// </summary> /// <param name="point">The point.</param> /// <param name="range">The range.</param> /// <returns><c>true</c> if the specified location is in range of the spell; otherwise, <c>false</c>.</returns> public bool IsInRange(Vector2 point, float range = -1) { return(RangeCheckFrom.To2D().Distance(point, true) < (range < 0 ? RangeSqr : range *range)); }
private CastStates _cast( Obj_AI_Base unit, bool packetCast = false, bool aoe = false, bool exactHitChance = false, int minTargets = -1) { if (unit == null || Shop.IsOpen || MenuGUI.IsChatOpen) { return(CastStates.NotCasted); } //Spell not ready. if (!IsReady()) { return(CastStates.NotReady); } if (minTargets != -1) { aoe = true; } //Targetted spell. if (!IsSkillshot) { //Target out of range if (RangeCheckFrom.Distance(unit.ServerPosition, true) > GetRangeSqr(unit)) { return(CastStates.OutOfRange); } LastCastAttemptT = Utils.TickCount; if (packetCast) { if (!ObjectManager.Player.Spellbook.CastSpell(Slot, unit, false)) { return(CastStates.NotCasted); } } else { //Cant cast the Spell. if (!ObjectManager.Player.Spellbook.CastSpell(Slot, unit)) { return(CastStates.NotCasted); } } return(CastStates.SuccessfullyCasted); } /* * //Get the best position to cast the spell. * var prediction = GetPrediction(unit, aoe); * * if (minTargets != -1 && prediction.AoeTargetsHitCount < minTargets) * { * return CastStates.NotEnoughTargets; * } * * //Skillshot collides. * if (prediction.CollisionObjects.Count > 0) * { * return CastStates.Collision; * } * * //Target out of range. * if (Vector3.Distance(prediction.CastPosition, true) > RangeSqr) * { * return CastStates.OutOfRange; * } * * //The hitchance is too low. * if (prediction.Hitchance < MinHitChance || (exactHitChance && prediction.Hitchance != MinHitChance)) ||{ || return CastStates.LowHitChance; ||} || ||LastCastAttemptT = Utils.TickCount; || ||if (IsChargedSpell) ||{ || if (IsCharging) || { || ShootChargedSpell(Slot, prediction.CastPosition); || } || else || { || StartCharging(); || } ||} ||else if (packetCast) ||{ || ObjectManager.Player.Spellbook.CastSpell(Slot, prediction.CastPosition, false); ||} ||else ||{ || //Cant cast the spell (actually should not happen). || if (!ObjectManager.Player.Spellbook.CastSpell(Slot, prediction.CastPosition)) || { || return CastStates.NotCasted; || } ||} */ return(CastStates.SuccessfullyCasted); }