public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            npcContext.SetFact(Facts.CanSeeEnemy, npcContext.EnemyPlayersInLineOfSight.Count > 0, true, true, true);
            float         single        = 0f;
            NpcPlayerInfo npcPlayerInfo = new NpcPlayerInfo();

            foreach (NpcPlayerInfo enemyPlayersInLineOfSight in npc.AiDomain.NpcContext.EnemyPlayersInLineOfSight)
            {
                float forwardDotDir = (enemyPlayersInLineOfSight.ForwardDotDir + 1f) * 0.5f;
                float sqrDistance   = (1f - enemyPlayersInLineOfSight.SqrDistance / npc.AiDefinition.Engagement.SqrAggroRange) * 2f + forwardDotDir;
                if (sqrDistance > single)
                {
                    single        = sqrDistance;
                    npcPlayerInfo = enemyPlayersInLineOfSight;
                }
                NpcPlayerInfo npcPlayerInfo1 = enemyPlayersInLineOfSight;
                npcPlayerInfo1.VisibilityScore = sqrDistance;
                npcContext.Memory.RememberEnemyPlayer(npc, ref npcPlayerInfo1, time, 0f, "SEE!");
            }
            npcContext.PrimaryEnemyPlayerInLineOfSight = npcPlayerInfo;
            if (npcPlayerInfo.Player != null && (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null || npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.AudibleScore < single))
            {
                npcContext.Memory.RememberPrimaryEnemyPlayer(npcPlayerInfo.Player);
                npcContext.IncrementFact(Facts.Alertness, 2, true, true, true);
            }
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            npcContext.SetFact(Facts.CanSeeEnemy, npcContext.EnemyPlayersInLineOfSight.Count > 0, true, true, true);
            float         num1           = 0.0f;
            NpcPlayerInfo npcPlayerInfo1 = new NpcPlayerInfo();

            foreach (NpcPlayerInfo npcPlayerInfo2 in npc.AiDomain.NpcContext.EnemyPlayersInLineOfSight)
            {
                float num2 = (float)((1.0 - (double)npcPlayerInfo2.SqrDistance / (double)npc.AiDefinition.Engagement.SqrAggroRange) * 2.0) + (float)(((double)npcPlayerInfo2.ForwardDotDir + 1.0) * 0.5);
                if ((double)num2 > (double)num1)
                {
                    num1           = num2;
                    npcPlayerInfo1 = npcPlayerInfo2;
                }
                NpcPlayerInfo info = npcPlayerInfo2;
                info.VisibilityScore = num2;
                npcContext.Memory.RememberEnemyPlayer(npc, ref info, time, 0.0f, "SEE!");
            }
            npcContext.PrimaryEnemyPlayerInLineOfSight = npcPlayerInfo1;
            if (!Object.op_Inequality((Object)npcPlayerInfo1.Player, (Object)null) || !Object.op_Equality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null) && (double)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.AudibleScore >= (double)num1)
            {
                return;
            }
            npcContext.Memory.RememberPrimaryEnemyPlayer(npcPlayerInfo1.Player);
            npcContext.IncrementFact(Facts.Alertness, 2, true, true, true);
        }
Beispiel #3
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null || !npcContext.IsFact(Facts.Frustration) || (double)time - (double)this._lastFrustrationDecrementTime <= 5.0)
            {
                return;
            }
            this._lastFrustrationDecrementTime = time;
            npcContext.IncrementFact(Facts.Frustration, -1, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            if (npcContext.IsFact(Facts.Frustration) && time - this._lastFrustrationDecrementTime > 5f)
            {
                this._lastFrustrationDecrementTime = time;
                npcContext.IncrementFact(Facts.Frustration, -1, true, true, true);
            }
        }
Beispiel #5
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            HTNPlayer htnPlayer = npc as HTNPlayer;

            if (Object.op_Equality((Object)htnPlayer, (Object)null) || (double)time - (double)htnPlayer.lastAttackedTime <= 3.0 || (!npcContext.IsFact(Rust.Ai.HTN.Murderer.Facts.Vulnerability) || (double)time - (double)this._lastVulnerabilityDecrementTime <= 2.0))
            {
                return;
            }
            this._lastVulnerabilityDecrementTime = time;
            npcContext.IncrementFact(Rust.Ai.HTN.Murderer.Facts.Vulnerability, -1, true, true, true);
        }
