using System; using System.Xml.Linq; /// /// /// This is a that will set the revenge target of all the /// target entities. /// /// /// This action takes a value attribute, which should be the entity ID of the revenge target. /// If the value of the attribute is 0 or less, the revenge target will be set to null. /// Omitting the "value" attribute will also set the revenge target to null. /// /// /// /// Example: Set the revenge target of the entity you're attacking, to yourself. /// This uses the read-only "_entityId" cvar that is introduced in this mod. /// (This is only an example; the game does this automatically.) /// /// <triggered_effect trigger="onSelfAttackedOther" action="SetRevengeTarget, SCore" target="other" value="@_entityId" /> /// /// /// /// /// Example: When the buff updates, set the revenge targets of everything within 10 meters of you, /// with the "friendly" tag, to your own revenge target, if you have one. /// This uses the read-only "_revengeTargetId" cvar that is introduced in this mod. /// /// <triggered_effect trigger = "onSelfBuffUpdate" action="SetRevengeTarget, SCore" target="selfAOE" range="10" target_tags="friendly" value="@_revengeTargetId"> /// <requirement name = "CVarCompare" target="self" cvar="_revengeTargetId" operation="GTE" value="0" /> /// </triggered_effect> /// /// /// /// /// Example: Clear the revenge target of the entity that damaged you. /// /// <!-- To clear the revenge target, set the "value" attribute to zero: --> /// <triggered_effect trigger="onOtherDamagedSelf" action="SetRevengeTarget, SCore" target="other" value="0" /> /// <!-- You can also use -1 or any other negative number: --> /// <triggered_effect trigger="onOtherDamagedSelf" action="SetRevengeTarget, SCore" target="other" value="-1" /> /// <!-- Or, omit the "value" attribute altogether: --> /// <triggered_effect trigger="onOtherDamagedSelf" action="SetRevengeTarget, SCore" target="other" /> /// /// /// public class MinEventActionSetRevengeTarget : MinEventActionTargetedBase { private int _entityId = 0; public override void Execute(MinEventParams _params) { EntityAlive entity = null; if (_entityId > 0) { entity = GameManager.Instance.World.GetEntity(_entityId) as EntityAlive; } for (var i = 0; i < targets.Count; i++) { targets[i]?.SetRevengeTarget(entity); } } public override bool ParseXmlAttribute(XAttribute _attribute) { if (string.Equals(_attribute.Name.LocalName, "value", StringComparison.OrdinalIgnoreCase)) { _entityId = StringParsers.ParseSInt32(_attribute.Value); return true; } return base.ParseXmlAttribute(_attribute); } }