public int CheckDigit(object o, string property) { if (o == null) { return(0); } if (property == null || property.Length <= 0) { return(0); } Type ptype; int ival = -1; string testvalue; // check to see whether this is a direct value request, or a test string[] argtest = BaseXmlSpawner.ParseString(property, 2, "<>!="); if (argtest.Length > 1) { // ok, its a test, so test it string status_str; if (BaseXmlSpawner.CheckPropertyString(null, o, property, null, out status_str)) { return(1); // true } else { return(0); // false } } // otherwise get the value of the property requested string result = BaseXmlSpawner.GetPropertyValue(null, o, property, out ptype); string[] arglist = BaseXmlSpawner.ParseString(result, 2, "="); if (arglist.Length < 2) { return(-1); } string[] arglist2 = BaseXmlSpawner.ParseString(arglist[1], 2, " "); if (arglist2.Length > 0) { testvalue = arglist2[0].Trim(); } else { return(-1); } if (BaseXmlSpawner.IsNumeric(ptype)) { try { ival = Convert.ToInt32(testvalue, 10); } catch { } } return(ival); }
// return true to allow use private bool CheckTargetCondition(Mobile from, object target) { // test the condition if there is one if (TargetCondition != null && TargetCondition.Length > 0) { string status_str; return(BaseXmlSpawner.CheckPropertyString(null, target, TargetCondition, from, out status_str)); } return(true); }
public bool IsEnemy(Mobile from) { if (from == null) { return(false); } bool isenemy = false; // test the condition if there is one if (Test != null && Test.Length > 0) { string status_str; isenemy = BaseXmlSpawner.CheckPropertyString(null, AttachedTo, Test, from, out status_str); } return(isenemy); }
public override void OnKilled(Mobile killed, Mobile killer) { base.OnKilled(killed, killer); if (killed == null) { return; } // now check for any conditions as well // check for any condition that must be met for this entry to be processed if (Condition != null) { string status_str; if (!BaseXmlSpawner.CheckPropertyString(null, killed, Condition, killer, out status_str)) { return; } } ExecuteDeathActions(killed.Corpse, killer, Action); }
// These are the various ways in which the message attachment can be constructed. // These can be called via the [addatt interface, via scripts, via the spawner ATTACH keyword. // Other overloads could be defined to handle other types of arguments public override bool CanEquip(Mobile from) { if (from == null) { return(false); } bool allowequip = true; // test the condition if there is one if (this.Test != null && this.Test.Length > 0) { string status_str; allowequip = BaseXmlSpawner.CheckPropertyString(null, this.AttachedTo, this.Test, from, out status_str); if (!allowequip && this.FailMsg != null) { from.SendMessage(this.FailMsg); } } return(allowequip); }
public void Transmute(Mobile from) { if (from == null) { return; } if (UsesRemaining == 0) { from.SendMessage("{0} is exhausted", Name); return; } // go through each recipe and determine if the conditions are met foreach (Recipe r in AllRecipes) { if (r.Ingredients == null || r.Ingredients.Length == 0 || r.Quantity == null || r.Ingredients.Length != r.Quantity.Length) { continue; } // go through all of the items in the container bool validrecipe = true; int [] quantity = new int[r.Quantity.Length]; foreach (Item i in Items) { // is this in the recipe? bool hasingredient = false; string status_str; for (int j = 0; j < r.Ingredients.Length; j++) { Type rt = r.Ingredients[j]; Type it = i.GetType(); if (it != null && rt != null && (it.Equals(rt) || it.IsSubclassOf(rt) || (rt.IsInterface && ContainsInterface(it.GetInterfaces(), rt)))) { // check any additional property requirements if (r.PropertyTests != null && r.PropertyTests[j] != null && !BaseXmlSpawner.CheckPropertyString(null, i, r.PropertyTests[j], null, out status_str)) { // failed to meet the requirement so skip it continue; } // found it, so add the quantity quantity[j] += i.Amount; hasingredient = true; break; } } // an item is present that is not an ingredient // that means an invalid recipe if (!hasingredient) { validrecipe = false; break; } } // check to see if all of the ingredient quantities have been satisfied for (int j = 0; j < r.Ingredients.Length; j++) { if ((quantity[j] == 0) || (r.Quantity[j] != 0 && quantity[j] != r.Quantity[j])) { validrecipe = false; break; } } if (validrecipe) { // check on stat and skill requirements if (CheckRequirements(from, r)) { // all recipe conditions are satisfied, so carry out the transmutation DoTransmute(from, r); break; } } } }