Skip to content

Commit

Permalink
Add NoInertiaPhysical
Browse files Browse the repository at this point in the history
- This class uses same Inertia as if player was wearing nothing at level 1
- Will be a server option whether Inertia is on or not
- Need to add to server config
  • Loading branch information
Lacyway committed Jun 20, 2024
1 parent a4f4758 commit 18922f5
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
59 changes: 59 additions & 0 deletions Fika.Core/Coop/ClientClasses/NoInertiaPhysical.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Comfort.Common;
using EFT;
using Fika.Core.Coop.Players;
using UnityEngine;

namespace Fika.Core.Coop.ClientClasses
{
public class NoInertiaPhysical : GClass682
{
private CoopPlayer coopPlayer;

public override void Init(IPlayer player)
{
base.Init(player);
coopPlayer = (CoopPlayer)player;
}

public override void OnWeightUpdated()
{
BackendConfigSettingsClass.InertiaSettings inertia = Singleton<BackendConfigSettingsClass>.Instance.Inertia;
float num = iobserverToPlayerBridge_0.Skills.StrengthBuffElite ? coopPlayer.GClass2777_0.Inventory.TotalWeightEliteSkill : coopPlayer.GClass2777_0.Inventory.TotalWeight;
Inertia = 0.0113f;
SprintAcceleration = 0.9887f;
PreSprintAcceleration = 2.9853f;
float num2 = Mathf.Lerp(inertia.MinMovementAccelerationRangeRight.x, inertia.MaxMovementAccelerationRangeRight.x, Inertia);
float num3 = Mathf.Lerp(inertia.MinMovementAccelerationRangeRight.y, inertia.MaxMovementAccelerationRangeRight.y, Inertia);
EFTHardSettings.Instance.MovementAccelerationRange.MoveKey(1, new Keyframe(num2, num3));
Overweight = BaseOverweightLimits.InverseLerp(num);
WalkOverweight = WalkOverweightLimits.InverseLerp(num);
WalkSpeedLimit = 1f;
float_3 = SprintOverweightLimits.InverseLerp(num);
MoveSideInertia = 1.9887f;
MoveDiagonalInertia = 1.3955f;
if (coopPlayer.IsAI)
{
float_3 = 0f;
}
MaxPoseLevel = (Overweight >= 1f) ? 0.9f : 1f;
Consumptions[EConsumptionType.OverweightIdle].SetActive(this, Overweight >= 1f);
Consumptions[EConsumptionType.OverweightIdle].Delta.SetDirty();
Consumptions[EConsumptionType.SitToStand].AllowsRestoration = Overweight >= 1f;
Consumptions[EConsumptionType.StandUp].AllowsRestoration = Overweight >= 1f;
Consumptions[EConsumptionType.Walk].Delta.SetDirty();
Consumptions[EConsumptionType.Sprint].Delta.SetDirty();
Consumptions[EConsumptionType.VaultLegs].Delta.SetDirty();
Consumptions[EConsumptionType.VaultHands].Delta.SetDirty();
Consumptions[EConsumptionType.ClimbLegs].Delta.SetDirty();
Consumptions[EConsumptionType.ClimbHands].Delta.SetDirty();
TransitionSpeed.SetDirty();
PoseLevelDecreaseSpeed.SetDirty();
PoseLevelIncreaseSpeed.SetDirty();
FallDamageMultiplier = Mathf.Lerp(1f, StaminaParameters.FallDamageMultiplier, Overweight);
SoundRadius = StaminaParameters.SoundRadius.Evaluate(Overweight);
MinStepSound.SetDirty();
method_3();
method_7(num);
}
}
}
7 changes: 6 additions & 1 deletion Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ await player.Init(rotation, layerName, pointOfView, profile, inventoryController
return player;
}

public override GClass681 CreatePhysical()
{
return FikaPlugin.Instance.UseInertia ? new GClass682() : new NoInertiaPhysical();
}

public override void OnSkillLevelChanged(GClass1778 skill)
{
NotificationManagerClass.DisplayMessageNotification(string.Format("SkillLevelUpMessage".Localized(null),
Expand Down Expand Up @@ -573,7 +578,6 @@ public HealthSyncPacket SetupDeathPacket(GStruct346 packet)
{
Packet = packet,
KillerId = !string.IsNullOrEmpty(KillerId) ? KillerId : null,
KillerWeaponId = LastDamageInfo.Weapon?.Id,
RagdollPacket = new()
{
BodyPartColliderType = LastDamageInfo.BodyPartColliderType,
Expand Down Expand Up @@ -1410,6 +1414,7 @@ public virtual void HandleDamagePacket(ref DamagePacket packet)
}
}

// TODO: Fix this and consistently get the correct data...
if (Singleton<GameWorld>.Instance.GetAlivePlayerByProfileID(packet.ProfileId).HandsController.Item is Weapon weapon)
{
damageInfo.Weapon = weapon;
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Coop/Players/ObservedCoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ private void CreateQuickUseItemController(string itemId)
}
}

public void SetAggressor(string killerId, string weaponId)
public void SetAggressor(string killerId)
{
Player killer = Singleton<GameWorld>.Instance.GetEverExistedPlayerByID(killerId);
if (killer != null)
Expand Down
1 change: 1 addition & 0 deletions Fika.Core/FikaPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public class FikaPlugin : BaseUnityPlugin
public bool AllowItemSending;
public string[] BlacklistedItems;
public bool ForceSaveOnDeath;
public bool UseInertia;
#endregion

protected void Awake()
Expand Down

0 comments on commit 18922f5

Please sign in to comment.