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

            if (npcContext == null)
            {
                return;
            }
            if (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null)
            {
                npcContext.SetFact(Facts.EnemyRange, EnemyRange.OutOfRange, true, true, true);
            }
            Vector3      lastKnownPosition = npcContext.Memory.PrimaryKnownEnemyPlayer.LastKnownPosition - npcContext.BodyPosition;
            float        single            = lastKnownPosition.sqrMagnitude;
            AttackEntity firearm           = npcContext.Domain.GetFirearm();

            if (single <= npcContext.Body.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm))
            {
                npcContext.SetFact(Facts.EnemyRange, EnemyRange.CloseRange, true, true, true);
                return;
            }
            if (single <= npcContext.Body.AiDefinition.Engagement.SqrMediumRangeFirearm(firearm))
            {
                npcContext.SetFact(Facts.EnemyRange, EnemyRange.MediumRange, true, true, true);
                return;
            }
            if (single <= npcContext.Body.AiDefinition.Engagement.SqrLongRangeFirearm(firearm))
            {
                npcContext.SetFact(Facts.EnemyRange, EnemyRange.LongRange, true, true, true);
                return;
            }
            npcContext.SetFact(Facts.EnemyRange, EnemyRange.OutOfRange, true, true, true);
        }
Exemplo n.º 2
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            NpcPlayerInfo enemyPlayerTarget = npcContext.GetPrimaryEnemyPlayerTarget();

            if (!Object.op_Inequality((Object)enemyPlayerTarget.Player, (Object)null))
            {
                return;
            }
            AttackEntity firearm = npcContext.Domain.GetFirearm();

            if (PreferredFightingRangeReasoner.IsAtPreferredRange(npcContext, ref enemyPlayerTarget, firearm))
            {
                npcContext.SetFact(Rust.Ai.HTN.Murderer.Facts.AtLocationPreferredFightingRange, 1, true, true, true);
            }
            else
            {
                npcContext.SetFact(Rust.Ai.HTN.Murderer.Facts.AtLocationPreferredFightingRange, 0, true, true, true);
            }
        }
Exemplo n.º 3
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            if (!npcContext.IsFact(Facts.AtLocationHome) && !npcContext.IsFact(Facts.IsReturningHome) && (!npcContext.IsFact(Facts.IsNavigating) && !npcContext.IsFact(Facts.IsWaiting)))
            {
                if (!Object.op_Equality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null) && (double)time - (double)npcContext.Memory.PrimaryKnownEnemyPlayer.Time <= (double)npcContext.Body.AiDefinition.Memory.NoSeeReturnToSpawnTime)
                {
                    return;
                }
                npcContext.SetFact(Facts.IsReturningHome, true, true, true, true);
                NavMeshHit navMeshHit;
                if (!NavMesh.SamplePosition(npcContext.Domain.SpawnPosition, ref navMeshHit, 1f, npcContext.Domain.NavAgent.get_areaMask()))
                {
                    return;
                }
                npcContext.Domain.SetDestination(((NavMeshHit) ref navMeshHit).get_position(), false);
            }
            else
            {
                if (!npcContext.IsFact(Facts.CanSeeEnemy) && !npcContext.IsFact(Facts.CanHearEnemy) && ((double)time - (double)npcContext.Body.lastAttackedTime >= 2.0 && !npcContext.IsFact(Facts.AtLocationHome)))
                {
                    return;
                }
                npcContext.SetFact(Facts.IsReturningHome, false, true, true, true);
            }
        }
