diff --git a/.gitignore b/.gitignore index 3646018..5b48ec9 100644 --- a/.gitignore +++ b/.gitignore @@ -20,8 +20,8 @@ package-lock.json desktop.ini ## Archive -Archive/CWX-AirDrop/bin -Archive/CWX-AirDrop/obj +Old/CWX-AirDrop/bin +Old/CWX-AirDrop/obj ## Live Live/CWX-BushWhacker/BushWhacker/bin diff --git a/Old/CWX-AirDrop/AirDrop.csproj b/Old/CWX-AirDrop/AirDrop.csproj new file mode 100644 index 0000000..2aeb0f5 --- /dev/null +++ b/Old/CWX-AirDrop/AirDrop.csproj @@ -0,0 +1,36 @@ + + + + net472 + aki-secret + 2.0.0 + + + + + shared\Aki.Common.dll + + + shared\Aki.Reflection.dll + + + shared\Assembly-CSharp.dll + + + shared\BepInEx.dll + + + shared\Comfort.dll + + + shared\UnityEngine.dll + + + shared\UnityEngine.AudioModule.dll + + + shared\UnityEngine.CoreModule.dll + + + + diff --git a/Old/CWX-AirDrop/AirDrop.sln b/Old/CWX-AirDrop/AirDrop.sln new file mode 100644 index 0000000..d8f4fb4 --- /dev/null +++ b/Old/CWX-AirDrop/AirDrop.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32014.148 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirDrop", "AirDrop.csproj", "{8E53AEF2-76DE-4BDC-917F-C1F0783E9D92}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8E53AEF2-76DE-4BDC-917F-C1F0783E9D92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E53AEF2-76DE-4BDC-917F-C1F0783E9D92}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E53AEF2-76DE-4BDC-917F-C1F0783E9D92}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E53AEF2-76DE-4BDC-917F-C1F0783E9D92}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {423EB4AC-2E05-43C2-BE85-903C2FFEBD61} + EndGlobalSection +EndGlobal diff --git a/Old/CWX-AirDrop/Patch.cs b/Old/CWX-AirDrop/Patch.cs new file mode 100644 index 0000000..2978814 --- /dev/null +++ b/Old/CWX-AirDrop/Patch.cs @@ -0,0 +1,26 @@ +using Aki.Reflection.Patching; +using EFT; +using System.Reflection; +using System; + +namespace AirDrop +{ + public class Patch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + var result = typeof(GameWorld).GetMethod("OnGameStarted", BindingFlags.Public | BindingFlags.Instance); + + return result; + } + [PatchPostfix] + public static void PatchPostFix() + { + int chance = AirDrop.RandomChanceGen(1, 99); + if (chance <= AirDrop.dropChance) + { + AirDrop.InitObjects(); + } + } + } +} diff --git a/Old/CWX-AirDrop/Program.cs b/Old/CWX-AirDrop/Program.cs new file mode 100644 index 0000000..bd4b4a9 --- /dev/null +++ b/Old/CWX-AirDrop/Program.cs @@ -0,0 +1,233 @@ +using BepInEx; +using Comfort.Common; +using EFT; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using System.Reflection; +using System; +using AirdropLogic2Class = GClass778; // wont be needed once we move to latest modules + +namespace AirDrop +{ + [BepInPlugin("com.aki.secret", "aki-secret", "1.0.0")] + public class AirDrop : BaseUnityPlugin + { + public static GameWorld gameWorld; + public static SynchronizableObject planes; // first plane in list which is always called: IL76MD-90 + public static SynchronizableObject boxes; // first box in the list which is always called: scontainer_airdrop_box_04 + public static bool planesEnabled = false; // used to check if the plane is currently visible on the map and Init'd + public static bool boxesEnabled = false; // used to check if the box is currently visible on the map and Init'd + public static int amountDropped; // used to make sure the EnableObjects.Start(); on line60 does not keep repeating + public static int dropChance = 20; // used to check if the airdrop can spawn from chance + public static List airdropPoints; // list of airdrop points on the map loaded + public static AirdropPoint randomAirdropPoint; // one random point picked to drop box too + public static int boxObjId = 10; // random number selected thats not the same as the plane can be + + public static Vector3 boxPosition; // randomAirdropPoints Position Coords (used as a targetPosition) + public static Vector3 planeStartPosition; // planes starting position which can be 4 different ones definded in EnableObjects.PlaneStartGen() + public static Vector3 planeStartRotation; // planes starting rotation which can be 4 different ones from above (might not be needed as we rotate to target) + public static int planeObjId; // range from 1 - 4 using RandomChanceGen, used planeObjId as a spawnpoint number as well as what EFT needs to init + public static float planeEndPointPositive = 3000f; + public static float planeEndPointNegative = -3000f; + public static float defaultDropHeight = 400f; + + public static float timer; // starting timer + public static float timeToDrop; // time when the plane should start moving in seconds + + public static bool doNotRun = false; // used to determine if map has planes and drops, line 130 + + // TODO: + // once server is converted to TS attach to server endpoint for chances and timeToDrop + // ask for advice on refactor, make things easier to read/better + + public void Start() + { + new Patch().Enable(); + } + + public void FixedUpdate() // FixedUpdate executes 50 times per second. https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html + { + if (gameWorld == null) + { + return; + } + + timer += 0.02f; + + if (timer >= timeToDrop && !planesEnabled && amountDropped != 1 && !doNotRun) + { + EnableObjects.Start(); + } + + if (timer >= timeToDrop && planesEnabled && !doNotRun) + { + planes.transform.Translate(Vector3.forward, Space.Self); // transform foward on local rotation using Space.Self, vector3.forward moves forward 1f per run + + switch (AirDrop.planeObjId) + { + case 1: + if (planes.transform.position.z >= planeEndPointPositive && planesEnabled) // spawn 1 moves along Z axis and goes in the positive direction, + { + DisableObjects.DisablePlanes(planes); + } + + if (planes.transform.position.z >= randomAirdropPoint.transform.position.z && !boxesEnabled) + { + EnableObjects.InitDrop(boxes); + } + break; + case 2: + if (planes.transform.position.x >= planeEndPointPositive && planesEnabled) // spawn 2 moves along x axis and goes in the positive direction + { + DisableObjects.DisablePlanes(planes); + } + + if (planes.transform.position.x >= randomAirdropPoint.transform.position.x && !boxesEnabled) + { + EnableObjects.InitDrop(boxes); + } + break; + case 3: + if (planes.transform.position.z <= planeEndPointNegative && planesEnabled) // spawn 3 moves along z axis and goes in the negative direction + { + DisableObjects.DisablePlanes(planes); + } + + if (planes.transform.position.z <= randomAirdropPoint.transform.position.z && !boxesEnabled) + { + EnableObjects.InitDrop(boxes); + } + break; + case 4: + if (planes.transform.position.x <= planeEndPointNegative && planesEnabled) // spawn 2 moves along x axis and goes in the negative direction + { + DisableObjects.DisablePlanes(planes); + } + + if (planes.transform.position.x <= randomAirdropPoint.transform.position.x && !boxesEnabled) + { + EnableObjects.InitDrop(boxes); + } + break; + } + } + } + + public static int RandomChanceGen(int minValue, int maxValue) + { + System.Random chance = new System.Random(); + return chance.Next(minValue, maxValue); + } + + public static void InitObjects() + { + // this method sets to default, checks if indoors map, gets new objects + boxesEnabled = false; + planesEnabled = false; + doNotRun = false; + timer = 0f; + amountDropped = 0; + + gameWorld = Singleton.Instance; + var player = gameWorld.RegisteredPlayers[0]; + if (player != null) + { + if (player.Location.Contains("factory") || player.Location.Contains("laboratory") || player.Location.Contains("hideout")) + { + doNotRun = true; // will stay true till next map load + return; + } + } + AirDrop.timeToDrop = RandomChanceGen(60, 900); + planes = LocationScene.GetAll().First(x => x.name.Contains("IL76MD-90")); + boxes = LocationScene.GetAll().First(x => x.name.Contains("scontainer_airdrop_box_04")); + airdropPoints = LocationScene.GetAll().ToList(); + randomAirdropPoint = airdropPoints.OrderBy(_ => Guid.NewGuid()).FirstOrDefault(); + } + } + + public static class EnableObjects + { + public static void Start() + { + if (AirDrop.boxes != null) + { + AirDrop.boxPosition = AirDrop.randomAirdropPoint.transform.position; + AirDrop.boxPosition.y = AirDrop.defaultDropHeight; + } + + if (AirDrop.planes != null) + { + PlaneStartGen(); + } + } + + public static void PlaneStartGen() + { + AirDrop.planeObjId = AirDrop.RandomChanceGen(1, 4); + + switch (AirDrop.planeObjId) + { + case 1: + AirDrop.planeStartPosition = new Vector3(0, AirDrop.defaultDropHeight, -3000); + AirDrop.planeStartRotation = new Vector3(0, 0, 0); + break; + case 2: + AirDrop.planeStartPosition = new Vector3(-3000, AirDrop.defaultDropHeight, 0); + AirDrop.planeStartRotation = new Vector3(0, 90, 0); + break; + case 3: + AirDrop.planeStartPosition = new Vector3(0, AirDrop.defaultDropHeight, 3000); + AirDrop.planeStartRotation = new Vector3(0, 180, 0); + break; + case 4: + AirDrop.planeStartPosition = new Vector3(3000, AirDrop.defaultDropHeight, 0); + AirDrop.planeStartRotation = new Vector3(0, 270, 0); + break; + } + + InitPlane(AirDrop.planes); + } + + public static void InitPlane(SynchronizableObject plane) + { + AirDrop.planesEnabled = true; + plane.TakeFromPool(); + plane.Init(AirDrop.planeObjId, AirDrop.planeStartPosition, AirDrop.planeStartRotation); + plane.transform.LookAt(AirDrop.boxPosition); // turns the plane to look at the box drop point + plane.ManualUpdate(0); + + var sound = plane.GetComponentInChildren(); + sound.volume = 1f; + sound.dopplerLevel = 1; + sound.Play(); + } + + public static void InitDrop(SynchronizableObject box) + { + // this is basically a copy of the debugAirdrop script BSG has in the syncProcess + object[] passToList = new object[1]; + passToList[0] = SynchronizableObjectType.AirDrop; + var syncProcess = AirDrop.gameWorld.SynchronizableObjectLogicProcessor; + syncProcess.GetType().GetMethod("method_9", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(syncProcess, passToList); + // if the drop is not in list_0, the box will not move, the above adds the box to that list + + AirDrop.boxesEnabled = true; + box.SetLogic(new AirdropLogic2Class()); + box.ReturnToPool(); + box.TakeFromPool(); + box.Init(AirDrop.boxObjId, AirDrop.boxPosition, Vector3.zero); + } + } + + public static class DisableObjects + { + public static void DisablePlanes(SynchronizableObject plane) + { + AirDrop.planesEnabled = false; + AirDrop.amountDropped = 1; + plane.ReturnToPool(); + } + } +} diff --git a/Old/CWX-AirDrop/README.md b/Old/CWX-AirDrop/README.md new file mode 100644 index 0000000..2de3191 --- /dev/null +++ b/Old/CWX-AirDrop/README.md @@ -0,0 +1,14 @@ +# AirDrops +## EFT - SPT-AKI +### CURRENT AKI VERSION: 2.3.1 +### GAMEVERSION: 0.12.12.17349 +### USING BEPINEX + +### 1 plane and 1 box spawns +### 4 different locations for the plane to come from (north, east, south, west) +### uses BSG's spawn points and is random to which it would use +### lootable +### has % chance to spawn +### has timer to spawn too ( could be made a range for randomness ) +### wont load drops for factory day or night, labs and hideout + diff --git a/Old/CWX-AirDrop/shared/Aki.Common.dll b/Old/CWX-AirDrop/shared/Aki.Common.dll new file mode 100644 index 0000000..5de967d Binary files /dev/null and b/Old/CWX-AirDrop/shared/Aki.Common.dll differ diff --git a/Old/CWX-AirDrop/shared/Aki.Reflection.dll b/Old/CWX-AirDrop/shared/Aki.Reflection.dll new file mode 100644 index 0000000..5b93eeb Binary files /dev/null and b/Old/CWX-AirDrop/shared/Aki.Reflection.dll differ diff --git a/Old/CWX-AirDrop/shared/Assembly-CSharp.dll b/Old/CWX-AirDrop/shared/Assembly-CSharp.dll new file mode 100644 index 0000000..aa2d4dc Binary files /dev/null and b/Old/CWX-AirDrop/shared/Assembly-CSharp.dll differ diff --git a/Old/CWX-AirDrop/shared/BepInEx.dll b/Old/CWX-AirDrop/shared/BepInEx.dll new file mode 100644 index 0000000..8aedff0 Binary files /dev/null and b/Old/CWX-AirDrop/shared/BepInEx.dll differ diff --git a/Old/CWX-AirDrop/shared/Comfort.dll b/Old/CWX-AirDrop/shared/Comfort.dll new file mode 100644 index 0000000..51bee17 Binary files /dev/null and b/Old/CWX-AirDrop/shared/Comfort.dll differ diff --git a/Old/CWX-AirDrop/shared/UnityEngine.AudioModule.dll b/Old/CWX-AirDrop/shared/UnityEngine.AudioModule.dll new file mode 100644 index 0000000..04a092a Binary files /dev/null and b/Old/CWX-AirDrop/shared/UnityEngine.AudioModule.dll differ diff --git a/Old/CWX-AirDrop/shared/UnityEngine.CoreModule.dll b/Old/CWX-AirDrop/shared/UnityEngine.CoreModule.dll new file mode 100644 index 0000000..7d585db Binary files /dev/null and b/Old/CWX-AirDrop/shared/UnityEngine.CoreModule.dll differ diff --git a/Old/CWX-AirDrop/shared/UnityEngine.dll b/Old/CWX-AirDrop/shared/UnityEngine.dll new file mode 100644 index 0000000..6ff1d0f Binary files /dev/null and b/Old/CWX-AirDrop/shared/UnityEngine.dll differ diff --git a/README.md b/README.md index db880da..5975bd7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # All in One CWX-Mods ## currently for EFT - SPT-AKI. - 2.3.1 -### Archive +### Old - CWX-AirDrop ### Live