public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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.ScientistJunkpile.Facts.AtLocationPreferredFightingRange, 1, true, true, true); } else { npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.AtLocationPreferredFightingRange, 0, true, true, true); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { NavMeshHit navMeshHit; ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } if (!npcContext.IsFact(Facts.IsReturningHome)) { if ((npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player == null || time - npcContext.Memory.PrimaryKnownEnemyPlayer.Time > npcContext.Body.AiDefinition.Memory.NoSeeReturnToSpawnTime) && npcContext.Domain.SqrDistanceToSpawn() > npcContext.Domain.SqrMovementRadius) { 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); return; } } } else if (npcContext.IsFact(Facts.CanSeeEnemy) || time - npcContext.Body.lastAttackedTime < 2f || npcContext.IsFact(Facts.AtLocationHome)) { npcContext.SetFact(Facts.IsReturningHome, false, true, true, true); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } for (int index = 0; index < npcContext.Memory.KnownTimedExplosives.Count; ++index) { BaseNpcMemory.EntityOfInterestInfo knownTimedExplosive = npcContext.Memory.KnownTimedExplosives[index]; if (Object.op_Inequality((Object)knownTimedExplosive.Entity, (Object)null)) { AttackEntity firearm = npcContext.Domain.GetFirearm(); Vector3 vector3 = Vector3.op_Subtraction(((Component)knownTimedExplosive.Entity).get_transform().get_position(), npcContext.BodyPosition); if ((double)((Vector3) ref vector3).get_sqrMagnitude() < (double)npcContext.Body.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm)) { npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.NearbyExplosives, true, true, true, true); npcContext.IncrementFact(Rust.Ai.HTN.ScientistJunkpile.Facts.Alertness, 2, true, true, true); return; } } } npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.NearbyExplosives, false, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } if (npcContext.IsFact(Facts.MaintainCover) || npcContext.IsFact(Facts.IsReloading) || npcContext.IsFact(Facts.IsApplyingMedical)) { if (npcContext.ReservedCoverPoint != null && !npcContext.ReservedCoverPoint.IsCompromised && !npcContext.IsFact(Facts.AtLocationCover) && time - npcContext.ReservedCoverTime < 0.8f) { return; } if (!npcContext.IsFact(Facts.CanSeeEnemy) && npcContext.Body.SecondsSinceAttacked - 1f > time - npcContext.ReservedCoverTime) { return; } if (ScientistJunkpileDomain.JunkpileCanNavigateToCoverLocation.Try(CoverTactic.Retreat, npcContext)) { Vector3 coverPosition = ScientistJunkpileDomain.JunkpileNavigateToCover.GetCoverPosition(CoverTactic.Retreat, npcContext); npcContext.Domain.SetDestination(coverPosition); npcContext.Body.modelState.ducked = false; npcContext.SetFact(Facts.IsDucking, 0, false, true, true); npcContext.SetFact(Facts.FirearmOrder, FirearmOrders.FireAtWill, false, true, true); } } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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) || !AnimalReasoner.IsNearby(npcContext.Domain, sqrDistance)) { npcContext.SetFact(Facts.NearbyAnimal, false, true, true, true); return; } npcContext.Memory.RememberPrimaryAnimal(animal); npcContext.SetFact(Facts.NearbyAnimal, true, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } BaseNpc animal = (BaseNpc)null; float sqrDistance = 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)sqrDistance) { sqrDistance = animalInfo.SqrDistance; animal = animalInfo.Animal; } } if (Object.op_Inequality((Object)animal, (Object)null) && AnimalReasoner.IsNearby(npcContext.Domain, sqrDistance)) { npcContext.Memory.RememberPrimaryAnimal(animal); npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.NearbyAnimal, true, true, true, true); } else { npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.NearbyAnimal, false, true, true, true); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } if (npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player != null && (ScientistJunkpileDomain.JunkpileNavigateToLastKnownLocationOfPrimaryEnemyPlayer.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); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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) { if (npcContext.Memory.MarkedEnemies.Contains(npcPlayerInfo2.Player)) { 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) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } if (Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null)) { Vector3 vector3 = Vector3.op_Subtraction(ScientistJunkpileDomain.JunkpileNavigateToLastKnownLocationOfPrimaryEnemyPlayer.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); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } if (Object.op_Equality((Object)npcContext.Memory.PrimaryKnownEnemyPlayer.PlayerInfo.Player, (Object)null)) { npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.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.ScientistJunkpile.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.ScientistJunkpile.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.ScientistJunkpile.Facts.EnemyRange, EnemyRange.LongRange, true, true, true); } else { npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.EnemyRange, EnemyRange.OutOfRange, true, true, true); } } } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } npcContext.SetFact(Facts.HasNearbyCover, (npcContext.CoverPoints.Count > 0 ? 1 : 0), true, true, true); if (!npcContext.IsFact(Facts.HasEnemyTarget)) { npcContext.ReserveCoverPoint(null); return; } HTNPlayer hTNPlayer = npc as HTNPlayer; if (hTNPlayer == null) { return; } float single = 0f; float single1 = 0f; float single2 = 0f; foreach (CoverPoint coverPoint in npcContext.CoverPoints) { if (coverPoint.IsCompromised || coverPoint.IsReserved && !coverPoint.ReservedFor.EqualNetID(hTNPlayer)) { continue; } float single3 = -0.8f; BaseNpcMemory.EnemyPlayerInfo primaryKnownEnemyPlayer = npcContext.Memory.PrimaryKnownEnemyPlayer; if (!coverPoint.ProvidesCoverFromPoint(primaryKnownEnemyPlayer.LastKnownPosition, single3)) { continue; } Vector3 position = coverPoint.Position - npc.transform.position; Vector3 lastKnownPosition = primaryKnownEnemyPlayer.LastKnownPosition - npc.transform.position; float single4 = Vector3.Dot(position.normalized, lastKnownPosition.normalized); if (single < 1f) { CoverPointsReasoner.EvaluateAdvancement(npc, npcContext, ref single, ref primaryKnownEnemyPlayer, coverPoint, position, lastKnownPosition, single4); } if (single2 < 1f) { CoverPointsReasoner.EvaluateRetreat(npc, npcContext, ref single2, ref primaryKnownEnemyPlayer, coverPoint, position, lastKnownPosition, ref single4); } if (single1 >= 1f) { continue; } CoverPointsReasoner.EvaluateFlanking(npc, npcContext, ref single1, ref primaryKnownEnemyPlayer, coverPoint, position, lastKnownPosition, single4); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } if (npcContext.ReservedCoverPoint == null) { npcContext.SetFact(Facts.AtLocationCover, false, true, true, true); npcContext.SetFact(Facts.CoverState, CoverState.None, true, true, true); } else { Vector3 vector3 = Vector3.op_Subtraction(npcContext.ReservedCoverPoint.Position, ((Component)npcContext.Body).get_transform().get_position()); if ((double)((Vector3) ref vector3).get_sqrMagnitude() < 1.0) { npcContext.SetFact(Facts.AtLocationCover, true, true, true, true); npcContext.SetFact(Facts.CoverState, npcContext.ReservedCoverPoint.NormalCoverType == CoverPoint.CoverType.Partial ? CoverState.Partial : CoverState.Full, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) return; if (!npcContext.IsFact(Facts.IsReturningHome)) { 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 || (double) npcContext.Domain.SqrDistanceToSpawn() <= (double) npcContext.Domain.SqrMovementRadius) 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()); } else { if (!npcContext.IsFact(Facts.CanSeeEnemy) && (double) time - (double) npcContext.Body.lastAttackedTime >= 2.0 && !npcContext.IsFact(Facts.AtLocationHome)) return; npcContext.SetFact(Facts.IsReturningHome, false, true, true, true); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.HasNearbyCover, npcContext.CoverPoints.Count > 0 ? 1 : 0, true, true, true); if (!npcContext.IsFact(Rust.Ai.HTN.ScientistJunkpile.Facts.HasEnemyTarget)) { npcContext.ReserveCoverPoint((CoverPoint)null); } else { HTNPlayer htnPlayer = npc as HTNPlayer; if (Object.op_Equality((Object)htnPlayer, (Object)null)) { return; } float bestScore1 = 0.0f; float bestScore2 = 0.0f; float bestScore3 = 0.0f; foreach (CoverPoint coverPoint in npcContext.CoverPoints) { if (!coverPoint.IsCompromised && (!coverPoint.IsReserved || coverPoint.ReservedFor.EqualNetID((BaseNetworkable)htnPlayer))) { float arcThreshold = -0.8f; BaseNpcMemory.EnemyPlayerInfo knownEnemyPlayer = npcContext.Memory.PrimaryKnownEnemyPlayer; if (coverPoint.ProvidesCoverFromPoint(knownEnemyPlayer.LastKnownPosition, arcThreshold)) { Vector3 dirCover = Vector3.op_Subtraction(coverPoint.Position, npc.transform.get_position()); Vector3 dirDanger = Vector3.op_Subtraction(knownEnemyPlayer.LastKnownPosition, npc.transform.get_position()); float directness = Vector3.Dot(((Vector3) ref dirCover).get_normalized(), ((Vector3) ref dirDanger).get_normalized()); if ((double)bestScore1 < 1.0) { CoverPointsReasoner.EvaluateAdvancement(npc, npcContext, ref bestScore1, ref knownEnemyPlayer, coverPoint, dirCover, dirDanger, directness); } if ((double)bestScore3 < 1.0) { CoverPointsReasoner.EvaluateRetreat(npc, npcContext, ref bestScore3, ref knownEnemyPlayer, coverPoint, dirCover, dirDanger, ref directness); } if ((double)bestScore2 < 1.0) { CoverPointsReasoner.EvaluateFlanking(npc, npcContext, ref bestScore2, ref knownEnemyPlayer, coverPoint, dirCover, dirDanger, directness); } } } } } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } for (int i = 0; i < npcContext.Memory.KnownTimedExplosives.Count; i++) { BaseNpcMemory.EntityOfInterestInfo item = npcContext.Memory.KnownTimedExplosives[i]; if (item.Entity != null) { AttackEntity firearm = npcContext.Domain.GetFirearm(); if ((item.Entity.transform.position - npcContext.BodyPosition).sqrMagnitude < npcContext.Body.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm)) { npcContext.SetFact(Facts.NearbyExplosives, true, true, true, true); npcContext.IncrementFact(Facts.Alertness, 2, true, true, true); return; } } } npcContext.SetFact(Facts.NearbyExplosives, false, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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 (Mathf.Approximately(sqrDistance, 0f)) { sqrDistance = Single.MaxValue; } } else if (npcContext.Memory.PrimaryKnownAnimal.Animal != null) { sqrDistance = npcContext.Memory.PrimaryKnownAnimal.SqrDistance; if (Mathf.Approximately(sqrDistance, 0f)) { sqrDistance = Single.MaxValue; } } 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); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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; if (Mathf.Approximately(num, 0.0f)) { num = float.MaxValue; } } else if (Object.op_Inequality((Object)npcContext.Memory.PrimaryKnownAnimal.Animal, (Object)null)) { num = npcContext.Memory.PrimaryKnownAnimal.SqrDistance; if (Mathf.Approximately(num, 0.0f)) { num = float.MaxValue; } } 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.ScientistJunkpile.Facts.FireTactic, fireTactic, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } HTNPlayer hTNPlayer = npc as HTNPlayer; if (hTNPlayer == null) { return; } AttackEntity heldEntity = hTNPlayer.GetHeldEntity() as AttackEntity; if (heldEntity) { BaseProjectile baseProjectile = heldEntity as BaseProjectile; if (baseProjectile != null) { float single = (float)baseProjectile.primaryMagazine.contents / (float)baseProjectile.primaryMagazine.capacity; if (single > 0.9f) { npcContext.SetFact(Facts.AmmoState, AmmoState.FullClip, true, true, true); return; } if (single > 0.6f) { npcContext.SetFact(Facts.AmmoState, AmmoState.HighClip, true, true, true); return; } if (single > 0.17f) { npcContext.SetFact(Facts.AmmoState, AmmoState.MediumClip, true, true, true); return; } if (single > 0f) { npcContext.SetFact(Facts.AmmoState, AmmoState.LowAmmo, true, true, true); return; } npcContext.SetFact(Facts.AmmoState, AmmoState.EmptyClip, true, true, true); return; } } npcContext.SetFact(Facts.AmmoState, AmmoState.DontRequireAmmo, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; if (npcContext == null) { return; } HTNPlayer htnPlayer = npc as HTNPlayer; if (Object.op_Equality((Object)htnPlayer, (Object)null)) { return; } AttackEntity heldEntity = htnPlayer.GetHeldEntity() as AttackEntity; if (Object.op_Implicit((Object)heldEntity)) { BaseProjectile baseProjectile = heldEntity as BaseProjectile; if (Object.op_Inequality((Object)baseProjectile, (Object)null)) { float num = (float)baseProjectile.primaryMagazine.contents / (float)baseProjectile.primaryMagazine.capacity; if ((double)num > 0.899999976158142) { npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.AmmoState, AmmoState.FullClip, true, true, true); return; } if ((double)num > 0.600000023841858) { npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.AmmoState, AmmoState.HighClip, true, true, true); return; } if ((double)num > 0.170000001788139) { npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.AmmoState, AmmoState.MediumClip, true, true, true); return; } if ((double)num > 0.0) { npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.AmmoState, AmmoState.LowAmmo, true, true, true); return; } npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.AmmoState, AmmoState.EmptyClip, true, true, true); return; } } npcContext.SetFact(Rust.Ai.HTN.ScientistJunkpile.Facts.AmmoState, AmmoState.DontRequireAmmo, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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) { if (!npcContext.Memory.MarkedEnemies.Contains(enemyPlayersInLineOfSight.Player)) { continue; } 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) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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 (npcContext.Memory.MarkedEnemies.Contains(npcPlayerInfo2.Player) && (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); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistJunkpileContext npcContext = npc.AiDomain.NpcContext as ScientistJunkpileContext; 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 (!npcContext.Memory.MarkedEnemies.Contains(enemyPlayersAudible.Player) || 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); } }