Add Actor.OnDamaged
Allows the AI to react to its units being attacked.
This commit is contained in:
@@ -15,12 +15,13 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
{
|
{
|
||||||
public class LuaScriptEventsInfo : TraitInfo<LuaScriptEvents> { }
|
public class LuaScriptEventsInfo : TraitInfo<LuaScriptEvents> { }
|
||||||
|
|
||||||
public class LuaScriptEvents : INotifyKilled, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyCapture
|
public class LuaScriptEvents : INotifyKilled, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyCapture, INotifyDamage
|
||||||
{
|
{
|
||||||
public event Action<Actor, AttackInfo> OnKilled = (self, e) => { };
|
public event Action<Actor, AttackInfo> OnKilled = (self, e) => { };
|
||||||
public event Action<Actor> OnAddedToWorld = self => { };
|
public event Action<Actor> OnAddedToWorld = self => { };
|
||||||
public event Action<Actor> OnRemovedFromWorld = self => { };
|
public event Action<Actor> OnRemovedFromWorld = self => { };
|
||||||
public event Action<Actor, Actor, Player, Player> OnCaptured = (self, captor, oldOwner, newOwner) => { };
|
public event Action<Actor, Actor, Player, Player> OnCaptured = (self, captor, oldOwner, newOwner) => { };
|
||||||
|
public event Action<Actor, AttackInfo> OnDamaged = (self, e) => { };
|
||||||
|
|
||||||
public void Killed(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
@@ -41,5 +42,10 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
{
|
{
|
||||||
OnCaptured(self, captor, oldOwner, newOwner);
|
OnCaptured(self, captor, oldOwner, newOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
|
{
|
||||||
|
OnDamaged(self, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,10 @@ Actor.SetStance = function(actor, stance)
|
|||||||
Internal.SetUnitStance(actor, stance)
|
Internal.SetUnitStance(actor, stance)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Actor.OnDamaged = function(actor, eh)
|
||||||
|
Actor.Trait(actor, "LuaScriptEvents").OnDamaged:Add(eh)
|
||||||
|
end
|
||||||
|
|
||||||
Actor.OnKilled = function(actor, eh)
|
Actor.OnKilled = function(actor, eh)
|
||||||
Actor.Trait(actor, "LuaScriptEvents").OnKilled:Add(eh)
|
Actor.Trait(actor, "LuaScriptEvents").OnKilled:Add(eh)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user