Ejemplo n.º 1
0
 public static bool IsFountain(Vector3 position)
 {
     float fountainRange = 750;
     var map = Map.GetMap();
     if (map != null && map.Type == MapType.SummonersRift)
     {
         fountainRange = 1050;
     }
     return ObjectManager.Get<GameObject>().Where(spawnPoint => spawnPoint is Obj_SpawnPoint && spawnPoint.IsAlly).Any(spawnPoint => Vector2.Distance(position.ToVector2(), spawnPoint.Position.ToVector2()) < fountainRange);
 }
Ejemplo n.º 2
0
 private static double GetAngle(Vector3 from, Obj_AI_Base target)
 {
     var c = target.ServerPosition.ToVector2();
     var a = target.GetWaypoints().Last();
     if (c == a)
     {
         return 60;
     }
     var b = from.ToVector2();
     var ab = Math.Pow(a.X - b.X, 2) + Math.Pow(a.Y - b.Y, 2);
     var bc = Math.Pow(b.X - c.X, 2) + Math.Pow(b.Y - c.Y, 2);
     var ac = Math.Pow(a.X - c.X, 2) + Math.Pow(a.Y - c.Y, 2);
     return Math.Cos((ab + bc - ac) / (2 * Math.Sqrt(ab) * Math.Sqrt(bc))) * 180 / Math.PI;
 }
