コード例 #1
0
 public void ConfigureTargetFinderForEnemies(EquipmentSlot self)
 {
     ConfigureTargetFinderBase(self);
     TargetFinder.teamMaskFilter = TeamMask.GetUnprotectedTeams(self.characterBody.teamComponent.teamIndex);
     TargetFinder.RefreshCandidates();
     TargetFinder.FilterOutGameObject(self.gameObject);
     AdditionalBullseyeFunctionality(TargetFinder);
     PlaceTargetingIndicator(TargetFinder.GetResults());
 }
コード例 #2
0
        private void SearchForAllies()
        {
            Ray aimRay = base.GetAimRay();

            BullseyeSearch search = new BullseyeSearch
            {
                teamMaskFilter    = TeamMask.none,
                filterByLoS       = false,
                searchOrigin      = base.transform.position,
                searchDirection   = Random.onUnitSphere,
                sortMode          = BullseyeSearch.SortMode.Distance,
                maxDistanceFilter = 3f,
                maxAngleFilter    = 360f
            };

            search.teamMaskFilter.AddTeam(base.GetTeam());

            search.RefreshCandidates();
            search.FilterOutGameObject(base.gameObject);

            HurtBox target = search.GetResults().FirstOrDefault <HurtBox>();

            if (target)
            {
                if (target.healthComponent && target.healthComponent.body)
                {
                    this.outer.SetNextState(new PeoplesElbow());
                    return;
                }
            }
        }
