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 bool ActivateEvadeSpell(Spell spell, bool checkSpell = false) { var sortedEvadeSpells = EvadeSpells.OrderBy(s => s.Dangerlevel); var extraDelayBuffer = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer); float spellActivationTime = ConfigValue.SpellActivationTime.GetInt() + Game.Ping + extraDelayBuffer; if (ConfigValue.CalculateWindupDelay.GetBool()) { var extraWindupDelay = Evade.LastWindupTime - EvadeUtils.TickCount; if (extraWindupDelay > 0) { return false; } } foreach (var evadeSpell in sortedEvadeSpells) { var processSpell = true; if (!Config.Properties.GetEvadeSpell(evadeSpell.Name).Use || ((int) GetSpellDangerLevel(evadeSpell) > (int) spell.GetSpellDangerLevel()) || (!evadeSpell.IsItem && MyHero.Spellbook.CanUseSpell(evadeSpell.SpellKey) != SpellState.Ready)|| (evadeSpell.IsItem && !(Items.CanUseItem((int) evadeSpell.ItemId))) || (evadeSpell.CheckSpellName && MyHero.Spellbook.GetSpell(evadeSpell.SpellKey).Name != evadeSpell.SpellName)) { continue; //can't use spell right now } float evadeTime, spellHitTime; spell.CanHeroEvade(MyHero, out evadeTime, out spellHitTime); float finalEvadeTime = (spellHitTime - evadeTime); if (checkSpell) { var mode = Config.Properties.GetEvadeSpell(evadeSpell.Name).SpellMode; switch (mode) { case SpellModes.Undodgeable: continue; case SpellModes.ActivationTime: if (spellActivationTime < finalEvadeTime) { continue; } break; } } else { //if (ObjectCache.menuCache.cache[evadeSpell.name + "LastResort"].Cast<CheckBox>().CurrentValue) 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, GameData.HeroInfo.MoveSpeed, 0, 0); if ((int) GetSpellDangerLevel(evadeSpell) > (int) posInfo.PosDangerLevel) { continue; } } } } if (evadeSpell.EvadeType != EvadeType.Dash && spellHitTime > evadeSpell.SpellDelay + 100 + Game.Ping + Config.Properties.GetInt(ConfigValue.ExtraPingBuffer)) { processSpell = false; if (checkSpell == false) { continue; } } if (evadeSpell.IsSpecial) { if (evadeSpell.UseSpellFunc != null) if (evadeSpell.UseSpellFunc(evadeSpell, processSpell)) return true; continue; } if (evadeSpell.EvadeType == EvadeType.Blink) { if (evadeSpell.CastType == CastType.Position) { var posInfo = EvadeHelper.GetBestPositionBlink(); if (posInfo != null) { CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Position), processSpell); //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.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) { CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Target), processSpell); //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D())); return true; } } } else if (evadeSpell.EvadeType == 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 - GameData.HeroInfo.ServerPos2D).Normalized(); var range = GameData.HeroInfo.ServerPos2D.Distance(posInfo.Position); var pos = GameData.HeroInfo.ServerPos2D - dir * range; posInfo.Position = pos; } CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Position), processSpell); //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.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) { CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Target), processSpell); //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D())); return true; } } } else if (evadeSpell.EvadeType == EvadeType.WindWall) { if (spell.HasProjectile() || evadeSpell.SpellName == "FioraW") //TODO: temp fix, don't have fiora :'( { var dir = (spell.StartPos - GameData.HeroInfo.ServerPos2D).Normalized(); var pos = GameData.HeroInfo.ServerPos2D + dir * 100; CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, pos), processSpell); return true; } } else if (evadeSpell.EvadeType == EvadeType.SpellShield) { if (evadeSpell.IsItem) { CastEvadeSpell(() => Items.UseItem((int)evadeSpell.ItemId), processSpell); return true; } else { if (evadeSpell.CastType == CastType.Target) { CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, MyHero), processSpell); return true; } else if (evadeSpell.CastType == CastType.Self) { CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell); return true; } } } else if (evadeSpell.EvadeType == EvadeType.MovementSpeedBuff) { } } return false; }
public static string GetSpellDangerString(this Spell spell) { return(Enum.GetName(typeof(SpellDangerLevel), spell.GetSpellDangerLevel())); }
public static bool ActivateEvadeSpell(Spell spell, bool checkSpell = false) { var sortedEvadeSpells = EvadeSpells.OrderBy(s => s.Dangerlevel); var extraDelayBuffer = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer); float spellActivationTime = ConfigValue.SpellActivationTime.GetInt() + Game.Ping + extraDelayBuffer; if (ConfigValue.CalculateWindupDelay.GetBool()) { var extraWindupDelay = Evade.LastWindupTime - EvadeUtils.TickCount; if (extraWindupDelay > 0) { return(false); } } foreach (var evadeSpell in sortedEvadeSpells) { var processSpell = true; if (!Config.Properties.GetEvadeSpell(evadeSpell.Name).Use || ((int)GetSpellDangerLevel(evadeSpell) > (int)spell.GetSpellDangerLevel()) || (!evadeSpell.IsItem && MyHero.Spellbook.CanUseSpell(evadeSpell.SpellKey) != SpellState.Ready) || (evadeSpell.IsItem && !(Items.CanUseItem((int)evadeSpell.ItemId))) || (evadeSpell.CheckSpellName && MyHero.Spellbook.GetSpell(evadeSpell.SpellKey).Name != evadeSpell.SpellName)) { continue; //can't use spell right now } float evadeTime, spellHitTime; spell.CanHeroEvade(MyHero, out evadeTime, out spellHitTime); float finalEvadeTime = (spellHitTime - evadeTime); if (checkSpell) { var mode = Config.Properties.GetEvadeSpell(evadeSpell.Name).SpellMode; switch (mode) { case SpellModes.Undodgeable: continue; case SpellModes.ActivationTime: if (spellActivationTime < finalEvadeTime) { continue; } break; } } else { //if (ObjectCache.menuCache.cache[evadeSpell.name + "LastResort"].Cast<CheckBox>().CurrentValue) 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, GameData.HeroInfo.MoveSpeed, 0, 0); if ((int)GetSpellDangerLevel(evadeSpell) > (int)posInfo.PosDangerLevel) { continue; } } } } if (evadeSpell.EvadeType != EvadeType.Dash && spellHitTime > evadeSpell.SpellDelay + 100 + Game.Ping + Config.Properties.GetInt(ConfigValue.ExtraPingBuffer)) { processSpell = false; if (checkSpell == false) { continue; } } if (evadeSpell.IsSpecial) { if (evadeSpell.UseSpellFunc != null) { if (evadeSpell.UseSpellFunc(evadeSpell, processSpell)) { return(true); } } continue; } if (evadeSpell.EvadeType == EvadeType.Blink) { if (evadeSpell.CastType == CastType.Position) { var posInfo = EvadeHelper.GetBestPositionBlink(); if (posInfo != null) { CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Position), processSpell); //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.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) { CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Target), processSpell); //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D())); return(true); } } } else if (evadeSpell.EvadeType == 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 - GameData.HeroInfo.ServerPos2D).Normalized(); var range = GameData.HeroInfo.ServerPos2D.Distance(posInfo.Position); var pos = GameData.HeroInfo.ServerPos2D - dir * range; posInfo.Position = pos; } CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Position), processSpell); //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.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) { CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.Target), processSpell); //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D())); return(true); } } } else if (evadeSpell.EvadeType == EvadeType.WindWall) { if (spell.HasProjectile() || evadeSpell.SpellName == "FioraW") //TODO: temp fix, don't have fiora :'( { var dir = (spell.StartPos - GameData.HeroInfo.ServerPos2D).Normalized(); var pos = GameData.HeroInfo.ServerPos2D + dir * 100; CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, pos), processSpell); return(true); } } else if (evadeSpell.EvadeType == EvadeType.SpellShield) { if (evadeSpell.IsItem) { CastEvadeSpell(() => Items.UseItem((int)evadeSpell.ItemId), processSpell); return(true); } else { if (evadeSpell.CastType == CastType.Target) { CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, MyHero), processSpell); return(true); } else if (evadeSpell.CastType == CastType.Self) { CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell); return(true); } } } else if (evadeSpell.EvadeType == EvadeType.MovementSpeedBuff) { } } return(false); }