Ejemplo n.º 3
0
        private void update_(Vector3 startV3)
        {
            //raycast to test how far we could go..
                     Vector3 MaxRangeTestVector3=MathEx.GetPointAt(startV3, Range, MathEx.ToRadians(DirectionDegrees));

                     Vector2 RaycastTestV2;
                     //we use main grid providers raycast to test since we are looking at how far we can travel and not if anything is blocking us.
                     if (Navigation.MGP.Raycast(startV3.ToVector2(), MaxRangeTestVector3.ToVector2(), out RaycastTestV2))
                     {//Set our endpoint at the Hit point
                          MaxRangeTestVector3=RaycastTestV2.ToVector3();
                          MaxRangeTestVector3.Z=Navigation.MGP.GetHeight(MaxRangeTestVector3.ToVector2()); //adjust height acordingly!
                     }
                     Range=Vector3.Distance2D(ref startV3, ref MaxRangeTestVector3);

                     //lets see if we can stand here at all?
                     if (!Navigation.MGP.CanStandAt(MaxRangeTestVector3))
                     {

                          //just because raycast set our max range, we need to see if we can use that cell as a walking point!
                          if (!Navigation.CanRayCast(startV3, MaxRangeTestVector3, Zeta.Internals.SNO.NavCellFlags.AllowWalk))
                          {
                                //loop to find a walkable range.
                                float currentRange=Range-2.5f;
                                float directionRadianFlipped=Navigation.FindDirection(MaxRangeTestVector3, startV3, true);
                                int maxTestAttempts=(int)(currentRange/2.5f);

                                for (int i=0; i<maxTestAttempts; i++)
                                {
                                     Vector3 newtestPoint=MathEx.GetPointAt(MaxRangeTestVector3, currentRange, directionRadianFlipped);
                                     newtestPoint.Z=Navigation.MGP.GetHeight(newtestPoint.ToVector2());//update Z
                                     if (Navigation.CanRayCast(startV3, newtestPoint, Zeta.Internals.SNO.NavCellFlags.AllowWalk))
                                     {
                                          MaxRangeTestVector3=newtestPoint;
                                          break;
                                     }

                                     if (currentRange-2.5f<=0f) break;
                                     currentRange=-2.5f;
                                }
                                Range=currentRange;
                          }

                     }

                     EndingPoint=MaxRangeTestVector3;
                     StartingPoint=startV3;
                     Range=startV3.Distance2D(MaxRangeTestVector3); //(float)GridPoint.GetDistanceBetweenPoints(StartingPoint, EndingPoint);
                     Center=MathEx.GetPointAt(startV3, Range/2, MathEx.ToRadians(DirectionDegrees));
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="RingPoly" /> class.
 /// </summary>
 /// <param name="center">
 ///     The Center
 /// </param>
 /// <param name="width">
 ///     The ring width
 /// </param>
 /// <param name="outerRadius">
 ///     Outer Radius
 /// </param>
 /// <param name="quality">
 ///     The Quality
 /// </param>
 public RingPoly(Vector3 center, float width, float outerRadius, int quality = 20)
     : this(center.ToVector2(), width, outerRadius, quality)
 {
 }
Ejemplo n.º 5
0
 public bool IsPathSafe(Vector3[] path)
 {
     return IsPathSafe(path.ToVector2());
 }
Ejemplo n.º 6
0
        public void MoveTowards(Vector3 destination)
        {
            if (Trinity.Settings.Advanced.DisableAllMovement)
                return;

            Trinity.NavServerReport(true);

            if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid || ZetaDia.Me.IsDead || ZetaDia.IsLoadingWorld)
            {
                return;
            }

            if (UISafetyCheck())
            {
                return;
            }

            TimeLastUsedPlayerMover = DateTime.UtcNow;
            LastMoveToTarget = destination;

            // Set the public variable

            destination = WarnAndLogLongPath(destination);

            // Store player current position

            // Store distance to current moveto target
            float destinationDistance = MyPosition.Distance2D(destination);

            // Do unstuckery things
            if (Trinity.Settings.Advanced.UnstuckerEnabled)
            {
                // See if we can reset the 10-limit unstuck counter, if >120 seconds since we last generated an unstuck location
                // this is used if we're NOT stuck...
                if (TotalAntiStuckAttempts > 1 && DateTime.UtcNow.Subtract(LastGeneratedStuckPosition).TotalSeconds >= 120)
                {
                    TotalAntiStuckAttempts = 1;
                    TimesReachedStuckPoint = 0;
                    vSafeMovementLocation = Vector3.Zero;
                    NavHelper.UsedStuckSpots = new List<GridPoint>();
                    Logger.Log(TrinityLogLevel.Info, LogCategory.Movement, "Resetting unstuck timers", true);
                }

                // See if we need to, and can, generate unstuck actions
                // check if we're stuck
                //bool isStuck = UnstuckChecker();

                //if (isStuck)
                //{
                //    // Record the time we last apparently couldn't move for a brief period of time
                //    LastRecordedAnyStuck = DateTime.UtcNow;

                //    // See if there's any stuck position to try and navigate to generated by random mover
                //    //vSafeMovementLocation = UnstuckHandler(MyPosition, vMoveToTarget);

                //    if (vSafeMovementLocation == Vector3.Zero)
                //    {
                //        Logger.Log(TrinityLogLevel.Info, LogCategory.Movement, "Unable to find Unstuck point!", vSafeMovementLocation);
                //        return;
                //    }
                //    Logger.Log(TrinityLogLevel.Verbose, LogCategory.Movement, "SafeMovement Location set to {0}", vSafeMovementLocation);

                //}

                // See if we can clear the total unstuckattempts if we haven't been stuck in over 6 minutes.
                if (DateTime.UtcNow.Subtract(LastRecordedAnyStuck).TotalSeconds >= 360)
                {
                    TimesReachedMaxUnstucks = 0;
                }
                // Did we have a safe point already generated (eg from last loop through), if so use it as our current location instead
                if (vSafeMovementLocation != Vector3.Zero)
                {
                    // Set our current movement target to the safe point we generated last cycle
                    destination = vSafeMovementLocation;
                    destinationDistance = MyPosition.Distance2D(destination);
                }
                // Get distance to current destination
                // Remove the stuck position if it's been reached, this bit of code also creates multiple stuck-patterns in an ever increasing amount
                if (vSafeMovementLocation != Vector3.Zero && destinationDistance <= 3f)
                {
                    vSafeMovementLocation = Vector3.Zero;
                    TimesReachedStuckPoint++;

                    // Do we want to immediately generate a 2nd waypoint to "chain" anti-stucks in an ever-increasing path-length?
                    if (TimesReachedStuckPoint <= TotalAntiStuckAttempts)
                    {
                        vSafeMovementLocation = NavHelper.FindSafeZone(true, TotalAntiStuckAttempts, MyPosition);
                        destination = vSafeMovementLocation;
                    }
                    else
                    {
                        if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                            Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "Clearing old route and trying new path find to: " + LastMoveToTarget.ToString());
                        // Reset the path and allow a whole "New" unstuck generation next cycle
                        TimesReachedStuckPoint = 0;
                        // And cancel unstucking for 9 seconds so DB can try to navigate
                        CancelUnstuckerForSeconds = (9 * TotalAntiStuckAttempts);
                        if (CancelUnstuckerForSeconds < 20)
                            CancelUnstuckerForSeconds = 20;
                        LastCancelledUnstucker = DateTime.UtcNow;

                        Navigator.Clear();
                        PlayerMover.NavigateTo(LastMoveToTarget, "original destination");

                        return;
                    }
                }
            }

            if (TargetUtil.AnyMobsInRange(40f))
            {
                // Always move with WW
                if (TryBulKathosWWMovement(destination, destinationDistance))
                    return;
            }

            // don't use special movement within 3 seconds of being stuck
            bool cancelSpecialMovementAfterStuck = DateTime.UtcNow.Subtract(LastGeneratedStuckPosition).TotalMilliseconds > 3000;

            // See if we can use abilities like leap etc. for movement out of combat, but not in town
            if (Trinity.Settings.Combat.Misc.AllowOOCMovement && !Trinity.Player.IsInTown && cancelSpecialMovementAfterStuck && !CombatBase.IsInCombat)
            {
                // Whirlwind for a barb, special context only
                if (Trinity.Settings.Combat.Barbarian.SprintMode != BarbarianSprintMode.CombatOnly &&
                    CacheData.Hotbar.ActivePowers.Contains(SNOPower.Barbarian_Whirlwind) && Trinity.ObjectCache.Any(u => u.IsUnit &&
                    MathUtil.IntersectsPath(u.Position, u.Radius + 5f, Trinity.Player.Position, destination)) &&
                    Trinity.Player.PrimaryResource >= V.F("Barbarian.Whirlwind.MinFury") && !Trinity.IsWaitingForSpecial && V.B("Barbarian.Whirlwind.UseForMovement"))
                {
                    Skills.Barbarian.Whirlwind.Cast(destination);
                    if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Whirlwind for OOC movement, distance={0:0}", destinationDistance);
                    return;
                }

                if (TryBulKathosWWMovement(destination, destinationDistance))
                    return;

                // Whirlwind to keep Taguk's up
                if (CombatBase.CanCast(SNOPower.Barbarian_Whirlwind) && Trinity.Player.PrimaryResource > 10 && !Sets.BulKathossOath.IsFullyEquipped &&
                    !(CurrentTarget != null && CurrentTarget.Type == TrinityObjectType.Item && CurrentTarget.Distance < 10f) &&
                    Gems.Taeguk.IsEquipped && Skills.Barbarian.Whirlwind.TimeSinceUse > 2500 && Skills.Barbarian.Whirlwind.TimeSinceUse < 3000)
                {
                    Skills.Barbarian.Whirlwind.Cast(destination);
                    if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Whirlwind for OOC movement, distance={0:0}", destinationDistance);
                    return;
                }

                // Leap movement for a barb
                if (Trinity.Settings.Combat.Barbarian.UseLeapOOC && CacheData.Hotbar.ActivePowers.Contains(SNOPower.Barbarian_Leap) &&
                PowerManager.CanCast(SNOPower.Barbarian_Leap) && !ShrinesInArea(destination))
                {
                    Vector3 vThisTarget = destination;
                    if (destinationDistance > 35f)
                        vThisTarget = MathEx.CalculatePointFrom(destination, MyPosition, 35f);
                    ZetaDia.Me.UsePower(SNOPower.Barbarian_Leap, vThisTarget, Trinity.CurrentWorldDynamicId, -1);
                    SpellHistory.RecordSpell(SNOPower.Barbarian_Leap);
                    if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Leap for OOC movement, distance={0:0}", destinationDistance);
                    return;
                }
                // Furious Charge movement for a barb
                if (Trinity.Settings.Combat.Barbarian.UseChargeOOC && CacheData.Hotbar.ActivePowers.Contains(SNOPower.Barbarian_FuriousCharge) &&
                    destinationDistance >= 20f && Skills.Barbarian.FuriousCharge.Charges > 0 &&
                    PowerManager.CanCast(SNOPower.Barbarian_FuriousCharge) && !ShrinesInArea(destination))
                {
                    Vector3 vThisTarget = destination;
                    if (destinationDistance > 35f)
                        vThisTarget = MathEx.CalculatePointFrom(destination, MyPosition, 35f);
                    ZetaDia.Me.UsePower(SNOPower.Barbarian_FuriousCharge, vThisTarget, Trinity.CurrentWorldDynamicId, -1);
                    SpellHistory.RecordSpell(SNOPower.Barbarian_FuriousCharge);
                    if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Furious Charge for OOC movement, distance={0:0}", destinationDistance);
                    return;
                }

                int vaultDelay = Trinity.Settings.Combat.DemonHunter.VaultMovementDelay;
                // DemonHunter Vault
                var vaultBaseCost = Skills.DemonHunter.Vault.Cost*(1 - Trinity.Player.ResourceCostReductionPct);
                var vaultCost = Runes.DemonHunter.Acrobatics.IsActive ? 0 : Runes.DemonHunter.Tumble.IsActive && Skills.DemonHunter.Vault.TimeSinceUse < 6000 ? Math.Round(vaultBaseCost * 0.5) : vaultBaseCost;

                if (CacheData.Hotbar.ActivePowers.Contains(SNOPower.DemonHunter_Vault) && Trinity.Settings.Combat.DemonHunter.VaultMode != DemonHunterVaultMode.CombatOnly &&
                    CombatBase.TimeSincePowerUse(SNOPower.DemonHunter_Vault) > vaultDelay && Trinity.Player.SecondaryResource >= vaultCost && 
                    destinationDistance >= 18f &&
                    PowerManager.CanCast(SNOPower.DemonHunter_Vault) && !ShrinesInArea(destination) &&
                    // Don't Vault into avoidance/monsters if we're kiting
                    (CombatBase.KiteDistance <= 0 || (CombatBase.KiteDistance > 0 &&
                     (!CacheData.TimeBoundAvoidance.Any(a => a.Position.Distance(destination) <= CombatBase.KiteDistance) ||
                     (!CacheData.TimeBoundAvoidance.Any(a => MathEx.IntersectsPath(a.Position, a.Radius, Trinity.Player.Position, destination))) ||
                     !CacheData.MonsterObstacles.Any(a => a.Position.Distance(destination) <= CombatBase.KiteDistance))))
                    )
                {
                    Vector3 vThisTarget = destination;
                    if (destinationDistance > 35f)
                        vThisTarget = MathEx.CalculatePointFrom(destination, MyPosition, 35f);
                    ZetaDia.Me.UsePower(SNOPower.DemonHunter_Vault, vThisTarget, Trinity.CurrentWorldDynamicId, -1);
                    SpellHistory.RecordSpell(SNOPower.DemonHunter_Vault);
                    if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Vault for OOC movement, distance={0}", destinationDistance);
                    return;
                }

                // DemonHunter Strafe
                if (Skills.DemonHunter.Strafe.IsActive && Trinity.Player.PrimaryResource > 12 && TargetUtil.AnyMobsInRange(30f, false) &&
                    !(CurrentTarget != null && CurrentTarget.Type == TrinityObjectType.Item && CurrentTarget.Distance < 10f) &&
                    // Don't Strafe into avoidance/monsters if we're kiting
                    (CombatBase.KiteDistance <= 0 || (CombatBase.KiteDistance > 0 &&
                     (!CacheData.TimeBoundAvoidance.Any(a => a.Position.Distance(destination) <= CombatBase.KiteDistance) ||
                     (!CacheData.TimeBoundAvoidance.Any(a => MathEx.IntersectsPath(a.Position, a.Radius, Trinity.Player.Position, destination)))))))
                {
                    if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Strafe for OOC movement, distance={0}", destinationDistance);
                    Skills.DemonHunter.Strafe.Cast(destination);
                }

                // Strafe to keep Taguk's up
                if (CombatBase.CanCast(SNOPower.DemonHunter_Strafe) && Trinity.Player.PrimaryResource > 12 &&
                    Gems.Taeguk.IsEquipped && Skills.DemonHunter.Strafe.TimeSinceUse > 2250 && Skills.DemonHunter.Strafe.TimeSinceUse < 3000)
                {
                    Skills.DemonHunter.Strafe.Cast(destination);
                    return;
                }

                // Tempest rush for a monk
                if (CacheData.Hotbar.ActivePowers.Contains(SNOPower.Monk_TempestRush) &&
                    (Trinity.Settings.Combat.Monk.TROption == TempestRushOption.MovementOnly || Trinity.Settings.Combat.Monk.TROption == TempestRushOption.Always ||
                    (Trinity.Settings.Combat.Monk.TROption == TempestRushOption.TrashOnly && !TargetUtil.AnyElitesInRange(40f))))
                {
                    Vector3 vTargetAimPoint = destination;

                    bool canRayCastTarget = true;

                    vTargetAimPoint = TargetUtil.FindTempestRushTarget();

                    if (!CanChannelTempestRush &&
                        ((Trinity.Player.PrimaryResource >= Trinity.Settings.Combat.Monk.TR_MinSpirit &&
                        destinationDistance >= Trinity.Settings.Combat.Monk.TR_MinDist) ||
                         DateTime.UtcNow.Subtract(CacheData.AbilityLastUsed[SNOPower.Monk_TempestRush]).TotalMilliseconds <= 150) &&
                        canRayCastTarget && PowerManager.CanCast(SNOPower.Monk_TempestRush))
                    {
                        CanChannelTempestRush = true;
                    }
                    else if ((CanChannelTempestRush && (Trinity.Player.PrimaryResource < 10f)) || !canRayCastTarget)
                    {
                        CanChannelTempestRush = false;
                    }

                    double lastUse = DateTime.UtcNow.Subtract(CacheData.AbilityLastUsed[SNOPower.Monk_TempestRush]).TotalMilliseconds;

                    if (CanChannelTempestRush)
                    {
                        if (Trinity.SNOPowerUseTimer(SNOPower.Monk_TempestRush))
                        {
                            LastTempestRushPosition = vTargetAimPoint;

                            ZetaDia.Me.UsePower(SNOPower.Monk_TempestRush, vTargetAimPoint, Trinity.CurrentWorldDynamicId, -1);
                            SpellHistory.RecordSpell(SNOPower.Monk_TempestRush);

                            // simulate movement speed of 30
                            SpeedSensor lastSensor = SpeedSensors.OrderByDescending(s => s.Timestamp).FirstOrDefault();
                            SpeedSensors.Add(new SpeedSensor()
                            {
                                Location = MyPosition,
                                TimeSinceLastMove = new TimeSpan(0, 0, 0, 0, 1000),
                                Distance = 5f,
                                WorldID = Trinity.CurrentWorldDynamicId
                            });

                            if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                                Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Tempest Rush for OOC movement, distance={0:0} spirit={1:0} cd={2} lastUse={3:0} V3={4} vAim={5}",
                                    destinationDistance, Trinity.Player.PrimaryResource, PowerManager.CanCast(SNOPower.Monk_TempestRush), lastUse, destination, vTargetAimPoint);
                            return;
                        }
                        else
                            return;
                    }
                    else
                    {
                        if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                            Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement,
                            "Tempest rush failed!: {0:00.0} / {1} distance: {2:00.0} / {3} Raycast: {4} MS: {5:0.0} lastUse={6:0}",
                            Trinity.Player.PrimaryResource,
                            Trinity.Settings.Combat.Monk.TR_MinSpirit,
                            destinationDistance,
                            Trinity.Settings.Combat.Monk.TR_MinDist,
                            canRayCastTarget,
                            GetMovementSpeed(),
                            lastUse);

                        Trinity.MaintainTempestRush = false;
                    }

                    // Always set this from PlayerMover
                    MonkCombat.LastTempestRushLocation = vTargetAimPoint;

                }

                // Dashing Strike OOC
                if (Trinity.Player.ActorClass == ActorClass.Monk && CombatBase.CanCast(SNOPower.X1_Monk_DashingStrike) && Trinity.Settings.Combat.Monk.UseDashingStrikeOOC &&
                    (destinationDistance > 12f || !NavHelper.CanRayCast(destination) || TargetUtil.UnitsPlayerFacing(15, 90) >=3)
                    && (!(Legendary.Ingeom.IsEquipped && CurrentTarget != null && CurrentTarget.Type == TrinityObjectType.Item) && Skills.Monk.DashingStrike.TimeSinceUse > 200))
                {
                    var charges = Skills.Monk.DashingStrike.Charges;

                    //Logger.LogVerbose("OOC Dash Charges={0}", charges);
                    if (Sets.ThousandStorms.IsSecondBonusActive && !Trinity.ShouldWaitForLootDrop &&
                        (charges > 1 || CacheData.BuffsCache.Instance.HasCastingShrine))
                    {
                        if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                            Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Dashing Strike for OOC movement, distance={0} charges={1}", destinationDistance, Skills.Monk.DashingStrike.Charges);
                        Skills.Monk.DashingStrike.Cast(destination);
                        return;
                    }

                    if (!Sets.ThousandStorms.IsSecondBonusActive && charges > 0 && PowerManager.CanCast(Skills.Monk.DashingStrike.SNOPower) && !Trinity.ShouldWaitForLootDrop)
                    {
                        Skills.Monk.DashingStrike.Cast(destination);
                        if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                            Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Dashing Strike for OOC movement, distance={0}", destinationDistance);
                        return;  
                    }
                }

                // Teleport for a wizard 
                if (!Runes.Wizard.Calamity.IsActive && CombatBase.CanCast(SNOPower.Wizard_Teleport, CombatBase.CanCastFlags.NoTimer) &&
                    CombatBase.TimeSincePowerUse(SNOPower.Wizard_Teleport) > 250 &&
                    destinationDistance >= 10f && !ShrinesInArea(destination))
                {
                    const float maxTeleportRange = 75f;

                    Vector3 vThisTarget = destination;
                    if (destinationDistance > maxTeleportRange)
                        vThisTarget = MathEx.CalculatePointFrom(destination, MyPosition, maxTeleportRange);
                    ZetaDia.Me.UsePower(SNOPower.Wizard_Teleport, vThisTarget, Trinity.CurrentWorldDynamicId, -1);
                    SpellHistory.RecordSpell(SNOPower.Wizard_Teleport);
                    if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Teleport for OOC movement, distance={0}", destinationDistance);
                    return;
                }

                // Archon Teleport for a wizard 
                if (CacheData.Hotbar.ActivePowers.Contains(SNOPower.Wizard_Archon_Teleport) && destinationDistance >= 10f &&
                PowerManager.CanCast(SNOPower.Wizard_Archon_Teleport) && !ShrinesInArea(destination))
                {
                    Vector3 vThisTarget = destination;
                    if (destinationDistance > 35f)
                        vThisTarget = MathEx.CalculatePointFrom(destination, MyPosition, 35f);
                    ZetaDia.Me.UsePower(SNOPower.Wizard_Archon_Teleport, vThisTarget, Trinity.CurrentWorldDynamicId, -1);
                    SpellHistory.RecordSpell(SNOPower.Wizard_Archon_Teleport);
                    if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Archon Teleport for OOC movement, distance={0}", destinationDistance);
                    return;
                }


            }

            if (MyPosition.Distance2D(destination) > 3f)
            {
                // Default movement
                ZetaDia.Me.UsePower(SNOPower.Walk, destination, Trinity.CurrentWorldDynamicId, -1);

                if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                    Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "PlayerMover Moved to:{0} dir:{1} Speed:{2:0.00} Dist:{3:0} ZDiff:{4:0} CanStand:{5} Raycast:{6}",
                        NavHelper.PrettyPrintVector3(destination), MathUtil.GetHeadingToPoint(destination), MovementSpeed, MyPosition.Distance2D(destination),
                        Math.Abs(MyPosition.Z - destination.Z),
                        Trinity.MainGridProvider.CanStandAt(Trinity.MainGridProvider.WorldToGrid(destination.ToVector2())),
                        !Navigator.Raycast(MyPosition, destination)
                        );

            }
            else
            {
                if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                    Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Reached MoveTowards Destination {0} Current Speed: {1:0.0}", destination, MovementSpeed);
            }

            //Trinity.IsMoveRequested = false;
        }
