Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Left stance sync and sandbox bot spawn fix from AKI #141

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Source/AkiSupport/Custom/FixBrokenSpawnOnSandboxPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Comfort.Common;
using EFT;
using HarmonyLib;
using StayInTarkov;
using System.Linq;
using System.Reflection;
using UnityEngine;

namespace Aki.Custom.Patches
{
/// <summary>
/// Fixes the map sandbox from only spawning 1 bot at start of game as well as fixing no spawns till all bots are dead.
/// Remove once BSG decides to fix their map
/// </summary>
public class FixBrokenSpawnOnSandboxPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(GameWorld), nameof(GameWorld.OnGameStarted));
}

[PatchPrefix]
private static void PatchPrefix()
{
var gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld == null)
{
return;
}

var playerLocation = gameWorld.MainPlayer.Location;

if (playerLocation == "Sandbox")
{
Object.FindObjectsOfType<BotZone>().ToList().First(x => x.name == "ZoneSandbox").MaxPersonsOnPatrol = 10;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,7 @@
, player.MovementContext.PoseLevel
, player.MovementContext.IsSprintEnabled
, player.InputDirection
, player.MovementContext.LeftStanceController.LastAnimValue
, playerHealth
, player.Physical.SerializationStruct
, player.MovementContext.BlindFire
Expand All @@ -1325,7 +1326,7 @@

public BaseLocalGame<GamePlayerOwner> LocalGameInstance { get; internal set; }

int GuiX = 10;

Check warning on line 1329 in Source/Coop/Components/CoopGameComponents/CoopGameComponent.cs

View workflow job for this annotation

GitHub Actions / Build-SIT (Debug)

The field 'CoopGameComponent.GuiX' is assigned but its value is never used
int GuiWidth = 400;

//public const int PING_LIMIT_HIGH = 125;
Expand All @@ -1338,9 +1339,9 @@
public bool ServerHasStopped { get; set; }
private bool ServerHasStoppedActioned { get; set; }

GUIStyle middleLabelStyle;

Check warning on line 1342 in Source/Coop/Components/CoopGameComponents/CoopGameComponent.cs

View workflow job for this annotation

GitHub Actions / Build-SIT (Debug)

Field 'CoopGameComponent.middleLabelStyle' is never assigned to, and will always have its default value null
GUIStyle middleLargeLabelStyle;

Check warning on line 1343 in Source/Coop/Components/CoopGameComponents/CoopGameComponent.cs

View workflow job for this annotation

GitHub Actions / Build-SIT (Debug)

The field 'CoopGameComponent.middleLargeLabelStyle' is never used
GUIStyle normalLabelStyle;

Check warning on line 1344 in Source/Coop/Components/CoopGameComponents/CoopGameComponent.cs

View workflow job for this annotation

GitHub Actions / Build-SIT (Debug)

The field 'CoopGameComponent.normalLabelStyle' is never used

//void OnGUI()
//{
Expand Down
6 changes: 5 additions & 1 deletion Source/Coop/NetworkPacket/PlayerStatePacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace StayInTarkov.Coop.NetworkPacket
{
public sealed class PlayerStatePacket : BasePlayerPacket, INetSerializable

Check warning on line 17 in Source/Coop/NetworkPacket/PlayerStatePacket.cs

View workflow job for this annotation

GitHub Actions / Build-SIT (Debug)

'PlayerStatePacket' overrides Object.Equals(object o) but does not override Object.GetHashCode()
{
public EPlayerState State { get; set; }
public float Tilt { get; set; }
Expand All @@ -35,14 +35,15 @@
public Vector2 InputDirection { get; set; }
public int Blindfire { get; set; }
public float LinearSpeed { get; set; }
public bool LeftStance { get; set; }

public PlayerHealthPacket PlayerHealth { get; set; }

public PlayerStatePacket() { }

public PlayerStatePacket(string profileId, Vector3 position, Vector2 rotation, Vector3 headRotation, Vector2 movementDirection,
EPlayerState state, float tilt, int step, int animatorStateIndex, float characterMovementSpeed,
bool isProne, float poseLevel, bool isSprinting, Vector2 inputDirection
bool isProne, float poseLevel, bool isSprinting, Vector2 inputDirection, bool leftStance
, PlayerHealthPacket playerHealth, Physical.PhysicalStamina stamina, int blindFire, float linearSpeed)
: base(new string(profileId.ToCharArray()), "PlayerState")
{
Expand Down Expand Up @@ -72,6 +73,7 @@
Stamina = stamina;
Blindfire = blindFire;
LinearSpeed = linearSpeed;
LeftStance = leftStance;
}

public override byte[] Serialize()
Expand All @@ -94,6 +96,7 @@
writer.Write(IsSprinting);
PhysicalUtils.Serialize(writer, Stamina);
Vector2Utils.Serialize(writer, InputDirection);
writer.Write(LeftStance);
writer.Write(Blindfire);
writer.Write(LinearSpeed);
writer.Write(TimeSerializedBetter);
Expand Down Expand Up @@ -145,6 +148,7 @@
IsSprinting = reader.ReadBoolean();
Stamina = PhysicalUtils.Deserialize(reader);
InputDirection = Vector2Utils.Deserialize(reader);
LeftStance = reader.ReadBoolean();
Blindfire = reader.ReadInt32();
LinearSpeed = reader.ReadSingle();
TimeSerializedBetter = reader.ReadString();
Expand Down
2 changes: 1 addition & 1 deletion Source/Coop/Players/CoopPlayerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected override void Interpolate()
CurrentManagedState.SetStep(NewState.Step);
MovementContext.PlayerAnimatorEnableSprint(NewState.IsSprinting);
MovementContext.EnableSprint(NewState.IsSprinting);

MovementContext.LeftStanceController.SetLeftStanceForce(NewState.LeftStance);
MovementContext.IsInPronePose = NewState.IsProne;
MovementContext.SetPoseLevel(Mathf.Lerp(LastState.PoseLevel, NewState.PoseLevel, InterpolationRatio));

Expand Down
1 change: 1 addition & 0 deletions Source/StayInTarkovPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
result = await client.GetStringAsync("http://wtfismyip.com/text");
SITIPAddresses.ExternalAddresses.ProcessIPAddressResult(result);
}
catch (WebException e)

Check warning on line 135 in Source/StayInTarkovPlugin.cs

View workflow job for this annotation

GitHub Actions / Build-SIT (Debug)

The variable 'e' is declared but never used
{
// offline...
}
Expand All @@ -142,7 +142,7 @@
result = await client.GetStringAsync("https://api.ipify.org/");
SITIPAddresses.ExternalAddresses.ProcessIPAddressResult(result);
}
catch (WebException e)

Check warning on line 145 in Source/StayInTarkovPlugin.cs

View workflow job for this annotation

GitHub Actions / Build-SIT (Debug)

The variable 'e' is declared but never used
{
// offline too...
}
Expand Down Expand Up @@ -443,6 +443,7 @@
new PmcFirstAidPatch().Enable();
new SpawnProcessNegativeValuePatch().Enable();
new LocationLootCacheBustingPatch().Enable();
new FixBrokenSpawnOnSandboxPatch().Enable();
}

private void EnableCoopPatches()
Expand Down
Loading