From 152d670223cdbe26f31fa73566d6d41e5e40ab24 Mon Sep 17 00:00:00 2001 From: pingu7867 Date: Sun, 24 Mar 2024 14:53:39 -0400 Subject: [PATCH] implement health modifier id for damage multiplier for controlling one named "type" of damage multiplier involving multiple parts (instead of proxies) when multiple parts can be active at a time, it's probably simpler to have the option to cleanup like this instead of making a complex event setup to force all the others to hide for the reset on hide --- lua/pac3/extra/shared/net_combat.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/pac3/extra/shared/net_combat.lua b/lua/pac3/extra/shared/net_combat.lua index f7120432a..048668345 100644 --- a/lua/pac3/extra/shared/net_combat.lua +++ b/lua/pac3/extra/shared/net_combat.lua @@ -461,7 +461,16 @@ if SERVER then local function AddDamageScale(ply, id,scale, part_uid) ply.pac_damage_scalings = ply.pac_damage_scalings or {} - ply.pac_damage_scalings[part_uid] = {scale = scale, id = id, uid = part_uid} + if id == "" then --no mod id = part uid mode, don't overwrite another part + ply.pac_damage_scalings[part_uid] = {scale = scale, id = id, uid = part_uid} + else --mod id = try to remove competing parts whose multipliers have the same mod id + for existing_uid,tbl in pairs(ply.pac_damage_scalings) do + if tbl.id == id then + ply.pac_damage_scalings[existing_uid] = nil + end + end + ply.pac_damage_scalings[part_uid] = {scale = scale, id = id, uid = part_uid} + end end local function FixMaxHealths(ply)