From 422edc7fa432a19b6d172ec6173ef00fee7a69ae Mon Sep 17 00:00:00 2001 From: Evil Factory <36804725+evilfactory@users.noreply.github.com> Date: Sat, 5 Mar 2022 22:30:30 -0300 Subject: [PATCH] new status effect tag added: "LuaHook", can be used to call lua hooks inside status effects --- .../SharedSource/StatusEffects/StatusEffect.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs b/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs index 0bb5c11b6..02bfd6578 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs @@ -377,6 +377,7 @@ namespace Barotrauma private readonly List talentTriggers; private readonly List giveExperiences; private readonly List giveSkills; + private readonly List luaHook; public float Duration => duration; @@ -431,6 +432,7 @@ namespace Barotrauma talentTriggers = new List(); giveExperiences = new List(); giveSkills = new List(); + luaHook = new List(); multiplyAfflictionsByMaxVitality = element.GetAttributeBool("multiplyafflictionsbymaxvitality", false); tags = new HashSet(element.GetAttributeString("tags", "").Split(',')); @@ -735,6 +737,9 @@ namespace Barotrauma case "giveskill": giveSkills.Add(new GiveSkill(subElement, parentDebugName)); break; + case "luahook": + luaHook.Add(subElement.GetAttributeString("name", "")); + break; } } InitProjSpecific(element, parentDebugName); @@ -1234,6 +1239,14 @@ namespace Barotrauma } } + foreach (string luaHooks in luaHook) + { + var result = new LuaResult(GameMain.Lua.hook.Call(luaHooks, this, deltaTime, entity, targets, worldPosition)); + + if (result.Bool()) + return; + } + Hull hull = GetHull(entity); Vector2 position = GetPosition(entity, targets, worldPosition); if (useItemCount > 0)