コード例 #3
0
        private Vector3 EvaluatePickupPosition(BulletstormPickupsComponent pickupsComponent, CharacterBody victimBody)
        {
            Vector3 PickupPosition = new Vector3();

            if (pickupsComponent.wasMapDeath)                                             //If they die from falling off the map
            {
                if (pickupsComponent.lastHitAttacker)                                     // get the last attacker
                {
                    PickupPosition = pickupsComponent.lastHitAttacker.transform.position; //set the position of the pickup to be on the player
                }
                else
                {
                    var playerSearch = new BullseyeSearch() //let's just get the nearest player
                    {
                        viewer         = victimBody,
                        sortMode       = BullseyeSearch.SortMode.Distance,
                        teamMaskFilter = TeamMask.allButNeutral
                    };
                    playerSearch.teamMaskFilter.RemoveTeam(TeamIndex.Monster);
                    playerSearch.RefreshCandidates();
                    playerSearch.FilterOutGameObject(victimBody.gameObject);
                    var  list    = playerSearch.GetResults().ToList();
                    bool success = false;
                    if (list.Count > 0)
                    {
                        foreach (var player in list)
                        {
                            var body = player.gameObject.GetComponent <CharacterBody>();
                            if (body)
                            {
                                if (body.isPlayerControlled)
                                {
                                    PickupPosition = body.corePosition;
                                    success        = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (!success) //
                    {
                        PickupPosition = list.FirstOrDefault().transform.position;
                    }
                }
            }
            else // If it wasn't a map death
            {
                PickupPosition = victimBody.transform.position;
            }
            return(PickupPosition);
        }
コード例 #4
0
        // Token: 0x060008A9 RID: 2217 RVA: 0x0002B684 File Offset: 0x00029884
        private void FireTethers()
        {
            Vector3           position         = this.muzzleTransform.position;
            float             breakDistanceSqr = Recover.maxTetherDistance * Recover.maxTetherDistance;
            List <GameObject> list             = new List <GameObject>();

            this.tetherControllers = new List <TarTetherController>();
            BullseyeSearch bullseyeSearch = new BullseyeSearch();

            bullseyeSearch.searchOrigin      = position;
            bullseyeSearch.maxDistanceFilter = Recover.maxTetherDistance;
            bullseyeSearch.teamMaskFilter    = TeamMask.allButNeutral;
            bullseyeSearch.sortMode          = BullseyeSearch.SortMode.Distance;
            bullseyeSearch.filterByLoS       = true;
            bullseyeSearch.searchDirection   = Vector3.up;
            bullseyeSearch.RefreshCandidates();
            bullseyeSearch.FilterOutGameObject(base.gameObject);
            List <HurtBox> list2 = bullseyeSearch.GetResults().ToList <HurtBox>();

            Debug.Log(list2);
            for (int i = 0; i < list2.Count; i++)
            {
                GameObject gameObject = list2[i].healthComponent.gameObject;
                if (gameObject)
                {
                    list.Add(gameObject);
                }
            }
            float      tickInterval             = 1f / Recover.damageTickFrequency;
            float      damageCoefficientPerTick = Recover.damagePerSecond / Recover.damageTickFrequency;
            float      mulchDistanceSqr         = Recover.tetherMulchDistance * Recover.tetherMulchDistance;
            GameObject original = Resources.Load <GameObject>("Prefabs/NetworkedObjects/TarTether");

            for (int j = 0; j < list.Count; j++)
            {
                GameObject          gameObject2 = UnityEngine.Object.Instantiate <GameObject>(original, position, Quaternion.identity);
                TarTetherController component   = gameObject2.GetComponent <TarTetherController>();
                component.NetworkownerRoot         = base.gameObject;
                component.NetworktargetRoot        = list[j];
                component.breakDistanceSqr         = breakDistanceSqr;
                component.damageCoefficientPerTick = damageCoefficientPerTick;
                component.tickInterval             = tickInterval;
                component.tickTimer              = (float)j * 0.1f;
                component.mulchDistanceSqr       = mulchDistanceSqr;
                component.mulchDamageScale       = Recover.tetherMulchDamageScale;
                component.mulchTickIntervalScale = Recover.tetherMulchTickIntervalScale;
                this.tetherControllers.Add(component);
                NetworkServer.Spawn(gameObject2);
            }
        }
コード例 #5
0
        // Token: 0x060032E2 RID: 13026 RVA: 0x000DC838 File Offset: 0x000DAA38
        public override void OnEnter()
        {
            base.OnEnter();
            Util.PlaySound(BuffBeam.playBeamSoundString, base.gameObject);
            Ray            aimRay         = base.GetAimRay();
            BullseyeSearch bullseyeSearch = new BullseyeSearch();

            bullseyeSearch.teamMaskFilter = TeamMask.none;
            if (base.teamComponent)
            {
                bullseyeSearch.teamMaskFilter.AddTeam(base.teamComponent.teamIndex);
            }
            bullseyeSearch.filterByLoS       = false;
            bullseyeSearch.maxDistanceFilter = 50f;
            bullseyeSearch.maxAngleFilter    = 180f;
            bullseyeSearch.searchOrigin      = aimRay.origin;
            bullseyeSearch.searchDirection   = aimRay.direction;
            bullseyeSearch.sortMode          = BullseyeSearch.SortMode.Angle;
            bullseyeSearch.RefreshCandidates();
            bullseyeSearch.FilterOutGameObject(base.gameObject);
            this.target = bullseyeSearch.GetResults().FirstOrDefault <HurtBox>();
            Debug.LogFormat("Buffing target {0}", new object[]
            {
                this.target
            });
            if (this.target)
            {
                this.targetBody = this.target.healthComponent.body;
                this.targetBody.AddBuff(BuffIndex.HiddenInvincibility);
            }
            string    childName      = "Muzzle";
            Transform modelTransform = base.GetModelTransform();

            if (modelTransform)
            {
                ChildLocator component = modelTransform.GetComponent <ChildLocator>();
                if (component)
                {
                    this.muzzleTransform  = component.FindChild(childName);
                    this.buffBeamInstance = UnityEngine.Object.Instantiate <GameObject>(BuffBeam.buffBeamPrefab);
                    ChildLocator component2 = this.buffBeamInstance.GetComponent <ChildLocator>();
                    if (component2)
                    {
                        this.beamTipTransform = component2.FindChild("BeamTip");
                    }
                    this.healBeamCurve = this.buffBeamInstance.GetComponentInChildren <BezierCurveLine>();
                }
            }
        }
コード例 #6
0
        // Token: 0x060007E9 RID: 2025 RVA: 0x00027338 File Offset: 0x00025538
        public override void OnEnter()
        {
            base.OnEnter();
            Util.PlaySound(HealBeam.playHealSoundString, base.gameObject);
            base.PlayCrossfade("Gesture", "Heal", 0.2f);
            this.healInterval = HealBeam.duration / (float)HealBeam.healCount;
            this.healChunk    = HealBeam.healCoefficient / (float)HealBeam.healCount;
            Ray            aimRay         = base.GetAimRay();
            BullseyeSearch bullseyeSearch = new BullseyeSearch();

            bullseyeSearch.teamMaskFilter = TeamMask.none;
            if (base.teamComponent)
            {
                bullseyeSearch.teamMaskFilter.AddTeam(base.teamComponent.teamIndex);
            }
            bullseyeSearch.filterByLoS       = false;
            bullseyeSearch.maxDistanceFilter = 50f;
            bullseyeSearch.maxAngleFilter    = 180f;
            bullseyeSearch.searchOrigin      = aimRay.origin;
            bullseyeSearch.searchDirection   = aimRay.direction;
            bullseyeSearch.sortMode          = BullseyeSearch.SortMode.Angle;
            bullseyeSearch.RefreshCandidates();
            bullseyeSearch.FilterOutGameObject(base.gameObject);
            this.target = bullseyeSearch.GetResults().FirstOrDefault <HurtBox>();
            Debug.LogFormat("Healing target {0}", new object[]
            {
                this.target
            });
            if (this.target)
            {
                this.targetHealthComponent = this.target.healthComponent;
            }
            string    childName      = "Muzzle";
            Transform modelTransform = base.GetModelTransform();

            if (modelTransform)
            {
                ChildLocator component = modelTransform.GetComponent <ChildLocator>();
                if (component)
                {
                    this.muzzleTransform = component.FindChild(childName);
                    this.healBeam        = UnityEngine.Object.Instantiate <GameObject>(HealBeam.healBeamPrefab, this.muzzleTransform);
                    this.healBeamCurve   = this.healBeam.GetComponent <BezierCurveLine>();
                }
            }
        }
コード例 #7
0
        // Token: 0x06003188 RID: 12680 RVA: 0x000D5660 File Offset: 0x000D3860
        private HurtBox FindTarget(Ray aimRay)
        {
            BullseyeSearch bullseyeSearch = new BullseyeSearch();

            bullseyeSearch.teamMaskFilter = TeamMask.none;
            if (base.teamComponent)
            {
                bullseyeSearch.teamMaskFilter.AddTeam(base.teamComponent.teamIndex);
            }
            bullseyeSearch.filterByLoS       = false;
            bullseyeSearch.maxDistanceFilter = this.targetSelectionRange;
            bullseyeSearch.maxAngleFilter    = 180f;
            bullseyeSearch.searchOrigin      = aimRay.origin;
            bullseyeSearch.searchDirection   = aimRay.direction;
            bullseyeSearch.sortMode          = BullseyeSearch.SortMode.Angle;
            bullseyeSearch.RefreshCandidates();
            bullseyeSearch.FilterOutGameObject(base.gameObject);
            return(bullseyeSearch.GetResults().Where(new Func <HurtBox, bool>(this.NotAlreadyHealingTarget)).Where(new Func <HurtBox, bool>(StartHealBeam.IsHurt)).FirstOrDefault <HurtBox>());
        }
コード例 #8
0
ファイル: Tools.cs プロジェクト: tung362/RoR2PVP
        public static void FilterOutMinionGroup(this BullseyeSearch search, NetworkInstanceId netId)
        {
            List <MinionOwnership.MinionGroup> minionGroups = (List <MinionOwnership.MinionGroup>) typeof(MinionOwnership.MinionGroup).GetField("instancesList", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);

            for (int i = 0; i < minionGroups.Count; i++)
            {
                if (netId == minionGroups[i].ownerId)
                {
                    MinionOwnership[] members = minionGroups[i].GetFieldValue <MinionOwnership[]>("members");
                    for (int j = 0; j < minionGroups[i].memberCount; j++)
                    {
                        CharacterBody minionBody = members[j].GetComponent <CharacterMaster>().GetBody();
                        if (minionBody)
                        {
                            search.FilterOutGameObject(minionBody.gameObject);
                        }
                    }
                    break;
                }
            }
        }
コード例 #9
0
        private HurtBox Evis_SearchForTarget(On.EntityStates.Merc.Evis.orig_SearchForTarget orig, EntityStates.Merc.Evis self)
        {
            var original = orig(self);

            if (!original.healthComponent.body.hasCloakBuff)
            {
                return(original);
            }
            BullseyeSearch bullseyeSearch = new BullseyeSearch
            {
                searchOrigin      = self.transform.position,
                searchDirection   = UnityEngine.Random.onUnitSphere,
                maxDistanceFilter = evisMaxRange,
                teamMaskFilter    = TeamMask.GetUnprotectedTeams(self.GetTeam()),
                sortMode          = BullseyeSearch.SortMode.Distance
            };

            bullseyeSearch.RefreshCandidates();
            bullseyeSearch.FilterOutGameObject(self.gameObject);
            return(FilterMethod(bullseyeSearch.GetResults()));
        }
コード例 #10
0
ファイル: GrabAttempt.cs プロジェクト: ArcPh1r3/RegigigasMod
        private void AttemptGrab(float grabRadius)
        {
            if (this.grabController)
            {
                return;
            }

            Ray aimRay = base.GetAimRay();

            BullseyeSearch search = new BullseyeSearch
            {
                teamMaskFilter    = TeamMask.GetEnemyTeams(base.GetTeam()),
                filterByLoS       = false,
                searchOrigin      = this.grabTransform.position,
                searchDirection   = Random.onUnitSphere,
                sortMode          = BullseyeSearch.SortMode.Distance,
                maxDistanceFilter = grabRadius,
                maxAngleFilter    = 360f
            };

            search.RefreshCandidates();
            search.FilterOutGameObject(base.gameObject);

            HurtBox target = search.GetResults().FirstOrDefault <HurtBox>();

            if (target)
            {
                if (target.healthComponent && target.healthComponent.body)
                {
                    if (BodyMeetsGrabConditions(target.healthComponent.body))
                    {
                        this.grabController = target.healthComponent.body.gameObject.AddComponent <RegigigasGrabController>();
                        this.grabController.pivotTransform         = this.grabTransform;
                        this.grabController.grabberHealthComponent = base.healthComponent;
                        this.grabTarget = target;
                        return;
                    }
                }
            }
        }
コード例 #11
0
        public void OnProjectileImpact(ProjectileImpactInfo impactInfo)
        {
            if (!this.alive)
            {
                return;
            }

            BullseyeSearch search = new BullseyeSearch
            {
                teamMaskFilter    = TeamMask.all,
                filterByLoS       = false,
                searchOrigin      = this.transform.position,
                searchDirection   = Random.onUnitSphere,
                sortMode          = BullseyeSearch.SortMode.Distance,
                maxDistanceFilter = 24f,
                maxAngleFilter    = 360f
            };

            search.RefreshCandidates();
            search.FilterOutGameObject(base.gameObject);

            HurtBox target = search.GetResults().FirstOrDefault <HurtBox>();

            if (target)
            {
                if (target.healthComponent && target.healthComponent.body)
                {
                    if (target.healthComponent.body.baseNameToken == "PALADIN_NAME")
                    {
                        PaladinSwordController swordController = target.healthComponent.body.GetComponent <PaladinSwordController>();
                        if (swordController)
                        {
                            swordController.ApplyLightningBuff();
                        }
                    }
                }
            }
        }
コード例 #12
0
        // Token: 0x0600317E RID: 12670 RVA: 0x000D52FC File Offset: 0x000D34FC
        public override void OnEnter()
        {
            base.OnEnter();
            base.PlayCrossfade("Gesture", "Heal", 0.2f);
            this.duration = HealBeam.baseDuration / this.attackSpeedStat;
            float     healRate  = HealBeam.healCoefficient * this.damageStat / this.duration;
            Ray       aimRay    = base.GetAimRay();
            Transform transform = base.FindModelChild("Muzzle");

            if (NetworkServer.active)
            {
                BullseyeSearch bullseyeSearch = new BullseyeSearch();
                bullseyeSearch.teamMaskFilter = TeamMask.none;
                if (base.teamComponent)
                {
                    bullseyeSearch.teamMaskFilter.AddTeam(base.teamComponent.teamIndex);
                }
                bullseyeSearch.filterByLoS       = false;
                bullseyeSearch.maxDistanceFilter = 50f;
                bullseyeSearch.maxAngleFilter    = 180f;
                bullseyeSearch.searchOrigin      = aimRay.origin;
                bullseyeSearch.searchDirection   = aimRay.direction;
                bullseyeSearch.sortMode          = BullseyeSearch.SortMode.Angle;
                bullseyeSearch.RefreshCandidates();
                bullseyeSearch.FilterOutGameObject(base.gameObject);
                this.target = bullseyeSearch.GetResults().FirstOrDefault <HurtBox>();
                if (transform && this.target)
                {
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(HealBeam.healBeamPrefab, transform);
                    this.healBeamController          = gameObject.GetComponent <HealBeamController>();
                    this.healBeamController.healRate = healRate;
                    this.healBeamController.target   = this.target;
                    this.healBeamController.ownership.ownerObject = base.gameObject;
                    NetworkServer.Spawn(gameObject);
                }
            }
        }
コード例 #13
0
ファイル: Hooks.cs プロジェクト: tung362/RoR2PVP
        static HurtBox CustomAITargetFilter(On.RoR2.CharacterAI.BaseAI.orig_FindEnemyHurtBox orig, RoR2.CharacterAI.BaseAI self, float maxDistance, bool full360Vision, bool filterByLoS)
        {
            if (!self.body)
            {
                return(null);
            }

            bool defaultSearch  = true;
            bool isPlayerBot    = self.master.playerCharacterMasterController ? true : false;
            bool isMinion       = self.master.minionOwnership.ownerMaster ? true : false;
            bool isPlayerMinion = false;

            if (isMinion)
            {
                if (self.master.minionOwnership.ownerMaster.playerCharacterMasterController)
                {
                    isPlayerMinion = true;
                }
            }

            BullseyeSearch enemySearch = self.GetFieldValue <BullseyeSearch>("enemySearch");

            enemySearch.viewer            = self.body;
            enemySearch.teamMaskFilter    = TeamMask.all;
            enemySearch.sortMode          = BullseyeSearch.SortMode.Distance;
            enemySearch.minDistanceFilter = 0f;
            enemySearch.maxDistanceFilter = maxDistance;
            enemySearch.searchOrigin      = self.bodyInputBank.aimOrigin;
            enemySearch.searchDirection   = self.bodyInputBank.aimDirection;
            enemySearch.maxAngleFilter    = (full360Vision ? 180f : 90f);
            enemySearch.filterByLoS       = filterByLoS;

            //Free for all pvp
            if (VoteAPI.VoteResults.HasVote(Settings.FreeForAllPVPToggle.Item2))
            {
                //Player bot AI  or player minion
                if (isPlayerBot || isPlayerMinion)
                {
                    if (PVPMode.IsGracePeriod)
                    {
                        enemySearch.teamMaskFilter.RemoveTeam(self.master.teamIndex);
                    }
                    enemySearch.RefreshCandidates();

                    enemySearch.FilterOutGameObject(self.body.gameObject);
                    if (isMinion)
                    {
                        CharacterBody ownerBody = self.master.minionOwnership.ownerMaster.GetBody();
                        if (ownerBody)
                        {
                            enemySearch.FilterOutGameObject(ownerBody.gameObject);
                        }
                        enemySearch.FilterOutMinionGroup(self.master.minionOwnership.ownerMaster.netId);
                    }
                    else
                    {
                        enemySearch.FilterOutMinionGroup(self.master.netId);
                    }

                    defaultSearch = false;
                }
            }

            //Team pvp or regular mobs AI
            if (defaultSearch)
            {
                enemySearch.teamMaskFilter.RemoveTeam(self.master.teamIndex);
                enemySearch.RefreshCandidates();
            }

            return(enemySearch.GetResults().FirstOrDefault <HurtBox>());
        }
コード例 #14
0
        private void DoTether()
        {
            if (this.hasFired)
            {
                return;
            }
            this.hasFired = true;
            Debug.Log("Setting tether handler!");

            //base.isAuthority -> will only run on local machine
            //if (base.isAuthority)
            //{
            tetherHandler = base.GetComponent <TetherHandler>();

            HurtBox closestHurtbox = null;

            Debug.Log("Raycasting!");
            //First check to see if we're aiming at a valid target
            Ray        aimRay      = base.GetAimRay();
            RaycastHit raycastHit  = new RaycastHit();
            bool       foundTarget = Physics.Raycast(aimRay, out raycastHit, maxDistanceFilter);

            if (foundTarget && raycastHit.collider.GetComponent <HurtBox>())
            {
                TeamIndex targetTeamIndex = raycastHit.collider.GetComponent <HurtBox>().healthComponent.body.teamComponent.teamIndex;
                //Make sure we're not targeting the enemy team
                if (base.GetTeam() == targetTeamIndex)
                {
                    closestHurtbox = raycastHit.collider.GetComponent <HurtBox>();
                    Debug.Log("Found aimed at object " + closestHurtbox.transform.root.name);
                }
            }
            //If we weren't aiming at something, just search for a valid nearby target
            else
            {
                //Search for all nearby targets
                BullseyeSearch bullseyeSearch = new BullseyeSearch();
                bullseyeSearch.searchOrigin      = base.transform.position;
                bullseyeSearch.searchDirection   = UnityEngine.Random.onUnitSphere;
                bullseyeSearch.maxDistanceFilter = maxDistanceFilter;
                TeamMask sameTeamMask = new TeamMask();
                sameTeamMask.AddTeam(base.GetTeam());
                bullseyeSearch.teamMaskFilter = sameTeamMask;

                //Sort by distance
                bullseyeSearch.sortMode = BullseyeSearch.SortMode.Distance;
                bullseyeSearch.RefreshCandidates();
                //Remove ourselves from the search results
                //(shouldn't be there in the first place, but hey)
                bullseyeSearch.FilterOutGameObject(base.gameObject);

                //Get the closest hurtbox
                closestHurtbox = bullseyeSearch.GetResults().FirstOrDefault <HurtBox>();

                Debug.Log("Found local object " + closestHurtbox.transform.root.name);
                if (closestHurtbox == default(HurtBox))
                {
                    Debug.LogError("Default value!");
                }
                if (closestHurtbox == null)
                {
                    Debug.LogError("Null value!");
                }
            }

            //Set up our grapple handler
            if (tetherHandler == null)
            {
                tetherHandler = base.gameObject.AddComponent <TetherHandler>();
                Debug.LogWarning("Added grapple handler via tether function");
                return;
            }

            //Then establish our grapple target
            if (closestHurtbox == null)
            {
                Debug.LogError("Null hurtbox");
                return;
            }
            //If we've successfully established a tether
            else if (closestHurtbox)
            {
                Debug.Log("Attempting to establish tether");
                //If adding a new grapple target would go beyond our max stock
                int curNumGrappled = tetherHandler.GetGrappleTargets().Count;
                if (curNumGrappled + 1 > base.activatorSkillSlot.maxStock)
                {
                    //Remove the oldest grapple target
                    tetherHandler.ClearGrappleTarget(tetherHandler.GetGrappleTargets()[0]);
                }

                tetherHandler.SetGrappleTarget(closestHurtbox);
                tetherHandler.TETHER_TYPE = TETHER_TYPE.TETHER;
                Debug.Log("Set grapple target");

                base.characterBody.AddBuff(WispSurvivor.Modules.Buffs.sustainSelf);
                closestHurtbox.healthComponent.body.AddBuff(WispSurvivor.Modules.Buffs.sustainTarget);
            }
            //}

            /*
             *  this.animator = base.GetModelAnimator();
             *  this.muzzleString = "Muzzle";
             *
             *
             *  base.PlayAnimation("Gesture, Override", "FireGrapple", "FireGrapple.playbackRate", this.duration);
             */
        }
コード例 #15
0
            public void FixedUpdate()
            {
                if (NetworkServer.active)
                {
                    while (enemyFollowers.Count < stack)
                    {
                        GameObject enemyFollower = Object.Instantiate(enemyFollowerPrefab, body.corePosition, Quaternion.identity);
                        enemyFollower.GetComponent <GenericOwnership>().ownerObject = gameObject;
                        NetworkServer.Spawn(enemyFollower);
                        enemyFollowers.Add(enemyFollower.GetComponent <MysticsItemsSpotterController>());
                    }
                    while (enemyFollowers.Count > stack)
                    {
                        MysticsItemsSpotterController enemyFollower = enemyFollowers.Last();
                        NetworkServer.UnSpawn(enemyFollower.gameObject);
                        Object.Destroy(enemyFollower.gameObject);
                        enemyFollowers.Remove(enemyFollower);
                    }
                }
                cooldown -= Time.fixedDeltaTime;
                if (cooldown <= 0f)
                {
                    cooldown = cooldownMax;

                    if (NetworkServer.active)
                    {
                        bullseyeSearch.teamMaskFilter = TeamMask.allButNeutral;
                        bullseyeSearch.teamMaskFilter.RemoveTeam(body.teamComponent.teamIndex);
                        Ray ray = CameraRigController.ModifyAimRayIfApplicable(new Ray
                        {
                            origin    = body.inputBank.aimOrigin,
                            direction = body.inputBank.aimDirection
                        }, body.gameObject, out _);
                        bullseyeSearch.searchOrigin      = ray.origin;
                        bullseyeSearch.searchDirection   = ray.direction;
                        bullseyeSearch.viewer            = body;
                        bullseyeSearch.maxDistanceFilter = 200f;
                        bullseyeSearch.RefreshCandidates();
                        bullseyeSearch.FilterOutGameObject(body.gameObject);
                        List <HurtBox> enemies = bullseyeSearch.GetResults().ToList();

                        foreach (MysticsItemsSpotterController enemyFollower in enemyFollowers)
                        {
                            enemyFollower.ClearTarget();
                        }

                        if (enemies.Count > 0)
                        {
                            Util.PlaySound("Play_item_proc_spotter", gameObject);
                            foreach (MysticsItemsSpotterController enemyFollower in enemyFollowers)
                            {
                                GameObject newTarget = null;
                                while (newTarget == null && enemies.Count > 0)
                                {
                                    int     index            = Mathf.FloorToInt(enemies.Count * (Random.value * 0.99f));
                                    HurtBox newTargetHurtBox = enemies.ElementAt(index);
                                    enemies.RemoveAt(index);
                                    if (newTargetHurtBox.healthComponent && newTargetHurtBox.healthComponent.body)
                                    {
                                        CharacterBody newTargetBody = newTargetHurtBox.healthComponent.body;
                                        if (!newTargetBody.HasBuff(buffDef))
                                        {
                                            newTarget = newTargetBody.gameObject;
                                        }
                                    }
                                }
                                if (newTarget)
                                {
                                    enemyFollower.SetTarget(newTarget);
                                }
                                else
                                {
                                    enemyFollower.ClearTarget();
                                }
                            }
                        }
                        else
                        {
                            cooldown = cooldownIfNoEnemiesFound;
                        }
                    }
                }
            }