public static float CompareFastestPosition(Spell spell, Vector2 start, Vector2 movePos) { var fastestPos = GetFastestPosition(spell); var moveDir = (movePos - start).Normalized(); var fastestDir = (GetFastestPosition(spell) - start).Normalized(); return(moveDir.AngleBetween(fastestDir)); // * (180 / ((float)Math.PI)); }
public static bool ShouldUseMovementBuff(Spell spell) { var sortedEvadeSpells = EvadeSpells.Where(s => s.EvadeType == EvadeType.MovementSpeedBuff).OrderBy(s => s.Dangerlevel); return(sortedEvadeSpells.All(evadeSpell => Evade.EvadeSpellMenu[evadeSpell.CharName + evadeSpell.Name + "EvadeSpellSettings"][evadeSpell.Name + "UseEvadeSpell"].Enabled && GetSpellDangerLevel(evadeSpell) <= spell.GetSpellDangerLevel() && (evadeSpell.IsItem || !MyHero.SpellBook.CanUseSpell(evadeSpell.SpellKey)) && (!evadeSpell.IsItem || MyHero.SpellBook.CanUseSpell(evadeSpell.SpellKey)) && (!evadeSpell.CheckSpellName || MyHero.SpellBook.GetSpell(evadeSpell.SpellKey).Name == evadeSpell.SpellName))); }
private void CompareSpellLocation(Spell spell, Vector2 pos, float time) { var pos2 = spell.CurrentSpellPosition; if (spell.SpellObject != null) { ConsolePrinter.Print("Compare: " + pos2.Distance(pos) / (Environment.TickCount - time)); } }
private void CompareSpellLocation2(Spell spell) { var pos1 = spell.CurrentSpellPosition; var timeNow = Environment.TickCount; if (spell.SpellObject != null) { ConsolePrinter.Print("start distance: " + spell.StartPos.Distance(pos1)); } DelayAction.Add(250, () => CompareSpellLocation(spell, pos1, timeNow)); }
public static Vector2 GetFastestPosition(Spell spell) { var heroPos = ObjectCache.MyHeroCache.ServerPos2D; switch (spell.SpellType) { case SpellType.Line: var projection = heroPos.ProjectOn(spell.StartPos, spell.EndPos).SegmentPoint; return(projection.Extend(heroPos, spell.Radius + ObjectCache.MyHeroCache.BoundingRadius + 10)); case SpellType.Circular: return(spell.EndPos.Extend(heroPos, spell.Radius + 10)); } return(Vector2.Zero); }
public static bool InSkillShot(this Vector2 position, Spell spell, float radius, bool predictCollision = true) { if (spell.SpellType == SpellType.Line) { var spellPos = spell.CurrentSpellPosition; var spellEndPos = predictCollision ? spell.GetSpellEndPosition() : spell.EndPos; var projection = position.ProjectOn(spellPos, spellEndPos); return(projection.IsOnSegment && projection.SegmentPoint.Distance(position) <= spell.Radius + radius); } if (spell.SpellType == SpellType.Circular) { if (spell.Info.SpellName == "VeigarEventHorizon") { return(position.Distance(spell.EndPos) <= spell.Radius + radius - ObjectCache.MyHeroCache.BoundingRadius && position.Distance(spell.EndPos) >= spell.Radius + radius - ObjectCache.MyHeroCache.BoundingRadius - 125); } if (spell.Info.SpellName == "DariusCleave") { return(position.Distance(spell.EndPos) <= spell.Radius + radius - ObjectCache.MyHeroCache.BoundingRadius && position.Distance(spell.EndPos) >= spell.Radius + radius - ObjectCache.MyHeroCache.BoundingRadius - 220); } return(position.Distance(spell.EndPos) <= spell.Radius + radius - ObjectCache.MyHeroCache.BoundingRadius); } if (spell.SpellType == SpellType.Arc) { if (position.IsLeftOfLineSegment(spell.StartPos, spell.EndPos)) { return(false); } var spellRange = spell.StartPos.Distance(spell.EndPos); var midPoint = spell.StartPos + spell.Direction * (spellRange / 2); return(position.Distance(midPoint) <= spell.Radius + radius - ObjectCache.MyHeroCache.BoundingRadius); } if (spell.SpellType == SpellType.Cone) { return(!position.IsLeftOfLineSegment(spell.CnStart, spell.CnLeft) && !position.IsLeftOfLineSegment(spell.CnLeft, spell.CnRight) && !position.IsLeftOfLineSegment(spell.CnRight, spell.CnStart)); } return(false); }
public static bool PredictSpellCollision(Spell spell, Vector2 pos, float speed, float delay, Vector2 heroPos, float extraDist, bool useServerPosition = true) { extraDist = extraDist + 10; if (useServerPosition == false) { return(GetClosestDistanceApproach(spell, pos, speed, 0, ObjectCache.MyHeroCache.ServerPos2D, 0) == 0); } return(GetClosestDistanceApproach(spell, pos, speed, delay, ObjectCache.MyHeroCache.ServerPos2DPing, extraDist) == 0 || GetClosestDistanceApproach(spell, pos, speed, ObjectCache.GamePing, //Game.Ping ObjectCache.MyHeroCache.ServerPos2DPing, extraDist) == 0); }
private static bool ShouldActivateEvadeSpell(Spell spell) { if (Evade.LastPosInfo == null) { return(false); } if (ObjectCache.MenuCache.Cache["DodgeSkillShots"].As <MenuKeyBind>().Enabled) { if (Evade.LastPosInfo.UndodgeableSpells.Contains(spell.SpellId) && ObjectCache.MyHeroCache.ServerPos2D.InSkillShot(spell, ObjectCache.MyHeroCache.BoundingRadius)) { return(true); } } else { if (ObjectCache.MyHeroCache.ServerPos2D.InSkillShot(spell, ObjectCache.MyHeroCache.BoundingRadius)) { return(true); } } return(false); }
public static float GetIntersectDistance(Spell spell, Vector2 start, Vector2 end) { if (spell == null) { return(float.MaxValue); } switch (spell.SpellType) { case SpellType.Line: var hasIntersection = spell.LineIntersectLinearSpellEx(start, end, out var intersection); if (hasIntersection) { return(start.Distance(intersection)); } break; case SpellType.Circular: if (end.InSkillShot(spell, ObjectCache.MyHeroCache.BoundingRadius) == false) { MathUtils.FindLineCircleIntersections(spell.EndPos, spell.Radius, start, end, out var intersection1, out var intersection2); if (intersection1.X != float.NaN && MathUtils.isPointOnLineSegment(intersection1, start, end)) { return(start.Distance(intersection1)); } if (intersection2.X != float.NaN && MathUtils.isPointOnLineSegment(intersection2, start, end)) { return(start.Distance(intersection2)); } } break; } return(float.MaxValue); }
public static float GetClosestDistanceApproach(Spell spell, Vector2 pos, float speed, float delay, Vector2 heroPos, float extraDist) { var walkDir = (pos - heroPos).Normalized(); switch (spell.SpellType) { case SpellType.Line when spell.Info.ProjectileSpeed != float.MaxValue: { var spellPos = spell.GetCurrentSpellPosition(true, delay); var spellEndPos = spell.GetSpellEndPosition(); var extendedPos = pos.ExtendDir(walkDir, ObjectCache.MyHeroCache.BoundingRadius + speed * delay / 1000); var cpa2 = MathUtils.GetCollisionDistanceEx(heroPos, walkDir * speed, ObjectCache.MyHeroCache.BoundingRadius, spellPos, spell.Direction * spell.Info.ProjectileSpeed, spell.Radius + extraDist, out var cHeroPos, out var 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 = ObjectCache.MyHeroCache.BoundingRadius + spell.Radius + extraDist; if (cSpellPosProjection.IsOnSegment && cHeroPosProjection.IsOnSegment) { return(Math.Max(0, cpa - checkDist)); } return(checkDist); //return MathUtils.ClosestTimeOfApproach(heroPos, walkDir * speed, spellPos, spell.Orientation * spell.info.projectileSpeed); } case SpellType.Line when spell.Info.ProjectileSpeed == float.MaxValue: { var spellHitTime = Math.Max(0, spell.EndTime - Environment.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 + ObjectCache.MyHeroCache.BoundingRadius + extraDist))); //+ dodgeBuffer } case SpellType.Circular: { var spellHitTime = Math.Max(0, spell.EndTime - Environment.TickCount - delay); //extraDelay var walkRange = heroPos.Distance(pos); var predictedRange = speed * (spellHitTime / 1000); var tHeroPos = heroPos + walkDir * Math.Min(predictedRange, walkRange); //Hero predicted pos switch (spell.Info.SpellName) { case "VeigarEventHorizon": { const int wallRadius = 65; var midRadius = spell.Radius - wallRadius; if (spellHitTime == 0) { return(0); } return(tHeroPos.Distance(spell.EndPos) >= spell.Radius ? Math.Max(0, tHeroPos.Distance(spell.EndPos) - midRadius - wallRadius) : Math.Max(0, midRadius - tHeroPos.Distance(spell.EndPos) - wallRadius)); } case "DariusCleave": { const int wallRadius = 115; var midRadius = spell.Radius - wallRadius; if (spellHitTime == 0) { return(0); } return(tHeroPos.Distance(spell.EndPos) >= spell.Radius ? Math.Max(0, tHeroPos.Distance(spell.EndPos) - midRadius - wallRadius) : 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 - Environment.TickCount - delay); var predictedRange2 = speed * (remainingTime / 1000); var tHeroPos2 = heroPos + walkDir * Math.Min(predictedRange2, walkRange); if (CheckMoveToDirection(tHeroPos, tHeroPos2)) { return(0); } } else { return(closestDist); } break; } case 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, ObjectCache.MyHeroCache.BoundingRadius); var cpa = MathUtilsCpa.CPAPointsEx(heroPos, walkDir * speed, spellPos, spell.Direction * spell.Info.ProjectileSpeed, pos, spellEndPos, out var cHeroPos, out var cSpellPos); var cHeroPosProjection = cHeroPos.ProjectOn(heroPos, extendedPos); var cSpellPosProjection = cSpellPos.ProjectOn(spellPos, spellEndPos); var checkDist = spell.Radius + extraDist; if (cHeroPos.InSkillShot(spell, ObjectCache.MyHeroCache.BoundingRadius)) { if (cSpellPosProjection.IsOnSegment && cHeroPosProjection.IsOnSegment) { return(Math.Max(0, cpa - checkDist)); } return(checkDist); } break; } case SpellType.Cone: { var spellHitTime = Math.Max(0, spell.EndTime - Environment.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 sides = new[] { heroPos.ProjectOn(spell.CnStart, spell.CnLeft).SegmentPoint, heroPos.ProjectOn(spell.CnLeft, spell.CnRight).SegmentPoint, heroPos.ProjectOn(spell.CnRight, spell.CnStart).SegmentPoint }; var p = sides.OrderBy(x => x.Distance(x)).First(); return(Math.Max(0, tHeroPos.Distance(p) - (spell.Radius + ObjectCache.MyHeroCache.BoundingRadius + extraDist))); } } return(1); }
public void Initialize(Entity holder, Spell[] newSpells, Slider manaUI) { spells = newSpells; this.holder = holder; this.manaUI = manaUI; }
public static PositionInfo InitPositionInfo(Vector2 pos, float extraDelayBuffer, float extraEvadeDistance, Vector2 lastMovePos, Spell lowestEvadeTimeSpell) { if (!ObjectCache.MyHeroCache.HasPath && ObjectCache.MyHeroCache.ServerPos2D.Distance(pos) <= 75) { pos = ObjectCache.MyHeroCache.ServerPos2D; } var extraDist = ObjectCache.MenuCache.Cache["ExtraCPADistance"].As <MenuSlider>().Value; PositionInfo posInfo; posInfo = CanHeroWalkToPos(pos, ObjectCache.MyHeroCache.MoveSpeed, extraDelayBuffer + ObjectCache.GamePing, extraDist); posInfo.IsDangerousPos = pos.CheckDangerousPos(6); posInfo.HasExtraDistance = extraEvadeDistance > 0 && pos.CheckDangerousPos(extraEvadeDistance); posInfo.ClosestDistance = posInfo.DistanceToMouse; posInfo.DistanceToMouse = pos.GetPositionValue(); posInfo.PosDistToChamps = pos.GetDistanceToChampions(); posInfo.Speed = ObjectCache.MyHeroCache.MoveSpeed; if (ObjectCache.MenuCache.Cache["RejectMinDistance"].As <MenuSlider>().Value > 0 && ObjectCache.MenuCache.Cache["RejectMinDistance"].As <MenuSlider>().Value > posInfo.ClosestDistance) //reject closestdistance { posInfo.RejectPosition = true; } if (ObjectCache.MenuCache.Cache["MinComfortZone"].As <MenuSlider>().Value > posInfo.PosDistToChamps) { posInfo.HasComfortZone = false; } return(posInfo); }
public static bool PlayerInSkillShot(Spell spell) { return(ObjectCache.MyHeroCache.ServerPos2D.InSkillShot(spell, ObjectCache.MyHeroCache.BoundingRadius)); }
public void ApplyEffects(Champion owner, AttackableUnit target, Spell spell, Projectile projectile) { }
public void OnStartCasting(Champion owner, Spell spell, AttackableUnit target) { }
public void UpdateSpells(Spell newSpell, int slot) { spells[slot] = newSpell; var slots = GameObject.FindGameObjectWithTag("Spellbar").GetComponentsInChildren<SpellSlot>(); slots[slot].Place(newSpell); }
public void BindCastableToSpell(Spell spell) { DatabaseInstance = spell; }
public static bool ActivateEvadeSpell(Spell spell, bool checkSpell = false) { if (spell.Info.SpellName.Contains("_trap")) { return(false); } var sortedEvadeSpells = EvadeSpells.OrderBy(s => s.Dangerlevel); var extraDelayBuffer = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value; var spellActivationTime = ObjectCache.MenuCache.Cache["SpellActivationTime"].As <MenuSlider>().Value + ObjectCache.GamePing + extraDelayBuffer; if (ObjectCache.MenuCache.Cache["CalculateWindupDelay"].Enabled) { var extraWindupDelay = Evade.LastWindupTime - Environment.TickCount; if (extraWindupDelay > 0) { return(false); } } foreach (var evadeSpell in sortedEvadeSpells) { var processSpell = true; if (!Evade.EvadeSpellMenu[evadeSpell.CharName + evadeSpell.Name + "EvadeSpellSettings"][evadeSpell.Name + "UseEvadeSpell"].Enabled || GetSpellDangerLevel(evadeSpell) > spell.GetSpellDangerLevel() || !MyHero.SpellBook.CanUseSpell(evadeSpell.SpellKey) || evadeSpell.CheckSpellName && MyHero.SpellBook.GetSpell(evadeSpell.SpellKey).Name != evadeSpell.SpellName) { continue; } spell.CanHeroEvade(MyHero, out var evadeTime, out var spellHitTime); var finalEvadeTime = spellHitTime - evadeTime; if (checkSpell) { var mode = Evade.EvadeSpellMenu[evadeSpell.CharName + evadeSpell.Name + "EvadeSpellSettings"][evadeSpell.Name + "EvadeSpellMode"].As <MenuList>().Value; switch (mode) { case 0: continue; case 1: if (spellActivationTime < finalEvadeTime) { continue; } break; } } else { if (evadeSpell.SpellDelay <= 50 && evadeSpell.EvadeType != EvadeType.Dash) { var path = MyHero.Path; if (path.Length > 0) { var movePos = path[path.Length - 1].To2D(); var posInfo = EvadeHelper.CanHeroWalkToPos(movePos, ObjectCache.MyHeroCache.MoveSpeed, 0, 0); if (GetSpellDangerLevel(evadeSpell) > posInfo.PosDangerLevel) { continue; } } } } if (evadeSpell.EvadeType != EvadeType.Dash && spellHitTime > evadeSpell.SpellDelay + 100 + Game.Ping + ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value) { processSpell = false; if (checkSpell == false) { continue; } } if (evadeSpell.IsSpecial) { if (evadeSpell.UseSpellFunc == null) { continue; } if (evadeSpell.UseSpellFunc(evadeSpell, processSpell)) { return(true); } } else { switch (evadeSpell.EvadeType) { case EvadeType.Blink: if (evadeSpell.CastType == CastType.Position) { var posInfo = EvadeHelper.GetBestPositionBlink(); if (posInfo != null) { if (processSpell) { MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Position.To3D()); } //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell); //DelayAction.Add(50, () => myHero.IssueOrder(OrderType.MoveTo, posInfo.position.To3D())); return(true); } } else if (evadeSpell.CastType == CastType.Target) { var posInfo = EvadeHelper.GetBestPositionTargetedDash(evadeSpell); if (posInfo != null && posInfo.Target != null && posInfo.PosDangerLevel == 0) { if (processSpell) { MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Target); } //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.target), processSpell); //DelayAction.Add(50, () => myHero.IssueOrder(OrderType.MoveTo, posInfo.position.To3D())); return(true); } } break; case EvadeType.Dash: if (evadeSpell.CastType == CastType.Position) { var posInfo = EvadeHelper.GetBestPositionDash(evadeSpell); if (posInfo != null && CompareEvadeOption(posInfo, checkSpell)) { if (evadeSpell.IsReversed) { var dir = (posInfo.Position - ObjectCache.MyHeroCache.ServerPos2D).Normalized(); var range = ObjectCache.MyHeroCache.ServerPos2D.Distance(posInfo.Position); var pos = ObjectCache.MyHeroCache.ServerPos2D - dir * range; posInfo.Position = pos; } if (processSpell) { MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Position.To3D()); } return(true); } } else if (evadeSpell.CastType == CastType.Target) { var posInfo = EvadeHelper.GetBestPositionTargetedDash(evadeSpell); if (posInfo != null && posInfo.Target != null && posInfo.PosDangerLevel == 0) { if (processSpell) { MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Target); } return(true); } } break; case EvadeType.WindWall: if (spell.HasProjectile() || evadeSpell.SpellName == "FioraW") { var dir = (spell.StartPos - ObjectCache.MyHeroCache.ServerPos2D).Normalized(); var pos = ObjectCache.MyHeroCache.ServerPos2D + dir * 100; if (processSpell) { MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, pos.To3D()); } return(true); } break; case EvadeType.SpellShield: if (evadeSpell.IsItem) { if (processSpell) { MyHero.SpellBook.CastSpell(evadeSpell.SpellKey); } //CastEvadeSpell(() => myHero.SpellBook.CastSpell(evadeSpell.spellKey), processSpell); return(true); } switch (evadeSpell.CastType) { case CastType.Target: if (processSpell) { MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, MyHero); } // CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, myHero), processSpell); return(true); case CastType.Self: if (processSpell) { MyHero.SpellBook.CastSpell(evadeSpell.SpellKey); } //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell); return(true); } break; case EvadeType.MovementSpeedBuff: if (evadeSpell.IsItem) { var posInfo = EvadeHelper.GetBestPosition(); if (posInfo != null) { if (processSpell) { MyHero.SpellBook.CastSpell(evadeSpell.SpellKey); } //CastEvadeSpell(() => myHero.SpellBook.CastSpell(evadeSpell.spellKey), processSpell); DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.Position)); return(true); } } else { switch (evadeSpell.CastType) { case CastType.Self: { var posInfo = EvadeHelper.GetBestPosition(); if (posInfo != null) { if (processSpell) { MyHero.SpellBook.CastSpell(evadeSpell.SpellKey); } //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell); DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.Position)); return(true); } break; } case CastType.Position: { var posInfo = EvadeHelper.GetBestPosition(); if (posInfo != null) { if (processSpell) { MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Position.To3D()); } //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell); DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.Position)); return(true); } break; } case CastType.Target: break; default: throw new ArgumentOutOfRangeException(); } } break; } } } return(false); }
public void OnFinishCasting(Champion owner, Spell spell, AttackableUnit target) { spell.spellAnimation("SPELL2", owner); ApiFunctionManager.AddParticleTarget(owner, "Evelynn_W_cas.troy", owner); FrenzyBuff = owner.AddBuffGameScript("EveFrenzy", "EveFrenzy", spell, 3.0f, true); }
public bool TryCastSpell(Spell spell, GameObject initialTarget) { return(TryCastSpell(spell, initialTarget, initialTarget.transform.position)); }
public void Initialize(Entity holder, Spell[] newSpells, float maxMana) { spells = newSpells; this.holder = holder; mana = maxMana; }