new affliction hook
This commit is contained in:
@@ -123,6 +123,7 @@ namespace Barotrauma
|
|||||||
UserData.RegisterType<Limb>();
|
UserData.RegisterType<Limb>();
|
||||||
UserData.RegisterType<Ragdoll>();
|
UserData.RegisterType<Ragdoll>();
|
||||||
UserData.RegisterType<ChatMessage>();
|
UserData.RegisterType<ChatMessage>();
|
||||||
|
UserData.RegisterType<CharacterHealth.LimbHealth>();
|
||||||
|
|
||||||
lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.LoadMethods);
|
lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.LoadMethods);
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,13 @@ using System.Xml.Linq;
|
|||||||
using Barotrauma.Networking;
|
using Barotrauma.Networking;
|
||||||
using Barotrauma.Extensions;
|
using Barotrauma.Extensions;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
partial class CharacterHealth
|
partial class CharacterHealth
|
||||||
{
|
{
|
||||||
class LimbHealth
|
public class LimbHealth
|
||||||
{
|
{
|
||||||
public Sprite IndicatorSprite;
|
public Sprite IndicatorSprite;
|
||||||
public Sprite HighlightSprite;
|
public Sprite HighlightSprite;
|
||||||
@@ -408,19 +409,47 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (targetLimb == null)
|
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
|
//if a limb-specific affliction is applied to no specific limb, apply to all limbs
|
||||||
foreach (LimbHealth limbHealth in limbHealths)
|
foreach (LimbHealth limbHealth in limbHealths)
|
||||||
{
|
{
|
||||||
AddLimbAffliction(limbHealth, affliction);
|
AddLimbAffliction(limbHealth, affliction);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
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);
|
AddLimbAffliction(targetLimb, affliction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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);
|
AddAffliction(affliction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user