Exemplo n.º 4
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            BaseNpc animal = (BaseNpc)null;
            float   num    = float.MaxValue;

            for (int index = 0; index < npcContext.AnimalsInRange.Count; ++index)
            {
                AnimalInfo animalInfo = npcContext.AnimalsInRange[index];
                if (Object.op_Inequality((Object)animalInfo.Animal, (Object)null) && (double)animalInfo.SqrDistance < (double)num)
                {
                    num    = animalInfo.SqrDistance;
                    animal = animalInfo.Animal;
                }
            }
            if (Object.op_Inequality((Object)animal, (Object)null))
            {
                AttackEntity firearm = npcContext.Domain.GetFirearm();
                if ((double)num < (double)npc.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm))
                {
                    npcContext.Memory.RememberPrimaryAnimal(animal);
                    npcContext.SetFact(Rust.Ai.HTN.Murderer.Facts.NearbyAnimal, true, true, true, true);
                    return;
                }
            }
            npcContext.SetFact(Rust.Ai.HTN.Murderer.Facts.NearbyAnimal, false, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            BaseNpc animal      = null;
            float   sqrDistance = Single.MaxValue;

            for (int i = 0; i < npcContext.AnimalsInRange.Count; i++)
            {
                AnimalInfo item = npcContext.AnimalsInRange[i];
                if (item.Animal != null && item.SqrDistance < sqrDistance)
                {
                    sqrDistance = item.SqrDistance;
                    animal      = item.Animal;
                }
            }
            if (animal != null)
            {
                AttackEntity firearm = npcContext.Domain.GetFirearm();
                if (sqrDistance < npc.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm))
                {
                    npcContext.Memory.RememberPrimaryAnimal(animal);
                    npcContext.SetFact(Facts.NearbyAnimal, true, true, true, true);
                    return;
                }
            }
            npcContext.SetFact(Facts.NearbyAnimal, false, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            NavMeshHit      navMeshHit;
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            if (!npcContext.IsFact(Facts.AtLocationHome) && !npcContext.IsFact(Facts.IsReturningHome) && !npcContext.IsFact(Facts.IsNavigating) && !npcContext.IsFact(Facts.IsWaiting))
            {
                if (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null || time - npcContext.Memory.PrimaryKnownEnemyPlayer.Time > npcContext.Body.AiDefinition.Memory.NoSeeReturnToSpawnTime)
                {
                    npcContext.SetFact(Facts.IsReturningHome, true, true, true, true);
                    if (NavMesh.SamplePosition(npcContext.Domain.SpawnPosition, out navMeshHit, 1f, npcContext.Domain.NavAgent.areaMask))
                    {
                        npcContext.Domain.SetDestination(navMeshHit.position, false);
                        return;
                    }
                }
            }
            else if (npcContext.IsFact(Facts.CanSeeEnemy) || npcContext.IsFact(Facts.CanHearEnemy) || time - npcContext.Body.lastAttackedTime < 2f || npcContext.IsFact(Facts.AtLocationHome))
            {
                npcContext.SetFact(Facts.IsReturningHome, false, true, true, true);
            }
        }
Exemplo n.º 7
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            float healthFraction = npc.healthFraction;

            if ((double)healthFraction > 0.899999976158142)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.FullHealth, true, true, true);
            }
            else if ((double)healthFraction > 0.600000023841858)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.HighHealth, true, true, true);
            }
            else if ((double)healthFraction > 0.300000011920929)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.MediumHealth, true, true, true);
            }
            else if ((double)healthFraction > 0.0)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.LowHealth, true, true, true);
            }
            else
            {
                npcContext.SetFact(Facts.HealthState, HealthState.Dead, true, true, true);
            }
        }
Exemplo n.º 8
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            float single = npc.healthFraction;

            if (single > 0.9f)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.FullHealth, true, true, true);
                return;
            }
            if (single > 0.6f)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.HighHealth, true, true, true);
                return;
            }
            if (single > 0.3f)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.MediumHealth, true, true, true);
                return;
            }
            if (single > 0f)
            {
                npcContext.SetFact(Facts.HealthState, HealthState.LowHealth, true, true, true);
                return;
            }
            npcContext.SetFact(Facts.HealthState, HealthState.Dead, true, true, true);
        }
Exemplo n.º 9
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            if (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player != null && (MurdererDomain.MurdererNavigateToLastKnownLocationOfPrimaryEnemyPlayer.GetDestination(npcContext) - npcContext.Body.transform.position).sqrMagnitude < 1f)
            {
                npcContext.SetFact(Facts.AtLocationLastKnownLocationOfPrimaryEnemyPlayer, 1, true, true, true);
                return;
            }
            npcContext.SetFact(Facts.AtLocationLastKnownLocationOfPrimaryEnemyPlayer, 0, true, true, true);
        }
Exemplo n.º 10
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            if ((npcContext.BodyPosition - npcContext.Domain.SpawnPosition).sqrMagnitude < 3f)
            {
                npcContext.SetFact(Facts.AtLocationHome, true, true, true, true);
                return;
            }
            npcContext.SetFact(Facts.AtLocationHome, false, 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);
        }
        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))
            {
                return;
            }
            FireTactic   fireTactic = FireTactic.Single;
            AttackEntity heldEntity = htnPlayer.GetHeldEntity() as AttackEntity;

            if (Object.op_Implicit((Object)heldEntity))
            {
                BaseProjectile baseProjectile = heldEntity as BaseProjectile;
                float          num            = float.MaxValue;
                if (Object.op_Inequality((Object)npcContext.PrimaryEnemyPlayerInLineOfSight.Player, (Object)null))
                {
                    num = npcContext.PrimaryEnemyPlayerInLineOfSight.SqrDistance;
                }
                fireTactic = (double)heldEntity.attackLengthMin <0.0 || (double)num> (double) npcContext.Body.AiDefinition.Engagement.SqrCloseRangeFirearm((AttackEntity)baseProjectile) ? ((double)heldEntity.attackLengthMin <0.0 || (double)num> (double) npcContext.Body.AiDefinition.Engagement.SqrMediumRangeFirearm((AttackEntity)baseProjectile) ? FireTactic.Single : FireTactic.Burst) : FireTactic.FullAuto;
            }
            npcContext.SetFact(Rust.Ai.HTN.Murderer.Facts.FireTactic, fireTactic, 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         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);
            }
        }
