PlayerSync
Sync additional player information across clients.
| Date uploaded | 2 weeks ago |
| Version | 1.1.2 |
| Download link | food-PlayerSync-1.1.2.zip |
| Downloads | 526 |
| Dependency string | food-PlayerSync-1.1.2 |
This mod requires the following mods to function
BepInEx-BepInExPack_GTFO
BepInEx pack for GTFO. Preconfigured and includes Unity Base DLLs.
Preferred version: 3.2.2README
PlayerSync
Synchronizes additional player information like ammo clip and stamina
For feedback and issues, DM @uwufood on the GTFO Modding Discord Server
Why?
The vanilla game doesn't perform synchronization for information such as stamina and weapon clip ammo count (only total ammo count is synced).
This mod adds synchronization for these values. It also performs these updates at a higher frequency than the vanilla game. For the mod to function, both ends needs to have the mod installed.
Synchronized Values
Weapon Ammo / Clip
Synchronization is done on every shot and reload by hooking BulletWeapon.Fire, Shotgun.Fire,
and PlayerInventoryLocal.DoReload. This is then capped at maximum frequency as defined in the config.
Clip information is written directly into all items and can be accessed via
ItemEquippable.GetCurrentClip for the respective item.
AmmoInPack information is simply updated at the same tigher frequency as clip information and can be access via PlayerAmmoStorage just like in the vanilla game.
Note on Reserve Ammo
The ammo information for non-local players/bots will include the clip count in the reserve count. This is to ensure correct display in vanilla inventory UI. To obtain the actual reserve count for non-local players/bots, subtract their clip count from the reserve count.
There is a convenience function AmmoSync.ReserveIncludesClip for determining if clip should be subtracted from reserve count to get actual reserve count, the logic is rather simple.
/// <summary>
/// Returns whether a given player's reserve ammo count includes the clip
/// ammo count, which means whether if the player is not local.
/// For bots this means checking if master is remote.
/// </summary>
/// <returns>
/// true if clip ammo count should be subtracted from
/// reserve ammo count to obtain the actual reserve ammo count.
/// For non-supporting clients, this has no side effects in interpretation
/// since clip would always be 0 for them.
/// </returns>
public static bool ReserveIncludesClip(SNet_Player player) {
if (player.IsBot) player = SNet.Master;
return !player.IsLocal;
}
Stamina
Stamina information is synced and managed by PlayerSync since the vanilla game does not provide a mechanism to track it for other players. The values can be queried via:
namespace PlayerSync.Sync.Stamina;
class StaminaSync {
/// <summary>
/// Tries to get the stamina info for a given player, returns false if
/// player doesn't exist or unsupported (i.e. not synced).
/// </summary>
/// <param name="player">player to query</param>
/// <param name="info">stamina information</param>
/// <returns>true if found</returns>
public static bool GetStaminaInfo(SNet_Player player, out StaminaInfo info) { ... }
}
Advanced Configuration
In general, no configuration is needed. Clients with this mod installed will update each other with the information.
The frequency for updates, however, can be configured in the config; this is hard capped at 60Hz.
Possible Future Plans
- Synchronize modded player attributes (e.g. Oxygen)
CHANGELOG
v1.1.2
- feat: expose
PeerInfoManager.TryGetPeerInfofor peer query.
v1.1.1
- feat: include a function
AmmoSync.ReserveIncludesClipfor determining if clip count should be subtracted from reserve count to get the actual reserve count. - docs: update README to reflect new ammo information behavior
v1.1.0
- fix: ammo updates only sent to one player b/c of bad cd management
- fix: reserve not showing correctly because we subtract clip from it
- reserve now shows total ammo (actual reserve + clip) instead of just reserve, which aligns with vanilla behavior but differs from local player style.
v1.0.2
- Remove il2cpp type registration discovery with reflection since it crashes UE
v1.0.1
- adjust peer unknown state judgement condition
v1.0.0
Initial release