Fixed lag caused by character.damageLimb

This commit is contained in:
EvilFactory
2024-09-06 18:58:08 -03:00
parent 911fff14e9
commit 307c81c3bd
3 changed files with 10 additions and 10 deletions

View File

@@ -66,12 +66,3 @@ function(instance, p)
return false
end
end, Hook.HookMethodType.Before)
Hook.Patch("Barotrauma.Character", "DamageLimb", function(instance, p)
local result = Hook.Call("character.damageLimb", instance, p["afflictions"], p["attacker"], p["hitLimb"], p["worldPosition"], p["stun"], p["attackImpulse"], p["damageMultiplier"], p["allowStacking"], p["penetration"], p["shouldImplode"], p["playSound"])
if result == true then
p.PreventExecution = true
return false
end
end, Hook.HookMethodType.Before)

View File

@@ -4468,6 +4468,12 @@ namespace Barotrauma
{
if (Removed) { return new AttackResult(); }
AttackResult? retAttackResult = GameMain.LuaCs.Hook.Call<AttackResult?>("character.damageLimb", this, worldPosition, hitLimb, afflictions, stun, playSound, attackImpulse, attacker, damageMultiplier, allowStacking, penetration, shouldImplode);
if (retAttackResult != null)
{
return retAttackResult.Value;
}
//character inside the sub received damage from a monster outside the sub
//can happen during normal gameplay if someone for example fires a ranged weapon from outside,
//the intention of this error message is to diagnose an issue with monsters being able to damage characters from outside

View File

@@ -185,6 +185,9 @@ function character.applyAffliction(character, limbHealth, newAffliction, allowSt
-- @realm shared
function character.applyDamage(characterHealth, attackResult, hitLimb, allowStacking) end
--- Gets gets called every time a limb gets damaged by an attack.
-- @realm shared
function character.damageLimb(character, worldPosition, hitLimb, afflictions, stun, playSound, attackImpulse, attacker, damageMultiplier, allowStacking, penetration, shouldImplode) end
--- Gets called every time an affliction updates.
-- @realm shared