public override bool Check(IGameContext context) { // Currently fighting, do not change target. if (!context.Target.IsValid) { // Still not time to update for new target. if (!ShouldCheckTarget()) { return(false); } // First get the first mob by distance. var mobs = context.Units.Where(x => x.IsValid).ToList(); mobs = TargetPriority.Prioritize(mobs).ToList(); // Set our new target at the end so that we don't accidentally cast on a new target. context.Target = mobs.FirstOrDefault() ?? new NullUnit(); // Update last time target was updated. _lastTargetCheck = DateTime.Now; if (context.Target.IsValid) { LogViewModel.Write("Now targeting " + context.Target.Name + " : " + context.Target.Id); } } return(false); }
public float GetPossibility(TargetPriority priority, TeamType team) { float result = 0f; Strategy strategy = this.GetStrategy(team); float strategyFactor = strategy.StrategyFactor; int curStage = StrategyHelper.GetCurStage(strategyFactor); switch (priority) { case TargetPriority.First_Monster_Low_Hp: result = this.GetFirstRate(strategy, this.GetRateList((int)priority, curStage)); break; case TargetPriority.Second_Hero_Low_Hp: result = this.GetSecondRate(strategy, this.GetRateList((int)priority, curStage)); break; case TargetPriority.Third_Hero_Assist_League: result = this.GetThirdRate(strategy, this.GetRateList((int)priority, curStage)); break; case TargetPriority.Fourth_State_Stuck_Hero: result = this.GetFourthRate(strategy, this.GetRateList((int)priority, curStage)); break; case TargetPriority.Fifth_State_Speed_Hero: result = this.GetFifthRate(strategy, this.GetRateList((int)priority, curStage)); break; case TargetPriority.Sixth_Attack_Self_Hero: result = this.GetSixthRate(strategy, this.GetRateList((int)priority, curStage)); break; case TargetPriority.Seventh_Attack_League_hero: result = this.GetSeventhRate(strategy, this.GetRateList((int)priority, curStage)); break; case TargetPriority.Eighth_Attack_League_Monster: result = this.GetEighthRate(strategy, this.GetRateList((int)priority, curStage)); break; case TargetPriority.Ninth_First_Insight: result = this.GetNinthRate(strategy, this.GetRateList((int)priority, curStage)); break; case TargetPriority.Last_Outsight: result = this.GetLastRate(strategy, this.GetRateList((int)priority, curStage)); break; } return(result); }
public void SetInitialValues(Tower tower, GameObject tilePos) { //Todo, use tile info to calculate the level of the tower initially. //Todo, set ammo effects initially. //Todo, generate random name? towerBase = tower; gridTile = tilePos; gridTileInfo = gridTile.GetComponent <TileInfo>(); if (towerBase.TargetsRadius) { targetPriority = TargetPriority.ALL; } level = 1; SetStatsForLevel(); }
public GameEntity[] GetEnemiesByPriority(Faction faction, TargetPriority priority, bool extendScan) { EntityType et = EntityType.Offensive; switch (priority) { case TargetPriority.Defensive: et = EntityType.Defensive; break; case TargetPriority.Offensive: et = EntityType.Offensive; break; case TargetPriority.Structure: et = EntityType.Structure; break; } if (priority != TargetPriority.Closest) { if (faction) { GameEntity[] tmplst = entities.Where(x => faction.GetAlignement(x.faction) == -1 && (x.entityType == et) && x.gameObject.activeInHierarchy).ToArray <GameEntity>(); if (tmplst.Length == 0 && extendScan) { tmplst = entities.Where(x => faction.GetAlignement(x.faction) == -1 && x.entityType != EntityType.Neutral && x.entityType != EntityType.NotTraceable && x.gameObject.activeInHierarchy).ToArray <GameEntity>(); } return(tmplst.ToArray()); } else { return(entities.Where(x => (x.entityType == et || extendScan) && x.gameObject.activeInHierarchy).ToArray <GameEntity>()); } } else { if (faction) { return(entities.Where(x => faction.GetAlignement(x.faction) == -1 && x.entityType != EntityType.Neutral && x.entityType != EntityType.NotTraceable && x.gameObject.activeInHierarchy).ToArray <GameEntity>()); } else { return(entities.Where(x => x.entityType != EntityType.Neutral && x.entityType != EntityType.NotTraceable && x.gameObject.activeInHierarchy).ToArray <GameEntity>()); } } }
public void WillOrderTargetsByPriority() { // Fixture setup IUnit[] units = InitializeUnits(numberUnits: 3); units[0] = FindPartyClaimedMob("PartyClaim"); units[1] = FindAggroedMob("Aggroed"); units[2] = FindLongDistanceMob("ShortestDistance"); units = ShuffleUnits(units); // Excercise system IUnit[] result = TargetPriority.Prioritize(units).ToArray(); // Verify outcome Assert.Equal("PartyClaim", result[0].Name); Assert.Equal("Aggroed", result[1].Name); Assert.Equal("ShortestDistance", result[2].Name); // Teardown }
public ActorRoot GetNearestEnemy(ActorRoot InActor, int srchR, TargetPriority priotity, uint filter) { ActorRoot root = null; ActorRoot root2 = null; ulong num = (ulong) (srchR * srchR); ulong num2 = num; for (int i = 0; i < 3; i++) { if (i != InActor.TheActorMeta.ActorCamp) { List<PoolObjHandle<ActorRoot>> campActors = Singleton<GameObjMgr>.GetInstance().GetCampActors((COM_PLAYERCAMP) i); int count = campActors.Count; for (int j = 0; j < count; j++) { PoolObjHandle<ActorRoot> handle = campActors[j]; ActorRoot target = handle.handle; if (((filter & (((int) 1) << target.TheActorMeta.ActorType)) <= 0L) && target.HorizonMarker.IsVisibleFor(InActor.TheActorMeta.ActorCamp)) { if ((((priotity == TargetPriority.TargetPriority_Hero) && (target.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Hero)) || ((priotity == TargetPriority.TargetPriority_Monster) && (target.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Monster))) || ((priotity == TargetPriority.TargetPriority_Organ) && (target.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Organ))) { VInt3 num8 = target.location - InActor.location; ulong num6 = (ulong) num8.sqrMagnitudeLong2D; if ((num6 < num) && InActor.CanAttack(target)) { root = target; num = num6; } } else { VInt3 num9 = target.location - InActor.location; ulong num7 = (ulong) num9.sqrMagnitudeLong2D; if ((num7 < num2) && InActor.CanAttack(target)) { root2 = target; num2 = num7; } } } } } } return ((root == null) ? root2 : root); }
/// <summary> Gets a weight for unit. </summary> /// <param name="unit"> The unit. </param> /// <param name="priorities"> </param> /// <returns> The weight for unit. </returns> private double GetWeightForUnit(DiaUnit unit, IEnumerable <TargetPriority> priorities) { double weight = 0d; weight += (int)GetMonsterSize(unit) * 20; weight -= unit.HitpointsCurrentPct * 100; weight += IsSummoner(unit) ? 100 : 0; weight += IsTreasureGoblin(unit) ? 200 : 0; weight += IsElite(unit.CommonData) ? 300 : 0; // Heavily score invulnerable units but don't remove them. weight -= unit.IsInvulnerable ? 10000 : 0; TargetPriority multiplier = priorities.FirstOrDefault(m => m.ActorId == unit.ActorSNO); if (multiplier != null) { weight *= multiplier.Multiplier; } return(weight); }
public override void Run(IGameContext context) { // First get the first mob by distance. var mobs = context.Units.Where(x => x.IsValid).ToList(); mobs = TargetPriority.Prioritize(mobs).ToList(); var lastTarget = context.Target; // Set our new target at the end so that we don't accidentally cast on a new target. var target = mobs.FirstOrDefault() ?? new NullUnit(); if (target.IsValid && lastTarget != target) { context.Target = target; // FIXME: if random path is set, do not reset? make this configurable? context.Config.Route.ResetCurrentWaypoint(); LogViewModel.Write("Now targeting " + context.Target.Name + " : " + context.Target.Id); } Player.SetTarget(context.API, target); }
public void SetTargetPriortiy(TargetPriority priortiy) { currentPriority = priortiy; }
public Assignment_bt_WrapperAI_Hero_HeroWarmSimpleAI_node590() { this.opr_p1 = TargetPriority.TargetPriority_Hero; }
public Assignment_bt_WrapperAI_Organ_CrystalWithAttack_node76() { this.opr_p0 = 35000; this.opr_p1 = TargetPriority.TargetPriority_Hero; }
public Assignment_bt_WrapperAI_Hero_HeroWarmNormalAI_node514() { this.opr_p1 = TargetPriority.TargetPriority_Hero; }
public Assignment_bt_WrapperAI_Soldier_BTSoldierSiege_node42() { this.opr_p1 = TargetPriority.TargetPriority_Organ; }
public Assignment_bt_WrapperAI_Monster_BTMonsterRob_node133() { this.opr_p1 = TargetPriority.TargetPriority_Monster; }
public void ReadFrom(SerializationInfo data, string prefix) { priority = (TargetPriority)data.GetInt16(prefix + "Priority"); }
public Assignment_bt_WrapperAI_Hero_HeroCommonAutoAI_node1075() { this.opr_p1 = TargetPriority.TargetPriority_Hero; }
GameObject findTarget(TargetPriority priority) { if (GameValues.Enemies.Count == 0) return null; GameObject currentTarget = new GameObject(); currentTarget.name = "placeholder target"; foreach (GameObject g in GameValues.Enemies) { if (Vector2.Distance(transform.position, g.transform.position) > Range - 1) { continue; } if (priority == TargetPriority.First) { float currentMostProgess = -1; if (currentMostProgess == -1 || g.GetComponent<Enemy>().Progress > currentMostProgess) { currentMostProgess = g.GetComponent<Enemy>().Progress; currentTarget = g; } return currentTarget; } else if (priority == TargetPriority.Last) { float currentLeastProgess = -1; if (currentLeastProgess == -1 || g.GetComponent<Enemy>().Progress < currentLeastProgess) { currentLeastProgess = g.GetComponent<Enemy>().Progress; currentTarget = g; } return currentTarget; } if (priority == TargetPriority.Close) { float currentLeastDist = -1; if (currentLeastDist == -1 || Vector2.Distance(g.transform.position, transform.position) < currentLeastDist) { currentLeastDist = Vector2.Distance(g.transform.position, transform.position); currentTarget = g; } return currentTarget; } else if (priority == TargetPriority.Highest) { float currentHighestHealth = -1; if (currentHighestHealth == -1 || g.GetComponent<Enemy>().CurrentHealth > currentHighestHealth) { currentHighestHealth = g.GetComponent<Enemy>().CurrentHealth; currentTarget = g; } return currentTarget; } else if (priority == TargetPriority.Lowest) { float currentLowestHealth = -1; if (currentLowestHealth == -1 || g.GetComponent<Enemy>().CurrentHealth < currentLowestHealth) { currentLowestHealth = g.GetComponent<Enemy>().CurrentHealth; currentTarget = g; } return currentTarget; } } return null; }
public ActorRoot GetNearestEnemyWithPriorityWithoutNotInBattleJungleMonsterWithoutActor(ActorRoot InActor, int srchR, TargetPriority priotity, uint withOutActor) { ActorRoot root = null; ActorRoot root2 = null; ulong num = (ulong)(srchR * srchR); for (int i = 0; i < 3; i++) { if (i != InActor.TheActorMeta.ActorCamp) { List <PoolObjHandle <ActorRoot> > campActors = Singleton <GameObjMgr> .GetInstance().GetCampActors((COM_PLAYERCAMP)i); int count = campActors.Count; for (int j = 0; j < count; j++) { PoolObjHandle <ActorRoot> handle = campActors[j]; ActorRoot target = handle.handle; if (((target != null) && (target.ObjID != withOutActor)) && target.HorizonMarker.IsVisibleFor(InActor.TheActorMeta.ActorCamp)) { MonsterWrapper wrapper = target.AsMonster(); if (wrapper != null) { ResMonsterCfgInfo cfgInfo = wrapper.cfgInfo; if ((cfgInfo != null) && (cfgInfo.bMonsterType == 2)) { switch (target.ActorAgent.GetCurBehavior()) { case ObjBehaviMode.State_Idle: case ObjBehaviMode.State_Dead: case ObjBehaviMode.State_Null: { continue; } } } } if ((((priotity == TargetPriority.TargetPriority_Hero) && (target.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Hero)) || ((priotity == TargetPriority.TargetPriority_Monster) && (target.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Monster))) || ((priotity == TargetPriority.TargetPriority_Organ) && (target.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Organ))) { VInt3 num7 = target.location - InActor.location; ulong num5 = (ulong)num7.sqrMagnitudeLong2D; if ((num5 >= num) || !InActor.CanAttack(target)) { continue; } root = target; num = num5; if (priotity != TargetPriority.TargetPriority_Organ) { continue; } break; } VInt3 num8 = target.location - InActor.location; if ((num8.sqrMagnitudeLong2D < num) && InActor.CanAttack(target)) { root2 = target; } } } } } return((root == null) ? root2 : root); }
public ActorRoot GetNearestEnemy(ActorRoot InActor, int srchR, TargetPriority priotity, uint filter, bool bWithMonsterNotInBattle = true) { ActorRoot root = null; ActorRoot root2 = null; ulong num = (ulong)(srchR * srchR); ulong num2 = num; for (int i = 0; i < 3; i++) { if (i != InActor.TheActorMeta.ActorCamp) { List <PoolObjHandle <ActorRoot> > campActors = Singleton <GameObjMgr> .GetInstance().GetCampActors((COM_PLAYERCAMP)i); int count = campActors.Count; for (int j = 0; j < count; j++) { PoolObjHandle <ActorRoot> handle = campActors[j]; ActorRoot target = handle.handle; if (((filter & (((int)1) << target.TheActorMeta.ActorType)) <= 0L) && target.HorizonMarker.IsVisibleFor(InActor.TheActorMeta.ActorCamp)) { if (!bWithMonsterNotInBattle) { MonsterWrapper actorControl = target.ActorControl as MonsterWrapper; if (actorControl != null) { ResMonsterCfgInfo cfgInfo = actorControl.cfgInfo; if ((cfgInfo != null) && (cfgInfo.bMonsterType == 2)) { switch (target.ActorAgent.GetCurBehavior()) { case ObjBehaviMode.State_Idle: case ObjBehaviMode.State_Dead: case ObjBehaviMode.State_Null: { continue; } } } } } if ((((priotity == TargetPriority.TargetPriority_Hero) && (target.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Hero)) || ((priotity == TargetPriority.TargetPriority_Monster) && (target.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Monster))) || ((priotity == TargetPriority.TargetPriority_Organ) && (target.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Organ))) { VInt3 num8 = target.location - InActor.location; ulong num6 = (ulong)num8.sqrMagnitudeLong2D; if ((num6 < num) && InActor.CanAttack(target)) { root = target; num = num6; } } else { VInt3 num9 = target.location - InActor.location; ulong num7 = (ulong)num9.sqrMagnitudeLong2D; if ((num7 < num2) && InActor.CanAttack(target)) { root2 = target; num2 = num7; } } } } } } return((root == null) ? root2 : root); }
public ActorRoot GetLowestHpTarget(ActorRoot InActor, int srchR, TargetPriority priotity, uint filter, bool bEnemy = true, bool bWithMonsterNotInBattle = true) { List <ActorRoot> list = new List <ActorRoot>(); List <ActorRoot> list2 = new List <ActorRoot>(); List <ActorRoot> list3 = new List <ActorRoot>(); TargetPropertyLessEqualFilter filter2 = new TargetPropertyLessEqualFilter(list, ulong.MaxValue); TargetPropertyLessEqualFilter filter3 = new TargetPropertyLessEqualFilter(list2, ulong.MaxValue); TargetDistanceNearFilter filter4 = new TargetDistanceNearFilter(ulong.MaxValue); if (bEnemy) { for (int i = 0; i < 3; i++) { if (i != InActor.TheActorMeta.ActorCamp) { List <PoolObjHandle <ActorRoot> > campActors = Singleton <GameObjMgr> .GetInstance().GetCampActors((COM_PLAYERCAMP)i); int num2 = campActors.Count; for (int j = 0; j < num2; j++) { PoolObjHandle <ActorRoot> handle2 = campActors[j]; ActorRoot target = handle2.handle; if ((((filter & (((int)1) << target.TheActorMeta.ActorType)) <= 0L) && target.HorizonMarker.IsVisibleFor(InActor.TheActorMeta.ActorCamp)) && InActor.CanAttack(target)) { if (TypeSearchCondition.Fit(target, ActorTypeDef.Actor_Type_Hero)) { if (DistanceSearchCondition.Fit(target, InActor, srchR)) { filter2.Searcher(target, RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP, new PropertyDelegate(TargetProperty.GetPropertyHpRate)); } } else if (TypeSearchCondition.Fit(target, ActorTypeDef.Actor_Type_Organ)) { if (DistanceSearchCondition.Fit(target, InActor, srchR)) { list3.Add(target); } } else if ((TypeSearchCondition.Fit(target, ActorTypeDef.Actor_Type_Monster) && TypeSearchCondition.FitWithJungleMonsterNotInBattle(target, bWithMonsterNotInBattle)) && DistanceSearchCondition.Fit(target, InActor, srchR)) { filter3.Searcher(target, RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP, new PropertyDelegate(TargetProperty.GetPropertyHpRate)); } } } } } } else { List <PoolObjHandle <ActorRoot> > list5 = Singleton <GameObjMgr> .GetInstance().GetCampActors(InActor.TheActorMeta.ActorCamp); int num4 = list5.Count; for (int k = 0; k < num4; k++) { PoolObjHandle <ActorRoot> handle3 = list5[k]; ActorRoot root2 = handle3.handle; if ((((filter & (((int)1) << root2.TheActorMeta.ActorType)) <= 0L) && !root2.ActorControl.IsDeadState) && root2.HorizonMarker.IsVisibleFor(InActor.TheActorMeta.ActorCamp)) { if (TypeSearchCondition.Fit(root2, ActorTypeDef.Actor_Type_Hero)) { if (DistanceSearchCondition.Fit(root2, InActor, srchR)) { filter2.Searcher(root2, RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP, new PropertyDelegate(TargetProperty.GetPropertyHpRate)); } } else if (TypeSearchCondition.Fit(root2, ActorTypeDef.Actor_Type_Organ)) { if (DistanceSearchCondition.Fit(root2, InActor, srchR)) { list3.Add(root2); } } else if (TypeSearchCondition.Fit(root2, ActorTypeDef.Actor_Type_Monster) && DistanceSearchCondition.Fit(root2, InActor, srchR)) { filter3.Searcher(root2, RES_FUNCEFT_TYPE.RES_FUNCEFT_MAXHP, new PropertyDelegate(TargetProperty.GetPropertyHpRate)); } } } } int num6 = (list.Count + list3.Count) + list2.Count; int count = list.Count; if (count > 0) { ActorRoot root3 = null; if (count == 1) { root3 = list[0]; } else { root3 = filter4.Searcher(list.GetEnumerator(), InActor); } PoolObjHandle <ActorRoot> selfPtr = new PoolObjHandle <ActorRoot>(); if (root3 != null) { selfPtr = root3.SelfPtr; } SkillChooseTargetEventParam prm = new SkillChooseTargetEventParam(selfPtr, InActor.SelfPtr, num6); Singleton <GameEventSys> .instance.SendEvent <SkillChooseTargetEventParam>(GameEventDef.Event_ActorBeChosenAsTarget, ref prm); return(root3); } count = list3.Count; if (count > 0) { if (count == 1) { return(list3[0]); } return(filter4.Searcher(list3.GetEnumerator(), InActor)); } count = list2.Count; if (count <= 0) { return(null); } if (count == 1) { return(list2[0]); } return(filter4.Searcher(list2.GetEnumerator(), InActor)); }
public static void Tab() { Prefab.MenuArea(new Rect(0, 0, 466, 436), "SILENT AIM", () => { GUILayout.Space(2); Prefab.Toggle("Enabled", ref RaycastOptions.Enabled); if (!RaycastOptions.Enabled) { return; } GUILayout.Space(5); Prefab.Toggle($"Hold Key ({HotkeyUtilities.GetHotkeyString("SilentAim", "_SilentAimKey")})", ref RaycastOptions.HoldKey); GUILayout.Space(5); GUILayout.Space(10); Prefab.Toggle("Sphere position prediction", ref SphereOptions.SpherePrediction); GUILayout.Space(5); if (!SphereOptions.SpherePrediction) { GUILayout.Label("Sphere Radius: " + Math.Round(SphereOptions.SphereRadius, 2) + "m", Prefab._TextStyle); Prefab.Slider(0, 16, ref SphereOptions.SphereRadius, 200); } GUILayout.Label("Recursion Level: " + SphereOptions.RecursionLevel, Prefab._TextStyle); SphereOptions.RecursionLevel = (int)Prefab.Slider(0, 4, SphereOptions.RecursionLevel, 200); GUILayout.Space(10); string[] TargetPriorities = { "Players", "Zombies", "Sentries", "Beds", "Claim Flags", "Storage", "Vehicles" }; for (int i = 0; i < TargetPriorities.Length; i++) { TargetPriority target = (TargetPriority)i; bool enabled = RaycastOptions.Targets.Contains(target); bool wasEnabled = enabled; Prefab.Toggle("Include " + TargetPriorities[i], ref enabled); if (enabled && !wasEnabled) { RaycastOptions.Targets.Add(target); } else if (!enabled && wasEnabled) { RaycastOptions.Targets.Remove(target); } } GUILayout.Space(15); Prefab.Toggle("Select Player", ref RaycastOptions.EnablePlayerSelection); if (RaycastOptions.EnablePlayerSelection) { GUILayout.Space(2); GUILayout.Label("Selection FOV: " + RaycastOptions.SelectedFOV, Prefab._TextStyle); RaycastOptions.SelectedFOV = Prefab.Slider(1, 180, RaycastOptions.SelectedFOV, 200); Prefab.Toggle("Only Shoot Selected", ref RaycastOptions.OnlyShootAtSelectedPlayer); } GUILayout.Space(2); Prefab.Toggle("Use FOV", ref RaycastOptions.SilentAimUseFOV); if (RaycastOptions.SilentAimUseFOV) { GUILayout.Space(2); GUILayout.Label("Aim FOV: " + RaycastOptions.SilentAimFOV, Prefab._TextStyle); RaycastOptions.SilentAimFOV = Prefab.Slider(1, 180, RaycastOptions.SilentAimFOV, 200); } }); }