Ejemplo n.º 7
0
        private static bool IsHitCollision(Obj_AI_Base collision, ICloneable input, Vector3 pos, float extraRadius)
        {
            var inputSub = input.Clone() as PredictionInput;

            if (inputSub == null)
            {
                return false;
            }

            inputSub.Unit = collision;
            var radius = inputSub.Unit.BoundingRadius;
            var predPos = Movement.GetPrediction(inputSub, false, false).UnitPosition.ToVector2();

            return (collision is Obj_AI_Minion
                    && (predPos.Distance(inputSub.From) < 10 + radius || predPos.Distance(pos) < radius))
                   || predPos.LSDistanceSquared(inputSub.From.ToVector2(), pos.ToVector2(), true)
                   <= Math.Pow(inputSub.Radius + radius + extraRadius, 2);
        }
Ejemplo n.º 8
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Rectangle" /> class.
 /// </summary>
 /// <param name="start">The start.</param>
 /// <param name="end">The end.</param>
 /// <param name="width">The width.</param>
 public Rectangle(Vector3 start, Vector3 end, float width)
     : this(start.ToVector2(), end.ToVector2(), width)
 {
 }
Ejemplo n.º 9
0
        /// <summary>
        ///     Returns if the spell will hit the point when casted
        /// </summary>
        /// <param name="point">
        ///     Vector3 Target
        /// </param>
        /// <param name="castPosition">
        ///     Cast Position
        /// </param>
        /// <param name="extraWidth">
        ///     Extra Width
        /// </param>
        /// <returns>
        ///     Will Spell Hit
        /// </returns>
        public bool WillHit(Vector3 point, Vector3 castPosition, int extraWidth = 0)
        {
            switch (this.Type)
            {
                case SkillshotType.SkillshotCircle:
                    if (point.LSDistanceSquared(castPosition) < this.WidthSqr)
                    {
                        return true;
                    }

                    break;

                case SkillshotType.SkillshotLine:
                    if (point.ToVector2().LSDistanceSquared(castPosition.ToVector2(), this.From.ToVector2(), true)
                        < Math.Pow(this.Width + extraWidth, 2))
                    {
                        return true;
                    }

                    break;
                case SkillshotType.SkillshotCone:
                    var edge1 = (castPosition.ToVector2() - this.From.ToVector2()).Rotated(-this.Width / 2);
                    var edge2 = edge1.Rotated(this.Width);
                    var v = point.ToVector2() - this.From.ToVector2();
                    if (point.LSDistanceSquared(this.From) < this.RangeSqr && edge1.CrossProduct(v) > 0
                        && v.CrossProduct(edge2) > 0)
                    {
                        return true;
                    }

                    break;
            }

            return false;
        }
