new affliction hook

This commit is contained in:
Evil Factory
2021-08-09 17:00:50 -03:00
parent 5caeee45ad
commit 7f0fac3553
2 changed files with 31 additions and 1 deletions

View File

@@ -123,6 +123,7 @@ namespace Barotrauma
UserData.RegisterType<Limb>();
UserData.RegisterType<Ragdoll>();
UserData.RegisterType<ChatMessage>();
UserData.RegisterType<CharacterHealth.LimbHealth>();
lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.LoadMethods);

View File

@@ -6,12 +6,13 @@ using System.Xml.Linq;
using Barotrauma.Networking;
using Barotrauma.Extensions;
using System.Globalization;
using MoonSharp.Interpreter;
namespace Barotrauma
{
partial class CharacterHealth
{
class LimbHealth
public class LimbHealth
{
public Sprite IndicatorSprite;
public Sprite HighlightSprite;
@@ -408,19 +409,47 @@ namespace Barotrauma
{
if (targetLimb == null)
{
#if SERVER
var should = GameMain.Lua.hook.Call("afflictionApplied", new DynValue[] { UserData.Create(this), UserData.Create(affliction) });
if (should != null && should.CastToBool())
{
return;
}
#endif
//if a limb-specific affliction is applied to no specific limb, apply to all limbs
foreach (LimbHealth limbHealth in limbHealths)
{
AddLimbAffliction(limbHealth, affliction);
}
}
else
{
#if SERVER
var should = GameMain.Lua.hook.Call("afflictionApplied", new DynValue[] { UserData.Create(this), UserData.Create(affliction), UserData.Create(targetLimb) });
if (should != null && should.CastToBool())
{
return;
}
#endif
AddLimbAffliction(targetLimb, affliction);
}
}
else
{
#if SERVER
var should = GameMain.Lua.hook.Call("afflictionApplied", new DynValue[] { UserData.Create(this), UserData.Create(affliction)});
if (should != null && should.CastToBool())
{
return;
}
#endif
AddAffliction(affliction);
}
}