Exemplo n.º 14
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            if (Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null))
            {
                Vector3 vector3 = Vector3.op_Subtraction(MurdererDomain.MurdererNavigateToLastKnownLocationOfPrimaryEnemyPlayer.GetDestination(npcContext), ((Component)npcContext.Body).get_transform().get_position());
                if ((double)((Vector3) ref vector3).get_sqrMagnitude() < 1.0)
                {
                    npcContext.SetFact(Facts.AtLocationLastKnownLocationOfPrimaryEnemyPlayer, 1, true, true, true);
                    return;
                }
            }
            npcContext.SetFact(Facts.AtLocationLastKnownLocationOfPrimaryEnemyPlayer, 0, true, true, true);
        }
Exemplo n.º 15
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            npcContext.SetFact(Facts.HasEnemyTarget, npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player != null, true, true, true);
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            if (Object.op_Equality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null))
            {
                npcContext.SetFact(Rust.Ai.HTN.Murderer.Facts.EnemyRange, EnemyRange.OutOfRange, true, true, true);
            }
            Vector3      vector3      = Vector3.op_Subtraction(npcContext.Memory.PrimaryKnownEnemyPlayer.LastKnownPosition, npcContext.BodyPosition);
            float        sqrMagnitude = ((Vector3) ref vector3).get_sqrMagnitude();
            AttackEntity firearm      = npcContext.Domain.GetFirearm();
            float        num1         = npcContext.Body.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm);

            if ((double)sqrMagnitude <= (double)num1)
            {
                npcContext.SetFact(Rust.Ai.HTN.Murderer.Facts.EnemyRange, EnemyRange.CloseRange, true, true, true);
            }
            else
            {
                float num2 = npcContext.Body.AiDefinition.Engagement.SqrMediumRangeFirearm(firearm);
                if ((double)sqrMagnitude <= (double)num2)
                {
                    npcContext.SetFact(Rust.Ai.HTN.Murderer.Facts.EnemyRange, EnemyRange.MediumRange, true, true, true);
                }
                else
                {
                    float num3 = npcContext.Body.AiDefinition.Engagement.SqrLongRangeFirearm(firearm);
                    if ((double)sqrMagnitude <= (double)num3)
                    {
                        npcContext.SetFact(Rust.Ai.HTN.Murderer.Facts.EnemyRange, EnemyRange.LongRange, true, true, true);
                    }
                    else
                    {
                        npcContext.SetFact(Rust.Ai.HTN.Murderer.Facts.EnemyRange, EnemyRange.OutOfRange, true, true, true);
                    }
                }
            }
        }
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            NpcPlayerInfo primaryEnemyPlayerTarget = npcContext.GetPrimaryEnemyPlayerTarget();

            if (primaryEnemyPlayerTarget.Player != null)
            {
                if (PreferredFightingRangeReasoner.IsAtPreferredRange(npcContext, ref primaryEnemyPlayerTarget, npcContext.Domain.GetFirearm()))
                {
                    npcContext.SetFact(Facts.AtLocationPreferredFightingRange, 1, true, true, true);
                    return;
                }
                npcContext.SetFact(Facts.AtLocationPreferredFightingRange, 0, true, true, true);
            }
        }
Exemplo n.º 18
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            if (npcContext == null)
            {
                return;
            }
            Vector3 vector3 = Vector3.op_Subtraction(npcContext.BodyPosition, npcContext.Domain.SpawnPosition);

            if ((double)((Vector3) ref vector3).get_sqrMagnitude() < 3.0)
            {
                npcContext.SetFact(Facts.AtLocationHome, true, true, true, true);
            }
Exemplo n.º 19
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;
            }
            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);
                }
            }
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
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);
            }
        }
        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;
            }
            FireTactic   fireTactic = FireTactic.Single;
            AttackEntity heldEntity = hTNPlayer.GetHeldEntity() as AttackEntity;

            if (heldEntity)
            {
                BaseProjectile baseProjectile = heldEntity as BaseProjectile;
                float          sqrDistance    = Single.MaxValue;
                if (npcContext.PrimaryEnemyPlayerInLineOfSight.Player != null)
                {
                    sqrDistance = npcContext.PrimaryEnemyPlayerInLineOfSight.SqrDistance;
                }
                if (heldEntity.attackLengthMin < 0f || sqrDistance > npcContext.Body.AiDefinition.Engagement.SqrCloseRangeFirearm(baseProjectile))
                {
                    fireTactic = (heldEntity.attackLengthMin <0f || sqrDistance> npcContext.Body.AiDefinition.Engagement.SqrMediumRangeFirearm(baseProjectile) ? FireTactic.Single : FireTactic.Burst);
                }
                else
                {
                    fireTactic = FireTactic.FullAuto;
                }
            }
            npcContext.SetFact(Facts.FireTactic, fireTactic, true, true, true);
        }
Exemplo n.º 24
0
        public void Tick(IHTNAgent npc, float deltaTime, float time)
        {
            MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext;

            npcContext?.SetFact(Facts.HasEnemyTarget, Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null), true, true, true);
        }