public static void CastWE(Obj_AI_Base target) { if (!SpellSlot.E.IsReady() || BallManager.Balls.Count <= 0 || !target.IsValidTarget(QE.Range + QE.Width) || !target.IsEnemy) { return; } if (SpellSlot.W.IsReady() && Game.Time - W_LastSentTime > 0.25f) { if (!IsW2 && W.Slot.Mana() + QE.Slot.Mana() <= Util.MyHero.Mana) { var best = BallManager.Balls.Where(m => m.IsIdle && !m.EIsOnTime) .OrderBy( m => target.Position.To2D() .ProjectOn(m.Position.To2D(), m.EEndPosition.To2D()) .SegmentPoint.Distance(target.Position.To2D(), true)) .LastOrDefault(); if (best != null) { Util.MyHero.Spellbook.CastSpell(W.Slot, best.Position); } } else if (IsW2 && QE.Slot.Mana() <= Util.MyHero.Mana && WObject != null && WObject.IsBall()) { if (!target.IsValidTarget(W.Range)) { QE.CastDelay = W.CastDelay + E.CastDelay; QE.Speed = W.Speed; QE.SourcePosition = Util.MyHero.Position; var pred1 = QE.GetPrediction(target); if (pred1.HitChancePercent >= 0 && pred1.CastPosition.Distance(Util.MyHero, true) <= Math.Pow(QE.Range, 2)) { var startPosition = pred1.CastPosition.E_StartPosition2(); var endPosition = startPosition.E_EndPosition().To2D(); QE.SourcePosition = startPosition; QE.CastDelay = W.CastDelay + E.CastDelay + 1000 * (int) (Util.MyHero.Distance(pred1.CastPosition) / W.Speed + Util.MyHero.Distance(startPosition) / E.Speed); var pred2 = QE.GetPrediction(target); var info = pred2.CastPosition.To2D() .ProjectOn(startPosition.To2D(), endPosition); if (pred2.HitChancePercent >= QE.Slot.HitChancePercent() && pred2.CastPosition.Distance(Util.MyHero, true) <= Math.Pow(QE.Range, 2) && info.IsOnSegment && pred2.CastPosition.To2D().Distance(info.SegmentPoint, true) <= Math.Pow(QE_Multiplier * (QE.Width + target.BoundingRadius), 2)) { var startPos = Util.MyHero.Position + (pred2.CastPosition - Util.MyHero.Position).Normalized() * (E.Range + E_ExtraWidth); Util.MyHero.Spellbook.CastSpell(W.Slot, startPos); Combo_WE = Game.Time; } } } else { if (target is AIHeroClient) { W = new Spell.Skillshot(SpellSlot.W, 950, SkillShotType.Circular, 0, 1450, W_Width2) { AllowedCollisionCount = int.MaxValue }; } var pred = W.GetPrediction(target); if (pred.HitChancePercent >= SpellSlot.W.HitChancePercent() / 2) { Util.MyHero.Spellbook.CastSpell(W.Slot, pred.CastPosition); Combo_WE = Game.Time; } } } } else if (_weObject.IsValidAlly() && _weObject.IsBall() && Game.Time - Combo_WE <= 2.0f * (W_CastDelay2 / 1000f + _weObject.Distance(W_EndPosition) / W_Speed2)) { float timeToArriveW = W_CastDelay2 / 1000f + 0.07f + Game.Ping / 2000f + (_weObject.Distance(W_EndPosition) / W_Speed2) - (Game.Time - W_LastCastTime); if (timeToArriveW >= 0) { if (timeToArriveW <= (W_EndPosition.Distance(Util.MyHero) / E.Speed) + E_CastDelay2 / 1000f) { CastE2(target, W_EndPosition); } } } }