Ejemplo n.º 10
0
 /// <summary>
 ///     Angle between a entity and a vector in degrees
 /// </summary>
 /// <param name="entity">
 ///     The entity.
 /// </param>
 /// <param name="vector">
 ///     The vector.
 /// </param>
 /// <param name="radian">
 ///     The radian.
 /// </param>
 /// <returns>
 ///     The <see cref="float" />.
 /// </returns>
 public static float FindAngleBetween(this Entity entity, Vector3 vector, bool radian = false)
 {
     return entity.Position.ToVector2().FindAngleBetween(vector.ToVector2(), radian);
 }
Ejemplo n.º 11
0
 public bool TraceRay_Projectile_CanPass(Vector3 from, Vector3 to)
 {
     Cell cellByPoint = this.GetCellByPoint(from);
     Cell cellByPoint2 = this.GetCellByPoint(to);
     bool result;
     if (cellByPoint2 == null || cellByPoint == null)
     {
         result = false;
     }
     else
     {
         if (cellByPoint2 == cellByPoint)
         {
             result = true;
         }
         else
         {
             if (!cellByPoint.AllowWalk || !cellByPoint2.AllowWalk)
             {
                 result = false;
             }
             else
             {
                 LineSegment lineSegment_ = new LineSegment(from.ToVector2(), to.ToVector2());
                 Cell cell = cellByPoint;
                 int num = 0;
                 List<Cell> list = new List<Cell>();
                 list.Add(cellByPoint);
                 while (cell != cellByPoint2)
                 {
                     if (++num >= 15)
                     {
                         result = false;
                         return result;
                     }
                     cell = cell.method_0(lineSegment_);
                     if (cell == null)
                     {
                         result = false;
                         return result;
                     }
                     if (!cell.AllowWalk)
                     {
                         result = false;
                         return result;
                     }
                     list.Add(cell);
                 }
                 result = true;
             }
         }
     }
     return result;
 }
