-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: multiple offraid_position by exfils
+ integration with Jehree's Interactable Exfils API
- Loading branch information
Trap
committed
Dec 22, 2024
1 parent
f43d8a8
commit 0fa13b9
Showing
23 changed files
with
517 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using SPT.Common.Http; | ||
using Newtonsoft.Json; | ||
|
||
namespace PTT.Data; | ||
|
||
/** | ||
* Request | ||
**/ | ||
public class ExfilsTargetsRequest | ||
{ | ||
public string locationId; | ||
} | ||
|
||
/** | ||
* Response | ||
**/ | ||
public class ExfilsTargetsResponse | ||
{ | ||
// indexed by exit name | ||
public Dictionary<string, List<ExfilTarget>> data; | ||
} | ||
|
||
public class ExfilTarget | ||
{ | ||
public bool isTransit; | ||
public string transitMapId; // transit only | ||
public string transitSpawnPointId; // transit only | ||
public string offraidPosition; // empty on transit | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using SPT.Common.Http; | ||
using Newtonsoft.Json; | ||
|
||
using PTT.Data; | ||
|
||
namespace PTT.Helpers; | ||
|
||
|
||
internal static class HttpRequest | ||
{ | ||
private const string EXFILS_TARGETS_PATH = "/PathToTarkov/ExfilsTargets"; | ||
|
||
static public ExfilsTargetsResponse FetchExfilsTargets(string locationId) | ||
{ | ||
string jsonRequest = JsonConvert.SerializeObject(new ExfilsTargetsRequest { locationId = locationId }); | ||
string jsonResponse = RequestHandler.PostJson(EXFILS_TARGETS_PATH, jsonRequest); | ||
var response = JsonConvert.DeserializeObject<ExfilsTargetsResponse>(jsonResponse); | ||
return response ?? throw new Exception("FetchExfilsTargets: response is null"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using EFT; | ||
|
||
namespace PTT.Utils; | ||
namespace PTT.Helpers; | ||
|
||
internal class Trader | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Comfort.Common; | ||
using EFT; | ||
using SPT.Reflection.Patching; | ||
using System.Reflection; | ||
using PTT.Services; | ||
|
||
namespace PTT.Patches; | ||
|
||
internal class OnGameStartedPatch() : ModulePatch | ||
{ | ||
protected override MethodBase GetTargetMethod() | ||
{ | ||
return typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted)); | ||
} | ||
|
||
[PatchPrefix] | ||
public static bool PatchPrefix() | ||
{ | ||
var exfilsTargetsService = Singleton<ExfilsTargetsService>.Instance; | ||
|
||
if (exfilsTargetsService != null) | ||
{ | ||
exfilsTargetsService.Init(); | ||
} | ||
else | ||
{ | ||
Logger.LogError("[PTT] ExfilsTargetsService instance not found"); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using EFT; | ||
using EFT.Interactive; | ||
using Comfort.Common; | ||
using BepInEx.Logging; | ||
using Fika.Core.Coop.GameMode; | ||
using Fika.Core.Coop.Players; | ||
using System.Reflection; | ||
using Fika.Core.Coop.Components; | ||
|
||
namespace PTT.Services; | ||
|
||
public static class CustomExfilService | ||
{ | ||
public static bool FikaExtractTo(ExfiltrationPoint exfiltrationPoint, string customExfilName) | ||
{ | ||
// BaseLocalGame<EftGamePlayerOwner> localGame = Singleton<AbstractGame>.Instance as BaseLocalGame<EftGamePlayerOwner>; | ||
// Player player = Singleton<GameWorld>.Instance.MainPlayer; | ||
|
||
CoopGame coopGame = (CoopGame)Singleton<IFikaGame>.Instance; | ||
CoopPlayer coopPlayer = (CoopPlayer)Singleton<GameWorld>.Instance.MainPlayer; | ||
|
||
if (coopGame == null || coopPlayer == null) | ||
{ | ||
return false; | ||
} | ||
|
||
// if (CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler)) | ||
// { | ||
// // coopHandler.ExtractedPlayers.Add(coopPlayer.NetId); | ||
// // coopHandler.Players.Remove(coopPlayer.NetId); | ||
|
||
// // coopGame.ExitLocation = exfiltrationPoint.Settings.Name; | ||
// return true; | ||
// } | ||
|
||
coopGame.ExitLocation = customExfilName; | ||
coopGame.Extract(coopPlayer, exfiltrationPoint, null); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using EFT; | ||
using Comfort.Common; | ||
using EFT.Interactive; | ||
using Fika.Core.Coop.GameMode; | ||
using Fika.Core.Coop.Players; | ||
|
||
namespace PTT.Services; | ||
|
||
public static class CustomTransitService | ||
{ | ||
public static bool TransitTo(string locationId, string exitName) | ||
{ | ||
LocalGame localGame = Singleton<AbstractGame>.Instance as LocalGame; | ||
Player player = Singleton<GameWorld>.Instance.MainPlayer; | ||
if (localGame == null || player == null) return false; | ||
if (!TarkovApplication.Exist(out TarkovApplication tarkovApplication)) return false; | ||
if (!TransitControllerAbstractClass.Exist(out GClass1642 vanillaTransitController)) return false; | ||
|
||
// 1. set transitionStatus | ||
var raidSettings = tarkovApplication.CurrentRaidSettings; | ||
var transitionStatus = new GStruct136(locationId, false, raidSettings.Side, raidSettings.RaidMode, raidSettings.SelectedDateTime); | ||
tarkovApplication.transitionStatus = transitionStatus; | ||
|
||
// 2. add the transitPayload in alreadyTransits | ||
// this will avoid an error when calling the `LocalRaidEnded` task | ||
string transitHash = Guid.NewGuid().ToString(); | ||
GClass1926 transitPayload = new GClass1926 | ||
{ | ||
hash = transitHash, | ||
playersCount = 1, // TODO: fika support ? | ||
ip = "", | ||
location = locationId, | ||
profiles = [], // TODO: fika support ? | ||
transitionRaidId = raidSettings.KeyId, // pretty sure it's not correct but it seems to not cause any issue | ||
raidMode = raidSettings.RaidMode, | ||
side = (player.Side == EPlayerSide.Savage) ? ESideType.Savage : ESideType.Pmc, | ||
dayTime = raidSettings.SelectedDateTime | ||
}; | ||
vanillaTransitController.alreadyTransits.Add(player.ProfileId, transitPayload); | ||
|
||
// 3. stop the game | ||
localGame.Stop(player.ProfileId, ExitStatus.Transit, exitName, 0f); | ||
|
||
return true; | ||
} | ||
|
||
public static bool FikaTransitTo(ExfiltrationPoint exfiltrationPoint) | ||
{ | ||
// BaseLocalGame<EftGamePlayerOwner> localGame = Singleton<AbstractGame>.Instance as BaseLocalGame<EftGamePlayerOwner>; | ||
// Player player = Singleton<GameWorld>.Instance.MainPlayer; | ||
|
||
// CoopGame coopGame = (CoopGame)Singleton<IFikaGame>.Instance; | ||
// CoopPlayer coopPlayer = (CoopPlayer)Singleton<GameWorld>.Instance.MainPlayer; | ||
|
||
// if (coopGame == null || coopPlayer == null) | ||
// { | ||
// return false; | ||
// } | ||
|
||
// coopGame.Extract(coopPlayer, exfiltrationPoint); | ||
return true; | ||
} | ||
} |
Oops, something went wrong.