public void EvadeThread() { //TO DO: collision check (minion, champ, yasuo wall) DetectedSpellData dcspell; while (true) { try { if (m_spell_queue.TryDequeue(out dcspell)) { Vector2 my_pos = ObjectManager.Player.ServerPosition.To2D(); Vector2 sender_pos = dcspell.StartPosition; Vector2 end_pos = dcspell.EndPosition; Vector2 direction = (end_pos - sender_pos).Normalized(); if (sender_pos.Distance(end_pos) > dcspell.Spell.Range) { end_pos = sender_pos + direction * dcspell.Spell.Range; } Geometry.Polygon my_hitbox = ClipperWrapper.DefineRectangle(my_pos - 60, my_pos + 60, 60); Geometry.Polygon spell_hitbox = null; if (dcspell.Spell.IsSkillshot) { if (dcspell.Spell.Type == SkillshotType.SkillshotLine) { spell_hitbox = ClipperWrapper.DefineRectangle(sender_pos, end_pos, dcspell.Spell.Radius); } else if (dcspell.Spell.Type == SkillshotType.SkillshotCircle) { spell_hitbox = ClipperWrapper.DefineCircle(end_pos, dcspell.Spell.Radius); } else if (dcspell.Spell.Type == SkillshotType.SkillshotCone) { spell_hitbox = ClipperWrapper.DefineSector(sender_pos, end_pos - sender_pos, dcspell.Spell.Radius * (float)Math.PI / 180, dcspell.Spell.Range); } } //spells with arc if (dcspell.Spell.IsArc) { float mul = (end_pos.Distance(sender_pos) / (dcspell.Spell.Range - 20.0f)); spell_hitbox = new Geometry.Polygon( ClipperWrapper.DefineArc(sender_pos - dcspell.Spell.ArcData.Pos, end_pos, dcspell.Spell.ArcData.Angle * mul, dcspell.Spell.ArcData.Width, dcspell.Spell.ArcData.Height * mul), ClipperWrapper.DefineArc(sender_pos - dcspell.Spell.ArcData.Pos, end_pos, dcspell.Spell.ArcData.Angle * mul, dcspell.Spell.ArcData.Width, (dcspell.Spell.ArcData.Height + dcspell.Spell.ArcData.Radius) * mul), spell_hitbox); } if (spell_hitbox != null) { if (ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(my_hitbox), ClipperWrapper.MakePaths(spell_hitbox))) { OnSpellHitDetected(direction, ObjectManager.Player); } else { if ((SpecialMethod.HasFlag(EvadeMethods.MorganaE) || SpecialMethod.HasFlag(EvadeMethods.KayleR)) && shieldAlly != null && shieldAlly.Item("SHIELDENABLED").GetValue <bool>()) { var allies = ObjectManager.Player.GetAlliesInRange(EvadeSpell.Range).Where(p => !p.IsMe && shieldAlly.Item("shield" + p.ChampionName).GetValue <bool>()).OrderByDescending(q => Utility.GetPriority(q.ChampionName)); if (allies != null) { foreach (Obj_AI_Base ally in allies) { Vector2 ally_pos = ally.ServerPosition.To2D(); Geometry.Polygon ally_hitbox = ClipperWrapper.DefineRectangle(ally_pos, ally_pos + 60, 60); if (ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ally_hitbox), ClipperWrapper.MakePaths(spell_hitbox))) { OnSpellHitDetected(direction, ally); break; } } } } } } m_spell_pool.PutObject(dcspell); } } catch { } Thread.Sleep(1); } }
public void EvadeThread() { //TO DO: collision check (minion, champ, yasuo wall) DetectedSpellData dcspell; while (true) { try { if (m_spell_queue.TryDequeue(out dcspell)) { Vector2 my_pos = ObjectManager.Player.ServerPosition.To2D(); Vector2 sender_pos = dcspell.StartPosition; Vector2 end_pos = dcspell.EndPosition; Vector2 direction = (end_pos - sender_pos).Normalized(); if (sender_pos.Distance(end_pos) > dcspell.Spell.Range) end_pos = sender_pos + direction * dcspell.Spell.Range; Geometry.Polygon my_hitbox = ClipperWrapper.DefineRectangle(my_pos - 60, my_pos + 60, 60); Geometry.Polygon spell_hitbox = null; if (dcspell.Spell.IsSkillshot) { if (dcspell.Spell.Type == SkillshotType.SkillshotLine) spell_hitbox = ClipperWrapper.DefineRectangle(sender_pos, end_pos, dcspell.Spell.Radius); else if (dcspell.Spell.Type == SkillshotType.SkillshotCircle) spell_hitbox = ClipperWrapper.DefineCircle(end_pos, dcspell.Spell.Radius); else if (dcspell.Spell.Type == SkillshotType.SkillshotCone) spell_hitbox = ClipperWrapper.DefineSector(sender_pos, end_pos - sender_pos, dcspell.Spell.Radius * (float)Math.PI / 180, dcspell.Spell.Range); } //spells with arc if (dcspell.Spell.IsArc) { float mul = (end_pos.Distance(sender_pos) / (dcspell.Spell.Range - 20.0f)); spell_hitbox = new Geometry.Polygon( ClipperWrapper.DefineArc(sender_pos - dcspell.Spell.ArcData.Pos, end_pos, dcspell.Spell.ArcData.Angle * mul, dcspell.Spell.ArcData.Width, dcspell.Spell.ArcData.Height * mul), ClipperWrapper.DefineArc(sender_pos - dcspell.Spell.ArcData.Pos, end_pos, dcspell.Spell.ArcData.Angle * mul, dcspell.Spell.ArcData.Width, (dcspell.Spell.ArcData.Height + dcspell.Spell.ArcData.Radius) * mul), spell_hitbox); } if (spell_hitbox != null) { if (ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(my_hitbox), ClipperWrapper.MakePaths(spell_hitbox))) OnSpellHitDetected(direction, ObjectManager.Player); else { if ((SpecialMethod.HasFlag(EvadeMethods.MorganaE) || SpecialMethod.HasFlag(EvadeMethods.KayleR)) && shieldAlly != null && shieldAlly.Item("SHIELDENABLED").GetValue<bool>()) { var allies = ObjectManager.Player.GetAlliesInRange(EvadeSpell.Range).Where(p => !p.IsMe && shieldAlly.Item("shield" + p.ChampionName).GetValue<bool>()).OrderByDescending(q => Utility.GetPriority(q.ChampionName)); if (allies != null) { foreach (Obj_AI_Base ally in allies) { Vector2 ally_pos = ally.ServerPosition.To2D(); Geometry.Polygon ally_hitbox = ClipperWrapper.DefineRectangle(ally_pos, ally_pos + 60, 60); if (ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ally_hitbox), ClipperWrapper.MakePaths(spell_hitbox))) { OnSpellHitDetected(direction, ally); break; } } } } } } m_spell_pool.PutObject(dcspell); } } catch { } Thread.Sleep(1); } }