public static bool CheckPositionForSkipping(Vector3 Position) { foreach (var v in UsedSkipAheadAreaCache) { if (Position.Distance2D(v.Position)<=v.Radius) return true; } bool valid=false; if (SkipAheadAreaCache.Count>0) { int validIndex=-1; for (int i=0; i<SkipAheadAreaCache.Count-1; i++) { SkipAheadNavigation v=SkipAheadAreaCache[i]; if (Position.Distance2D(v.Position)<=v.Radius) { validIndex=i; valid=true; break; } } if (valid&&validIndex>0) { UsedSkipAheadAreaCache.Add(SkipAheadAreaCache[validIndex].Clone()); SkipAheadAreaCache.RemoveRange(0, validIndex-1); SkipAheadAreaCache.TrimExcess(); } } return valid; }
public static async Task<bool> MoveTo(Vector3 location, string destinationName, float range = 10f) { while (ZetaDia.Me.IsFullyValid() && !ZetaDia.Me.IsInCombat && location.Distance2D(ZetaDia.Me.Position) > range) { Logger.LogVerbose("Moving to " + destinationName); PlayerMover.NavigateTo(location, destinationName); await Coroutine.Yield(); } if (location.Distance2D(ZetaDia.Me.Position) <= range) Navigator.PlayerMover.MoveStop(); return true; }
public static Point[] GetNeededPoinits( Vector3 startPosition, Vector3 endPosition, float startWidth, float endWidth = 0) { if (endWidth <= 0) { endWidth = startWidth; } endPosition = startPosition.Extend(endPosition, startPosition.Distance2D(endPosition) + endWidth / 2); var difference = startPosition - endPosition; var rotation = difference.Rotated(MathUtil.DegreesToRadians(90)); rotation.Normalize(); var start = rotation * startWidth; var end = rotation * endWidth; var rightStartPosition = startPosition + start; var leftStartPosition = startPosition - start; var rightEndPosition = endPosition + end; var leftEndPosition = endPosition - end; /*Vector2 leftStart, rightStart, leftEnd, rightEnd; Drawing.WorldToScreen(leftStartPosition, out leftStart); Drawing.WorldToScreen(rightStartPosition, out rightStart); Drawing.WorldToScreen(leftEndPosition, out leftEnd); Drawing.WorldToScreen(rightEndPosition, out rightEnd); Drawing.DrawLine(leftStart, rightStart, Color.Orange); Drawing.DrawLine(rightStart, rightEnd, Color.Orange); Drawing.DrawLine(rightEnd, leftEnd, Color.Orange); Drawing.DrawLine(leftEnd, leftStart, Color.Orange);*/ var p1 = new Point((int) rightStartPosition.X, (int) rightStartPosition.Y); var p2 = new Point((int) leftStartPosition.X, (int) leftStartPosition.Y); var p3 = new Point((int) rightEndPosition.X, (int) rightEndPosition.Y); var p4 = new Point((int) leftEndPosition.X, (int) leftEndPosition.Y); return new[] {p1, p2, p4, p3}; }
public void CancelHook(object s, ElapsedEventArgs args) { e = Toolset.ClosestToMouse(me); if (e == null) return; if (e.HasModifier("modifier_spirit_breaker_charge_of_darkness")) return; double travelTime = HookPosition.Distance2D(me.Position) / 1600; Vector3 ePosition = new Vector3((float)((travelTime) * Math.Cos(e.RotationRad) * e.MovementSpeed + e.NetworkPosition.X), (float)((travelTime) * Math.Sin(e.RotationRad) * e.MovementSpeed + e.NetworkPosition.Y), 0); if (e != null && e.NetworkActivity == NetworkActivity.Move && ePosition.Distance2D(HookPosition) > minRangeHook + Menu.Item("x").GetValue<Slider>().Value) { me.Stop(); time.Stop(); } else { if (Q!=null) time.Stop(); } }
private static bool IsPointOnLine( Vector3 point, Vector3 start, Vector3 end, float radius, bool forceRadius = true) { var endDistance = end.Distance2D(point); var startDistance = start.Distance2D(point); var distance = start.Distance2D(end); return Math.Abs(endDistance + startDistance - distance) < (forceRadius ? radius : (end.Distance2D(start) < radius ? radius : 50)); }
public void SetUnavailableTrees(Vector3 start, Vector3 end, Chakram chakram) { var precision = chakram.Radius; var count = (int)Math.Ceiling(start.Distance2D(end) / precision); var ping = Game.Ping / 1000; var time = Game.RawGameTime; for (var i = 1; i <= count; i++) { var position = i == count ? end : start.Extend(end, precision * i); unavailableTrees.Add( Tuple.Create( position, chakram.Radius, chakram.CastPoint + ping + start.Distance2D(position) / chakram.Speed + time)); } }
public static bool TrinityIntersectsPath(Vector3 start, Vector3 obstacle, Vector3 destination, float distanceToObstacle = -1, float distanceToDestination = -1) { var toObstacle = distanceToObstacle >= 0 ? distanceToObstacle : start.Distance2D(obstacle); var toDestination = distanceToDestination >= 0 ? distanceToDestination : start.Distance2D(destination); if (toDestination > 500) return false; var relativeAngularVariance = GetRelativeAngularVariance(start, obstacle, destination); // Angular Variance at 20yd distance const int angularVarianceBase = 45; // Halve/Double required angle every 20yd; 60* @ 15yd, 11.25* @ 80yd var angularVarianceThreshold = Math.Min(angularVarianceBase / (toDestination / 20), 90); //Logger.Log("DistToObj={0} DistToDest={1} relativeAV={2} AVThreshold={3} Result={4}", // toObstacle, toDestination, relativeAngularVariance, angularVarianceThreshold, // toObstacle < toDestination && relativeAngularVariance <= angularVarianceThreshold); if (toObstacle < toDestination) { // If the angle between lines (A) from start to obstacle and (B) from start to destination // are small enough then we know both targets are in the same-ish direction from start. if (relativeAngularVariance <= angularVarianceThreshold) { return true; } } return false; }
private static bool IsPointOnLine(Vector3 point, Vector3 start, Vector3 end, float radius) { var endDistance = end.Distance2D(point); var startDistance = start.Distance2D(point); var distance = start.Distance2D(end); return Math.Abs(endDistance + startDistance - distance) < radius; }
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)); }
//Special Movements public Vector3 FindZigZagTargetLocation(Vector3 vTargetLocation, float fDistanceOutreach, bool bRandomizeDistance=false, bool bRandomizeStart=false, bool bCheckGround=false) { Vector3 vThisZigZag=Vector3.Zero; bool useTargetBasedZigZag=false; float minDistance=6f; float maxDistance=16f; int minTargets=2; if (useTargetBasedZigZag&&!Bot.Combat.bAnyTreasureGoblinsPresent&&Bot.Combat.UnitRAGUIDs.Count>=minTargets) { List<CacheServerObject> units_=Bot.Combat.NearbyObstacleObjects.Where(obj => Bot.Combat.UnitRAGUIDs.Contains(obj.RAGUID)).ToList(); IEnumerable<CacheObject> zigZagTargets= from u in units_ where u.CentreDistance>minDistance&&u.CentreDistance<maxDistance&&u.RAGUID!=Bot.Target.CurrentTarget.RAGUID&& !ObjectCache.Obstacles.IsPositionWithinAvoidanceArea(u.Position)&&MGP.CanStandAt(u.BotMeleeVector) select u; if (zigZagTargets.Count()>=minTargets) { CacheObject unit=zigZagTargets.OrderByDescending(u => u.Weight).FirstOrDefault(); vThisZigZag=unit.Position; return vThisZigZag; } } Random rndNum=new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), NumberStyles.HexNumber)); bool bCanRayCast; float iFakeStart=0; //K: bRandomizeStart is for boss and elite, they usually jump around, make obstacles, let you Incapacitated. // you usually have to move back and forth to hit them if (bRandomizeStart) iFakeStart=rndNum.Next(18)*5; if (bRandomizeDistance) fDistanceOutreach+=rndNum.Next(18); float fDirectionToTarget=Navigation.FindDirection(Bot.Character.Position, vTargetLocation); float fPointToTarget; float fHighestWeight=float.NegativeInfinity; Vector3 vBestLocation=Vector3.Zero; bool bFoundSafeSpotsFirstLoop=false; float fAdditionalRange=0f; //K: Direction is more important than distance for (int iMultiplier=1; iMultiplier<=2; iMultiplier++) { if (iMultiplier==2) { if (bFoundSafeSpotsFirstLoop) break; fAdditionalRange=150f; if (bRandomizeStart) iFakeStart=30f+(rndNum.Next(16)*5); else iFakeStart=(rndNum.Next(17)*5); } float fRunDistance=fDistanceOutreach; for (float iDegreeChange=iFakeStart; iDegreeChange<=30f+fAdditionalRange; iDegreeChange+=5) { float iPosition=iDegreeChange; //point to target is better, otherwise we have to avoid obstacle first if (iPosition>105f) iPosition=90f-iPosition; else if (iPosition>30f) iPosition-=15f; else iPosition=15f-iPosition; fPointToTarget=iPosition; iPosition+=fDirectionToTarget; if (iPosition<0) iPosition=360f+iPosition; if (iPosition>=360f) iPosition=iPosition-360f; vThisZigZag=MathEx.GetPointAt(Bot.Character.Position, fRunDistance, MathEx.ToRadians(iPosition)); if (fPointToTarget<=30f||fPointToTarget>=330f) { vThisZigZag.Z=vTargetLocation.Z; } else if (fPointToTarget<=60f||fPointToTarget>=300f) { //K: we are trying to find position that we can circle around the target // but we shouldn't run too far away from target vThisZigZag.Z=(vTargetLocation.Z+Bot.Character.Position.Z)/2; fRunDistance=fDistanceOutreach-5f; } else { //K: don't move too far if we are not point to target, we just try to move // this can help a lot when we are near stairs fRunDistance=8f; } bCanRayCast=MGP.CanStandAt(vThisZigZag); // Give weight to each zigzag point, so we can find the best one to aim for if (bCanRayCast) { bool bAnyAvoidance=false; // Starting weight is 1000f float fThisWeight=1000f; if (iMultiplier==2) fThisWeight-=80f; if (Bot.Character.ShouldFlee&&ObjectCache.Objects.IsPointNearbyMonsters(vThisZigZag, Bot.SettingsFunky.FleeMaxMonsterDistance)) continue; if (ObjectCache.Obstacles.Navigations.Any(obj => obj.Obstacletype.Value!=ObstacleType.Monster&&obj.TestIntersection(Bot.Character.Position, vThisZigZag, false))) continue; float distanceToPoint=vThisZigZag.Distance2D(Bot.Character.Position); float distanceToTarget=vTargetLocation.Distance2D(Bot.Character.Position); fThisWeight+=(distanceToTarget*10f); // Use this one if it's more weight, or we haven't even found one yet, or if same weight as another with a random chance if (fThisWeight>fHighestWeight) { fHighestWeight=fThisWeight; vBestLocation=new Vector3(vThisZigZag.X, vThisZigZag.Y, MGP.GetHeight(vThisZigZag.ToVector2())); if (!bAnyAvoidance) bFoundSafeSpotsFirstLoop=true; } } // Can we raycast to the point at minimum? } // Loop through degrees } // Loop through multiplier return vBestLocation; }
public static void Tick(EventArgs args) { if (!Game.IsInGame || Game.IsPaused || Game.IsWatchingGame) return; me = ObjectMgr.LocalHero; if (me == null) return; if (me.ClassID != ClassID.CDOTA_Unit_Hero_EarthSpirit) return; //SKILLS if (Qskill == null) Qskill = me.Spellbook.SpellQ; if (Wskill == null) Wskill = me.Spellbook.SpellW; if (Eskill == null) Eskill = me.Spellbook.SpellE; if (DRemnant == null) DRemnant = me.Spellbook.SpellD; if (Rskill == null) Rskill = me.Spellbook.SpellR; if (Fskill == null) Fskill = me.Spellbook.SpellF; // UNIT VARIABLES stone_for_combo = ObjectMgr.GetEntities<Unit>().Where(x => x.ClassID == ClassID.CDOTA_Unit_Earth_Spirit_Stone && me.Distance2D(x.NetworkPosition) < 200).FirstOrDefault(); stone = ObjectMgr.GetEntities<Unit>().Where(x => x.ClassID == ClassID.CDOTA_Unit_Earth_Spirit_Stone && x.NetworkPosition.Distance2D(me.NetworkPosition) <= 1300).ToList(); if (boulder_slow == null || stage_combo4 == 0) boulder_slow = ObjectMgr.GetEntities<Hero>().Where(x => x.Team != me.Team && x.IsVisible && !x.IsIllusion && x.NetworkPosition.Distance2D(me.NetworkPosition) < 200 && x.Modifiers.Any(y => y.Name == "modifier_earth_spirit_rolling_boulder_slow")).FirstOrDefault(); if (stage == 2 && stunned == null) stunned = ObjectMgr.GetEntities<Hero>().Where(x => x.Modifiers.Any(y => y.Name == "modifier_stunned") && !x.IsIllusion && x.Team != me.Team && x.IsVisible).FirstOrDefault(); //KEYS TOGGLE if ((Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo1").GetValue<KeyBind>().Key)) && !Game.IsChatOpen && stunned == null) key_active = true; if ((Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo3").GetValue<KeyBind>().Key)) && !Game.IsChatOpen) key_active_2 = true; if ((Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo5").GetValue<KeyBind>().Key)) && !Game.IsChatOpen) key_active_4 = true; if (key_active == false) { stage = 0; key_active = false; stunned = null; } if (me.CanCast() && !me.IsChanneling() && key_active) { Mouse_Position = Game.MousePosition; if ((!Eskill.CanBeCasted() && !Qskill.CanBeCasted() && !Wskill.CanBeCasted() && (!DRemnant.CanBeCasted() && stone_for_combo == null) || ((!DRemnant.CanBeCasted() && stone_for_combo == null))) || (Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo2").GetValue<KeyBind>().Key))) { if (auto_atack_after_spell) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1"); auto_atack_after_spell = false; } if (auto_atack) { Game.ExecuteCommand("dota_player_units_auto_attack 1"); auto_atack = false; } key_active = false; stage = 0; stunned = null; } if (stage == 0 && Utils.SleepCheck("auto_atack_change")) { if (Game.GetConsoleVar("dota_player_units_auto_attack_after_spell").GetInt() == 1) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0"); auto_atack_after_spell = true; } else auto_atack_after_spell = false; if (Game.GetConsoleVar("dota_player_units_auto_attack").GetInt() == 1) { Game.ExecuteCommand("dota_player_units_auto_attack 0"); auto_atack = true; } else auto_atack = false; stage = 1; Utils.Sleep(Game.Ping, "auto_atack_change"); } else if (stage == 1 && Utils.SleepCheck("Qskill") && Utils.SleepCheck("auto_atack_change")) { if (DRemnant.CanBeCasted() && Utils.SleepCheck("DRemnant") && stone_for_combo == null && (Qskill.CanBeCasted() && Wskill.CanBeCasted() && Eskill.CanBeCasted())) { DRemnant.UseAbility(me.NetworkPosition); Utils.Sleep(500 - (int)Game.Ping, "DRemnant"); } if (Qskill.CanBeCasted()) { Qskill.UseAbility((Mouse_Position - me.NetworkPosition) * 200 / Mouse_Position.Distance2D(me) + me.NetworkPosition); Utils.Sleep((int)Game.Ping + 50, "Qskill"); } else stage = 2; } else if (stage == 2 && stunned != null && Utils.SleepCheck("Eskill")) { stone_nearly = stone.Where(x => stunned.Distance2D(x) < stunned.Distance2D((me.NetworkPosition - stunned.NetworkPosition) * 400 / stunned.NetworkPosition.Distance2D(me.NetworkPosition) + stunned.NetworkPosition)).FirstOrDefault(); if (Eskill.CanBeCasted()) { if (stone_nearly != null) { if (Game.Ping < 100) { Eskill.UseAbility(stone_nearly.NetworkPosition); Utils.Sleep((int)Game.Ping + 100, "Eskill"); } else { Eskill.UseAbility(stunned.Predict(-Game.Ping)); Utils.Sleep((int)Game.Ping + 100, "Eskill"); } } } else stage = 3; } else if ((Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo1").GetValue<KeyBind>().Key)) && stage == 2 && Utils.SleepCheck("Eskill") && stunned == null) { stone_nearly = stone.Where(x => x.NetworkPosition.Distance2D(Mouse_Position) < 200).FirstOrDefault(); if (Eskill.CanBeCasted() && stone_nearly != null) { Eskill.UseAbility(Mouse_Position); Utils.Sleep( 100, "Eskill"); } if (!Eskill.CanBeCasted()) stage = 3; } else if (stage == 3 && stunned != null && stunned.Modifiers.Any(x => x.Name == "modifier_earth_spirit_geomagnetic_grip_debuff") && Utils.SleepCheck("Wskill")) { if (auto_atack_after_spell) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1"); Utils.Sleep(Game.Ping + 50, "auto_attack_1"); auto_atack_after_spell = false; } if (auto_atack) { Game.ExecuteCommand("dota_player_units_auto_attack 1"); Utils.Sleep(Game.Ping + 50, "auto_attack_1"); auto_atack = false; } if (Wskill.CanBeCasted() && Utils.SleepCheck("auto_attack_1")) { Wskill.UseAbility(stunned.NetworkPosition); Utils.Sleep(Game.Ping + (Qskill.GetCastDelay(me, stunned, true, true) * 100), "Wskill"); } } else if (stage == 3 && stunned == null && Utils.SleepCheck("Wskill") && (Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo1").GetValue<KeyBind>().Key))) { if (auto_atack_after_spell) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1"); Utils.Sleep(Game.Ping + 50, "auto_attack_1"); auto_atack_after_spell = false; } if (auto_atack) { Game.ExecuteCommand("dota_player_units_auto_attack 1"); Utils.Sleep(Game.Ping+50, "auto_attack_1"); auto_atack = false; } if (Wskill.CanBeCasted() && Utils.SleepCheck("auto_attack_1")) { Wskill.UseAbility(Mouse_Position); Utils.Sleep((int)Game.Ping + 100, "Wskill"); } } else if (!Wskill.CanBeCasted()) { stage = 0; key_active = false; stunned = null; if (auto_atack_after_spell) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1"); auto_atack_after_spell = false; } if (auto_atack) { Game.ExecuteCommand("dota_player_units_auto_attack 1"); auto_atack = false; } } } if (key_active_2 && !Game.IsChatOpen) { if ((Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo2").GetValue<KeyBind>().Key) && !Game.IsChatOpen)) { stage_combo2 = 0; key_active_2 = false; if (auto_atack_after_spell) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1"); auto_atack_after_spell = false; } if (auto_atack) { Game.ExecuteCommand("dota_player_units_auto_attack 1"); auto_atack = false; } } if (stage_combo2 == 0 || stone_peoples == null) { stone_peoples = ObjectMgr.GetEntities<Hero>().Where(x => !x.IsIllusion && x.Modifiers.Any(xy => xy.Name == "modifier_earthspirit_petrify") && x.Distance2D(me) <= 1600); Mouse_Position = Game.MousePosition; } if (stone_peoples.FirstOrDefault() != null && me.CanCast() && !me.IsChanneling()) { if (stage_combo2 == 0) { if (Game.GetConsoleVar("dota_player_units_auto_attack_after_spell").GetInt() == 1) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0"); auto_atack_after_spell = true; } else auto_atack_after_spell = false; if (Game.GetConsoleVar("dota_player_units_auto_attack").GetInt() == 1) { Game.ExecuteCommand("dota_player_units_auto_attack 0"); auto_atack = true; } else auto_atack = false; Utils.Sleep(Game.Ping + 50, "auto_atack_change"); stage_combo2 = 1; } if (stage_combo2 == 1 && Utils.SleepCheck("EskillSleep") && Utils.SleepCheck("auto_atack_change")) { if (Eskill.CanBeCasted() && stone_peoples.FirstOrDefault().NetworkPosition.Distance2D(me) >= 180) { Eskill.UseAbility(stone_peoples.FirstOrDefault().NetworkPosition); Utils.Sleep(Game.Ping, "EskillSleep"); } else stage_combo2 = 2; } else if (stage_combo2 == 2) { if (Wskill.CanBeCasted()) { int DelayCombo = 0; if (stone_peoples.FirstOrDefault().NetworkPosition.Distance2D(stone_peoples.FirstOrDefault().NetworkPosition / me.NetworkPosition * 100) < 200) DelayCombo = 150 - (int)Game.Ping; else DelayCombo = 400 - (int)Game.Ping; Wskill.UseAbility(Mouse_Position); Utils.Sleep(Game.Ping + DelayCombo + (me.GetTurnTime(Mouse_Position) * 100), "PerfectDelay"); } else stage_combo2 = 3; } else if (stage_combo2 == 3 && Utils.SleepCheck("PerfectDelay")) { if (Qskill.CanBeCasted()) Qskill.UseAbility(Mouse_Position); else { stage_combo2 = 0; key_active_2 = false; if (auto_atack_after_spell) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1"); auto_atack_after_spell = false; } if (auto_atack) { auto_atack = false; Game.ExecuteCommand("dota_player_units_auto_attack 1"); } } } } if (stone_peoples.FirstOrDefault() == null || !me.CanCast()) { stage_combo2 = 0; key_active_2 = false; if (auto_atack_after_spell) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1"); auto_atack_after_spell = false; } if (auto_atack) { Game.ExecuteCommand("dota_player_units_auto_attack 1"); auto_atack = false; } } } if (key_active_4 && !Game.IsChatOpen) { if ((stage_combo4 == 0 && (!Qskill.CanBeCasted() || !Wskill.CanBeCasted())) || (Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo2").GetValue<KeyBind>().Key) && !Game.IsChatOpen)) { stage_combo4 = 0; key_active_4 = false; if (auto_atack_after_spell) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1"); auto_atack_after_spell = false; } if (auto_atack) { Game.ExecuteCommand("dota_player_units_auto_attack 1"); auto_atack = false; } } if (stage_combo4 == 0) { if (Game.GetConsoleVar("dota_player_units_auto_attack_after_spell").GetInt() == 1) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0"); auto_atack_after_spell = true; } else auto_atack_after_spell = false; if (Game.GetConsoleVar("dota_player_units_auto_attack").GetInt() == 1) { Game.ExecuteCommand("dota_player_units_auto_attack 0"); auto_atack = true; } else auto_atack = false; Utils.Sleep(Game.Ping+50, "auto_atack_change"); stage_combo4 = 1; } else if (stage_combo4 == 1 && Utils.SleepCheck("auto_atack_change")) { Mouse_Position = Game.MousePosition; stone_for_combo = ObjectMgr.GetEntities<Unit>().Where(x => x.ClassID == ClassID.CDOTA_Unit_Earth_Spirit_Stone && Mouse_Position.Distance2D(x.NetworkPosition) < 200).FirstOrDefault(); Hero geomagnetic_target = ObjectMgr.GetEntities<Hero>().Where(x => x.Team != me.Team && x.IsVisible && !x.IsIllusion && x.NetworkPosition.Distance2D(me.NetworkPosition) <= 1600 && x.Modifiers.Any(y => y.Name == "modifier_earth_spirit_geomagnetic_grip_debuff")).FirstOrDefault(); if (DRemnant.CanBeCasted() && Utils.SleepCheck("DRemnant") && stone_for_combo == null && (Qskill.CanBeCasted() && Wskill.CanBeCasted() && Eskill.CanBeCasted())) { DRemnant.UseAbility(Mouse_Position); Utils.Sleep((int)Game.Ping + 2000, "DRemnant"); } else if (Eskill.CanBeCasted() && Utils.SleepCheck("Eskill_3combo")) { Eskill.UseAbility(Mouse_Position); Utils.Sleep(500, "Eskill_3combo"); } else if ((!Eskill.CanBeCasted() || Eskill.Level == 0) && geomagnetic_target == null) { stone_for_combo = ObjectMgr.GetEntities<Unit>().Where(x => x.ClassID == ClassID.CDOTA_Unit_Earth_Spirit_Stone && me.Distance2D(x.NetworkPosition) < 400).FirstOrDefault(); if (DRemnant.CanBeCasted() && Utils.SleepCheck("DRemnant") && stone_for_combo == null && (Qskill.CanBeCasted() && Wskill.CanBeCasted())) { DRemnant.UseAbility(me.NetworkPosition); Utils.Sleep((int)Game.Ping + 2000, "DRemnant"); } else stage_combo4 = 2; } else if ((!Eskill.CanBeCasted() || Eskill.Level == 0) && stone_for_combo != null) stage_combo4 = 2; } else if (stage_combo4 == 2) { if (Wskill.CanBeCasted() && Utils.SleepCheck("Wskill_3combo")) { Wskill.UseAbility(Mouse_Position); Utils.Sleep(500, "Wskill_3combo"); } if (!Wskill.CanBeCasted()) stage_combo4 = 3; } else if (stage_combo4 == 3) { if( boulder_slow != null) { Mouse_Position = Game.MousePosition; Vector3 perfect_position = (boulder_slow.NetworkPosition - Mouse_Position) * 150 / boulder_slow.NetworkPosition.Distance2D(Mouse_Position) + boulder_slow.NetworkPosition; if (Utils.SleepCheck("moving") && me.NetworkPosition.Distance2D(perfect_position) >= 70) { me.Move(perfect_position); Utils.Sleep(500-Game.Ping, "moving"); } if (me.NetworkPosition.ToVector2().FindAngleBetween(Mouse_Position.ToVector2(), true) - me.NetworkPosition.ToVector2().FindAngleBetween(boulder_slow.NetworkPosition.ToVector2(), true) <= 0.1 && me.NetworkPosition.ToVector2().FindAngleBetween(Mouse_Position.ToVector2(), true) - me.NetworkPosition.ToVector2().FindAngleBetween(boulder_slow.NetworkPosition.ToVector2(), true) >= -0.1) { if (Qskill.CanBeCasted() && Utils.SleepCheck("Qskill_combo3")) { Qskill.UseAbility(boulder_slow); Utils.Sleep(500, "Qskill_combo3"); } if (!Qskill.CanBeCasted()) { stage_combo4 = 0; key_active_4 = false; if (auto_atack_after_spell) { Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1"); auto_atack_after_spell = false; } if (auto_atack) { Game.ExecuteCommand("dota_player_units_auto_attack 1"); auto_atack = false; } } } } } } //if (key_active_3 && !Game.IsChatOpen) //{ // if (stun_target == null || stage_combo3 == 0) // { // Mouse_Position = Game.MousePosition; // stun_target = ObjectMgr.GetEntities<Hero>().Where(x => x.Team != me.Team && !x.IsIllusion && x.IsAlive && x.Distance2D(me) <= 1600); // } // int distance = 0; // int last_distance = 50000; // Hero most_closer_mouse_position_hero; // foreach (var v in stun_target) // { // distance = (int)v.NetworkPosition.Distance2D(Mouse_Position); // if (distance < last_distance) // { // last_distance = distance; // most_closer_mouse_position_hero = v; // } // } //} }
public override void OnStart() { _lastMoveResult = MoveResult.Moved; float x = MyPos.X + OffsetX; float y = MyPos.Y + OffsetY; Position = new Vector3(x, y, MainGridProvider.GetHeight(new Vector2(x, y))); if (Math.Abs(PathPrecision) < 1f) PathPrecision = 10f; Logger.Log("OffsetMove Initialized offset x={0} y={1} distance={2:0} position={3}", OffsetX, OffsetY, Position.Distance2D(MyPos), Position); }
private MoveResult NavigateMove(Vector3 destination, string name = "", bool raycast = true) { try { if (lastDestination != destination) { lastDestination = destination; //Navigator.Clear(); } const float pathPointLimit = 250; if (!ZetaDia.IsInTown && destination.Distance2D(Me.Position) > pathPointLimit) destination = MathEx.CalculatePointFrom(Me.Position, destination, destination.Distance2D(Me.Position) - pathPointLimit); if (string.IsNullOrEmpty(name)) { name = destination.ToString(); } //Logr.Debug(("Moving to {0}, distance: {1:0}", name, destination.Distance2D(ZetaDia.Me.Position)); return NavHelper.NavigateTo(destination, name); } catch (Exception ex) { Logr.Log("DB Navigation Exception: {0}", ex); GridSegmentation.Reset(); Navigator.Clear(); return MoveResult.Failed; } }
internal static MoveResult NavigateTo(Vector3 moveTarget, string destinationName="") { Vector3 MyPos=ZetaDia.Me.Position; float distanceToTarget=moveTarget.Distance2D(ZetaDia.Me.Position); bool MoveTargetIsInLoS=distanceToTarget<=90f&&!Navigator.Raycast(MyPos, moveTarget); if (distanceToTarget<=5f||MoveTargetIsInLoS) { //Special cache for skipping locations visited. if (Bot.SettingsFunky.SkipAhead) SkipAheadCache.RecordSkipAheadCachePoint(); Navigator.PlayerMover.MoveTowards(moveTarget); return MoveResult.Moved; } return Navigator.MoveTo(moveTarget, destinationName, true); }
private static void GetClosest(ref Vector3 returnPoint, Hero me,Dictionary<int,Vector3> points) { for (var i = 0; i <= 8; i++) { Vector3 vec; if (!points.TryGetValue(i, out vec)) continue; if (!returnPoint.IsZero) { if (_nearestPoint) { if (vec.Distance2D(me) <= returnPoint.Distance2D(me)) returnPoint = vec; } else { if (vec.Distance2D(_globalTarget) <= returnPoint.Distance2D(_globalTarget)) returnPoint = vec; } } else { returnPoint = vec; } } }
/// <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; }
public void Combo() { if (!Menu.Item("enabled").IsActive() || Game.IsChatOpen || time.Enabled) return; me = ObjectManager.LocalHero; Q = me.Spellbook.SpellQ; W = me.Spellbook.SpellW; R = me.Spellbook.SpellR; leans = me.FindItem("item_aether_lens"); urn = me.FindItem("item_urn_of_shadows"); dagon = me.Inventory.Items.FirstOrDefault(x => x.Name.Contains("item_dagon")); ethereal = me.FindItem("item_ethereal_blade"); Shiva = me.FindItem("item_shivas_guard"); glimmer = me.FindItem("item_glimmer_cape"); vail = me.FindItem("item_veil_of_discord"); orchid = me.FindItem("item_orchid") ?? me.FindItem("item_bloodthorn"); abyssal = me.FindItem("item_abyssal_blade"); atos = me.FindItem("item_rod_of_atos"); bkb = me.FindItem("item_black_king_bar"); mail = me.FindItem("item_blade_mail"); lotus = me.FindItem("item_lotus_orb"); Active = Game.IsKeyDown(Menu.Item("Combo Key").GetValue<KeyBind>().Key); var v = ObjectManager.GetEntities<Hero>().Where(x => x.Team != me.Team && x.IsAlive && x.IsVisible && !x.IsIllusion && !x.IsMagicImmune()).ToList(); if (Active && Menu.Item("Skills").GetValue<AbilityToggler>().IsEnabled(W.Name)) { if (me.HasModifier("modifier_pudge_rot") && v.Count(x => x.Distance2D(me) <= W.GetCastRange()+me.HullRadius) == 0) { W.ToggleAbility(); time.Start(); } else if(!me.HasModifier("modifier_pudge_rot") && v.Count(x => x.Distance2D(me) <= W.GetCastRange() + me.HullRadius) > 0) { W.ToggleAbility(); time.Start(); } } e = Toolset.ClosestToMouse(me); if (e == null || !me.IsAlive) return; sheep = e.ClassID == ClassID.CDOTA_Unit_Hero_Tidehunter ? null : me.FindItem("item_sheepstick"); if (R.IsInAbilityPhase || R.IsChanneling || me.IsChanneling()) return; if (Active) { minRangeHook = e.HullRadius + 27; CastRange = leans != null ? (Q.CastRange + 200 + e.HullRadius) : (Q.CastRange + e.HullRadius); eMoveSpeed = e.HasModifier("modifier_spirit_breaker_charge_of_darkness") ? 550 + ((int)e.Spellbook.Spell1.Level * 50) : e.MovementSpeed; Vector2 vector = new Vector2((float)Math.Cos(e.RotationRad) * eMoveSpeed, (float)Math.Sin(e.RotationRad) * eMoveSpeed); Vector3 start = new Vector3((float)((0.3 + (Game.Ping / 1000)) * Math.Cos(e.RotationRad) * eMoveSpeed + e.Position.X), (float)((0.3 + (Game.Ping / 1000)) * Math.Sin(e.RotationRad) * eMoveSpeed + e.NetworkPosition.Y), e.NetworkPosition.Z); Vector3 specialPosition = new Vector3((float)(minRangeHook * Math.Cos(e.RotationRad) + e.NetworkPosition.X), (float)(minRangeHook * Math.Sin(e.RotationRad) + e.NetworkPosition.Y), e.NetworkPosition.Z); HookPosition = Interception(start, vector, me.Position, 1600); if ( atos != null && atos.CanBeCasted() && me.CanCast() && !e.IsMagicImmune() && !e.HasModifier("modifier_spirit_breaker_charge_of_darkness") && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(atos.Name) && me.Distance2D(e) <= 1500 && Utils.SleepCheck("a") ) { atos.UseAbility(e); Utils.Sleep(250, "a"); } else if (Q.CanBeCasted() && Menu.Item("Skills").GetValue<AbilityToggler>().IsEnabled(Q.Name)) { if (e.NetworkActivity == NetworkActivity.Move || e.HasModifier("modifier_spirit_breaker_charge_of_darkness")) { for (double i = 0.03; i <= 0.135; i += 0.03) { Vector3 estimated = new Vector3((float)(i * Math.Cos(e.RotationRad) * eMoveSpeed + HookPosition.X), (float)(i * Math.Sin(e.RotationRad) * eMoveSpeed + HookPosition.Y), e.NetworkPosition.Z); if (GetTimeToTurn(estimated) <= i) { HookPosition = estimated; TimeTurn = i; break; } } CastPos = (HookPosition - me.Position) * ((Q.GetCastRange()+me.HullRadius) / HookPosition.Distance2D(me.Position)) + me.Position; if (me.Position.Distance2D(HookPosition) < CastRange) { Q.UseAbility(CastPos); time.Interval = 150 + TimeTurn * 1000; time.Start(); } } else { CastPos = (specialPosition - me.Position) * ((Q.GetCastRange() + me.HullRadius) / specialPosition.Distance2D(me.Position)) + me.Position; if (me.Position.Distance2D(e.NetworkPosition) < CastRange) { Q.UseAbility(CastPos); time.Start(); } } } else { if (R.IsInAbilityPhase || R.IsChanneling) return; uint countElse = 0; countElse += 1; if (vail != null && vail.CanBeCasted() && me.Distance2D(e) <= 1100 && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(vail.Name) && Utils.SleepCheck("vail")) { vail.UseAbility(e.Position); Utils.Sleep(130, "vail"); } else countElse += 1; if (orchid != null && orchid.CanBeCasted() && me.Distance2D(e) <= 900 && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(orchid.Name) && Utils.SleepCheck("orchid")) { orchid.UseAbility(e); Utils.Sleep(100, "orchid"); } else countElse += 1; if (Shiva != null && Shiva.CanBeCasted() && me.Distance2D(e) <= 600 && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(Shiva.Name) && !e.IsMagicImmune() && Utils.SleepCheck("Shiva")) { Shiva.UseAbility(); Utils.Sleep(100, "Shiva"); } else countElse += 1; if (ethereal != null && ethereal.CanBeCasted() && me.Distance2D(e) <= 700 && me.Distance2D(e) <= 400 && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(ethereal.Name) && Utils.SleepCheck("ethereal")) { ethereal.UseAbility(e); Utils.Sleep(100, "ethereal"); } else countElse += 1; if (dagon != null && dagon.CanBeCasted() && me.Distance2D(e) <= dagon.GetCastRange() && Utils.SleepCheck("dagon")) { dagon.UseAbility(e); Utils.Sleep(100, "dagon"); } else countElse += 1; if (urn != null && urn.CanBeCasted() && urn.CurrentCharges > 0 && me.Distance2D(e) <= 400 && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(urn.Name) && Utils.SleepCheck("urn")) { urn.UseAbility(e); Utils.Sleep(240, "urn"); } else countElse += 1; if (glimmer != null && glimmer.CanBeCasted() && me.Distance2D(e) <= 300 && Utils.SleepCheck("glimmer")) { glimmer.UseAbility(me); Utils.Sleep(200, "glimmer"); } else countElse += 1; if (mail != null && mail.CanBeCasted() && v.Count(x => x.Distance2D(me) <= 650) >= (Menu.Item("Heel").GetValue<Slider>().Value) && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(mail.Name) && Utils.SleepCheck("mail")) { mail.UseAbility(); Console.WriteLine(countElse.ToString()); Utils.Sleep(100, "mail"); } else countElse += 1; if (bkb != null && bkb.CanBeCasted() && v.Count(x => x.Distance2D(me) <= 650) >= (Menu.Item("Heel").GetValue<Slider>().Value) && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(bkb.Name) && Utils.SleepCheck("bkb")) { bkb.UseAbility(); Utils.Sleep(100, "bkb"); } else countElse += 1; if (lotus != null && lotus.CanBeCasted() && v.Count(x => x.Distance2D(me) <= 650) >= 2 && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(lotus.Name) && Utils.SleepCheck("lotus")) { lotus.UseAbility(me); Utils.Sleep(100, "lotus"); } else countElse += 1; if (countElse == 11 && R != null && R.CanBeCasted() && me.Distance2D(e) <= R.GetCastRange() + 150 && (!urn.CanBeCasted() || urn.CurrentCharges <= 0) && Menu.Item("Skills").GetValue<AbilityToggler>().IsEnabled(R.Name) && Utils.SleepCheck("R") ) { R.UseAbility(e); Utils.Sleep(150, "R"); } else countElse += 1; if (abyssal != null && !R.CanBeCasted() && abyssal.CanBeCasted() && !e.IsStunned() && !e.IsHexed() && me.Distance2D(e) <= 300 && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(abyssal.Name) && Utils.SleepCheck("abyssal")) { abyssal.UseAbility(e); Utils.Sleep(200, "abyssal"); } else countElse += 1; if (sheep != null && !R.CanBeCasted() && sheep.CanBeCasted() && !e.IsStunned() && !e.IsHexed() && me.Distance2D(e) <= 900 && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(sheep.Name) && Utils.SleepCheck("sheep")) { sheep.UseAbility(e); Utils.Sleep(200, "sheep"); } else countElse += 1; if (countElse == 14 && me.Distance2D(e) <= 300 && mail != null && mail.CanBeCasted() && (e.NetworkActivity == NetworkActivity.Attack || e.Spellbook.Spells.All(x => x.IsInAbilityPhase)) && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(mail.Name) && Utils.SleepCheck("mail")) { mail.UseAbility(); Utils.Sleep(100, "mail"); } else countElse += 1; if (countElse == 15 && lotus != null && lotus.CanBeCasted() && me.Distance2D(e) <= 600 && Menu.Item("Items").GetValue<AbilityToggler>().IsEnabled(lotus.Name) && Utils.SleepCheck("lotus")) { lotus.UseAbility(me); Utils.Sleep(100, "lotus"); } if ((R == null || !R.CanBeCasted() || !Q.CanBeCasted() && me.Distance2D(e) >= R.GetCastRange() + me.HullRadius && !e.HasModifier("pudge_meat_hook")) && !e.IsAttackImmune()) { if (Menu.Item("orbwalk").GetValue<bool>() && me.Distance2D(e) <= 1900) { Orbwalking.Orbwalk(e, 0, 1600, true, true); } } } } }
/// <summary> /// Finds a navigable point in a priority scene /// </summary> private void FindPrioritySceneTarget() { if (SceneId == 0 && string.IsNullOrWhiteSpace(SceneName)) return; if (_prioritySceneTarget != Vector3.Zero) return; bool foundPriorityScene = false; // find any matching priority scenes in scene manager - match by name or SNOId List<Scene> pScenes; var allScenes = ZetaDia.Scenes.ToList(); if (allScenes.Any()) { pScenes = GetPScenesBySceneId(allScenes); pScenes.AddRange(GetPScenesByName(allScenes)); } else { return; } List<Scene> foundPriorityScenes = new List<Scene>(); Dictionary<int, Vector3> foundPrioritySceneIndex = new Dictionary<int, Vector3>(); foreach (Scene scene in pScenes) { try { if (_priorityScenesInvestigated.Contains(scene.SceneInfo.SNOId)) continue; foundPriorityScene = true; NavZone navZone = scene.Mesh.Zone; NavZoneDef zoneDef = navZone.NavZoneDef; Vector3 zoneCenter = GetNavZoneCenter(navZone); List<NavCell> navCells = zoneDef.NavCells.Where(c => c.Flags.HasFlag(NavCellFlags.AllowWalk)).ToList(); if (!navCells.Any()) continue; NavCell bestCell = navCells.OrderBy(c => GetNavCellCenter(c.Min, c.Max, navZone).Distance2D(zoneCenter)).FirstOrDefault(); if (bestCell != null) { foundPrioritySceneIndex.Add(scene.SceneInfo.SNOId, GetNavCellCenter(bestCell, navZone)); foundPriorityScenes.Add(scene); } else { Logger.Log("Found Scene but could not find a navigable point!", true); } } catch (Exception ex) { Logger.Log(ex.ToString()); } } if (foundPrioritySceneIndex.Any()) { KeyValuePair<int, Vector3> nearestPriorityScene = foundPrioritySceneIndex.OrderBy(s => s.Value.Distance2D(myPos)).FirstOrDefault(); _prioritySceneSNOId = nearestPriorityScene.Key; _prioritySceneTarget = nearestPriorityScene.Value; _currentPriorityScene = foundPriorityScenes.FirstOrDefault(s => s.SceneInfo.SNOId == _prioritySceneSNOId); if (_currentPriorityScene != null) { Logger.Log("Found Scene {0} - {1} Center {2} Distance {3:0}", _currentPriorityScene.Name, _currentPriorityScene.SceneInfo.SNOId, _prioritySceneTarget, _prioritySceneTarget.Distance2D(myPos)); } } if (!foundPriorityScene) { _prioritySceneTarget = Vector3.Zero; } }
//Special Movements public Vector3 FindZigZagTargetLocation(Vector3 vTargetLocation, float fDistanceOutreach, bool bRandomizeDistance = false, bool bRandomizeStart = false) { var rndNum = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), NumberStyles.HexNumber)); float iFakeStart = 0; //K: bRandomizeStart is for boss and elite, they usually jump around, make obstacles, let you Incapacitated. // you usually have to move back and forth to hit them if (bRandomizeStart) iFakeStart = rndNum.Next(18) * 5; if (bRandomizeDistance) fDistanceOutreach += rndNum.Next(18); float fDirectionToTarget = FindDirection(FunkyGame.Hero.Position, vTargetLocation); float fHighestWeight = float.NegativeInfinity; Vector3 vBestLocation = Vector3.Zero; bool bFoundSafeSpotsFirstLoop = false; float fAdditionalRange = 0f; //K: Direction is more important than distance for (int iMultiplier = 1; iMultiplier <= 2; iMultiplier++) { if (iMultiplier == 2) { if (bFoundSafeSpotsFirstLoop) break; fAdditionalRange = 150f; if (bRandomizeStart) iFakeStart = 30f + (rndNum.Next(16) * 5); else iFakeStart = (rndNum.Next(17) * 5); } float fRunDistance = fDistanceOutreach; for (float iDegreeChange = iFakeStart; iDegreeChange <= 30f + fAdditionalRange; iDegreeChange += 5) { float iPosition = iDegreeChange; //point to target is better, otherwise we have to avoid obstacle first if (iPosition > 105f) iPosition = 90f - iPosition; else if (iPosition > 30f) iPosition -= 15f; else iPosition = 15f - iPosition; float fPointToTarget = iPosition; iPosition += fDirectionToTarget; if (iPosition < 0) iPosition = 360f + iPosition; if (iPosition >= 360f) iPosition = iPosition - 360f; Vector3 vThisZigZag = MathEx.GetPointAt(FunkyGame.Hero.Position, fRunDistance, MathEx.ToRadians(iPosition)); if (fPointToTarget <= 30f || fPointToTarget >= 330f) { vThisZigZag.Z = vTargetLocation.Z; } else if (fPointToTarget <= 60f || fPointToTarget >= 300f) { //K: we are trying to find position that we can circle around the target // but we shouldn't run too far away from target vThisZigZag.Z = (vTargetLocation.Z + FunkyGame.Hero.Position.Z) / 2; fRunDistance = fDistanceOutreach - 5f; } else { //K: don't move too far if we are not point to target, we just try to move // this can help a lot when we are near stairs fRunDistance = 8f; } bool bCanRayCast = MGP.CanStandAt(vThisZigZag); // Give weight to each zigzag point, so we can find the best one to aim for if (bCanRayCast) { const bool bAnyAvoidance = false; // Starting weight is 1000f float fThisWeight = 1000f; if (iMultiplier == 2) fThisWeight -= 80f; //FLEEING //if (Targeting.Behaviors.TBFleeing.ShouldFlee && ObjectCache.Objects.IsPointNearbyMonsters(vThisZigZag, FunkyBaseExtension.Settings.Fleeing.FleeMaxMonsterDistance)) // continue; if (ObjectCache.Obstacles.Navigations.Any(obj => obj.Obstacletype.Value != ObstacleType.Monster && obj.TestIntersection(FunkyGame.Hero.Position, vThisZigZag, false))) continue; float distanceToTarget = vTargetLocation.Distance2D(FunkyGame.Hero.Position); fThisWeight += (distanceToTarget * 10f); // Use this one if it's more weight, or we haven't even found one yet, or if same weight as another with a random chance if (fThisWeight > fHighestWeight) { fHighestWeight = fThisWeight; vBestLocation = new Vector3(vThisZigZag.X, vThisZigZag.Y, MGP.GetHeight(vThisZigZag.ToVector2())); if (!bAnyAvoidance) bFoundSafeSpotsFirstLoop = true; } } // Can we raycast to the point at minimum? } // Loop through degrees } // Loop through multiplier return vBestLocation; }
internal static void GenerateMonkZigZag() { float extraDistance = CurrentTarget.RadiusDistance <= 20f ? 15f : 20f; ZigZagPosition = TargetUtil.GetZigZagTarget(CurrentTarget.Position, extraDistance); double direction = MathUtil.FindDirectionRadian(Player.Position, ZigZagPosition); ZigZagPosition = MathEx.GetPointAt(Player.Position, 40f, (float)direction); Logger.Log(TrinityLogLevel.Debug, LogCategory.Behavior, "Generated ZigZag {0} distance {1:0}", ZigZagPosition, ZigZagPosition.Distance2D(Player.Position)); }
/// <summary> /// Finds a navigable point in a priority scene /// </summary> private void FindPrioritySceneTarget() { if (SceneId==0&&String.IsNullOrEmpty(SceneName)) return; //gp.Update(); if (PrioritySceneTarget!=Vector3.Zero) return; var foundPriorityScene=false; // find any matching priority scenes in scene manager - match by name or SNOId var PScenes=ZetaDia.Scenes.GetScenes() .Where(s => s.SceneInfo.SNOId==SceneId).ToList(); PScenes.AddRange(ZetaDia.Scenes.GetScenes() .Where(s => !String.IsNullOrEmpty(SceneName.Trim())&&s.Name.ToLower().Contains(SceneName.ToLower())).ToList()); var foundPriorityScenes=new List<Scene>(); var foundPrioritySceneIndex=new Dictionary<int, Vector3>(); foreach (var scene in PScenes) { if (PriorityScenesInvestigated.Contains(scene.SceneInfo.SNOId)) continue; foundPriorityScene=true; var navZone=scene.Mesh.Zone; var zoneDef=navZone.NavZoneDef; var zoneCenter=GetNavZoneCenter(navZone); var NavCells=zoneDef.NavCells.Where(c => c.Flags.HasFlag(NavCellFlags.AllowWalk)).ToList(); if (!NavCells.Any()) continue; var bestCell=NavCells.OrderBy(c => GetNavCellCenter(c.Min, c.Max, navZone).Distance2D(zoneCenter)).FirstOrDefault(); if (bestCell!=null) { foundPrioritySceneIndex.Add(scene.SceneInfo.SNOId, GetNavCellCenter(bestCell, navZone)); foundPriorityScenes.Add(scene); } else { Logger.DBLog.DebugFormat("Found Priority Scene but could not find a navigable point!"); } } if (foundPrioritySceneIndex.Any()) { var nearestPriorityScene=foundPrioritySceneIndex.OrderBy(s => s.Value.Distance2D(myPos)).FirstOrDefault(); PrioritySceneSNOId=nearestPriorityScene.Key; PrioritySceneTarget=nearestPriorityScene.Value; CurrentPriorityScene=foundPriorityScenes.FirstOrDefault(s => s.SceneInfo.SNOId==PrioritySceneSNOId); Logger.DBLog.DebugFormat("Found Priority Scene {0} - {1} Center {2} Distance {3:0}", CurrentPriorityScene.Name, CurrentPriorityScene.SceneInfo.SNOId, PrioritySceneTarget, PrioritySceneTarget.Distance2D(myPos)); } if (!foundPriorityScene) { PrioritySceneTarget=Vector3.Zero; } }
internal static async Task<MoveResult> NavigateToTask(Vector3 destination, string destinationName = "") { PositionCache.AddPosition(); MoveResult result; try { Stopwatch t1 = new Stopwatch(); t1.Start(); using (new PerformanceLogger("Navigator.MoveTo")) { result = await Navigator.MoveTo(destination, destinationName); } t1.Stop(); const float maxTime = 750; // Shit was slow, make it slower but tell us why :) string pathCheck = ""; if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Navigator) && t1.ElapsedMilliseconds > maxTime) { //if (Navigator.GetNavigationProviderAs<DefaultNavigationProvider>().CanFullyClientPathTo(destination)) // pathCheck = "CanFullyPath"; //else pathCheck = "CannotFullyPath"; } LogCategory lc; TrinityLogLevel ll; if (t1.ElapsedMilliseconds > maxTime) { lc = LogCategory.UserInformation; ll = TrinityLogLevel.Info; } else { lc = LogCategory.Navigator; ll = TrinityLogLevel.Debug; } Logger.Log(ll, lc, "{0} in {1:0}ms {2} dist={3:0} {4}", result, t1.ElapsedMilliseconds, destinationName, destination.Distance2D(Trinity.Player.Position), pathCheck); } catch (OutOfMemoryException) { Logger.LogDebug("Navigator ran out of memory!"); return MoveResult.Failed; } catch (Exception ex) { Logger.Log("{0}", ex); return MoveResult.Failed; } return result; }
private static bool CheckForEnemy(Vector3 pos, List<Hero> validHeroes,Hero main) { var any = !validHeroes.Any(y => y.Distance2D(pos) <= 175+y.HullRadius && !Equals(main, y)) && !Creeps.All.Any( y => y.IsValid && y.IsAlive && y.IsVisible && y.Team == _myHero.GetEnemyTeam() && y.Distance2D(pos) <= 175+50) && pos.Distance2D(main)<170-main.HullRadius; return any; }