public static void AttackEnemy(NPCHumanContext c, AttackOperator.AttackType type) { if (c.GetFact(NPCPlayerApex.Facts.IsWeaponAttackReady) == (byte)0) { return; } BaseCombatEntity target = (BaseCombatEntity)null; if (Object.op_Inequality((Object)c.EnemyNpc, (Object)null)) { target = (BaseCombatEntity)c.EnemyNpc; } if (Object.op_Inequality((Object)c.EnemyPlayer, (Object)null)) { target = (BaseCombatEntity)c.EnemyPlayer; } if (Object.op_Equality((Object)target, (Object)null)) { return; } c.AIAgent.StartAttack(type, target); c.SetFact(NPCPlayerApex.Facts.IsWeaponAttackReady, (byte)0, true, true); if ((double)Random.get_value() >= 0.100000001490116 || c.Human.OnAggro == null) { return; } c.Human.OnAggro(); }
private static Item FindBestMelee(NPCHumanContext c) { if (c.Human.GetPathStatus() != 0) { return(null); } Item item = null; BaseMelee baseMelee = null; Item[] itemArray = c.Human.inventory.AllItems(); for (int i = 0; i < (int)itemArray.Length; i++) { Item item1 = itemArray[i]; if (item1.info.category == ItemCategory.Weapon && !item1.isBroken) { BaseMelee heldEntity = item1.GetHeldEntity() as BaseMelee; if (heldEntity) { if (item == null) { item = item1; baseMelee = heldEntity; } else if (heldEntity.hostileScore > baseMelee.hostileScore) { item = item1; baseMelee = heldEntity; } } } } return(item); }
public static void NavigateToLastEnemy(NPCHumanContext c) { NavMeshHit navMeshHit; if (c.AIAgent.AttackTarget != null && c.AIAgent.IsNavRunning()) { Memory.SeenInfo info = c.Memory.GetInfo(c.AIAgent.AttackTarget); if (info.Entity != null && info.Position.sqrMagnitude > 0f) { BasePlayer player = c.AIAgent.AttackTarget.ToPlayer(); if (player != null && (player.IsAdmin || player.IsDeveloper) && player.IsFlying) { SetHumanSpeed.Set(c, NPCPlayerApex.SpeedEnum.StandStill); return; } if (!NavMesh.SamplePosition(info.Position, out navMeshHit, 1f, c.AIAgent.GetNavAgent.areaMask)) { SetHumanSpeed.Set(c, NPCPlayerApex.SpeedEnum.StandStill); return; } HumanNavigateToOperator.MakeUnstuck(c); c.Human.StoppingDistance = 1f; c.Human.Destination = navMeshHit.position; c.Human.SetTargetPathStatus(0.05f); } } HumanNavigateToOperator.UpdateRoamTime(c); }
public static void NavigateToMountableLoc(NPCHumanContext c, HumanNavigateToOperator.OperatorType mountableType) { NavMeshHit navMeshHit; if (mountableType == HumanNavigateToOperator.OperatorType.MountableChair && ConVar.AI.npc_ignore_chairs) { return; } BaseMountable chairTarget = c.ChairTarget; if (chairTarget == null) { return; } Vector3 vector3 = chairTarget.transform.position; if (NavMesh.SamplePosition(vector3, out navMeshHit, 10f, c.Human.NavAgent.areaMask)) { vector3 = navMeshHit.position; } if (Mathf.Approximately(vector3.sqrMagnitude, 0f)) { return; } HumanNavigateToOperator.MakeUnstuck(c); c.Human.StoppingDistance = 0.05f; c.Human.Destination = vector3; c.Human.SetTargetPathStatus(0.05f); }
public static void Reload(NPCHumanContext c) { if (c == null) { return; } AttackEntity heldEntity = c.Human.GetHeldEntity() as AttackEntity; if (Object.op_Equality((Object)heldEntity, (Object)null)) { return; } BaseProjectile baseProjectile = heldEntity as BaseProjectile; if (!Object.op_Implicit((Object)baseProjectile) || !baseProjectile.primaryMagazine.CanAiReload((BasePlayer)c.Human)) { return; } baseProjectile.ServerReload(); if (c.Human.OnReload == null) { return; } c.Human.OnReload(); }
public static void FleeHurtDir(NPCHumanContext c) { if (c.AIAgent.IsNavRunning() && HumanNavigateToOperator.NavigateInDirOfBestSample(c, NavPointSampler.SampleCount.Eight, 4f, NavPointSampler.SampleFeatures.RetreatFromDirection, c.AIAgent.GetStats.MinFleeRange, c.AIAgent.GetStats.MaxFleeRange)) { c.SetFact(NPCPlayerApex.Facts.IsFleeing, 1, true, true); } }
public static void NavigateToMountableLoc( NPCHumanContext c, HumanNavigateToOperator.OperatorType mountableType) { if (mountableType == HumanNavigateToOperator.OperatorType.MountableChair && ConVar.AI.npc_ignore_chairs) { return; } BaseMountable chairTarget = (BaseMountable)c.ChairTarget; if (Object.op_Equality((Object)chairTarget, (Object)null)) { return; } Vector3 position = ((Component)chairTarget).get_transform().get_position(); NavMeshHit navMeshHit; if (NavMesh.SamplePosition(position, ref navMeshHit, 10f, c.Human.NavAgent.get_areaMask())) { position = ((NavMeshHit) ref navMeshHit).get_position(); } if (Mathf.Approximately(((Vector3) ref position).get_sqrMagnitude(), 0.0f)) { return; } HumanNavigateToOperator.MakeUnstuck(c); c.Human.StoppingDistance = 0.05f; c.Human.Destination = position; c.Human.SetTargetPathStatus(0.05f); }
private static void UpdateRoamTime(NPCHumanContext c) { float num1 = c.AIAgent.GetStats.MaxRoamDelay - c.AIAgent.GetStats.MinRoamDelay; float num2 = c.AIAgent.GetStats.RoamDelayDistribution.Evaluate(Random.get_value()) * num1; c.NextRoamTime = Time.get_realtimeSinceStartup() + c.AIAgent.GetStats.MinRoamDelay + num2; }
public static void NavigateToPatrolLoc(NPCHumanContext c) { if (Object.op_Equality((Object)c.AiLocationManager, (Object)null) || !IsHumanRoamReady.Evaluate(c) || !c.AIAgent.IsNavRunning()) { return; } PathInterestNode patrolPointInRange = c.AiLocationManager.GetRandomPatrolPointInRange(c.Position, c.AIAgent.GetStats.MinRoamRange, c.AIAgent.GetStats.MaxRoamRange, c.CurrentPatrolPoint); if (Object.op_Inequality((Object)patrolPointInRange, (Object)null)) { Vector3 position = ((Component)patrolPointInRange).get_transform().get_position(); if ((double)((Vector3) ref position).get_sqrMagnitude() > 0.0) { HumanNavigateToOperator.MakeUnstuck(c); c.Human.Destination = ((Component)patrolPointInRange).get_transform().get_position(); c.Human.SetTargetPathStatus(0.05f); c.CurrentPatrolPoint = patrolPointInRange; } } HumanNavigateToOperator.UpdateRoamTime(c); if (c.Human.OnChatter == null) { return; } c.Human.OnChatter(); }
public static void NavigateToLastEnemy(NPCHumanContext c) { if (Object.op_Inequality((Object)c.AIAgent.AttackTarget, (Object)null) && c.AIAgent.IsNavRunning()) { Memory.SeenInfo info = c.Memory.GetInfo(c.AIAgent.AttackTarget); if (Object.op_Inequality((Object)info.Entity, (Object)null) && (double)((Vector3) ref info.Position).get_sqrMagnitude() > 0.0) { BasePlayer player = c.AIAgent.AttackTarget.ToPlayer(); if (Object.op_Inequality((Object)player, (Object)null) && (player.IsAdmin || player.IsDeveloper) && player.IsFlying) { SetHumanSpeed.Set((BaseContext)c, NPCPlayerApex.SpeedEnum.StandStill); return; } NavMeshHit navMeshHit; if (!NavMesh.SamplePosition(info.Position, ref navMeshHit, 1f, c.AIAgent.GetNavAgent.get_areaMask())) { SetHumanSpeed.Set((BaseContext)c, NPCPlayerApex.SpeedEnum.StandStill); return; } HumanNavigateToOperator.MakeUnstuck(c); c.Human.StoppingDistance = 1f; c.Human.Destination = ((NavMeshHit) ref navMeshHit).get_position(); c.Human.SetTargetPathStatus(0.05f); } } HumanNavigateToOperator.UpdateRoamTime(c); }
public static void NavigateToEnemy(NPCHumanContext c) { if (c.GetFact(NPCPlayerApex.Facts.HasEnemy) <= (byte)0 || !c.AIAgent.IsNavRunning()) { return; } if (c.GetFact(NPCPlayerApex.Facts.HasLineOfSight) > (byte)0) { Vector3 enemyPosition = c.EnemyPosition; if ((double)((Vector3) ref enemyPosition).get_sqrMagnitude() > 0.0) { HumanNavigateToOperator.MakeUnstuck(c); c.Human.StoppingDistance = 1.5f; c.Human.Destination = c.EnemyPosition; goto label_6; } } Memory.SeenInfo info = c.Memory.GetInfo(c.AIAgent.AttackTarget); if (Object.op_Inequality((Object)info.Entity, (Object)null) && (double)((Vector3) ref info.Position).get_sqrMagnitude() > 0.0) { HumanNavigateToOperator.MakeUnstuck(c); c.Human.StoppingDistance = 1.5f; c.Human.Destination = info.Position; } label_6: c.Human.SetTargetPathStatus(0.05f); }
public static bool TrySwitchToolTo( NPCHumanContext c, NPCPlayerApex.ToolTypeEnum toolDay, NPCPlayerApex.ToolTypeEnum toolNight) { if (c != null) { Item obj = (Item)null; uint svActiveItemId = c.Human.svActiveItemID; if (Object.op_Inequality((Object)TOD_Sky.get_Instance(), (Object)null)) { obj = !TOD_Sky.get_Instance().get_IsDay() ? SwitchToolOperator.FindTool(c, toolNight) : SwitchToolOperator.FindTool(c, toolDay); } if (obj != null) { c.Human.UpdateActiveItem(obj.uid); if ((int)svActiveItemId != (int)c.Human.svActiveItemID) { c.Human.NextToolSwitchTime = Time.get_realtimeSinceStartup() + c.Human.ToolSwitchFrequency; c.SetFact(NPCPlayerApex.Facts.CurrentWeaponType, (byte)0, true, true); c.SetFact(NPCPlayerApex.Facts.CurrentToolType, (byte)c.Human.GetCurrentToolTypeEnum(), true, true); } return(true); } } return(false); }
private static void UpdateRoamTime(NPCHumanContext c) { float maxRoamDelay = c.AIAgent.GetStats.MaxRoamDelay - c.AIAgent.GetStats.MinRoamDelay; float single = c.AIAgent.GetStats.RoamDelayDistribution.Evaluate(UnityEngine.Random.@value) * maxRoamDelay; c.NextRoamTime = UnityEngine.Time.realtimeSinceStartup + c.AIAgent.GetStats.MinRoamDelay + single; }
private static float IsInRange(NPCHumanContext c, BaseMountable mountable) { Vector3 vector3 = Vector3.op_Subtraction(((Component)mountable).get_transform().get_position(), c.Position); if (vector3.y > (double)mountable.maxMountDistance) { ref __Null local = ref vector3.y;
public static void AttackEnemy(NPCHumanContext c, AttackOperator.AttackType type) { if (c.GetFact(NPCPlayerApex.Facts.IsWeaponAttackReady) == 0) { return; } BaseCombatEntity enemyNpc = null; if (c.EnemyNpc != null) { enemyNpc = c.EnemyNpc; } if (c.EnemyPlayer != null) { enemyNpc = c.EnemyPlayer; } if (enemyNpc == null) { return; } c.AIAgent.StartAttack(type, enemyNpc); c.SetFact(NPCPlayerApex.Facts.IsWeaponAttackReady, 0, true, true); if (UnityEngine.Random.@value < 0.1f && c.Human.OnAggro != null) { c.Human.OnAggro(); } }
internal static CoverPoint GetClosestCover( NPCHumanContext c, Vector3 point, float MaxDistance, ProximityToCover.CoverType _coverType, out float bestDistance) { bestDistance = MaxDistance; CoverPoint coverPoint = (CoverPoint)null; for (int index = 0; index < c.sampledCoverPoints.Count; ++index) { CoverPoint sampledCoverPoint = c.sampledCoverPoints[index]; CoverPoint.CoverType sampledCoverPointType = c.sampledCoverPointTypes[index]; if ((_coverType != ProximityToCover.CoverType.Full || sampledCoverPointType == CoverPoint.CoverType.Full) && (_coverType != ProximityToCover.CoverType.Partial || sampledCoverPointType == CoverPoint.CoverType.Partial)) { float num = Vector3.Distance(sampledCoverPoint.Position, point); if ((double)num < (double)bestDistance) { bestDistance = num; coverPoint = sampledCoverPoint; } } } return(coverPoint); }
private static Item FindBestMelee(NPCHumanContext c) { if (c.Human.GetPathStatus() != (byte)0) { return((Item)null); } Item obj = (Item)null; BaseMelee baseMelee = (BaseMelee)null; foreach (Item allItem in c.Human.inventory.AllItems()) { if (allItem.info.category == ItemCategory.Weapon && !allItem.isBroken) { BaseMelee heldEntity = allItem.GetHeldEntity() as BaseMelee; if (Object.op_Implicit((Object)heldEntity)) { if (obj == null) { obj = allItem; baseMelee = heldEntity; } else if ((double)heldEntity.hostileScore > (double)baseMelee.hostileScore) { obj = allItem; baseMelee = heldEntity; } } } } return(obj); }
public static void MountOperation(NPCHumanContext c, MountOperator.MountOperationType type) { switch (type) { case MountOperator.MountOperationType.Mount: if (c.GetFact(NPCPlayerApex.Facts.IsMounted) != (byte)0 || AI.npc_ignore_chairs) { break; } BaseChair chairTarget = c.ChairTarget; if (!Object.op_Inequality((Object)chairTarget, (Object)null)) { break; } c.Human.Mount((BaseMountable)chairTarget); break; case MountOperator.MountOperationType.Dismount: if (c.GetFact(NPCPlayerApex.Facts.IsMounted) != (byte)1) { break; } c.Human.Dismount(); break; } }
private static Item FindBestProjInRange( NPCPlayerApex.WeaponTypeEnum from, NPCPlayerApex.WeaponTypeEnum to, NPCHumanContext c) { Item obj = (Item)null; BaseProjectile baseProjectile = (BaseProjectile)null; foreach (Item allItem in c.Human.inventory.AllItems()) { if (allItem.info.category == ItemCategory.Weapon && !allItem.isBroken) { BaseProjectile heldEntity = allItem.GetHeldEntity() as BaseProjectile; if (Object.op_Inequality((Object)heldEntity, (Object)null) && heldEntity.effectiveRangeType <= to && heldEntity.effectiveRangeType > from) { if (obj == null) { obj = allItem; baseProjectile = heldEntity; } else if ((double)heldEntity.hostileScore > (double)baseProjectile.hostileScore) { obj = allItem; baseProjectile = heldEntity; } } } } return(obj); }
public override void DoExecute(BaseContext c) { Vector3 best = base.GetBest(c, c.sampledPositions); if (best.sqrMagnitude == 0f) { return; } NPCHumanContext nPCHumanContext = c as NPCHumanContext; if (nPCHumanContext != null && nPCHumanContext.CurrentCoverVolume != null) { int num = 0; while (num < nPCHumanContext.sampledCoverPoints.Count) { CoverPoint item = nPCHumanContext.sampledCoverPoints[num]; CoverPoint.CoverType coverType = nPCHumanContext.sampledCoverPointTypes[num]; if (Vector3Ex.Distance2D(item.Position, best) >= 1f) { num++; } else { nPCHumanContext.CoverSet.Update(item, item, item); break; } } } c.AIAgent.UpdateDestination(best); c.lastSampledPosition = best; }
public override void DoExecute(BaseContext c) { BaseEntity best; float bestScore; if (!this.TryGetBest(c, (IList <BaseEntity>)c.Memory.Visible, this.AllScorersMustScoreAboveZero, out best, out bestScore) || (double)bestScore < (double)this.ScoreThreshold) { NPCHumanContext npcHumanContext = c as NPCHumanContext; c.AIAgent.AttackTarget = npcHumanContext == null || (double)c.AIAgent.GetWantsToAttack(npcHumanContext.LastAttacker) <= 0.0 ? (BaseEntity)null : npcHumanContext.LastAttacker; } else { if ((double)c.AIAgent.GetWantsToAttack(best) < 0.100000001490116) { best = (BaseEntity)null; } c.AIAgent.AttackTarget = best; } if (!Object.op_Inequality((Object)c.AIAgent.AttackTarget, (Object)null)) { return; } foreach (Memory.SeenInfo seenInfo in c.Memory.All) { if (Object.op_Equality((Object)seenInfo.Entity, (Object)best)) { c.AIAgent.AttackTargetMemory = seenInfo; break; } } }
public override void DoExecute(BaseContext c) { Vector3 best = this.GetBest((IAIContext)c, (IList <Vector3>)c.sampledPositions); if ((double)((Vector3) ref best).get_sqrMagnitude() == 0.0) { return; } NPCHumanContext npcHumanContext = c as NPCHumanContext; if (npcHumanContext != null && Object.op_Inequality((Object)npcHumanContext.CurrentCoverVolume, (Object)null)) { for (int index = 0; index < npcHumanContext.sampledCoverPoints.Count; ++index) { CoverPoint sampledCoverPoint = npcHumanContext.sampledCoverPoints[index]; int sampledCoverPointType = (int)npcHumanContext.sampledCoverPointTypes[index]; if ((double)Vector3Ex.Distance2D(sampledCoverPoint.Position, best) < 1.0) { npcHumanContext.CoverSet.Update(sampledCoverPoint, sampledCoverPoint, sampledCoverPoint); break; } } } c.AIAgent.UpdateDestination(best); c.lastSampledPosition = best; }
public static bool Test(NPCHumanContext c, AiLocationSpawner.SquadSpawnerLocation location) { if (c.AiLocationManager == null) { return(false); } return(c.AiLocationManager.LocationType == location); }
public static bool Test(NPCHumanContext c, AiLocationSpawner.SquadSpawnerLocation location) { if (Object.op_Inequality((Object)c.AiLocationManager, (Object)null)) { return(c.AiLocationManager.LocationType == location); } return(false); }
public static float Test(NPCHumanContext c) { if (!Object.op_Inequality((Object)c.ChairTarget, (Object)null)) { return(0.0f); } return(InMountRangeOfChair.IsInRange(c, (BaseMountable)c.ChairTarget)); }
public static bool Evaluate(NPCHumanContext c) { if (c == null || c.Human.AttackTarget == null) { return(false); } return(c.Human.PathDistanceIsValid(c.Human.ServerPosition, c.Human.AttackTarget.ServerPosition, false)); }
public static bool Evaluate(NPCHumanContext c) { if (c == null || Object.op_Equality((Object)c.Human.AttackTarget, (Object)null)) { return(false); } return(c.Human.PathDistanceIsValid(c.Human.ServerPosition, c.Human.AttackTarget.ServerPosition, false)); }
public static float Test(NPCHumanContext c) { if (c.ChairTarget == null) { return(0f); } return(1f); }
public static float Test(NPCHumanContext c) { if (c.ChairTarget == null) { return(0f); } return(InMountRangeOfChair.IsInRange(c, c.ChairTarget)); }
public override void DoExecute(BaseContext context) { NPCHumanContext nPCHumanContext = context as NPCHumanContext; if (nPCHumanContext != null) { LookAtClosestPlayer.Do(nPCHumanContext); } }