Beispiel #6
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null || !npcContext.IsFact(Facts.Alertness))
            {
                return;
            }
            if (npcContext.GetFact(Facts.Alertness) > (byte)10)
            {
                npcContext.SetFact(Facts.Alertness, 10, true, false, true);
            }
            if ((double)time - (double)this._lastFrustrationDecrementTime <= 1.0)
            {
                return;
            }
            this._lastFrustrationDecrementTime = time;
            npcContext.IncrementFact(Facts.Alertness, -1, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            HTNPlayer hTNPlayer = npc as HTNPlayer;

            if (hTNPlayer == null)
            {
                return;
            }
            if (time - hTNPlayer.lastAttackedTime > 3f && npcContext.IsFact(Facts.Vulnerability) && time - this._lastVulnerabilityDecrementTime > 2f)
            {
                this._lastVulnerabilityDecrementTime = time;
                npcContext.IncrementFact(Facts.Vulnerability, -1, true, true, true);
            }
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            if (npcContext.IsFact(Facts.Alertness))
            {
                if (npcContext.GetFact(Facts.Alertness) > 10)
                {
                    npcContext.SetFact(Facts.Alertness, 10, true, false, true);
                }
                if (time - this._lastFrustrationDecrementTime > 1f)
                {
                    this._lastFrustrationDecrementTime = time;
                    npcContext.IncrementFact(Facts.Alertness, -1, true, true, true);
                }
            }
        }
Beispiel #9
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            npcContext.SetFact(Facts.CanHearEnemy, npcContext.EnemyPlayersAudible.Count > 0, true, true, true);
            float         num1           = 0.0f;
            NpcPlayerInfo npcPlayerInfo1 = new NpcPlayerInfo();

            foreach (NpcPlayerInfo npcPlayerInfo2 in npc.AiDomain.NpcContext.EnemyPlayersAudible)
            {
                if ((double)npcPlayerInfo2.SqrDistance <= (double)npc.AiDefinition.Sensory.SqrHearingRange)
                {
                    float num2 = 1f - Mathf.Min(1f, npcPlayerInfo2.SqrDistance / npc.AiDefinition.Sensory.SqrHearingRange);
                    float num3 = num2 * 2f;
                    if ((double)num3 > (double)num1)
                    {
                        num1           = num3;
                        npcPlayerInfo1 = npcPlayerInfo2;
                    }
                    NpcPlayerInfo info = npcPlayerInfo2;
                    info.AudibleScore = num3;
                    npcContext.Memory.RememberEnemyPlayer(npc, ref info, time, (float)((1.0 - (double)num2) * 20.0), "SOUND!");
                }
            }
            npcContext.PrimaryEnemyPlayerAudible = npcPlayerInfo1;
            if (!Object.op_Inequality((Object)npcPlayerInfo1.Player, (Object)null) || !Object.op_Equality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null) && (double)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.VisibilityScore >= (double)num1)
            {
                return;
            }
            npcContext.Memory.RememberPrimaryEnemyPlayer(npcPlayerInfo1.Player);
            npcContext.IncrementFact(Facts.Alertness, 1, true, true, true);
        }
Beispiel #10
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            npcContext.SetFact(Facts.CanHearEnemy, npcContext.EnemyPlayersAudible.Count > 0, true, true, true);
            float         single        = 0f;
            NpcPlayerInfo npcPlayerInfo = new NpcPlayerInfo();

            foreach (NpcPlayerInfo enemyPlayersAudible in npc.AiDomain.NpcContext.EnemyPlayersAudible)
            {
                if (enemyPlayersAudible.SqrDistance > npc.AiDefinition.Sensory.SqrHearingRange)
                {
                    continue;
                }
                float single1 = 1f - Mathf.Min(1f, enemyPlayersAudible.SqrDistance / npc.AiDefinition.Sensory.SqrHearingRange);
                float single2 = single1 * 2f;
                if (single2 > single)
                {
                    single        = single2;
                    npcPlayerInfo = enemyPlayersAudible;
                }
                NpcPlayerInfo npcPlayerInfo1 = enemyPlayersAudible;
                npcPlayerInfo1.AudibleScore = single2;
                npcContext.Memory.RememberEnemyPlayer(npc, ref npcPlayerInfo1, time, (1f - single1) * 20f, "SOUND!");
            }
            npcContext.PrimaryEnemyPlayerAudible = npcPlayerInfo;
            if (npcPlayerInfo.Player != null && (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null || npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.VisibilityScore < single))
            {
                npcContext.Memory.RememberPrimaryEnemyPlayer(npcPlayerInfo.Player);
                npcContext.IncrementFact(Facts.Alertness, 1, true, true, true);
            }
        }