You are viewing a potentially older version of this package. View all versions.
randomuserhi-KillIndicatorFix-0.0.9 icon

KillIndicatorFix

A client-side mod that makes kill indicators consistent when you are not host.

Date uploaded a year ago
Version 0.0.9
Download link randomuserhi-KillIndicatorFix-0.0.9.zip
Downloads 1825
Dependency string randomuserhi-KillIndicatorFix-0.0.9

This mod requires the following mods to function

BepInEx-BepInExPack_GTFO-3.1.0 icon
BepInEx-BepInExPack_GTFO

BepInEx pack for GTFO. Preconfigured and includes Unity Base DLLs.

Preferred version: 3.1.0
randomuserhi-DamageSync-0.0.4 icon
randomuserhi-DamageSync

A host only mod that syncs enemy HP with clients.

Preferred version: 0.0.4

README

A client-side mod that makes kill indicators consistent when you are not host.

Requires Bepinex, but is not dependent on GTFO-API plugin, so you can remove GTFO-API.dll from plugins folder to keep vanilla rundown and progression.

Known Limitations:

  • Sentry's will not show kill indicators as it would for host (client simply won't see their own sentry's kills).
  • Delay on kill indicator due to ping when client prediction fails.

============ Config File ============

The way this fix works is by keeping track of enemies you are shooting at:

  • If your shot is predicted to kill on client side, the kill marker is shown.
  • If a onkill event from host is received for an enemy you are shooting at then a kill marker is shown.

To prevent two kill markers from showing, the plugin keeps note of what enemies you are shooting at and what enemies it has already shown the kill marker for:

  • If the kill marker for an enemy has already been shown, it will not show it again when receiving the onkill event from host.
  • It will keep track of kill markers that have been shown in the last 3 seconds (dictated by markerLifeTime in config)

To prevent a kill marker showing on an enemy you shot 30 minutes ago, the plugin keeps track of enemies you have shot at recently within a 1 second period (dictated by tagBufferPeriod in config)

============ Compatability Notice for other Plugin Developers ============

This plugin alters the internal hp values stored by the game (when ran as client):

[HarmonyPatch(typeof(Dam_EnemyDamageLimb), nameof(Dam_EnemyDamageLimb.BulletDamage))]
[HarmonyPrefix]
public static void BulletDamage(Dam_EnemyDamageLimb __instance, float dam, ...)
{
    ...
    
    // Apply damage modifiers (head, occiput etc...)
    float num = __instance.ApplyWeakspotAndArmorModifiers(dam, precisionMulti);
    num = __instance.ApplyDamageFromBehindBonus(num, position, direction);
    __instance.m_base.Health -= num; // Alter the internal health value

    ...
}

The decision to do so was done out of laziness and to avoid overcomplicating the system. As a result, if your plugin relies on these values (either through modification or by reading it) then the plugin will be incompatible with this one.

If you wish to use the health values whilst still maintaining compatability, you will need to store and manage your own health values seperately. This can be done using a dictionary of InstanceIDs to corresponding health values and manually subtracting health from damage sources:

// Dictionary storing hp values for enemies
// make sure to clear this dictionary OnRundownStart() or something to prevent leaks.
private static Dictionary<int, float> hpTracker = new Dictionary<int, float>();

[HarmonyPatch(typeof(Dam_EnemyDamageLimb), nameof(Dam_EnemyDamageLimb.BulletDamage))]
[HarmonyPrefix]
public static void BulletDamage(Dam_EnemyDamageLimb __instance, float dam, ...)
{
    ...
    
    Dam_EnemyDamageBase m_base = __instance.m_base;
    EnemyAgent owner = m_base.Owner;
    int instanceID = owner.GetInstanceID();
    
    // Apply damage modifiers (head, occiput etc...)
    float num = __instance.ApplyWeakspotAndArmorModifiers(dam, precisionMulti);
    num = __instance.ApplyDamageFromBehindBonus(num, position, direction);
    
    // Manage your own health tracker - maybe remove trackers when their hp falls below 0
    if (hpTracker.ContainsKey(instanceID))
    {
        hpTracker[instanceID] = hpTracker[instanceID] - num;
    }
    else hpTracker.Add(instanceID, m_base.HealthMax - num);
    
    ...
}

It should be noted that the above example only tracks changes to hp from bullet damage, you will need to extend this example to include melee damage etc...

  • Furthermore, for client side, getting health changes from Sentries is impossible since they run on host side. Unless you fundementally change how sentries work, you will not be able to determine health changes from sentries as a client.

============ Change Log ============

v0.0.9

  • Fixed wack damage calculation bug from previous update

v0.0.8

  • Added note for other plugin developers when it comes to compatability.
  • Changed damage calculation to be closer to original source.

v0.0.7

  • Fixed a bug where clients could see kill markers of bots when they melee kill an enemy.

v0.0.6

  • Fixed a bug where clients could see kill markers of bots.

v0.0.5

  • Fixed the "Double hit marker on kill" bug -> Used to show both the kill marker and the regular hit marker for the killing shot.
  • Added config file to edit timing values for different ping situations (In general, values should be larger for high ping, refer to notes above).

v0.0.4

  • Made KillIndicatorFix work together with DamageSync for better indicators.

v0.0.3

  • Added DamageSync as a dependency, so if you are hosting with DamageSync + KillIndicatorFix, clients will have slightly more consistent kill indicators if they are unmodded.

v0.0.2

  • Changed hit marker from network sync to use your last shot location instead of EyePosition to make seeing the marker for giants clearer

v0.0.1

  • Initial Release