Add a damage parameter to Lua OnDamage callback

This commit is contained in:
Curtis Shmyr
2020-06-22 12:25:21 -06:00
committed by abcdefg30
parent fea35923f0
commit 3c7f119bb1
2 changed files with 3 additions and 2 deletions

View File

@@ -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);

View File

@@ -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)
{