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; } NpcOrientation npcOrientation = NpcOrientation.Heading; if (npc.IsDestroyed || htnPlayer.IsDead() || htnPlayer.IsWounded()) { npcOrientation = NpcOrientation.None; } else if (Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownAnimal.Animal, (Object)null)) { npcOrientation = !Object.op_Inequality((Object)npcContext.PrimaryEnemyPlayerInLineOfSight.Player, (Object)null) ? NpcOrientation.LookAtAnimal : ((double)npcContext.Memory.PrimaryKnownAnimal.SqrDistance >= (double)npcContext.PrimaryEnemyPlayerInLineOfSight.SqrDistance ? (npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible ? NpcOrientation.PrimaryTargetBody : (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation)) : NpcOrientation.LookAtAnimal); } else if (Object.op_Inequality((Object)npcContext.PrimaryEnemyPlayerInLineOfSight.Player, (Object)null)) { npcOrientation = npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible ? NpcOrientation.PrimaryTargetBody : (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation); } else if (Object.op_Inequality((Object)htnPlayer.lastAttacker, (Object)null) && (double)htnPlayer.lastAttackedTime > 0.0 && (double)time - (double)htnPlayer.lastAttackedTime < 2.0) { npcOrientation = NpcOrientation.LastAttackedDirection; } else if (Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null)) { npcOrientation = npcContext.GetFact(Rust.Ai.HTN.Murderer.Facts.IsSearching) <= (byte)0 || npcContext.GetFact(Rust.Ai.HTN.Murderer.Facts.IsNavigating) != (byte)0 ? (npcContext.GetFact(Rust.Ai.HTN.Murderer.Facts.IsIdle) <= (byte)0 ? NpcOrientation.LastKnownPrimaryTargetLocation : (!npcContext.IsFact(Rust.Ai.HTN.Murderer.Facts.CanHearEnemy) ? NpcOrientation.Heading : NpcOrientation.AudibleTargetDirection)) : NpcOrientation.LookAround; } else if (npcContext.IsFact(Rust.Ai.HTN.Murderer.Facts.CanHearEnemy)) { npcOrientation = NpcOrientation.AudibleTargetDirection; } if (npcContext.IsFact(Rust.Ai.HTN.Murderer.Facts.IsRoaming) && !npcContext.IsFact(Rust.Ai.HTN.Murderer.Facts.HasEnemyTarget)) { npcOrientation = NpcOrientation.Heading; } else if (npcContext.IsFact(Rust.Ai.HTN.Murderer.Facts.IsReturningHome) && !npcContext.IsFact(Rust.Ai.HTN.Murderer.Facts.HasEnemyTarget)) { npcOrientation = NpcOrientation.Home; } npcContext.OrientationType = npcOrientation; }
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); } } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { NpcOrientation npcOrientation; NpcOrientation npcOrientation1; MurdererContext npcContext = npc.AiDomain.NpcContext as MurdererContext; if (npcContext == null) { return; } HTNPlayer hTNPlayer = npc as HTNPlayer; if (hTNPlayer == null) { return; } NpcOrientation npcOrientation2 = NpcOrientation.Heading; if (npc.IsDestroyed || hTNPlayer.IsDead() || hTNPlayer.IsWounded()) { npcOrientation2 = NpcOrientation.None; } else if (npcContext.Memory.PrimaryKnownAnimal.Animal != null) { if (npcContext.PrimaryEnemyPlayerInLineOfSight.Player == null) { npcOrientation2 = NpcOrientation.LookAtAnimal; } else if (npcContext.Memory.PrimaryKnownAnimal.SqrDistance >= npcContext.PrimaryEnemyPlayerInLineOfSight.SqrDistance) { if (npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible) { npcOrientation1 = NpcOrientation.PrimaryTargetBody; } else { npcOrientation1 = (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation); } npcOrientation2 = npcOrientation1; } else { npcOrientation2 = NpcOrientation.LookAtAnimal; } } else if (npcContext.PrimaryEnemyPlayerInLineOfSight.Player != null) { if (npcContext.PrimaryEnemyPlayerInLineOfSight.BodyVisible) { npcOrientation = NpcOrientation.PrimaryTargetBody; } else { npcOrientation = (npcContext.PrimaryEnemyPlayerInLineOfSight.HeadVisible ? NpcOrientation.PrimaryTargetHead : NpcOrientation.LastKnownPrimaryTargetLocation); } npcOrientation2 = npcOrientation; } else if (hTNPlayer.lastAttacker != null && hTNPlayer.lastAttackedTime > 0f && time - hTNPlayer.lastAttackedTime < 2f) { npcOrientation2 = NpcOrientation.LastAttackedDirection; } else if (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null) { if (npcContext.IsFact(Facts.CanHearEnemy)) { npcOrientation2 = NpcOrientation.AudibleTargetDirection; } } else if (npcContext.GetFact(Facts.IsSearching) > 0 && npcContext.GetFact(Facts.IsNavigating) == 0) { npcOrientation2 = NpcOrientation.LookAround; } else if (npcContext.GetFact(Facts.IsIdle) <= 0) { npcOrientation2 = NpcOrientation.LastKnownPrimaryTargetLocation; } else { npcOrientation2 = (!npcContext.IsFact(Facts.CanHearEnemy) ? NpcOrientation.Heading : NpcOrientation.AudibleTargetDirection); } if (npcContext.IsFact(Facts.IsRoaming) && !npcContext.IsFact(Facts.HasEnemyTarget)) { npcOrientation2 = NpcOrientation.Heading; } else if (npcContext.IsFact(Facts.IsReturningHome) && !npcContext.IsFact(Facts.HasEnemyTarget)) { npcOrientation2 = NpcOrientation.Home; } npcContext.OrientationType = npcOrientation2; }