Exemplo n.º 1
0
        private static HurtBox BaseAI_CustomTargeting(On.RoR2.CharacterAI.BaseAI.orig_FindEnemyHurtBox orig, RoR2.CharacterAI.BaseAI self, float maxDistance, bool full360Vision, bool filterByLoS)
        {
            var gameObject = self.body.gameObject;

            if (gameObject)
            {
                var isCharmed = gameObject.GetComponent <IsCharmed>();
                if (isCharmed && isCharmed.enabled)
                {
                    self.enemySearch.viewer         = self.body;
                    self.enemySearch.teamMaskFilter = TeamMask.allButNeutral;
                    self.enemySearch.teamMaskFilter.RemoveTeam(isCharmed.GetOppositeTeamIndex(isCharmed.GetOldTeam()));
                    self.enemySearch.sortMode          = BullseyeSearch.SortMode.Distance;
                    self.enemySearch.minDistanceFilter = 0;
                    self.enemySearch.maxDistanceFilter = maxDistance * 4f; //maxDistance
                    self.enemySearch.searchOrigin      = self.bodyInputBank.aimOrigin;
                    self.enemySearch.searchDirection   = self.bodyInputBank.aimDirection;
                    self.enemySearch.maxAngleFilter    = 180f; // (full360Vision ? 180f : 90f)
                    self.enemySearch.filterByLoS       = filterByLoS;
                    self.enemySearch.RefreshCandidates();
                    self.enemySearch.FilterOutGameObject(gameObject);
                    var list = self.enemySearch.GetResults().ToList();

                    foreach (HurtBox hurtBox in list)
                    {
                        if (!hurtBox.GetComponent <IsCharmed>())
                        {
                            return(hurtBox); //Chooses the first non-charmed target
                        }
                    }
                    return(list.FirstOrDefault()); //and falls back if it can't
                }
            }
            return(orig(self, maxDistance, full360Vision, filterByLoS));
        }
Exemplo n.º 2
0
        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>());
        }
Exemplo n.º 3
0
        private HurtBox BaseAI_FindEnemyHurtBox(On.RoR2.CharacterAI.BaseAI.orig_FindEnemyHurtBox orig, RoR2.CharacterAI.BaseAI self, float maxDistance, bool full360Vision, bool filterByLoS)
        {
            var original = orig(self, maxDistance, full360Vision, filterByLoS);

            if (original != null)
            {
                if (original.healthComponent == LocalUserManager.readOnlyLocalUsersList[0].cachedBody.healthComponent)
                {
                    NoticedEnemiesList.Add(self);
                }
                else
                {
                    NoticedEnemiesList.Remove(self);
                }
            }

            return(original);
        }