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); }
public static bool TrySwitchWeaponTo(NPCHumanContext c, NPCPlayerApex.WeaponTypeEnum WeaponType) { if (c != null && (double)Time.get_realtimeSinceStartup() >= (double)c.Human.NextWeaponSwitchTime) { uint svActiveItemId = c.Human.svActiveItemID; Item obj; switch (WeaponType) { case NPCPlayerApex.WeaponTypeEnum.CloseRange: obj = SwitchWeaponOperator.FindBestMelee(c); if (obj == null) { obj = SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.None, NPCPlayerApex.WeaponTypeEnum.CloseRange, c) ?? SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.CloseRange, NPCPlayerApex.WeaponTypeEnum.MediumRange, c) ?? SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.MediumRange, NPCPlayerApex.WeaponTypeEnum.LongRange, c); c.Human.StoppingDistance = 2.5f; break; } c.Human.StoppingDistance = 1.5f; break; case NPCPlayerApex.WeaponTypeEnum.MediumRange: obj = SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.CloseRange, NPCPlayerApex.WeaponTypeEnum.MediumRange, c) ?? SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.MediumRange, NPCPlayerApex.WeaponTypeEnum.LongRange, c); c.Human.StoppingDistance = 0.1f; break; case NPCPlayerApex.WeaponTypeEnum.LongRange: obj = SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.MediumRange, NPCPlayerApex.WeaponTypeEnum.LongRange, c) ?? SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.CloseRange, NPCPlayerApex.WeaponTypeEnum.MediumRange, c); c.Human.StoppingDistance = 0.1f; break; default: c.Human.UpdateActiveItem(0U); if ((int)svActiveItemId != (int)c.Human.svActiveItemID) { c.Human.NextWeaponSwitchTime = Time.get_realtimeSinceStartup() + c.Human.WeaponSwitchFrequency; c.SetFact(NPCPlayerApex.Facts.CurrentWeaponType, (byte)c.Human.GetCurrentWeaponTypeEnum(), true, true); c.SetFact(NPCPlayerApex.Facts.CurrentAmmoState, (byte)c.Human.GetCurrentAmmoStateEnum(), true, true); } c.Human.StoppingDistance = 1f; return(true); } if (obj != null) { c.Human.UpdateActiveItem(obj.uid); if ((int)svActiveItemId != (int)c.Human.svActiveItemID) { c.Human.NextWeaponSwitchTime = Time.get_realtimeSinceStartup() + c.Human.WeaponSwitchFrequency; c.SetFact(NPCPlayerApex.Facts.CurrentWeaponType, (byte)c.Human.GetCurrentWeaponTypeEnum(), true, true); c.SetFact(NPCPlayerApex.Facts.CurrentAmmoState, (byte)c.Human.GetCurrentAmmoStateEnum(), true, true); c.SetFact(NPCPlayerApex.Facts.CurrentToolType, (byte)0, true, true); } return(true); } } return(false); }
private static void NavigateToWaypointLoc(NPCHumanContext c) { if (c.GetFact(NPCPlayerApex.Facts.HasWaypoints) > 0 && c.Human.IsNavRunning()) { c.Human.StoppingDistance = 0.3f; WaypointSet.Waypoint item = c.Human.WaypointSet.Points[c.Human.CurrentWaypointIndex]; bool flag = false; Vector3 transform = item.Transform.position; if ((c.Human.Destination - transform).sqrMagnitude > 0.01f) { HumanNavigateToOperator.MakeUnstuck(c); c.Human.Destination = transform; c.Human.SetTargetPathStatus(0.05f); flag = true; } float single = 0f; int num = c.Human.PeekNextWaypointIndex(); if (c.Human.WaypointSet.Points.Count > num && Mathf.Approximately(c.Human.WaypointSet.Points[num].WaitTime, 0f)) { single = 1f; } if ((c.Position - c.Human.Destination).sqrMagnitude > c.Human.SqrStoppingDistance + single) { c.Human.LookAtPoint = null; c.Human.LookAtEyes = null; if (c.GetFact(NPCPlayerApex.Facts.IsMoving) != 0 || flag) { c.SetFact(NPCPlayerApex.Facts.IsMovingTowardWaypoint, 1, true, true); return; } c.Human.CurrentWaypointIndex = c.Human.GetNextWaypointIndex(); c.SetFact(NPCPlayerApex.Facts.IsMovingTowardWaypoint, 0, true, true); return; } if (HumanNavigateToOperator.IsWaitingAtWaypoint(c, ref item)) { if (!IsClosestPlayerWithinDistance.Test(c, 4f)) { c.Human.LookAtEyes = null; c.Human.LookAtRandomPoint(5f); } else { LookAtClosestPlayer.Do(c); } c.SetFact(NPCPlayerApex.Facts.IsMovingTowardWaypoint, 0, true, true); return; } c.Human.CurrentWaypointIndex = c.Human.GetNextWaypointIndex(); c.Human.LookAtPoint = null; } }
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(); }
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(); } }
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); } }
private static void NavigateToWaypointLoc(NPCHumanContext c) { if (c.GetFact(NPCPlayerApex.Facts.HasWaypoints) <= (byte)0 || !c.Human.IsNavRunning()) { return; } c.Human.StoppingDistance = 0.3f; WaypointSet.Waypoint point = c.Human.WaypointSet.Points[c.Human.CurrentWaypointIndex]; bool flag = false; Vector3 position = point.Transform.get_position(); Vector3 vector3_1 = Vector3.op_Subtraction(c.Human.Destination, position); if ((double)((Vector3) ref vector3_1).get_sqrMagnitude() > 0.00999999977648258) { HumanNavigateToOperator.MakeUnstuck(c); c.Human.Destination = position; c.Human.SetTargetPathStatus(0.05f); flag = true; } float num = 0.0f; int index = c.Human.PeekNextWaypointIndex(); if (c.Human.WaypointSet.Points.Count > index && Mathf.Approximately(c.Human.WaypointSet.Points[index].WaitTime, 0.0f)) { num = 1f; } Vector3 vector3_2 = Vector3.op_Subtraction(c.Position, c.Human.Destination); if ((double)((Vector3) ref vector3_2).get_sqrMagnitude() > (double)c.Human.SqrStoppingDistance + (double)num) { c.Human.LookAtPoint = (Transform)null; c.Human.LookAtEyes = (PlayerEyes)null; if (c.GetFact(NPCPlayerApex.Facts.IsMoving) == (byte)0 && !flag) { c.Human.CurrentWaypointIndex = c.Human.GetNextWaypointIndex(); c.SetFact(NPCPlayerApex.Facts.IsMovingTowardWaypoint, (byte)0, true, true); } else { c.SetFact(NPCPlayerApex.Facts.IsMovingTowardWaypoint, (byte)1, true, true); } }
public static void PathToCover(NPCHumanContext c, Vector3 coverPosition) { if (coverPosition.sqrMagnitude > 0f) { HumanNavigateToOperator.MakeUnstuck(c); c.AIAgent.GetNavAgent.destination = coverPosition; c.Human.SetTargetPathStatus(0.05f); c.SetFact(NPCPlayerApex.Facts.IsMovingToCover, 1, true, true); if (c.Human.OnTakeCover != null) { c.Human.OnTakeCover(); } } }
public static bool TrySwitchToolTo(NPCHumanContext c, NPCPlayerApex.ToolTypeEnum toolDay, NPCPlayerApex.ToolTypeEnum toolNight) { if (c != null) { Item item = null; uint human = c.Human.svActiveItemID; if (TOD_Sky.Instance != null) { item = (!TOD_Sky.Instance.IsDay ? SwitchToolOperator.FindTool(c, toolNight) : SwitchToolOperator.FindTool(c, toolDay)); } if (item != null) { c.Human.UpdateActiveItem(item.uid); if (human != c.Human.svActiveItemID) { c.Human.NextToolSwitchTime = UnityEngine.Time.realtimeSinceStartup + c.Human.ToolSwitchFrequency; c.SetFact(NPCPlayerApex.Facts.CurrentWeaponType, 0, true, true); c.SetFact(NPCPlayerApex.Facts.CurrentToolType, (byte)c.Human.GetCurrentToolTypeEnum(), true, true); } return(true); } } return(false); }
private static bool IsWaitingAtWaypoint(NPCHumanContext c, ref WaypointSet.Waypoint waypoint) { if (c.Human.IsWaitingAtWaypoint || waypoint.WaitTime <= 0f) { if (c.Human.IsWaitingAtWaypoint && UnityEngine.Time.time >= c.Human.WaypointDelayTime) { c.Human.IsWaitingAtWaypoint = false; } if (!c.Human.IsWaitingAtWaypoint) { return(false); } } else { c.Human.WaypointDelayTime = UnityEngine.Time.time + waypoint.WaitTime; c.Human.IsWaitingAtWaypoint = true; c.SetFact(NPCPlayerApex.Facts.Speed, 0, true, true); } return(true); }
public static void NavigateToCover(NPCHumanContext c, HumanNavigateToOperator.TakeCoverIntention intention) { if (!c.AIAgent.IsNavRunning()) { return; } c.Human.TimeLastMovedToCover = UnityEngine.Time.realtimeSinceStartup; switch (intention) { case HumanNavigateToOperator.TakeCoverIntention.Advance: { if (c.CoverSet.Advance.ReservedCoverPoint != null) { HumanNavigateToOperator.PathToCover(c, c.CoverSet.Advance.ReservedCoverPoint.Position); return; } if (c.CoverSet.Closest.ReservedCoverPoint == null) { break; } HumanNavigateToOperator.PathToCover(c, c.CoverSet.Closest.ReservedCoverPoint.Position); return; } case HumanNavigateToOperator.TakeCoverIntention.Flank: { if (c.CoverSet.Flank.ReservedCoverPoint != null) { HumanNavigateToOperator.PathToCover(c, c.CoverSet.Flank.ReservedCoverPoint.Position); c.SetFact(NPCPlayerApex.Facts.IsRetreatingToCover, 1, true, true); return; } if (c.CoverSet.Closest.ReservedCoverPoint == null) { break; } HumanNavigateToOperator.PathToCover(c, c.CoverSet.Closest.ReservedCoverPoint.Position); c.SetFact(NPCPlayerApex.Facts.IsRetreatingToCover, 1, true, true); return; } case HumanNavigateToOperator.TakeCoverIntention.Retreat: { if (c.CoverSet.Retreat.ReservedCoverPoint != null) { HumanNavigateToOperator.PathToCover(c, c.CoverSet.Retreat.ReservedCoverPoint.Position); c.SetFact(NPCPlayerApex.Facts.IsRetreatingToCover, 1, true, true); return; } if (c.CoverSet.Closest.ReservedCoverPoint == null) { break; } HumanNavigateToOperator.PathToCover(c, c.CoverSet.Closest.ReservedCoverPoint.Position); c.SetFact(NPCPlayerApex.Facts.IsRetreatingToCover, 1, true, true); return; } case HumanNavigateToOperator.TakeCoverIntention.Closest: { if (c.CoverSet.Closest.ReservedCoverPoint == null) { break; } HumanNavigateToOperator.PathToCover(c, c.CoverSet.Closest.ReservedCoverPoint.Position); break; } default: { goto case HumanNavigateToOperator.TakeCoverIntention.Closest; } } }
public static bool TrySwitchWeaponTo(NPCHumanContext c, NPCPlayerApex.WeaponTypeEnum WeaponType) { Item item; if (c != null) { if (Time.realtimeSinceStartup < c.Human.NextWeaponSwitchTime) { return(false); } uint human = c.Human.svActiveItemID; switch (WeaponType) { case NPCPlayerApex.WeaponTypeEnum.CloseRange: { item = SwitchWeaponOperator.FindBestMelee(c); if (item != null) { c.Human.StoppingDistance = 1.5f; break; } else { item = SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.None, NPCPlayerApex.WeaponTypeEnum.CloseRange, c) ?? (SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.CloseRange, NPCPlayerApex.WeaponTypeEnum.MediumRange, c) ?? SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.MediumRange, NPCPlayerApex.WeaponTypeEnum.LongRange, c)); c.Human.StoppingDistance = 2.5f; break; } } case NPCPlayerApex.WeaponTypeEnum.MediumRange: { item = SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.CloseRange, NPCPlayerApex.WeaponTypeEnum.MediumRange, c) ?? SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.MediumRange, NPCPlayerApex.WeaponTypeEnum.LongRange, c); c.Human.StoppingDistance = 0.1f; break; } case NPCPlayerApex.WeaponTypeEnum.LongRange: { item = SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.MediumRange, NPCPlayerApex.WeaponTypeEnum.LongRange, c) ?? SwitchWeaponOperator.FindBestProjInRange(NPCPlayerApex.WeaponTypeEnum.CloseRange, NPCPlayerApex.WeaponTypeEnum.MediumRange, c); c.Human.StoppingDistance = 0.1f; break; } default: { c.Human.UpdateActiveItem(0); if (human != c.Human.svActiveItemID) { c.Human.NextWeaponSwitchTime = Time.realtimeSinceStartup + c.Human.WeaponSwitchFrequency; c.SetFact(NPCPlayerApex.Facts.CurrentWeaponType, (byte)c.Human.GetCurrentWeaponTypeEnum(), true, true); c.SetFact(NPCPlayerApex.Facts.CurrentAmmoState, (byte)c.Human.GetCurrentAmmoStateEnum(), true, true); } c.Human.StoppingDistance = 1f; return(true); } } if (item != null) { c.Human.UpdateActiveItem(item.uid); if (human != c.Human.svActiveItemID) { c.Human.NextWeaponSwitchTime = Time.realtimeSinceStartup + c.Human.WeaponSwitchFrequency; c.SetFact(NPCPlayerApex.Facts.CurrentWeaponType, (byte)c.Human.GetCurrentWeaponTypeEnum(), true, true); c.SetFact(NPCPlayerApex.Facts.CurrentAmmoState, (byte)c.Human.GetCurrentAmmoStateEnum(), true, true); c.SetFact(NPCPlayerApex.Facts.CurrentToolType, 0, true, true); } return(true); } } return(false); }