public static void UpdateSpellInfo(this Spell spell) { spell.CurrentSpellPosition = spell.GetCurrentSpellPosition(); spell.CurrentNegativePosition = spell.GetCurrentSpellPosition(true, 0); spell.Dangerlevel = spell.GetSpellDangerLevel(); //spell.radius = spell.GetSpellRadius(); }
public static float GetSpellHitTime(this Spell spell, Vector2 pos) { if (spell.SpellType == SpellType.Line) { if (spell.Info.ProjectileSpeed == float.MaxValue) { return(Math.Max(0, spell.EndTime - EvadeUtils.TickCount - Game.Ping)); } var spellPos = spell.GetCurrentSpellPosition(true, Game.Ping); return(1000 * spellPos.Distance(pos) / spell.Info.ProjectileSpeed); } else if (spell.SpellType == SpellType.Circular) { return(Math.Max(0, spell.EndTime - EvadeUtils.TickCount - Game.Ping)); } return(float.MaxValue); }
public static float GetClosestDistanceApproach(Spell spell, Vector2 pos, float speed, float delay, Vector2 heroPos, float extraDist) { var walkDir = (pos - heroPos).Normalized(); if (spell.SpellType == SpellType.Line && spell.Info.ProjectileSpeed != float.MaxValue) { var spellPos = spell.GetCurrentSpellPosition(true, delay); var spellStartPos = spell.CurrentSpellPosition; var spellEndPos = spell.GetSpellEndPosition(); var extendedPos = pos.ExtendDir(walkDir, GameData.HeroInfo.BoundingRadius + speed * delay / 1000); Vector2 cHeroPos; Vector2 cSpellPos; var cpa2 = MathUtils.GetCollisionDistanceEx( heroPos, walkDir * speed, GameData.HeroInfo.BoundingRadius, spellPos, spell.Direction * spell.Info.ProjectileSpeed, spell.Radius + extraDist, out cHeroPos, out cSpellPos); var cHeroPosProjection = cHeroPos.ProjectOn(heroPos, extendedPos); var cSpellPosProjection = cSpellPos.ProjectOn(spellPos, spellEndPos); if (cSpellPosProjection.IsOnSegment && cHeroPosProjection.IsOnSegment && cpa2 != float.MaxValue) { return 0; } var cpa = MathUtilsCpa.CPAPointsEx(heroPos, walkDir * speed, spellPos, spell.Direction * spell.Info.ProjectileSpeed, pos, spellEndPos, out cHeroPos, out cSpellPos); cHeroPosProjection = cHeroPos.ProjectOn(heroPos, extendedPos); cSpellPosProjection = cSpellPos.ProjectOn(spellPos, spellEndPos); var checkDist = GameData.HeroInfo.BoundingRadius + spell.Radius + extraDist; if (cSpellPosProjection.IsOnSegment && cHeroPosProjection.IsOnSegment) { return Math.Max(0, cpa - checkDist); } else { return checkDist; } //return MathUtils.ClosestTimeOfApproach(heroPos, walkDir * speed, spellPos, spell.direction * spell.info.projectileSpeed); } else if (spell.SpellType == SpellType.Line && spell.Info.ProjectileSpeed == float.MaxValue) { var spellHitTime = Math.Max(0, spell.EndTime - EvadeUtils.TickCount - delay); //extraDelay var walkRange = heroPos.Distance(pos); var predictedRange = speed * (spellHitTime / 1000); var tHeroPos = heroPos + walkDir * Math.Min(predictedRange, walkRange); //Hero predicted pos var projection = tHeroPos.ProjectOn(spell.StartPos, spell.EndPos); return Math.Max(0, tHeroPos.Distance(projection.SegmentPoint) - (spell.Radius + GameData.HeroInfo.BoundingRadius + extraDist)); //+ dodgeBuffer } else if (spell.SpellType == SpellType.Circular) { var spellHitTime = Math.Max(0, spell.EndTime - EvadeUtils.TickCount - delay); //extraDelay var walkRange = heroPos.Distance(pos); var predictedRange = speed * (spellHitTime / 1000); var tHeroPos = heroPos + walkDir * Math.Min(predictedRange, walkRange); //Hero predicted pos if (spell.Info.SpellName == "VeigarEventHorizon") { var wallRadius = 65; var midRadius = spell.Radius - wallRadius; if (spellHitTime == 0) { return 0; } if (tHeroPos.Distance(spell.EndPos) >= spell.Radius) { return Math.Max(0, tHeroPos.Distance(spell.EndPos) - midRadius - wallRadius); } else { return Math.Max(0, midRadius - tHeroPos.Distance(spell.EndPos) - wallRadius); } } var closestDist = Math.Max(0, tHeroPos.Distance(spell.EndPos) - (spell.Radius + extraDist)); if (spell.Info.ExtraEndTime > 0 && closestDist != 0) { var remainingTime = Math.Max(0, spell.EndTime + spell.Info.ExtraEndTime - EvadeUtils.TickCount - delay); var predictedRange2 = speed * (remainingTime / 1000); var tHeroPos2 = heroPos + walkDir * Math.Min(predictedRange2, walkRange); if (CheckMoveToDirection(tHeroPos, tHeroPos2)) { return 0; } } else { return closestDist; } } else if (spell.SpellType == SpellType.Arc) { var spellPos = spell.GetCurrentSpellPosition(true, delay); var spellEndPos = spell.GetSpellEndPosition(); var pDir = spell.Direction.Perpendicular(); spellPos = spellPos - pDir * spell.Radius / 2; spellEndPos = spellEndPos - pDir * spell.Radius / 2; var extendedPos = pos.ExtendDir(walkDir, GameData.HeroInfo.BoundingRadius); Vector2 cHeroPos; Vector2 cSpellPos; var cpa = MathUtilsCpa.CPAPointsEx(heroPos, walkDir * speed, spellPos, spell.Direction * spell.Info.ProjectileSpeed, pos, spellEndPos, out cHeroPos, out cSpellPos); var cHeroPosProjection = cHeroPos.ProjectOn(heroPos, extendedPos); var cSpellPosProjection = cSpellPos.ProjectOn(spellPos, spellEndPos); var checkDist = spell.Radius + extraDist; if (cHeroPos.InSkillShot(spell, GameData.HeroInfo.BoundingRadius)) { if (cSpellPosProjection.IsOnSegment && cHeroPosProjection.IsOnSegment) { return Math.Max(0, cpa - checkDist); } else { return checkDist; } } } return 1; }