using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using RavenM;
using Ravenfield.SpecOps;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("specopsplus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("specopsplus")]
[assembly: AssemblyTitle("specopsplus")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace specopsplus;
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.personperhaps.specopsplus", "specopsplus", "0.1")]
public class SpecOpsPlus : BaseUnityPlugin
{
[HarmonyPatch(typeof(SpecOpsMode), "SetDifficultyFlags")]
public class DifficultyPatch
{
public static void Postfix(SpecOpsMode __instance)
{
SetPrivateVar<int>("nInfantryPatrols", __instance, (int)Mathf.Ceil((float)(GameManager.GameParameters().actorCount / 40 + (int)Mathf.Ceil((float)(ActorManager.instance.spawnPoints.Length / 3)) * InfantryPatrolCountMultiplier.Value)));
}
}
[HarmonyPatch(typeof(IngameDialog), "PrintActorText", new Type[]
{
typeof(string),
typeof(string),
typeof(string),
typeof(float),
typeof(AudioClip),
typeof(bool)
})]
public class DialogPatch
{
public static void Prefix(IngameDialog __instance, string actorPose, ref string text, string overrideName, float noiseAmount, AudioClip blipSoundOverride, bool blipOneShot)
{
if (text == "TALON, the mission is go.")
{
text = "TALON, please go silent i beg of you please i will literally give you this random rock i found in my backyard and this dead rat.";
}
if (text == "Move swiftly and quietly.")
{
text = "Move swiftly and quietly (pretty please)\n :)";
}
if (text == "I'm in position with eyes on TALON.")
{
text = "No I can't read.\n Sorry";
}
if (text == "Great!\nEYES will be relaying enemy movement.")
{
text = "What?";
}
if (text == "That should give you an edge today.")
{
text = "Huh.";
}
}
}
[HarmonyPatch(typeof(GameModeBase), "Win")]
public class WinTeamPatch
{
public static void Prefix(GameModeBase __instance)
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
if (!GameCheck())
{
return;
}
List<Actor> allPlayers = IngameNetManager.instance.GetPlayers();
List<ScoreboardActorEntry> list = GetPrivateVar<Dictionary<int, List<ScoreboardActorEntry>>>("entriesOfTeam", ScoreboardUi.instance)[((SpecOpsMode)((__instance is SpecOpsMode) ? __instance : null)).attackingTeam].Where((ScoreboardActorEntry x) => allPlayers.Contains(x.actor)).ToList();
foreach (ScoreboardActorEntry item in list)
{
Color val = (item.actor.dead ? Color.red : Color.white);
ChatManager.instance.PushCommandChatMessage($"{item.actor.name}: {item.kills} kills, {item.deaths} deaths", val, false, true);
}
}
}
public class VultureSquad
{
public Squad squad;
public bool died = false;
private void Update()
{
if (!died && squad.members.All((ActorController x) => x.actor.dead))
{
died = true;
}
}
}
[HarmonyPatch(typeof(CapturePoint), "RandomPatrolPosition")]
public class PatrolFix
{
public static Vector3 RandomPositionInCaptureZone(SpawnPoint __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = Random.insideUnitCircle * 50f;
Vector3 val2 = ((Component)__instance).transform.position + new Vector3(val.x, 0f, val.y);
RaycastHit val3 = default(RaycastHit);
if (Physics.Raycast(new Ray(val2 + Vector3.up * 3f, Vector3.down), ref val3))
{
return ((RaycastHit)(ref val3)).point;
}
return val2;
}
public static Vector3 RandomPatrolPosition(SpawnPoint __instance)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance.spawnpointContainer != (Object)null)
{
return __instance.RandomSpawnPointPosition(__instance.spawnpointContainer);
}
return RandomPositionInCaptureZone(__instance);
}
public static bool Prefix(CapturePoint __instance, ref Vector3 __result)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
if (GameCheck())
{
if (Random.Range(0, 4) > 1)
{
__result = RandomPatrolPosition((SpawnPoint)(object)__instance);
}
else
{
Vector3 val = RandomPositionInCaptureZone((SpawnPoint)(object)__instance);
__result = val;
}
return false;
}
return true;
}
}
[HarmonyPatch(typeof(SpecOpsMode), "SpawnScenarios")]
public class SpawnScenariosPatch
{
private static bool ActivateScenario(SpecOpsScenario scenario, SpawnPoint spawn, SpecOpsMode __instance)
{
try
{
Debug.LogFormat("Initializing {0} at {1}", new object[2] { scenario, spawn.shortName });
scenario.Initialize(__instance, spawn);
spawn.SetGhost(false);
}
catch (Exception ex)
{
Debug.LogException(ex);
return false;
}
__instance.activeScenarios.Add(scenario);
if (!__instance.scenarioAtSpawn.ContainsKey(spawn))
{
__instance.scenarioAtSpawn.Add(spawn, scenario);
}
__instance.activeObjectives.Add((SpecOpsObjective)(object)scenario);
return false;
}
public static bool Prefix(SpecOpsMode __instance, ref List<SpawnPoint> __result)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
if (!GameCheck())
{
return true;
}
List<SpecOpsScenario> list = new List<SpecOpsScenario>
{
(SpecOpsScenario)new DestroyScenario(),
(SpecOpsScenario)new AssassinateScenario(),
(SpecOpsScenario)new ClearScenario(),
(SpecOpsScenario)new SabotageScenario(),
(SpecOpsScenario)new AssassinateScenario(),
(SpecOpsScenario)new ClearScenario(),
(SpecOpsScenario)new AssassinateScenario(),
(SpecOpsScenario)new ClearScenario()
};
__instance.activeScenarios = new List<SpecOpsScenario>();
__instance.activePatrols = new List<SpecOpsPatrol>();
__instance.activeObjectives = new List<SpecOpsObjective>();
List<SpawnPoint> list2 = new List<SpawnPoint>(ActorManager.instance.spawnPoints);
int num = GameManager.GameParameters().gameLength + 10;
int num2 = list2.Count;
if ((bool)typeof(SpecOpsMode).GetField("tinyMap", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance))
{
num2--;
}
num = Mathf.Min(num, num2);
__instance.scenarioAtSpawn = new Dictionary<SpawnPoint, SpecOpsScenario>();
IEnumerable<SpawnPoint> source = list2.Where((SpawnPoint s) => s.vehicleSpawners.Any((VehicleSpawner spawner) => (Object)(object)spawner.GetPrefab() != (Object)null));
IEnumerable<SpawnPoint> source2 = source.Where((SpawnPoint s) => s.vehicleSpawners.Any((VehicleSpawner spawner) => (Object)(object)spawner.GetPrefab() != (Object)null && DestroyScenario.IsHighValueType(spawner.typeToSpawn)));
List<SpawnPoint> list3 = ((source2.Count() > 0) ? source2.ToList() : source.ToList());
List<SpecOpsScenario> list4 = new List<SpecOpsScenario>();
for (int i = 0; i < num; i++)
{
if (list.Count == 0)
{
break;
}
if (list2.Count == 0)
{
break;
}
SpecOpsScenario val = PickRandomEntry(list);
list.Remove(val);
if (val is DestroyScenario)
{
if (list3.Count() == 0)
{
num++;
continue;
}
SpawnPoint val2 = PickRandomEntry(list3);
list2.Remove(val2);
if (!ActivateScenario(val, val2, __instance))
{
Debug.LogFormat("Failed to initialize scenario {0}, replace it with a new scenario", new object[1] { val });
num++;
}
}
else
{
list4.Add(val);
}
}
foreach (SpecOpsScenario item in list4)
{
if (list2.Count > 0)
{
SpawnPoint val3 = PickRandomEntry(list2);
list2.Remove(val3);
ActivateScenario(item, val3, __instance);
Debug.Log((object)("Activated point: " + ((Object)((SpecOpsObjective)item).objective).name + ", " + ((Object)val3).name));
}
}
ObjectiveUi.SortEntries();
__result = list2;
heat = 0;
Debug.Log((object)"FinishedLoading");
SetPrivateVar<TimedAction>("flareCooldown", __instance, (object)new TimedAction((float)FlareDelay.Value, false));
return false;
}
}
[HarmonyPatch(typeof(SpecOpsScenario), "SpawnActors")]
public class ScenarioPatrolPatch
{
public static void Prefix(SpecOpsScenario __instance, SpawnPoint spawn, int team, ref int count)
{
if (GameCheck())
{
int num = count;
count = (int)Mathf.Ceil((float)(GameManager.GameParameters().actorCount / 5));
if (count <= 0)
{
count = num;
}
}
}
}
[HarmonyPatch(typeof(ExfilHelicopter), "SpawnHelicopter")]
public class HeliFix
{
public static void Postfix(ExfilHelicopter __instance, Vector3 spawnPosition, Vector3 approachDirection)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
if (!GameCheck())
{
return;
}
Helicopter val = (Helicopter)typeof(ExfilHelicopter).GetField("helicopter", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
((Vehicle)val).isInvulnerable = false;
((Vehicle)val).canBeTakenOverByPlayerSquad = false;
((Vehicle)val).countermeasuresCooldown = 0f;
((Vehicle)val).allowPlayerSeatSwap = true;
((Vehicle)val).allowPlayerSeatChange = true;
((Vehicle)val).maxHealth = 1000000f;
((Vehicle)val).health = 1000000f;
foreach (Seat seat in ((Vehicle)val).seats)
{
seat.allowUnderwater = true;
}
}
}
[HarmonyPatch(typeof(ExfilHelicopter), "Update")]
public class HeliPickupFix
{
public static void Postfix(ExfilHelicopter __instance)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
if (GameCheck())
{
Helicopter helicopter = (Helicopter)typeof(ExfilHelicopter).GetField("helicopter", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
if ((from x in IngameNetManager.instance.GetPlayers()
where !x.dead
select x).All((Actor x) => (Object)(object)x.seat != (Object)null && (Object)(object)x.seat.vehicle == (Object)(object)helicopter) || ((Vehicle)helicopter).IsFull())
{
typeof(ExfilHelicopter).GetMethod("CompleteExfiltration", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, null);
}
}
}
}
[HarmonyPatch(typeof(SpecOpsPatrol), "Update")]
public class SpecOpsPatrolFlarePatch
{
public static TimedAction patrolFlareStartup = new TimedAction(13f, false);
public static Dictionary<SpecOpsPatrol, bool> alertedPatrols = new Dictionary<SpecOpsPatrol, bool>();
public static void Postfix(SpecOpsPatrol __instance)
{
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
if (!GameCheck() || __instance.squad == null || __instance.squad.members.Count <= 0)
{
return;
}
if (!alertedPatrols.ContainsKey(__instance))
{
alertedPatrols.Add(__instance, value: false);
}
else if ((__instance.squad.AnyMemberHasSpottedTarget() || __instance.squad.isAlert) && !alertedPatrols[__instance])
{
((TimedAction)(ref patrolFlareStartup)).Start();
alertedPatrols[__instance] = true;
}
if (((SpecOpsObjective)__instance).specOps.FlareIsOnCooldown() || !__instance.squad.AnyMemberHasSpottedTarget() || !((TimedAction)(ref patrolFlareStartup)).TrueDone())
{
return;
}
foreach (AiActorController aiMember in __instance.squad.aiMembers)
{
if (!((ActorController)aiMember).HasSpottedTarget() && !Physics.Raycast(((ActorController)aiMember).actor.CenterPosition(), Vector3.up, 2232321f))
{
((SpecOpsObjective)__instance).specOps.FireFlare(((ActorController)aiMember).actor, ActorManager.ClosestSpawnPoint(((ActorController)aiMember).actor.Position()));
break;
}
}
}
}
[HarmonyPatch(typeof(SpecOpsPatrol), "SpawnSquad")]
public class PatrolSpawnPatch
{
public static bool Prefix(SpecOpsPatrol __instance)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Invalid comparison between Unknown and I4
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Invalid comparison between Unknown and I4
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Expected O, but got Unknown
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Expected O, but got Unknown
if (!GameCheck())
{
return true;
}
int num = PatrolActorCount.Value;
Vehicle val = null;
Vector3 privateVar = GetPrivateVar<Vector3>("squadSpawnPoint", __instance);
Quaternion privateVar2 = GetPrivateVar<Quaternion>("squadSpawnRotation", __instance);
bool flag = false;
if ((int)__instance.type == 1)
{
VehicleSpawnType val2;
if (Random.Range(1, 4) > 2)
{
val2 = (VehicleSpawnType)10;
}
else
{
val2 = (VehicleSpawnType)1;
flag = true;
}
val = VehicleSpawner.SpawnVehicleAt(privateVar, privateVar2, ((SpecOpsObjective)__instance).specOps.defendingTeam, val2);
}
if ((int)__instance.type == 2)
{
VehicleSpawnType val3 = (VehicleSpawnType)((Random.Range(1, 4) > 2) ? 7 : 6);
val = VehicleSpawner.SpawnVehicleAt(privateVar, privateVar2, ((SpecOpsObjective)__instance).specOps.defendingTeam, val3);
}
if ((Object)(object)val != (Object)null)
{
num = Mathf.Min(val.seats.Count, 4);
}
List<Actor> list = new List<Actor>();
float num2 = (GameManager.GameParameters().nightMode ? 70f : 110f);
float num3 = (GameManager.GameParameters().nightMode ? 0.33f : 0.4f);
bool ignoreFovCheck = (Object)(object)val != (Object)null && val.seats[0].enclosed;
num2 *= 1.2f;
num3 *= 0.7f;
for (int i = 0; i < num; i++)
{
Actor val4 = ActorManager.instance.CreateAIActor(((SpecOpsObjective)__instance).specOps.defendingTeam);
val4.SpawnAt(privateVar, privateVar2, (LoadoutSet)null);
ActorController controller = val4.controller;
AiActorController val5 = (AiActorController)(object)((controller is AiActorController) ? controller : null);
val5.ActivateSlowTargetDetection(num3);
val5.modifier.maxDetectionDistance = num2;
val5.modifier.ignoreFovCheck = ignoreFovCheck;
if (flag)
{
val5.modifier.maxDetectionDistance = 200f;
val5.modifier.alwaysChargeTarget = true;
}
val5.modifier.canSprint = false;
list.Add(val4);
}
__instance.squad = new Squad((IEnumerable<Actor>)list, (SpawnPoint)null, __instance.patrolOrder, val, 0f);
__instance.squad.SetRandomFormation();
__instance.squad.SetFormationSize(3f, 3f);
__instance.squad.allowRequestNewOrders = false;
__instance.squad.autoAssignNewOrders = false;
__instance.squad.SetNotAlert(false);
if ((Object)(object)val != (Object)null)
{
foreach (Actor item in list)
{
item.EnterVehicle(val);
}
}
__instance.squad.onAlerted = (DelOnAlerted)delegate
{
if (((SpecOpsObjective)__instance).specOps.attackingTeam == 0)
{
IngameDialog.PrintActorText("p advisor tense", "A patrol was alerted, TALON", "", 0f, (AudioClip)null, false);
IngameDialog.HideAfter(5f);
}
else
{
IngameDialog.PrintActorText("p unknown", "A patrol was alerted, RAVEN", "", 0f, (AudioClip)null, false);
IngameDialog.HideAfter(5f);
}
};
return false;
}
}
[HarmonyPatch(typeof(SpawnPoint), "RandomPositionInCaptureZone")]
public class RoamSizePatch
{
public static bool Prefix(SpawnPoint __instance, ref Vector3 __result)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
if (!GameCheck())
{
return true;
}
Vector2 val = Random.insideUnitCircle * 20f;
Vector3 val2 = ((Component)__instance).transform.position + new Vector3(val.x, 0f, val.y);
RaycastHit val3 = default(RaycastHit);
if (Physics.Raycast(new Ray(val2 + Vector3.up * 3f, Vector3.down), ref val3))
{
__result = ((RaycastHit)(ref val3)).point;
}
else
{
__result = val2;
}
return false;
}
}
[HarmonyPatch(typeof(ActorManager), "OnActorDied")]
public class OnHostDeath
{
public static void Postfix(ActorManager __instance, Actor actor, Squad belongedToSquad, bool isSilentKill)
{
if (!GameCheck() || !((Object)(object)actor == (Object)(object)((ActorController)FpsActorController.instance).actor))
{
return;
}
foreach (Actor player in IngameNetManager.instance.GetPlayers())
{
GameModeBase activeGameMode = GameModeBase.activeGameMode;
((SpecOpsMode)((activeGameMode is SpecOpsMode) ? activeGameMode : null)).attackerSquad.AddMember(player.controller);
}
}
}
[HarmonyPatch(typeof(Weapon), "Shoot")]
public class WeaponShootPatch
{
[HarmonyPatch(typeof(AiActorController), "Die")]
public class ActorDiePatch
{
public static void Postfix(AiActorController __instance)
{
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
if (!GameCheck() || __instance.squad == null)
{
return;
}
bool flag = false;
foreach (AiActorController aiMember in __instance.squad.aiMembers)
{
if (!((ActorController)aiMember).IsAlert() && DoCanSeeCheck(((ActorController)__instance).actor, ((ActorController)aiMember).actor, out var distance))
{
if (distance < 30f)
{
flag = true;
__instance.SetAlert();
((ActorController)__instance).FindCoverAwayFrom(((ActorController)__instance).actor.Position());
}
else if (distance < 20f)
{
float targetDetectionProgress = aiMember.targetDetectionProgress;
__instance.ActivateSlowTargetDetection(2f);
__instance.targetDetectionProgress = targetDetectionProgress;
}
}
}
if (flag)
{
ActorManager.RegisterSmokeTarget(((ActorController)__instance).actor.GetPosition(), ((Hurtable)((ActorController)__instance).actor).team, 10f, true);
}
}
public static Vector3 GetEyeOrigin(Vector3 actorRootPosition, Stance stance, out float verticalJitter)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected I4, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
verticalJitter = 0.1f;
switch ((int)stance)
{
case 0:
actorRootPosition.y += 1.4f;
return actorRootPosition;
case 1:
actorRootPosition.y += 0.7f;
return actorRootPosition;
case 2:
verticalJitter = 0f;
actorRootPosition.y += 0.2f;
return actorRootPosition;
default:
return actorRootPosition;
}
}
public static bool DoCanSeeCheck(Actor a, Actor b, out float distance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
Vector3 actorRootPosition = a.Position();
Vector3 actorRootPosition2 = b.Position();
bool flag = true;
actorRootPosition = GetEyeOrigin(actorRootPosition, a.stance, out var verticalJitter);
actorRootPosition2 = GetEyeOrigin(actorRootPosition2, b.stance, out var verticalJitter2);
distance = Vector3.Distance(actorRootPosition, actorRootPosition2);
if (!flag)
{
return ActorManager.CanSeeRayTest(a, b, actorRootPosition, actorRootPosition2);
}
for (int i = 0; i < 2; i++)
{
actorRootPosition += Vector3.Scale(Random.insideUnitSphere, new Vector3(0.05f, verticalJitter, 0.05f));
actorRootPosition2 += Vector3.Scale(Random.insideUnitSphere, new Vector3(0.05f, verticalJitter2, 0.05f));
if (ActorManager.CanSeeRayTest(a, b, actorRootPosition, actorRootPosition2))
{
return true;
}
}
return false;
}
}
[HarmonyPatch(typeof(AiActorController), "CanSeeActor")]
public class CanSeeActorPatch
{
public static bool Prefix(AiActorController __instance, ref bool __result)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Invalid comparison between Unknown and I4
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if (!GameCheck() || !((ActorController)__instance).IsAlert())
{
return true;
}
if ((int)__instance.skill == 3 && (Object)(object)__instance.target != (Object)null && Random.Range(0, 10) > 2 && Vector3.Distance(__instance.target.Position(), __instance.ExtrapolateLastSeenTargetPosition(0f)) < 10f)
{
__result = true;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(SpecOpsPatrol), "CreateOrder")]
public class CreateOrderPatch
{
public static void Postfix(SpecOpsPatrol __instance, List<Vector3> waypoints)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Invalid comparison between Unknown and I4
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
if (GameCheck())
{
Vector3 val = Vector3.zero;
int num = 0;
int num2 = 0;
RaycastHit val3 = default(RaycastHit);
for (int i = 0; i < 30 || (Vector3.Distance(val, ((SpecOpsObjective)__instance).specOps.attackerSpawnPosition) <= 50f && num < 5); i++)
{
num++;
num2 = Random.Range(0, waypoints.Count - 1);
Vector3 zero = Vector3.zero;
Vector3 val2 = (((int)__instance.type != 2) ? waypoints[num2] : (Vector3.Lerp(waypoints[num2], waypoints[num2 + 1], Random.Range(0f, 1f)) + Vector3.Scale(Random.insideUnitSphere, new Vector3(1f, 0f, 1f))));
zero = Vector3.Lerp(waypoints[num2], waypoints[num2 + 1], Random.Range(0f, 1f)) + Vector3.Scale(Random.insideUnitSphere, new Vector3(1f, 0f, 1f));
val = ((!Physics.Raycast(new Ray(zero + Vector3.up * 50f, Vector3.down), ref val3)) ? zero : ((RaycastHit)(ref val3)).point);
}
val += Vector3.up * 2f;
SetPrivateVar<Vector3>("squadSpawnPoint", __instance, val);
Vector3 val4 = waypoints[num2 + 1] - waypoints[num2];
SetPrivateVar<Quaternion>("squadSpawnRotation", __instance, SMath.LookRotationRespectUp(val4, Vector3.up));
}
}
}
[HarmonyPatch(typeof(SpecOpsPatrolGenerator), "ClusterWaypoints")]
public class MorePatrolsPatch
{
public static bool Prefix(SpecOpsPatrolGenerator __instance)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Invalid comparison between Unknown and I4
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
if (!GameCheck())
{
return true;
}
int num = 3;
num = Mathf.Clamp((int)Mathf.Ceil((float)(ActorManager.instance.spawnPoints.Length / 2)), 1, 5) + ExtraPatrolGroupCount.Value;
for (int i = 0; i < num; i++)
{
foreach (Type key in GetPrivateVar<Dictionary<Type, List<Vector3>>>("waypoints", __instance).Keys)
{
List<Vector3> list = GetPrivateVar<Dictionary<Type, List<Vector3>>>("waypoints", __instance)[key];
if (list.Count != 0 || ((int)key != 0 && Random.Range(0, 2) == 2))
{
bool flag = (int)key == 0;
InvokeMethod(__instance, "RemoveFarawayWaypoints", new object[2] { list, 300f });
DecimateWaypoints(list, !flag);
List<Vector3> list2 = (List<Vector3>)InvokeMethod(__instance, "ConstructWaypointPath", new object[1] { list });
if (list2.Count > 1)
{
GetPrivateVar<SpecOpsMode>("specOps", __instance).RegisterPatrol(key, list2);
}
}
}
}
return false;
}
public static void DecimateWaypoints(List<Vector3> waypoints, bool biasAwayFromCenter)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
int num = Mathf.Max(waypoints.Count / 2, 2);
int num2 = waypoints.Count - num;
Vector3 val = Vector3.zero;
foreach (Vector3 waypoint in waypoints)
{
val += waypoint;
}
val /= (float)waypoints.Count;
for (int i = 0; i < num2; i++)
{
int num3 = -1;
int index = -1;
float num4 = float.MaxValue;
for (int j = 0; j < waypoints.Count; j++)
{
for (int k = j + 1; k < waypoints.Count; k++)
{
float num5 = Vector3.Distance(waypoints[j], waypoints[k]);
if (num5 < num4)
{
num3 = j;
index = k;
num4 = num5;
}
}
}
if (num3 == -1)
{
break;
}
if (biasAwayFromCenter == Vector3.Distance(waypoints[num3], val) < Vector3.Distance(waypoints[index], val))
{
waypoints.RemoveAt(num3);
}
else
{
waypoints.RemoveAt(index);
}
}
}
}
[HarmonyPatch(typeof(AiActorController), "GetSwingMagnitude")]
public class SwingMagnitudePatch
{
public static bool Prefix(AiActorController __instance, ref float __result)
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Invalid comparison between Unknown and I4
if (GameCheck())
{
float num = (((ActorController)__instance).actor.parachuteDeployed ? AiActorController.PARAMETERS.AIM_SWING_PARACHUTING : 0f);
float num2 = ((((ActorController)__instance).actor.closestEnemyDistance < 40f) ? 0.1f : 1f);
float num3 = ((((ActorController)__instance).IsTakingFire() && !((ActorController)__instance).IsOnPlayerSquad()) ? 10f : 0f);
if ((Object)(object)((ActorController)__instance).actor.activeWeapon != (Object)null)
{
num += ((ActorController)__instance).actor.activeWeapon.configuration.aiAimSwing + num3 * num2;
if ((int)__instance.skill == 3 && ((ActorController)__instance).IsTakingFire())
{
num += ((ActorController)__instance).actor.activeWeapon.configuration.aiAimSwing + num3 * num2 / 4f;
}
}
__result = num;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(SpecOpsMode), "FireFlare")]
public class FlarePatch
{
public static bool Prefix(SpecOpsMode __instance, Actor actor, SpawnPoint spawn, out bool __state)
{
if (!GameCheck())
{
__state = false;
return true;
}
__state = false;
bool result;
if (__instance.FlareIsOnCooldown())
{
__state = true;
result = false;
}
else
{
result = true;
}
return result;
}
public static void Postfix(SpecOpsMode __instance, Actor actor, SpawnPoint spawn, bool __state)
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
if (!GameCheck() || __state || !HeatEnabled.Value)
{
return;
}
heat++;
IngameUI.ShowOverlayText("HEAT " + heat, 4f);
if (IngameNetManager.instance.IsHost)
{
ChatManager.instance.PushCommandChatMessage("HEAT " + heat, Color.red, false, true);
}
if (heat == 2)
{
foreach (SpecOpsScenario activeScenario in __instance.activeScenarios)
{
if (activeScenario.actors.Count > 0 && activeScenario.actors.All(delegate(Actor x)
{
ActorController controller4 = x.controller;
return !((controller4 is AiActorController) ? controller4 : null).IsAlert();
}))
{
activeScenario.actors.ForEach(delegate(Actor x)
{
ActorController controller3 = x.controller;
((AiActorController)((controller3 is AiActorController) ? controller3 : null)).ActivateSlowTargetDetection(0.7f);
});
}
}
}
if (heat >= 6)
{
foreach (SpecOpsScenario activeScenario2 in __instance.activeScenarios)
{
if (activeScenario2.actors.Count > 0 && activeScenario2.actors.All(delegate(Actor x)
{
ActorController controller2 = x.controller;
return !((controller2 is AiActorController) ? controller2 : null).IsAlert();
}))
{
activeScenario2.squad.SetAlert();
activeScenario2.actors.ForEach(delegate(Actor x)
{
ActorController controller = x.controller;
((AiActorController)((controller is AiActorController) ? controller : null)).DeactivateSlowTargetDetection();
});
}
}
}
PlayerFpParent.instance.ApplyScreenshake(4f, 3);
}
}
[HarmonyPatch(typeof(SpecOpsMode), "SpawnHelicopterPatrol")]
public class HelicopterReinforcementPatch
{
public static bool Prefix(SpecOpsMode __instance, SpawnPoint spawn)
{
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
//IL_035e: Unknown result type (might be due to invalid IL or missing references)
//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
//IL_040c: Expected O, but got Unknown
//IL_0407: Unknown result type (might be due to invalid IL or missing references)
//IL_0411: Expected O, but got Unknown
//IL_0432: Unknown result type (might be due to invalid IL or missing references)
//IL_0453: Unknown result type (might be due to invalid IL or missing references)
//IL_045d: Expected O, but got Unknown
//IL_0467: Unknown result type (might be due to invalid IL or missing references)
//IL_0471: Expected O, but got Unknown
//IL_0480: Unknown result type (might be due to invalid IL or missing references)
//IL_048a: Expected O, but got Unknown
if (!GameCheck() || !HeatEnabled.Value)
{
return true;
}
((BaseUnityPlugin)instance).Logger.LogDebug((object)("Current Heat: " + heat));
bool result;
if (heat == 1)
{
SpawnAttackHeli(__instance, spawn);
result = false;
}
else
{
if (heat >= 2)
{
SpawnAttackHeli(__instance, spawn);
}
GameObject val = GameManager.instance.gameInfo.team[__instance.defendingTeam].vehiclePrefab[(VehicleSpawnType)9];
if ((Object)(object)val == (Object)null)
{
result = false;
}
else
{
SpawnPoint spawnInit = ((Random.Range(0, 1) == 1) ? PickRandomEntry(SpawnPointNeighborManager.GetActiveNeighbors(spawn)) : spawn);
Vector3 val2 = default(Vector3);
RaycastHit val5 = default(RaycastHit);
for (int i = 0; i < (int)Mathf.Clamp(Mathf.Ceil((float)(heat / 2)), 1f, 4f); i++)
{
Vector3 helicopterLandingZone = spawnInit.GetHelicopterLandingZone();
Vector2 insideUnitCircle = Random.insideUnitCircle;
Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized;
((Vector3)(ref val2))..ctor(normalized.x, 0f, normalized.y);
Vector3 val3 = helicopterLandingZone + val2 * 1500f;
float num = ExfilHelicopter.CalculateFlightAltitudeLimit(val3, helicopterLandingZone);
val3.y = num + 120f;
Quaternion val4 = Quaternion.LookRotation(-val2);
Vehicle component = Object.Instantiate<GameObject>(val, val3, val4).GetComponent<Vehicle>();
component.maxHealth *= 2f;
component.health *= 2f;
bool nightMode = GameManager.instance.gameModeParameters.nightMode;
if (nightMode)
{
Vector3 position = ((Component)component.seats[0]).transform.position;
position.y -= 30f;
if (Physics.Raycast(new Ray(position, Vector3.up), ref val5, 50f, 4096))
{
GameObject val6 = Object.Instantiate<GameObject>(__instance.spotlightPrefab, ((Component)component).transform);
val6.transform.localRotation = Quaternion.identity;
val6.transform.position = ((RaycastHit)(ref val5)).point;
Vector3 localPosition = val6.transform.localPosition;
localPosition.x = 0f;
val6.transform.localPosition = localPosition;
SetPrivateVar<Light>("searchlight", __instance, val6.GetComponentInChildren<Light>());
SetPrivateVar<float>("searchlightDotFOV", __instance, Mathf.Cos(val6.GetComponentInChildren<Light>().spotAngle * ((float)Math.PI / 180f) / 2f));
}
}
float num2 = (nightMode ? 0f : 100f);
List<Actor> list = new List<Actor>();
for (int j = 0; j < component.seats.Count; j++)
{
list.Add(CreateVulture(__instance, val3, val4, j, component));
}
SetPrivateVar<Actor>("heliPilot", __instance, list[0]);
ActorController controller = list[0].controller;
((AiActorController)((controller is AiActorController) ? controller : null)).modifier.vehicleTopSpeedMultiplier = 2f;
Squad helicopterSquad = new Squad((IEnumerable<Actor>)list, spawnInit, new Order((OrderType)2, spawnInit, spawnInit, true), component, 0f);
helicopterSquad.allowRequestNewOrders = false;
helicopterSquad.allowAutoLeaveVehicle = true;
helicopterSquad.LandAtPosition(helicopterLandingZone);
ActorController obj = helicopterSquad.Leader();
((AiActorController)((obj is AiActorController) ? obj : null)).onDetectedEnemy = (DelOnDetectedEnemy)delegate
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
Order val7 = new Order((OrderType)0, (SpawnPoint)null, (SpawnPoint)null, true);
val7.targetSquad = __instance.attackerSquad;
helicopterSquad.AssignOrder(val7);
foreach (AiActorController aiMember in helicopterSquad.aiMembers)
{
if (((ActorController)aiMember).actor.IsSeated() && ((ActorController)aiMember).actor.seat.HasAnyMountedWeapons())
{
aiMember.SetAlert();
aiMember.DeactivateSlowTargetDetection();
}
}
};
component.onDestroyed = (DelOnDestroyed)delegate
{
if (!GetPrivateVar<bool>("heliPatrolHasLanded", __instance) && helicopterSquad.members.Count > 0)
{
foreach (AiActorController aiMember2 in helicopterSquad.aiMembers)
{
aiMember2.modifier.maxDetectionDistance = 500f;
aiMember2.modifier.ignoreFovCheck = true;
}
helicopterSquad.RequestNewOrder();
helicopterSquad.allowRequestNewOrders = true;
}
};
helicopterSquad.onLandingCompleted = (OnLandingCompletedDelegate)delegate
{
((MonoBehaviour)__instance).StartCoroutine(CustomOnLand(helicopterSquad, spawnInit, __instance));
};
((MonoBehaviour)__instance).StartCoroutine("NotifyHelicopter", (object)component);
spawnInit = PickRandomEntry(SpawnPointNeighborManager.GetActiveNeighbors(spawnInit));
}
result = false;
}
}
return result;
}
public static void SpawnAttackHeli(SpecOpsMode __instance, SpawnPoint spawn)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Expected O, but got Unknown
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Expected O, but got Unknown
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Expected O, but got Unknown
//IL_030b: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Expected O, but got Unknown
GameObject val = GameManager.instance.gameInfo.team[__instance.defendingTeam].vehiclePrefab[(VehicleSpawnType)4];
if ((Object)(object)val == (Object)null)
{
return;
}
Vector3 helicopterLandingZone = spawn.GetHelicopterLandingZone();
Vector2 insideUnitCircle = Random.insideUnitCircle;
Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized;
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(normalized.x, 0f, normalized.y);
Vector3 val3 = helicopterLandingZone + val2 * 1500f;
float num = ExfilHelicopter.CalculateFlightAltitudeLimit(val3, helicopterLandingZone);
val3.y = num + 80f;
Quaternion val4 = Quaternion.LookRotation(-val2);
Vehicle component = Object.Instantiate<GameObject>(val, val3, val4).GetComponent<Vehicle>();
bool nightMode = GameManager.instance.gameModeParameters.nightMode;
if (nightMode)
{
Vector3 position = ((Component)component.seats[0]).transform.position;
position.y -= 30f;
RaycastHit val5 = default(RaycastHit);
if (Physics.Raycast(new Ray(position, Vector3.up), ref val5, 50f, 4096))
{
GameObject val6 = Object.Instantiate<GameObject>(__instance.spotlightPrefab, ((Component)component).transform);
val6.transform.localRotation = Quaternion.identity;
val6.transform.position = ((RaycastHit)(ref val5)).point;
Vector3 localPosition = val6.transform.localPosition;
localPosition.x = 0f;
val6.transform.localPosition = localPosition;
SetPrivateVar<Light>("searchlight", __instance, val6.GetComponentInChildren<Light>());
SetPrivateVar<float>("searchlightDotFOV", __instance, Mathf.Cos(val6.GetComponentInChildren<Light>().spotAngle * ((float)Math.PI / 180f) / 2f));
}
}
float num2 = (nightMode ? 50f : 1000f);
List<Actor> list = new List<Actor>();
for (int i = 0; i < component.seats.Count; i++)
{
list.Add(CreateVulture(__instance, val3, val4, i, component));
}
SetPrivateVar<Actor>("heliPilot", __instance, list[0]);
ActorController controller = list[0].controller;
((AiActorController)((controller is AiActorController) ? controller : null)).modifier.vehicleTopSpeedMultiplier = 1f;
Squad helicopterSquad = new Squad((IEnumerable<Actor>)list, spawn, new Order((OrderType)2, spawn, spawn, true), component, 0f);
helicopterSquad.allowAutoLeaveVehicle = true;
ActorController controller2 = list[0].controller;
((AiActorController)((controller2 is AiActorController) ? controller2 : null)).onDetectedEnemy = (DelOnDetectedEnemy)delegate
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
Order val7 = new Order((OrderType)0, (SpawnPoint)null, (SpawnPoint)null, true);
val7.targetSquad = __instance.attackerSquad;
helicopterSquad.AssignOrder(val7);
foreach (AiActorController aiMember in helicopterSquad.aiMembers)
{
aiMember.SetAlert();
aiMember.DeactivateSlowTargetDetection();
}
};
component.onDestroyed = (DelOnDestroyed)delegate
{
foreach (AiActorController aiMember2 in helicopterSquad.aiMembers)
{
aiMember2.modifier.maxDetectionDistance = 500f;
aiMember2.modifier.ignoreFovCheck = false;
}
helicopterSquad.RequestNewOrder();
helicopterSquad.allowRequestNewOrders = true;
};
((MonoBehaviour)__instance).StartCoroutine("NotifyHelicopter", (object)component);
}
public static IEnumerator CustomOnLand(Squad squad, SpawnPoint spawn, SpecOpsMode __instance)
{
Vehicle squadVehicle = squad.squadVehicle;
squadVehicle.maxHealth /= 2f;
Vehicle squadVehicle2 = squad.squadVehicle;
squadVehicle2.health /= 2f;
bool flag = (int)squad.order.type == 0;
List<ActorController> leavingMembers = ((IEnumerable<ActorController>)squad.aiMembers.Where((AiActorController a) => !((ActorController)a).actor.IsDriver() && !((ActorController)a).actor.seat.HasAnyMountedWeapons())).ToList();
Squad squad2 = squad.SplitSquad(leavingMembers);
int i2 = squad2.members.Count;
for (int i = 0; i < heat; i++)
{
i2++;
squad2.AddMember(CreateVulture(__instance, squad2.members[0].actor.GetPosition(), Quaternion.identity, i2, null).controller);
}
if (__instance.attackingTeam == 0)
{
IngameDialog.PrintActorText("p advisor tense", "Beware, a VULTURE squad has landed, TALON", "", 0f, (AudioClip)null, false);
IngameDialog.HideAfter(5f);
}
else
{
IngameDialog.PrintActorText("p unknown", "A VULTURE squad has landed, RAVEN", "", 0f, (AudioClip)null, false);
IngameDialog.HideAfter(5f);
}
squad2.allowRequestNewOrders = true;
squad2.autoAssignNewOrders = true;
Order order = new Order((OrderType)0, (SpawnPoint)null, (SpawnPoint)null, true);
order.targetSquad = __instance.attackerSquad;
squad2.AssignOrder(order);
squad2.ExitVehicle();
foreach (AiActorController aiActorController in squad2.aiMembers)
{
aiActorController.modifier.maxDetectionDistance = (flag ? 500f : 200f);
}
yield return (object)new WaitForSeconds(2f);
try
{
squad.TakeOff();
AiActorController aiActorController2 = squad.aiMembers[0];
aiActorController2.modifier.vehicleTopSpeedMultiplier = 0.3f;
aiActorController2.targetFlightHeight = 40f;
}
catch (Exception exception)
{
Debug.LogException(exception);
}
}
}
private static TimedAction alertCooldown = new TimedAction(0.05f, false);
public static void Prefix(Weapon __instance)
{
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Invalid comparison between Unknown and I4
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
if (!GameCheck())
{
return;
}
GameModeBase activeGameMode = GameModeBase.activeGameMode;
SpecOpsMode val = (SpecOpsMode)(object)((activeGameMode is SpecOpsMode) ? activeGameMode : null);
AudioSource component = ((Component)__instance).GetComponent<AudioSource>();
if (!((Object)(object)__instance.user != (Object)null) || component.spatialBlend != 1f)
{
return;
}
float num = 0.1f;
num += ((((Hurtable)__instance.user).team == val.attackingTeam) ? 0.4f : 0.2f);
num += (__instance.configuration.loud ? 1f : 0f);
num += __instance.configuration.cooldown / 2f;
num += (__instance.IsMountedWeapon() ? 1f : 0f);
num += (((int)__instance.projectileArmorRating == 2) ? 0.5f : 0f);
if (num < 1f)
{
if (!((TimedAction)(ref alertCooldown)).Done())
{
return;
}
((TimedAction)(ref alertCooldown)).Start();
}
AnimationCurve customCurve = component.GetCustomCurve((AudioSourceCurveType)0);
((MonoBehaviour)instance).StartCoroutine(SemiAlertActors(num, __instance.user.Position(), customCurve, val.defendingTeam));
}
public static IEnumerator SemiAlertActors(float detectionPower, Vector3 point, AnimationCurve curve, int team)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
foreach (Actor actor in ActorManager.AliveActorsOnTeam(team))
{
if (curve.Evaluate(Vector3.Distance(point, actor.Position())) > 0.5f && actor.aiControlled)
{
ActorController controller2 = actor.controller;
AiActorController controller = (AiActorController)(object)((controller2 is AiActorController) ? controller2 : null);
if (!((ActorController)controller).IsAlert() && controller.slowTargetDetection)
{
controller.targetDetectionProgress += detectionPower / 10f;
}
}
}
yield break;
}
}
public static SpecOpsPlus instance;
public static int heat;
public static ConfigEntry<bool> RailgunSquad;
public static ConfigEntry<int> ExtraPatrolGroupCount;
public static ConfigEntry<int> InfantryPatrolCountMultiplier;
public static ConfigEntry<int> FlareDelay;
public static ConfigEntry<int> PatrolActorCount;
public static ConfigEntry<bool> HeatEnabled;
private static int HeatUp()
{
heat++;
return heat;
}
private void Awake()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
instance = this;
((BaseUnityPlugin)this).Logger.LogDebug((object)"specopsplus: Loading!");
Harmony val = new Harmony("specopsplus");
val.PatchAll();
RailgunSquad = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "Railgun Squad", true, "enable/disable railgun squad");
ExtraPatrolGroupCount = ((BaseUnityPlugin)this).Config.Bind<int>("General.Toggles", "Extra Patrol Group Count", 0, "patrols spawn in groups of one of each patrol type, ie: one infantry patrol, one car patrol, one boat patrol");
InfantryPatrolCountMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("General.Toggles", "Extra Patrol Group Count", 3, "in each group, spawn an extra patrol");
FlareDelay = ((BaseUnityPlugin)this).Config.Bind<int>("General.Toggles", "Flare Delay", 80, "self explanatory. best kept between 60-100");
PatrolActorCount = ((BaseUnityPlugin)this).Config.Bind<int>("General.Toggles", "Patrol Actor Count", 4, "keep between 3-7");
HeatEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "Heat Enabled", true, "heat system and vulture squad system");
string[] value = new string[5] { "Those idiots. Why did we ever send them in", "Who's idea was this? \nwhat the hell are the higherups thinking", "augh", ">:(", "hahaha imagine dying" };
string[] value2 = new string[5] { "They probably weren't swift, nor quiet", "Well, this was a disappointment!", "Which of you numbnuts let us down?", "rip", "unfortunate..." };
typeof(SpecOpsDialog).GetField("TEAM_WIPE_LINES", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, value);
typeof(SpecOpsDialog).GetField("TEAM_WIPE_LINES_RED", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, value2);
}
public static T GetPrivateVar<T>(string varname, object instance)
{
return (T)instance.GetType().GetField(varname, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(instance);
}
public static object InvokeMethod(object instance, string varname, object[] param)
{
return instance.GetType().GetMethod(varname, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(instance, param);
}
public static void SetPrivateVar<T>(string varname, object instance, object value)
{
instance.GetType().GetField(varname, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(instance, value);
}
public static bool GameCheck()
{
return IngameNetManager.instance.IsHost && GameModeBase.activeGameMode is SpecOpsMode;
}
public static MethodInfo GetMethodByName(object obj, string methodName)
{
return obj.GetType().GetMethods().FirstOrDefault((MethodInfo m) => m.Name == methodName);
}
public static void AssignWeaponDifficulty(Weapon weapon, Difficulty infantry, Difficulty infantryGroup, Difficulty groundVehicle, Difficulty air, Difficulty airFastMover)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Invalid comparison between Unknown and I4
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Invalid comparison between Unknown and I4
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Invalid comparison between Unknown and I4
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Invalid comparison between Unknown and I4
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
if ((int)weapon.configuration.diffInfantry == 0)
{
weapon.configuration.diffInfantry = infantry;
}
if ((int)weapon.configuration.diffInfantryGroup == 0)
{
weapon.configuration.diffInfantryGroup = infantryGroup;
}
if ((int)weapon.configuration.diffGroundVehicles == 0)
{
weapon.configuration.diffGroundVehicles = groundVehicle;
}
if ((int)weapon.configuration.diffAir == 0)
{
weapon.configuration.diffAir = air;
}
if ((int)weapon.configuration.diffAirFastMover == 0)
{
weapon.configuration.diffAirFastMover = airFastMover;
}
}
public static void AssignWeaponDifficultyTrivial(Weapon weapon)
{
AssignWeaponDifficulty(weapon, (Difficulty)1, (Difficulty)1, (Difficulty)1, (Difficulty)1, (Difficulty)1);
}
public static Actor CreateVulture(SpecOpsMode specOps, Vector3 vector, Quaternion rotation, int i, Vehicle vehicle)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
Actor val = ActorManager.instance.CreateAIActor(specOps.defendingTeam);
LoadoutSet val2 = new LoadoutSet();
LoadoutPickStrategy val3 = new LoadoutPickStrategy((LoadoutType)((Random.Range(0, 1) == 1) ? 1 : 2), (Distance)3);
val2.primary = WeaponManager.GetAiWeaponPrimary(val3, ((Hurtable)val).team);
val2.secondary = WeaponManager.GetAiWeaponSecondary(val3, ((Hurtable)val).team);
val2.gear1 = WeaponManager.GetAiWeaponAllGear(val3, ((Hurtable)val).team);
val2.gear2 = WeaponManager.GetAiWeaponAllGear(val3, ((Hurtable)val).team);
val2.gear3 = WeaponManager.GetAiWeaponAllGear(val3, ((Hurtable)val).team);
bool flag = val2.primary != null && val2.primary.sourceMod.isOfficialContent;
bool flag2 = false;
if (flag)
{
val2.primary = ((Random.Range(0, 6) > 1) ? WeaponManager.GetWeaponEntryByName("PATRIOT TAC", (ModInformation)null) : WeaponManager.GetWeaponEntryByName("PATRIOT GL", (ModInformation)null));
}
if (heat > 4 && RailgunSquad.Value && Random.Range(0, 1) == 1)
{
val2.primary = WeaponManager.GetWeaponEntryByName("RAILGUN", (ModInformation)null);
flag2 = true;
}
val.SpawnAt(vector, rotation, val2);
val.name = "VULTURE-" + i;
if ((Object)(object)vehicle != (Object)null)
{
val.EnterSeat(vehicle.seats[i], false);
}
Weapon[] weapons = val.weapons;
foreach (Weapon val4 in weapons)
{
AssignWeaponDifficultyTrivial(val4);
if (!val4.HasAnySubWeapons())
{
continue;
}
foreach (Weapon alternativeWeapon in val4.alternativeWeapons)
{
AssignWeaponDifficultyTrivial(alternativeWeapon);
}
}
if (flag2)
{
val.weapons[0].configuration.cooldown = 0.1f;
val.weapons[0].configuration.reloadTime = 0.1f;
}
ActorController controller = val.controller;
AiActorController val5 = (AiActorController)(object)((controller is AiActorController) ? controller : null);
val5.ActivateSlowTargetDetection(0.5f);
val5.targetFlightHeight = 80f;
val5.modifier.canSprint = true;
val5.skill = (SkillLevel)3;
Actor actor = ((ActorController)val5).actor;
actor.maxHealth *= 2f;
Actor actor2 = ((ActorController)val5).actor;
actor2.maxBalance *= 10f;
Actor actor3 = ((ActorController)val5).actor;
actor3.speedMultiplier *= 1.6f;
val5.SetNotAlert(false);
if (ActorManager.instance.hasDefaultSkin[specOps.attackingTeam])
{
ActorSkin modelSkin = (GameManager.GameParameters().nightMode ? specOps.talonSkinNight : specOps.talonSkinDay);
((ActorController)val5).actor.SetModelSkin(modelSkin);
}
val5.modifier.maxDetectionDistance = 1E+10f;
val5.modifier.ignoreFovCheck = true;
return val;
}
public static T PickRandomEntry<T>(List<T> collection)
{
int index = Random.Range(0, collection.Count);
return collection[index];
}
}