public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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) { return; } npcContext.SetFact(Facts.IsReturningHome, true, true, true, true); } 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) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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); }
private static bool EvaluateAdvancement( IHTNAgent npc, ScientistAStarContext c, ref float bestScore, ref BaseNpcMemory.EnemyPlayerInfo enemyInfo, CoverPoint option, Vector3 dirCover, Vector3 dirDanger, float directness) { if ((double)directness >= 0.200000002980232) { float sqrMagnitude1 = ((Vector3) ref dirCover).get_sqrMagnitude(); if ((double)sqrMagnitude1 > (double)((Vector3) ref dirDanger).get_sqrMagnitude() || (double)sqrMagnitude1 < 0.5) { return(false); } Vector3 vector3_1 = Vector3.op_Subtraction(option.Position, enemyInfo.LastKnownPosition); float sqrMagnitude2 = ((Vector3) ref vector3_1).get_sqrMagnitude(); float allowedCoverRangeSqr = c.Domain.GetAllowedCoverRangeSqr(); float num = (float)((double)directness + ((double)allowedCoverRangeSqr - (double)sqrMagnitude1) / (double)allowedCoverRangeSqr + (double)option.Score + ((double)sqrMagnitude2 < (double)sqrMagnitude1 ? 1.0 : 0.0)); if ((double)num > (double)bestScore && (!AI.npc_cover_use_path_distance || npc == null || c.Domain.PathDistanceIsValid(enemyInfo.LastKnownPosition, option.Position, false))) { Vector3 vector3_2 = Vector3.op_Subtraction(option.Position, enemyInfo.LastKnownPosition); if ((double)((Vector3) ref vector3_2).get_sqrMagnitude() < (double)sqrMagnitude1) { num *= 0.9f; } bestScore = num; c.BestAdvanceCover = option; return(true); } } return(false); }
private static bool EvaluateAdvancement(IHTNAgent npc, ScientistAStarContext c, ref float bestScore, ref BaseNpcMemory.EnemyPlayerInfo enemyInfo, CoverPoint option, Vector3 dirCover, Vector3 dirDanger, float directness) { if (directness >= 0.2f) { float single = dirCover.sqrMagnitude; if (single > dirDanger.sqrMagnitude || single < 0.5f) { return(false); } float position = (option.Position - enemyInfo.LastKnownPosition).sqrMagnitude; float allowedCoverRangeSqr = c.Domain.GetAllowedCoverRangeSqr(); float single1 = directness + (allowedCoverRangeSqr - single) / allowedCoverRangeSqr + option.Score + (position < single ? 1f : 0f); if (single1 > bestScore) { if (ConVar.AI.npc_cover_use_path_distance && npc != null && !c.Domain.PathDistanceIsValid(enemyInfo.LastKnownPosition, option.Position, false)) { return(false); } if ((option.Position - enemyInfo.LastKnownPosition).sqrMagnitude < single) { single1 *= 0.9f; } bestScore = single1; c.BestAdvanceCover = option; return(true); } } return(false); }
public static bool IsAtPreferredRange(ScientistAStarContext context, ref NpcPlayerInfo target, AttackEntity firearm) { if (firearm == null) { return(false); } switch (firearm.effectiveRangeType) { case NPCPlayerApex.WeaponTypeEnum.CloseRange: { return(target.SqrDistance <= context.Body.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm)); } case NPCPlayerApex.WeaponTypeEnum.MediumRange: { if (target.SqrDistance > context.Body.AiDefinition.Engagement.SqrMediumRangeFirearm(firearm)) { return(false); } return(target.SqrDistance > context.Body.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm)); } case NPCPlayerApex.WeaponTypeEnum.LongRange: { if (target.SqrDistance >= context.Body.AiDefinition.Engagement.SqrLongRangeFirearm(firearm)) { return(false); } return(target.SqrDistance > context.Body.AiDefinition.Engagement.SqrMediumRangeFirearm(firearm)); } } return(false); }
private static bool EvaluateRetreat( IHTNAgent npc, ScientistAStarContext c, ref float bestScore, ref BaseNpcMemory.EnemyPlayerInfo enemyInfo, CoverPoint option, Vector3 dirCover, Vector3 dirDanger, ref float directness) { float sqrMagnitude = ((Vector3) ref dirCover).get_sqrMagnitude(); if ((double)directness <= -0.200000002980232) { float allowedCoverRangeSqr = c.Domain.GetAllowedCoverRangeSqr(); float num = (float)((double)directness * -1.0 + ((double)allowedCoverRangeSqr - (double)sqrMagnitude) / (double)allowedCoverRangeSqr) + option.Score; if ((double)num > (double)bestScore) { bestScore = num; c.BestRetreatCover = option; return(true); } } return(false); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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 static bool IsAtPreferredRange( ScientistAStarContext context, ref NpcPlayerInfo target, AttackEntity firearm) { if (Object.op_Equality((Object)firearm, (Object)null)) { return(false); } switch (firearm.effectiveRangeType) { case NPCPlayerApex.WeaponTypeEnum.CloseRange: return((double)target.SqrDistance <= (double)context.Body.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm)); case NPCPlayerApex.WeaponTypeEnum.MediumRange: if ((double)target.SqrDistance <= (double)context.Body.AiDefinition.Engagement.SqrMediumRangeFirearm(firearm)) { return((double)target.SqrDistance > (double)context.Body.AiDefinition.Engagement.SqrCloseRangeFirearm(firearm)); } return(false); case NPCPlayerApex.WeaponTypeEnum.LongRange: if ((double)target.SqrDistance < (double)context.Body.AiDefinition.Engagement.SqrLongRangeFirearm(firearm)) { return((double)target.SqrDistance > (double)context.Body.AiDefinition.Engagement.SqrMediumRangeFirearm(firearm)); } return(false); default: return(false); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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.ScientistAStar.Facts.AtLocationPreferredFightingRange, 1, true, true, true); } else { npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.AtLocationPreferredFightingRange, 0, true, true, true); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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.ScientistAStar.Facts.NearbyExplosives, true, true, true, true); npcContext.IncrementFact(Rust.Ai.HTN.ScientistAStar.Facts.Alertness, 2, true, true, true); return; } } } npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.NearbyExplosives, false, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; if (npcContext == null) { return; } if (npcContext.ReservedCoverPoint == null) { npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.AtLocationCover, false, true, true, true); npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.CoverState, Rust.Ai.HTN.ScientistAStar.CoverState.None, true, true, true); } else { Vector3 position = npcContext.ReservedCoverPoint.Position; BasePathNode closestToPoint = npcContext.Domain.Path.GetClosestToPoint(position); if (Object.op_Inequality((Object)closestToPoint, (Object)null) && Object.op_Inequality((Object)((Component)closestToPoint).get_transform(), (Object)null)) { Vector3 vector3 = Vector3.op_Subtraction(((Component)closestToPoint).get_transform().get_position(), npcContext.BodyPosition); if ((double)((Vector3) ref vector3).get_sqrMagnitude() < 1.0) { npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.AtLocationCover, true, true, true, true); npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.CoverState, npcContext.ReservedCoverPoint.NormalCoverType == CoverPoint.CoverType.Partial ? Rust.Ai.HTN.ScientistAStar.CoverState.Partial : Rust.Ai.HTN.ScientistAStar.CoverState.Full, true, true, true); return; } } npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.AtLocationCover, false, true, true, true); npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.CoverState, Rust.Ai.HTN.ScientistAStar.CoverState.None, true, true, true); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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; } } 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.ScientistAStar.Facts.FireTactic, fireTactic, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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.ScientistAStar.Facts.NearbyAnimal, true, true, true, true); return; } } npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.NearbyAnimal, false, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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); return; } Vector3 position = npcContext.ReservedCoverPoint.Position; BasePathNode closestToPoint = npcContext.Domain.Path.GetClosestToPoint(position); if (!(closestToPoint != null) || !(closestToPoint.transform != null) || (closestToPoint.transform.position - npcContext.BodyPosition).sqrMagnitude >= 1f) { npcContext.SetFact(Facts.AtLocationCover, false, true, true, true); npcContext.SetFact(Facts.CoverState, CoverState.None, true, true, true); return; } 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) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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.BodyPosition; Vector3 lastKnownPosition = primaryKnownEnemyPlayer.LastKnownPosition - npc.BodyPosition; 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) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; if (npcContext == null || !npcContext.IsFact(Facts.CanSeeEnemy) || !npcContext.IsFact(Facts.MaintainCover) && !npcContext.IsFact(Facts.IsReloading) && !npcContext.IsFact(Facts.IsApplyingMedical) || (npcContext.ReservedCoverPoint != null && !npcContext.ReservedCoverPoint.IsCompromised && (!npcContext.IsFact(Facts.AtLocationCover) && (double)time - (double)npcContext.ReservedCoverTime < 1.0) || !ScientistAStarDomain.AStarCanNavigateToCoverLocation.Try(CoverTactic.Retreat, npcContext))) { return; } Vector3 coverPosition = ScientistAStarDomain.AStarNavigateToCover.GetCoverPosition(CoverTactic.Retreat, npcContext); npcContext.Domain.SetDestination(coverPosition); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; if (npcContext == null) { return; } npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.HasNearbyCover, npcContext.CoverPoints.Count > 0 ? 1 : 0, true, true, true); if (!npcContext.IsFact(Rust.Ai.HTN.ScientistAStar.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.BodyPosition); Vector3 dirDanger = Vector3.op_Subtraction(knownEnemyPlayer.LastKnownPosition, npc.BodyPosition); 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) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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(Rust.Ai.HTN.ScientistAStar.Facts.AtLocationHome, true, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; if (npcContext == null) { return; } if (npcContext.IsFact(Facts.Frustration) && time - this._lastFrustrationDecrementTime > 5f) { this._lastFrustrationDecrementTime = time; npcContext.IncrementFact(Facts.Frustration, -1, true, true, true); } }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; if (npcContext == null) { return; } if (npcContext.Domain.IsAtFinalDestination()) { npcContext.SetFact(Facts.AtLocationNextAStarWaypoint, 1, true, true, true); } npcContext.SetFact(Facts.AtLocationNextAStarWaypoint, 0, true, true, true); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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.ScientistAStar.Facts.AmmoState, AmmoState.FullClip, true, true, true); return; } if ((double)num > 0.600000023841858) { npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.AmmoState, AmmoState.HighClip, true, true, true); return; } if ((double)num > 0.170000001788139) { npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.AmmoState, AmmoState.MediumClip, true, true, true); return; } if ((double)num > 0.0) { npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.AmmoState, AmmoState.LowAmmo, true, true, true); return; } npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.AmmoState, AmmoState.EmptyClip, true, true, true); return; } } npcContext.SetFact(Rust.Ai.HTN.ScientistAStar.Facts.AmmoState, AmmoState.DontRequireAmmo, true, true, true); }
private static bool EvaluateRetreat(IHTNAgent npc, ScientistAStarContext c, ref float bestScore, ref BaseNpcMemory.EnemyPlayerInfo enemyInfo, CoverPoint option, Vector3 dirCover, Vector3 dirDanger, ref float directness) { float single = dirCover.sqrMagnitude; if (directness <= -0.2f) { float allowedCoverRangeSqr = c.Domain.GetAllowedCoverRangeSqr(); float single1 = directness * -1f + (allowedCoverRangeSqr - single) / allowedCoverRangeSqr + option.Score; if (single1 > bestScore) { bestScore = single1; c.BestRetreatCover = option; return(true); } } return(false); }
public void Tick(IHTNAgent npc, float deltaTime, float time) { ScientistAStarContext npcContext = npc.AiDomain.NpcContext as ScientistAStarContext; 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.ScientistAStar.Facts.Vulnerability) || (double)time - (double)this._lastVulnerabilityDecrementTime <= 2.0)) { return; } this._lastVulnerabilityDecrementTime = time; npcContext.IncrementFact(Rust.Ai.HTN.ScientistAStar.Facts.Vulnerability, -1, true, true, true); }