Ejemplo n.º 12
0
 private static bool IsThroughWall(Vector3 from, Vector3 to)
 {
     if (wallLeft == null || wallRight == null)
     {
         return false;
     }
     wallPoly = new RectanglePoly(wallLeft.Position, wallRight.Position, 75);
     for (var i = 0; i < wallPoly.Points.Count; i++)
     {
         var inter = wallPoly.Points[i].LSIntersection(
             wallPoly.Points[i != wallPoly.Points.Count - 1 ? i + 1 : 0],
             from.ToVector2(),
             to.ToVector2());
         if (inter.Intersects)
         {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 13
0
        /// <summary>
        ///     Uses prediction to cast given skill shot ability
        /// </summary>
        /// <param name="ability">
        ///     The ability.
        /// </param>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="sourcePosition">
        ///     The source Position.
        /// </param>
        /// <param name="abilityName">
        ///     The ability Name.
        /// </param>
        /// <param name="soulRing">
        ///     The soul Ring.
        /// </param>
        /// <param name="otherTargets">
        ///     Targets which are supposed to be hit by AOE Skill Shot
        /// </param>
        /// <returns>
        ///     returns true in case of successful cast
        /// </returns>
        public static bool CastSkillShot(
            this Ability ability, 
            Unit target, 
            Vector3 sourcePosition, 
            string abilityName = null, 
            Ability soulRing = null, 
            List<Unit> otherTargets = null)
        {
            if (ability == null || !ability.IsValid)
            {
                return false;
            }

            if (target == null || !target.IsValid)
            {
                return false;
            }

            if (!Utils.SleepCheck("CastSkillshot" + ability.Handle))
            {
                return false;
            }

            var name = abilityName ?? ability.StoredName();
            var owner = ability.Owner as Unit;
            var position = sourcePosition;
            var delay = ability.GetHitDelay(target, name);
            var data = ability.CommonProperties();

            // delay += data.AdditionalDelay;
            if (target.IsInvul() && !Utils.ChainStun(target, delay, null, false))
            {
                return false;
            }

            var xyz = ability.GetPrediction(target, abilityName: name);
            if (otherTargets != null)
            {
                var avPosX = otherTargets.Average(x => ability.GetPrediction(x, abilityName: name).X);
                var avPosY = otherTargets.Average(x => ability.GetPrediction(x, abilityName: name).Y);
                xyz = (xyz + new Vector3(avPosX, avPosY, 0)) / 2;
            }

            var radius = ability.GetRadius(name);
            var range = ability.TravelDistance();

            if (data.AllyBlock)
            {
                if (
                    Creeps.All.Any(
                        x =>
                        x.IsValid && x.IsAlive && x.Team == owner.Team && x.Distance2D(xyz) <= range
                        && x.Distance2D(owner) < owner.Distance2D(target)
                        && x.Position.ToVector2().DistanceToLineSegment(sourcePosition.ToVector2(), xyz.ToVector2())
                        <= radius + x.HullRadius))
                {
                    return false;
                }

                if (
                    Heroes.GetByTeam(owner.Team)
                        .Any(
                            hero =>
                            hero.IsAlive && !hero.Equals(owner) && !hero.Equals(target) && hero.Distance2D(xyz) <= range
                            && hero.Distance2D(owner) < owner.Distance2D(target)
                            && hero.Position.ToVector2()
                                   .DistanceToLineSegment(sourcePosition.ToVector2(), xyz.ToVector2())
                            <= radius + hero.HullRadius))
                {
                    return false;
                }
            }

            if (data.EnemyBlock)
            {
                if (
                    Creeps.All.Any(
                        x =>
                        x.IsValid && x.IsAlive && x.Team != owner.Team && x.Distance2D(xyz) <= range
                        && x.Distance2D(owner) < owner.Distance2D(target)
                        && x.Position.ToVector2().DistanceToLineSegment(sourcePosition.ToVector2(), xyz.ToVector2())
                        <= radius + x.HullRadius))
                {
                    return false;
                }

                if (
                    Heroes.GetByTeam(owner.GetEnemyTeam())
                        .Any(
                            hero =>
                            hero.IsAlive && !hero.Equals(target) && hero.Distance2D(xyz) <= range
                            && hero.Distance2D(owner) < owner.Distance2D(target)
                            && hero.Position.ToVector2()
                                   .DistanceToLineSegment(sourcePosition.ToVector2(), xyz.ToVector2())
                            <= radius + hero.HullRadius))
                {
                    return false;
                }
            }

            var speed = ability.GetProjectileSpeed(name);
            var distanceXyz = xyz.Distance2D(position);
            var lion = name == "lion_impale" ? ability.GetAbilityData("length_buffer") : 0;
            if (!(distanceXyz <= range + radius + lion + target.HullRadius))
            {
                return false;
            }

            if (distanceXyz > range)
            {
                xyz = xyz - position;
                xyz /= xyz.Length();
                xyz *= range;
                xyz += position;
            }

            // Console.WriteLine(ability.GetCastRange() + " " + radius);
            if (name.StartsWith("nevermore_shadowraze"))
            {
                xyz = Prediction.SkillShotXYZ(
                    owner, 
                    target, 
                    (float)((delay + (float)owner.GetTurnTime(xyz)) * 1000), 
                    speed, 
                    radius);

                // Console.WriteLine(distanceXyz + " " + range + " " + radius);
                if (distanceXyz < range + radius && distanceXyz > range - radius)
                {
                    if (owner.GetTurnTime(xyz) > 0.01)
                    {
                        owner.Move((owner.Position - xyz) * 25 / distanceXyz + xyz);
                        owner.Stop();
                    }
                    else
                    {
                        ability.UseAbility();
                    }

                    return true;
                }

                return false;
            }

            if (name == "invoker_ice_wall" && distanceXyz - 50 > 200 && distanceXyz - 50 < 610)
            {
                var mepred = (position - target.Position) * 50 / position.Distance2D(target) + target.Position;
                var v1 = xyz.X - mepred.X;
                var v2 = xyz.Y - mepred.Y;
                var a = Math.Acos(175 / xyz.Distance(mepred));
                var x1 = v1 * Math.Cos(a) - v2 * Math.Sin(a);
                var y1 = v2 * Math.Cos(a) + v1 * Math.Sin(a);
                var b = Math.Sqrt(x1 * x1 + y1 * y1);
                var k1 = x1 * 50 / b;
                var k2 = y1 * 50 / b;
                var vec1 = new Vector3((float)(k1 + mepred.X), (float)(k2 + mepred.Y), mepred.Z);
                if (vec1.Distance2D(mepred) > 0)
                {
                    owner.Move(mepred);
                    owner.Move(vec1, true);
                    ability.UseAbility(true);

                    return true;
                }

                return false;
            }

            if (ability.ManaCost > 0 && soulRing.CanBeCasted())
            {
                soulRing.UseAbility();
            }

            ability.UseAbility(xyz);
            return true;
        }
Ejemplo n.º 14
0
        private static void LaneClear()
        {
            if (ObjectManager.Player.ManaPercent < main_menu["taliyah.laneclear"]["taliyah.laneclear.manaperc"].GetValue<MenuSlider>().Value)
                return;

            if (main_menu["taliyah.laneclear"]["taliyah.laneclear.useq"].GetValue<MenuBool>().Value && Q.IsReady())
            {
                var farm = Q.GetCircularFarmLocation(ObjectManager.Get<Obj_AI_Minion>().Where(p => p.IsEnemy && p.DistanceToPlayer() < Q.Range).ToList());
                if (farm.MinionsHit >= main_menu["taliyah.laneclear"]["taliyah.laneclear.minq"].GetValue<MenuSlider>().Value)
                    Q.Cast(farm.Position);
            }

            if (main_menu["taliyah.laneclear"]["taliyah.laneclear.useew"].GetValue<MenuBool>().Value && W.IsReady() && E.IsReady())
            {
                var farm = W.GetCircularFarmLocation(ObjectManager.Get<Obj_AI_Minion>().Where(p => p.IsEnemy && p.DistanceToPlayer() < W.Range).ToList());
                if (farm.MinionsHit >= main_menu["taliyah.laneclear"]["taliyah.laneclear.minew"].GetValue<MenuSlider>().Value)
                {
                    E.Cast(farm.Position);
                    lastE = ObjectManager.Player.ServerPosition;
                    if (W.Instance.Name == "TaliyahW")
                        W.Cast(farm.Position, lastE.ToVector2());
                }
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Determines if a given Vector3 is in a provided IgnoreScene (if the scene is loaded)
        /// </summary>
        /// <param name="position"></param>
        /// <returns></returns>
        private bool PositionInsideIgnoredScene(Vector3 position)
        {
            List<Scene> ignoredScenes=ZetaDia.Scenes.GetScenes()
                .Where(scn => IgnoreScenes.Any(igscn => !String.IsNullOrEmpty(igscn.SceneName)&&scn.Name.ToLower().Contains(igscn.SceneName.ToLower()))||
                              IgnoreScenes.Any(igscn => scn.SceneInfo.SNOId==igscn.SceneId)&&
                              !PriorityScenes.Any(psc => !String.IsNullOrEmpty(psc.SceneName.Trim())&&scn.Name.ToLower().Contains(psc.SceneName))&&
                              !PriorityScenes.Any(psc => psc.SceneId!=-1&&scn.SceneInfo.SNOId!=psc.SceneId)).ToList();

            foreach (Scene scene in ignoredScenes)
            {
                if (scene.Mesh.Zone==null)
                    return true;

                Vector2 pos=position.ToVector2();
                Vector2 min=scene.Mesh.Zone.ZoneMin;
                Vector2 max=scene.Mesh.Zone.ZoneMax;

                if (pos.X>=min.X&&pos.X<=max.X&&pos.Y>=min.Y&&pos.Y<=max.Y)
                    return true;
            }
            return false;
        }
Ejemplo n.º 16
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Ring" /> class.
 /// </summary>
 /// <param name="center">
 ///     The Center
 /// </param>
 /// <param name="innerRadius">
 ///     Inner Radius
 /// </param>
 /// <param name="outerRadius">
 ///     Outer Radius
 /// </param>
 /// <param name="quality">
 ///     The Quality
 /// </param>
 public Ring(Vector3 center, float innerRadius, float outerRadius, int quality = 20)
     : this(center.ToVector2(), innerRadius, outerRadius, quality)
 {
 }
Ejemplo n.º 17
0
        ///<summary>
        ///Runs raycasting and intersection tests to validate LOS.
        ///</summary>
        public bool LOSTest(Vector3 PositionToTestFrom, Vector3 objposition, bool NavRayCast = true, bool searchGridRayCast = false, bool ServerObjectIntersection = true, NavCellFlags Flags = NavCellFlags.None, bool ContinueOnFailures = true)
        {
            LastLOSCheck=DateTime.Now;
              bool Failed=false;

              if (NavRayCast)
              {//This is a basic raycast test to see if we have clear view of the object.

                    if (PositionToTestFrom.Z > objposition.Z)
                        RayCast = Navigation.Navigation.CanRayCast(PositionToTestFrom, objposition);
                    else
                        RayCast = Navigation.Navigation.CanRayCast(objposition, PositionToTestFrom);

                    if (!RayCast.Value)
                    {
                         Failed=true;
                         if (!ContinueOnFailures) return false;
                    }

              }

             if (searchGridRayCast)
             {
                 Vector2 hitpos;

                 //Must check the Z difference.. (so we don't get false-positive result)
                 if (PositionToTestFrom.Z > objposition.Z)
                     SearchGridRayCast = !Navigator.SearchGridProvider.Raycast(PositionToTestFrom.ToVector2(), objposition.ToVector2(), out hitpos);
                 else
                     SearchGridRayCast = !Navigator.SearchGridProvider.Raycast(objposition.ToVector2(), PositionToTestFrom.ToVector2(), out hitpos);

                 if (!SearchGridRayCast.Value)
                 {
                     Failed = true;
                     if (!ContinueOnFailures) return false;
                 }
             }

              if (ServerObjectIntersection)
              {//This test uses the obstacle cache to check objects for intersection

                    if (FunkyBaseExtension.Difference(FunkyGame.Hero.Position.Z, objposition.Z) > 1f)
                    {
                        //Get actual height using MGP
                        objposition.Z = Navigation.Navigation.MGP.GetHeight(objposition.ToVector2());
                    }

                    ObjectIntersection=ObjectCache.Obstacles.Values.OfType<CacheServerObject>()
                         .Any(obstacle =>
                              obstacle.RAGUID!=Obj.RAGUID&&
                              obstacle.Obstacletype.HasValue&&
                              obstacle.Obstacletype.Value==ObstacleType.ServerObject &&
                              obstacle.TestIntersection(PositionToTestFrom, objposition,false));

                    if (!Failed&&ObjectIntersection.Value)
                    {
                         Failed=true;
                         if (!ContinueOnFailures) return false;
                    }
              }

              if (!Flags.Equals(NavCellFlags.None))
              {//Raycast test to validate it can preform the path -- walk/projectile
                  bool NavTest = Navigation.Navigation.CanRayCast(PositionToTestFrom, objposition, Flags);

                    if (Flags.HasFlag(NavCellFlags.AllowWalk)) NavCellWalk=NavTest;
                    if (Flags.HasFlag(NavCellFlags.AllowProjectile)) NavCellProjectile=NavTest;
                    if (!Failed&&!NavTest)
                    {
                         Failed=true;
                    }
              }

              //this.LastVectorTested=PositionToTestFrom;
              return !Failed;
        }
Ejemplo n.º 18
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ArcPoly" /> class, after converting the points to 2D.
 /// </summary>
 /// <param name="start">
 ///     Start of the Arc
 /// </param>
 /// <param name="direction">
 ///     Direction of the Arc
 /// </param>
 /// <param name="angle">
 ///     Angle of the Arc
 /// </param>
 /// <param name="radius">
 ///     Radius of the Arc
 /// </param>
 /// <param name="quality">
 ///     Quality of the Arc
 /// </param>
 public ArcPoly(Vector3 start, Vector3 direction, float angle, float radius, int quality = 20)
     : this(start.ToVector2(), direction.ToVector2(), angle, radius, quality)
 {
 }
Ejemplo n.º 19
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="SectorPoly" /> class.
 /// </summary>
 /// <param name="center">
 ///     The Center
 /// </param>
 /// <param name="direction">
 ///     The Direction
 /// </param>
 /// <param name="angle">
 ///     The Angle
 /// </param>
 /// <param name="radius">
 ///     The Radius
 /// </param>
 /// <param name="quality">
 ///     The Quality
 /// </param>
 public SectorPoly(Vector3 center, Vector3 direction, float angle, float radius, int quality = 20)
     : this(center.ToVector2(), direction.ToVector2(), angle, radius, quality)
 {
 }
Ejemplo n.º 20
0
 /// <summary>
 ///     Returns if the angle is orthogonal.
 /// </summary>
 /// <param name="vector3">Extended SharpDX Vector3</param>
 /// <param name="toVector2">SharpDX Vector2</param>
 /// <returns>Returns if the angle is orthogonal</returns>
 public static bool IsOrthogonal(Vector3 vector3, Vector2 toVector2)
 {
     return vector3.ToVector2().IsOrthogonal(toVector2);
 }
Ejemplo n.º 21
0
 private bool method_3(Vector3 vector3_0, Vector3 vector3_1)
 {
     Cell cellByPoint = this.GetCellByPoint(vector3_0);
     Cell cellByPoint2 = this.GetCellByPoint(vector3_1);
     bool result;
     if (cellByPoint2 == null || cellByPoint == null)
     {
         result = false;
     }
     else
     {
         if (cellByPoint2 == cellByPoint)
         {
             result = true;
         }
         else
         {
             if (!cellByPoint.AllowWalk || !cellByPoint2.AllowWalk)
             {
                 result = false;
             }
             else
             {
                 LineSegment lineSegment_ = new LineSegment(vector3_0.ToVector2(), vector3_1.ToVector2());
                 Cell cell = cellByPoint;
                 int num = 0;
                 this.lastRayTraceErrorStart = vector3_0;
                 this.lastRayTraceErrorEnd = vector3_1;
                 List<Cell> list = new List<Cell>();
                 list.Add(cellByPoint);
                 while (cell != cellByPoint2)
                 {
                     this.lastRayTraceErrorCells = list;
                     if (++num >= 40)
                     {
                         int count = this.lastRayTraceErrorCells.Count;
                         int num2 = this.lastRayTraceErrorCells.Distinct<Cell>().Count<Cell>();
                         if (Math.Abs(num2 - count) > 40 || num >= 100)
                         {
                             if (this.int_5 <= Environment.TickCount)
                             {
                                 Framework.smethod_0(string.Concat(new object[]
                                 {
                                     "RayTracer: Aborting... i>100 or more than 10 same elements: c1/c2 = ",
                                     count,
                                     "/",
                                     num2
                                 }));
                                 this.int_5 = Environment.TickCount + 500;
                             }
                             result = false;
                             return result;
                         }
                     }
                     cell = cell.method_0(lineSegment_);
                     if (cell == null)
                     {
                         result = false;
                         return result;
                     }
                     if (!cell.AllowWalk)
                     {
                         result = false;
                         return result;
                     }
                     list.Add(cell);
                 }
                 result = true;
             }
         }
     }
     return result;
 }
Ejemplo n.º 22
0
 /// <summary>
 ///     Calculates the squared distance between two vectors.
 /// </summary>
 /// <param name="vector2">Extended SharpDX Vector2</param>
 /// <param name="toVector3">SharpDX Vector3</param>
 /// <returns>The squared distance between the two vectors.</returns>
 public static float DistanceSquared(this Vector2 vector2, Vector3 toVector3)
 {
     return Vector2.DistanceSquared(vector2, toVector3.ToVector2());
 }
Ejemplo n.º 23
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Circle" /> class.
 /// </summary>
 /// <param name="center">
 ///     The Center
 /// </param>
 /// <param name="radius">
 ///     The Radius
 /// </param>
 /// <param name="quality">
 ///     The Quality
 /// </param>
 public Circle(Vector3 center, float radius, int quality = 20)
     : this(center.ToVector2(), radius, quality)
 {
 }
Ejemplo n.º 24
0
 /// <summary>
 ///     Returns if the Vector3 is in range of the spell.
 /// </summary>
 /// <param name="point">
 ///     Vector3 point
 /// </param>
 /// <param name="otherRange">
 ///     The Range
 /// </param>
 /// <returns>
 ///     The <see cref="bool" />.
 /// </returns>
 public bool IsInRange(Vector3 point, float otherRange = -1)
 {
     return this.IsInRange(point.ToVector2(), otherRange);
 }
Ejemplo n.º 25
0
 /// <summary>
 ///     Converts the points to 2D, then returns the projection of the Vector2 on the segment.
 /// </summary>
 /// <param name="point">The point</param>
 /// <param name="segmentStart">Start of Segment</param>
 /// <param name="segmentEnd">End of Segment</param>
 /// <returns><see cref="ProjectionInfo" /> containing the projection.</returns>
 public static ProjectionInfo ProjectOn(this Vector3 point, Vector3 segmentStart, Vector3 segmentEnd)
 {
     return point.ToVector2().LSProjectOn(segmentStart.ToVector2(), segmentEnd.ToVector2());
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Extension wrapper for Vector2.Distance method
 /// </summary>
 /// <param name="v1">First vector</param>
 /// <param name="v2">Second vector</param>
 /// <returns>The distance between two vectors</returns>
 public static float Distance2D(this Vector3 v1, Vector3 v2)
 {
     return Vector2.Distance(v1.ToVector2(), v2.ToVector2());
 }
Ejemplo n.º 27
0
 /// <summary>
 ///     Extends a Vector2 to a Vector3.
 /// </summary>
 /// <param name="vector2">Extended SharpDX Vector2 (From)</param>
 /// <param name="toVector3">SharpDX Vector3 (To)</param>
 /// <param name="distance">Distance (float units)</param>
 /// <returns>Extended Vector2</returns>
 public static Vector2 Extend(this Vector2 vector2, Vector3 toVector3, float distance)
 {
     return vector2 + distance * (toVector3.ToVector2() - vector2).Normalized();
 }
Ejemplo n.º 28
0
 public static float FindAngleBetween(this Vector3 first, Vector3 second, bool radian = false)
 {
     return (second.ToVector2() - first.ToVector2()).PolarAngle(radian);
 }
Ejemplo n.º 29
0
 public static Vector2? GetFirstWallPoint(Vector3 from, Vector3 to, float step = 25)
 {
     return GetFirstWallPoint(from.ToVector2(), to.ToVector2(), step);
 }
Ejemplo n.º 30
0
 private static bool UnderTower(Vector3 pos)
 {
     return
         GameObjects.EnemyTurrets.Any(
             i => !i.IsDead && i.Distance(pos.ToVector2()) < 850 + Player.BoundingRadius);
 }