From 3c7f119bb165537be09698a97b23baafb8d643fc Mon Sep 17 00:00:00 2001 From: Curtis Shmyr Date: Mon, 22 Jun 2020 12:25:21 -0600 Subject: [PATCH] Add a damage parameter to Lua OnDamage callback --- OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs | 2 +- OpenRA.Mods.Common/Scripting/ScriptTriggers.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs index 1072be43b2..0c20596074 100644 --- a/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs @@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Scripting } [Desc("Call a function when the actor is damaged. The callback " + - "function will be called as func(Actor self, Actor attacker).")] + "function will be called as func(Actor self, Actor attacker, int damage).")] public void OnDamaged(Actor a, LuaFunction func) { GetScriptTriggers(a).RegisterCallback(Trigger.OnDamaged, func, Context); diff --git a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs index e52a8304f1..c670e62d79 100644 --- a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs +++ b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs @@ -118,7 +118,8 @@ namespace OpenRA.Mods.Common.Scripting try { using (var b = e.Attacker.ToLuaValue(f.Context)) - f.Function.Call(f.Self, b).Dispose(); + using (var c = e.Damage.Value.ToLuaValue(f.Context)) + f.Function.Call(f.Self, b, c).Dispose(); } catch (Exception ex) {