using System.Xml; using System.Xml.Linq; using UnityEngine; /// /// /// Sets the target's relationship with the specified faction. /// /// /// Supported tag attributes: /// /// /// target /// /// The entity target(s), to change relationships with the factions. /// Valid target values: "self", "other", "selfAOE", "otherAOE", "positionAOE". /// In most cases you should use "self" (the player). /// Required. /// /// /// /// range /// /// Maximum range (distance in meters) to include entities as targets. /// Used only when the target is one of the AOE (Area Of Effect) values. /// Optional. /// /// /// /// target_tags /// /// Adds entities with these tags, to the list of entity targets. /// Special tag values: "party", "ally", "enemy". /// Optional. /// /// /// /// faction /// /// The primary faction whose relationship with the target will be set. /// Required. /// /// /// /// value /// /// The value of the new relationship between the target and faction. /// Required. /// /// /// /// /// /// These are the relationship values you should use for each relationship tier. /// /// /// Relationship tier /// Relationship values /// /// /// Hate /// 0 - 199 /// /// /// Dislike /// 200 - 399 /// /// /// Neutral /// 400 - 599 /// /// /// Like /// 600 - 799 /// /// /// Love /// 800 - 1000 (1000 is the maximum value) /// /// /// /// /// /// /// /// /// /// public class MinEventActionSetFactionRelationship : MinEventActionTargetedBase { private readonly bool debug = false; // for logging when testing private string faction = ""; private float value = 0f; public override void Execute(MinEventParams _params) { if (debug) { Debug.Log("MinEventActionSetFactionRelationshipSDX.Execute..."); } for (int i = 0; i < targets.Count; i++) { EntityAlive entity = targets[i]; if (entity != null) { Faction otherFaction = FactionManager.Instance.GetFactionByName(faction); if (otherFaction != null) { otherFaction.SetRelationship(entity.factionId, value); if (debug) { Debug.Log(string.Format("relationship to {0} set to {1}", faction, value)); } } } } } public override bool ParseXmlAttribute(XAttribute _attribute) { if (base.ParseXmlAttribute(_attribute)) { return true; } string name = _attribute.Name.LocalName; if (name == "faction") { faction = _attribute.Value.Trim(); return true; } if (name == "value") { value = StringParsers.ParseFloat(_attribute.Value); return true; } return false; } }