Skip to content

Commit

Permalink
Add lua stuff about AttackSuicides
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR committed Feb 5, 2018
1 parent 4004f17 commit 284506c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions OpenRA.Mods.Common/Scripting/Properties/CombatProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,39 @@ public bool CanTarget(Actor targetActor)
return Target.FromActor(targetActor).IsValidFor(Self);
}
}

[ScriptPropertyGroup("Combat")]
public class AttackSuicidesProperties : ScriptActorProperties, Requires<AttackSuicidesInfo>, Requires<IMoveInfo>
{
readonly AttackSuicides attackSuicides;
readonly IMove move;

public AttackSuicidesProperties(ScriptContext context, Actor self)
: base(context, self)
{
attackSuicides = self.TraitOrDefault<AttackSuicides>();
move = self.Trait<IMove>();
}

[Desc("Attack the target actor.")]
public void DetonateAttack(Actor targetActor, bool queued = true)
{
if (attackSuicides != null)
{
Self.QueueActivity(move.MoveToTarget(Self, Target.FromActor(targetActor)));
Self.QueueActivity(new CallFunc(() => Self.Kill(Self, attackSuicides.Info.DamageTypes)));
}
else
Log.Write("lua", "Actor {0} doesn't have AttackSuicides trait!", Self);
}

[Desc("Self destruct.")]
public void Detonate()
{
if (attackSuicides != null)
Self.Kill(Self, attackSuicides.Info.DamageTypes);
else
Log.Write("lua", "Actor {0} doesn't have AttackSuicides trait!", Self);
}
}
}

0 comments on commit 284506c

Please sign in to comment.