예제 #1
0
        private static void ExecuteDeathAction(Item corpse, Mobile killer, string action)
        {
            if (action == null || action.Length <= 0 || corpse == null)
            {
                return;
            }

            string status_str = null;

            XmlSpawner.SpawnObject TheSpawn = new XmlSpawner.SpawnObject(null, 0);

            TheSpawn.TypeName = action;
            string substitutedtypeName = BaseXmlSpawner.ApplySubstitution(null, corpse, killer, action);
            string typeName            = BaseXmlSpawner.ParseObjectType(substitutedtypeName);

            Point3D loc = corpse.Location;
            Map     map = corpse.Map;

            if (BaseXmlSpawner.IsTypeOrItemKeyword(typeName))
            {
                BaseXmlSpawner.SpawnTypeKeyword(corpse, TheSpawn, typeName, substitutedtypeName, true, killer, loc, map, out status_str);
            }
            else
            {
                // its a regular type descriptor so find out what it is
                Type type = SpawnerType.GetType(typeName);
                try
                {
                    string[] arglist = BaseXmlSpawner.ParseString(substitutedtypeName, 3, "/");
                    object   o       = XmlSpawner.CreateObject(type, arglist[0]);

                    if (o == null)
                    {
                        status_str = "invalid type specification: " + arglist[0];
                    }
                    else
                    if (o is Mobile)
                    {
                        Mobile m = (Mobile)o;
                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;
                            c.Home = loc;                                     // Spawners location is the home point
                        }

                        m.Location = loc;
                        m.Map      = map;

                        BaseXmlSpawner.ApplyObjectStringProperties(null, substitutedtypeName, m, killer, corpse, out status_str);
                    }
                    else
                    if (o is Item)
                    {
                        Item item = (Item)o;
                        BaseXmlSpawner.AddSpawnItem(null, corpse, TheSpawn, item, loc, map, killer, false, substitutedtypeName, out status_str);
                    }
                }
                catch { }
            }
        }
예제 #2
0
        public override void OnDoubleClick(Mobile from)
        {
            if (from == null)
            {
                return;
            }

            if (!from.InRange(GetWorldLocation(), 2) || !from.InLOS(this))
            {
                from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045);                 // I can't reach that.
                return;
            }
            string status_str;

            // test the combination and apply the property to the target item
            if (Matched)
            {
                //from.PlaySound(m_CombinationSound);
                try
                {
                    Effects.PlaySound(Location, Map, m_CombinationSound);
                }
                catch { }

                BaseXmlSpawner.ApplyObjectStringProperties(null, m_TargetProperty, m_TargetItem, from, this, out status_str);
            }
        }
예제 #3
0
        public override void OnDoubleClick(Mobile from)
        {
            if (from == null)
            {
                return;
            }

            if (!from.InRange(GetWorldLocation(), 2) || !from.InLOS(this))
            {
                from.SendLocalizedMessage(500446);                 // That is too far away.
                return;
            }
            string status_str;

            // test the combination and apply the property to the target item
            if (Matched)
            {
                //from.PlaySound(m_CombinationSound);
                try
                {
                    Effects.PlaySound(Location, Map, m_CombinationSound);
                }
                catch { }

                BaseXmlSpawner.ApplyObjectStringProperties(null, m_TargetProperty, m_TargetItem, from, this, out status_str);
            }
        }
예제 #4
0
        public virtual void OnEnter(Mobile m)
        {
            string status_str;

            m.PlaySound(SwitchSound);
            BaseXmlSpawner.ApplyObjectStringProperties(null, m_TargetProperty1, m_TargetItem1, m, this, out status_str);
        }
        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);
        }
예제 #6
0
        public static bool ActionOnSpawner(ISpawner spawner, Type typeCheck, string lineCheck, string exempt, Action <ISpawner> action, bool inherits)
        {
            string[] list = GetSpawnList(spawner);

            if (list == null)
            {
                return(false);
            }

            foreach (var str in list)
            {
                if (string.IsNullOrEmpty(str))
                {
                    continue;
                }

                string spawnObject = str.ToLower();

                if (typeCheck != null)
                {
                    Type t;

                    if (spawner is Spawner)
                    {
                        t = ScriptCompiler.FindTypeByName(spawnObject);
                    }
                    else
                    {
                        t = ScriptCompiler.FindTypeByName(BaseXmlSpawner.ParseObjectType(spawnObject));
                    }

                    if (t == typeCheck || (t != null && inherits && t.IsSubclassOf(typeCheck)))
                    {
                        if (action != null)
                        {
                            action(spawner);
                        }

                        return(true);
                    }
                }
                else
                {
                    string lookFor = lineCheck != null?lineCheck.ToLower() : null;

                    if ((lookFor == null || spawnObject.IndexOf(lookFor) >= 0) && (exempt == null || spawnObject.IndexOf(exempt.ToLower()) <= 0))
                    {
                        if (action != null)
                        {
                            action(spawner);
                        }

                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #7
0
파일: XmlUse.cs 프로젝트: Pumpk1ns/outlands
        // 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);
        }
예제 #8
0
        public virtual Spell GetRandomDamageSpell()
        {
            // ARTEGORDONMOD
            // restrict the damage spells that can be cast by this mob
            // look for the xmldata attachment named "DamageSpells"
            // the Data string will contain a list of space-separated spells that can be cast
            XmlData x = (XmlData)XmlAttach.FindAttachment(m_Mobile, typeof(XmlData), "DamageSpells");

            if (x != null)
            {
                // get the spell list
                string[] spells = BaseXmlSpawner.ParseSpaceArgs(x.Data, 20);
                if (spells != null && spells.Length > 0)
                {
                    // choose one at random
                    int index = Utility.Random(spells.Length);

                    return(SpellRegistry.NewSpell(spells[index], m_Mobile, null));
                }
            }

            int maxCircle = (int)((m_Mobile.Skills[SkillName.Magery].Value + 20.0) / (100.0 / 7.0));

            if (maxCircle < 1)
            {
                maxCircle = 1;
            }

            switch (Utility.Random(maxCircle * 2))
            {
            case  0:
            case  1: return(new MagicArrowSpell(m_Mobile, null));

            case  2:
            case  3: return(new HarmSpell(m_Mobile, null));

            case  4:
            case  5: return(new FireballSpell(m_Mobile, null));

            case  6:
            case  7: return(new LightningSpell(m_Mobile, null));

            case  8:
            case  9: return(new MindBlastSpell(m_Mobile, null));

            case 10: return(new EnergyBoltSpell(m_Mobile, null));

            case 11: return(new ExplosionSpell(m_Mobile, null));

            default: return(new FlameStrikeSpell(m_Mobile, null));
            }
        }
예제 #9
0
        public void OnHit(Mobile hit, Mobile hitter)
        {
            if (hit == null)
            {
                return;
            }

            // now check for any conditions as well
            // check for any condition that must be met for this entry to be processed
            if (!BaseXmlSpawner.CheckCondition(Condition, hitter, hit))
            {
                return;
            }

            BaseXmlSpawner.ExecuteActions(hitter, hit, Action);
        }
예제 #10
0
        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 (!BaseXmlSpawner.CheckCondition(Condition, killer, killed) || killed == null)
            {
                return;
            }

            BaseXmlSpawner.ExecuteActions(killer, killed, Action);
        }
예제 #11
0
        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);
        }
예제 #12
0
        public virtual void OnEnter(Mobile m)
        {
            string status_str;

            m.PlaySound(SwitchSound);
            BaseXmlSpawner.ApplyObjectStringProperties(null, m_TargetProperty1, m_TargetItem1, m, this, out status_str);
            if (m is BaseCreature || m is PlayerMobile)
            {
                m.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Head);
                m.PlaySound(0x307);
                m.DoHarmful(m, true);
                m.Damage(Utility.Random(30, 75));
                if (m is PlayerMobile)
                {
                    ;
                }
                {
                    m.SendMessage(38, "You stepped on a mine!");
                }
                this.Delete();
            }
        }
예제 #13
0
        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);
        }
예제 #14
0
        public override void OnKilled(Mobile killed, Mobile killer)
        {
            base.OnKilled(killed, killer);

            if (killed == null || killed.Corpse == null)
            {
                return;
            }

            // now check for any conditions as well
            // check for any condition that must be met for this entry to be processed
            if (!BaseXmlSpawner.CheckCondition(Condition, killer, killed))
            {
                return;
            }

            // proxy corpses: appear to be for things (like "Peasant" that have a human bodyvalue)
            // do the actions on both of them
            BaseXmlSpawner.ExecuteActions(killer, killed.Corpse, Action);
            if (killed.Corpse is Corpse && ((Corpse)killed.Corpse).ProxyCorpse != null)
            {
                BaseXmlSpawner.ExecuteActions(killer, ((Corpse)killed.Corpse).ProxyCorpse, Action);
            }
        }
예제 #15
0
        // 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);
        }
예제 #16
0
        private static bool CheckSmartSpawn(XmlSpawner spawner, Type check, bool subclasses)
        {
            foreach (var obj in spawner.SpawnObjects)
            {
                if (obj.TypeName != null)
                {
                    var t = ScriptCompiler.FindTypeByName(BaseXmlSpawner.ParseObjectType(obj.TypeName));

                    if (t != null && (t == check || (subclasses && t.IsSubclassOf(check))))
                    {
                        spawner.SmartSpawning = false;

                        if (spawner.CurrentCount == 0)
                        {
                            spawner.DoRespawn = true;
                        }

                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #17
0
 // return true to allow use
 private bool CheckTargetCondition(Mobile from, object target)
 {
     return(BaseXmlSpawner.CheckCondition(TargetCondition, from, target));
 }
예제 #18
0
파일: XmlUse.cs 프로젝트: Pumpk1ns/outlands
        private void ExecuteAction(Mobile mob, object target, string action)
        {
            if (action == null || action.Length <= 0)
            {
                return;
            }

            string status_str = null;

            Server.Mobiles.XmlSpawner.SpawnObject TheSpawn = new Server.Mobiles.XmlSpawner.SpawnObject(null, 0);

            TheSpawn.TypeName = action;
            string substitutedtypeName = BaseXmlSpawner.ApplySubstitution(null, target, mob, action);
            string typeName            = BaseXmlSpawner.ParseObjectType(substitutedtypeName);

            Point3D loc = new Point3D(0, 0, 0);
            Map     map = null;


            if (target is Item)
            {
                Item ti = target as Item;
                if (ti.Parent == null)
                {
                    loc = ti.Location;
                    map = ti.Map;
                }
                else if (ti.RootParent is Item)
                {
                    loc = ((Item)ti.RootParent).Location;
                    map = ((Item)ti.RootParent).Map;
                }
                else if (ti.RootParent is Mobile)
                {
                    loc = ((Mobile)ti.RootParent).Location;
                    map = ((Mobile)ti.RootParent).Map;
                }
            }
            else if (target is Mobile)
            {
                Mobile ti = target as Mobile;

                loc = ti.Location;
                map = ti.Map;
            }

            if (BaseXmlSpawner.IsTypeOrItemKeyword(typeName))
            {
                BaseXmlSpawner.SpawnTypeKeyword(target, TheSpawn, typeName, substitutedtypeName, true, mob, loc, map, out status_str);
            }
            else
            {
                // its a regular type descriptor so find out what it is
                Type type = SpawnerType.GetType(typeName);
                try
                {
                    string[] arglist = BaseXmlSpawner.ParseString(substitutedtypeName, 3, "/");
                    object   o       = Server.Mobiles.XmlSpawner.CreateObject(type, arglist[0]);

                    if (o == null)
                    {
                        status_str = "invalid type specification: " + arglist[0];
                    }
                    else
                    if (o is Mobile)
                    {
                        Mobile m = (Mobile)o;
                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;
                            c.Home = loc;     // Spawners location is the home point
                        }

                        m.Location = loc;
                        m.Map      = map;

                        BaseXmlSpawner.ApplyObjectStringProperties(null, substitutedtypeName, m, mob, target, out status_str);
                    }
                    else
                    if (o is Item)
                    {
                        Item item = (Item)o;
                        BaseXmlSpawner.AddSpawnItem(null, target, TheSpawn, item, loc, map, mob, false, substitutedtypeName, out status_str);
                    }
                }
                catch { }
            }

            ReportError(mob, status_str);
        }
예제 #19
0
        public void DisplayQuestStatus(int x, int y, string objectivestr, string statestr, bool status, string descriptionstr)
        {
            if (objectivestr != null && objectivestr.Length > 0)
            {
                // look for special keywords
                string[] arglist      = BaseXmlSpawner.ParseString(objectivestr, 5, ",");
                int      targetcount  = 1;
                bool     foundkill    = false;
                bool     foundcollect = false;
                bool     foundgive    = false;
                bool     foundescort  = false;
                string   name         = null;
                string   mobname      = null;
                string   type         = null;

                string status_str;
                string text = null;
                string typestr;
                bool   checkprop;

                if (arglist.Length > 0)
                {
                    switch (arglist[0])
                    {
                    case "GIVE":
                        // format for the objective string will be GIVE,mobname,itemtype[,count][,proptest]
                        if (arglist.Length > 2)
                        {
                            mobname = arglist[1];
                            //name = arglist[2];
                            type = arglist[2];
                        }

                        XmlQuest.CheckArgList(arglist, 3, null, out typestr, out targetcount, out checkprop, out status_str);

                        foundgive = true;
                        break;

                    case "GIVENAMED":
                        // format for the objective string will be GIVENAMED,mobname,itemname[,type][,count][,proptest]
                        if (arglist.Length > 2)
                        {
                            mobname = arglist[1];
                            name    = arglist[2];
                        }

                        XmlQuest.CheckArgList(arglist, 3, null, out typestr, out targetcount, out checkprop, out status_str);

                        if (typestr != null)
                        {
                            type = typestr;
                        }

                        foundgive = true;
                        break;

                    case "KILL":
                        // format for the objective string will be KILL,mobtype[,count][,proptest]

                        if (arglist.Length > 1)
                        {
                            //name = arglist[1];
                            type = arglist[1];
                        }

                        XmlQuest.CheckArgList(arglist, 2, null, out typestr, out targetcount, out checkprop, out status_str);

                        foundkill = true;
                        break;

                    case "KILLNAMED":
                        // format for the objective string KILLNAMED,mobname[,type][,count][,proptest]
                        if (arglist.Length > 1)
                        {
                            name = arglist[1];
                        }

                        XmlQuest.CheckArgList(arglist, 2, null, out typestr, out targetcount, out checkprop, out status_str);

                        if (typestr != null)
                        {
                            type = typestr;
                        }

                        foundkill = true;
                        break;

                    case "COLLECT":
                        // format for the objective string will be COLLECT,itemtype[,count][,proptest]
                        if (arglist.Length > 1)
                        {
                            //name = arglist[1];
                            type = arglist[1];
                        }

                        XmlQuest.CheckArgList(arglist, 2, null, out typestr, out targetcount, out checkprop, out status_str);



                        foundcollect = true;
                        break;

                    case "COLLECTNAMED":
                        // format for the objective string will be COLLECTNAMED,itemname[,itemtype][,count][,proptest]
                        if (arglist.Length > 1)
                        {
                            name = arglist[1];
                        }

                        XmlQuest.CheckArgList(arglist, 2, null, out typestr, out targetcount, out checkprop, out status_str);

                        if (typestr != null)
                        {
                            type = typestr;
                        }

                        foundcollect = true;
                        break;

                    case "ESCORT":
                        // format for the objective string will be ESCORT,mobname[,proptest]
                        if (arglist.Length > 1)
                        {
                            name = arglist[1];
                        }
                        foundescort = true;
                        break;
                    }
                }

                if (foundkill)
                {
                    // get the current kill status
                    int killed = 0;
                    try
                    {
                        killed = int.Parse(statestr);
                    }
                    catch { }

                    int remaining = targetcount - killed;

                    if (remaining < 0)
                    {
                        remaining = 0;
                    }

                    // report the kill task objective status
                    if (descriptionstr != null)
                    {
                        text = String.Format("{0} ({1} left)", descriptionstr, remaining);
                    }
                    else
                    {
                        if (name != null)
                        {
                            if (type == null)
                            {
                                type = "mob";
                            }

                            text = String.Format("Kill {0} {1}(s) named {2} ({3} left)", targetcount, type, name, remaining);
                        }
                        else
                        {
                            text = String.Format("Kill {0} {1}(s) ({2} left)", targetcount, type, remaining);
                        }
                    }
                }
                else
                if (foundescort)
                {
                    // get the current escort status
                    int escorted = 0;
                    try
                    {
                        escorted = int.Parse(statestr);
                    }
                    catch { }

                    int remaining = targetcount - escorted;

                    if (remaining < 0)
                    {
                        remaining = 0;
                    }

                    // report the escort task objective status
                    if (descriptionstr != null)
                    {
                        text = descriptionstr;
                    }
                    else
                    {
                        text = String.Format("Escort {0}", name);
                    }
                }
                else
                if (foundcollect)
                {
                    // get the current collection status
                    int collected = 0;
                    try
                    {
                        collected = int.Parse(statestr);
                    }
                    catch { }

                    int remaining = targetcount - collected;

                    if (remaining < 0)
                    {
                        remaining = 0;
                    }

                    // report the collect task objective status
                    if (descriptionstr != null)
                    {
                        text = String.Format("{0} ({1} left)", descriptionstr, remaining);
                    }
                    else
                    {
                        if (name != null)
                        {
                            if (type == null)
                            {
                                type = "mob";
                            }

                            text = String.Format("Collect {0} {1}(s) named {2} ({3} left)", targetcount, type, name, remaining);
                        }
                        else
                        {
                            text = String.Format("Collect {0} {1}(s) ({2} left)", targetcount, type, remaining);
                        }
                    }
                }
                else
                if (foundgive)
                {
                    // get the current give status
                    int collected = 0;

                    try
                    {
                        collected = int.Parse(statestr);
                    }
                    catch { }

                    int remaining = targetcount - collected;

                    if (remaining < 0)
                    {
                        remaining = 0;
                    }

                    // report the collect task objective status
                    if (descriptionstr != null)
                    {
                        text = String.Format("{0} ({1} left)", descriptionstr, remaining);
                    }
                    else
                    {
                        if (name != null)
                        {
                            if (type == null)
                            {
                                type = "item";
                            }

                            text = String.Format("Give {0} {1}(s) named {2} to {3} ({4} left)", targetcount, type, name, mobname, remaining);
                        }
                        else
                        {
                            text = String.Format("Give {0} {1}(s) to {2} ({3} left)", targetcount, type, mobname, remaining);
                        }
                    }
                }
                else
                {
                    // just report the objectivestring
                    text = objectivestr;
                }

                AddHtml(x, y, 223, 35, XmlSimpleGump.Color(text, "EFEF5A"), false, false);

                if (status)
                {
                    AddImage(x - 20, y + 3, 0x939);                                       // bullet
                    AddHtmlLocalized(x + 222, y, 225, 37, 1046033, 0xff42, false, false); // Complete
                }
                else
                {
                    AddImage(x - 20, y + 3, 0x938);                                       // bullet
                    AddHtmlLocalized(x + 222, y, 225, 37, 1046034, 0x7fff, false, false); // Incomplete
                }
            }
        }
예제 #20
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 1:
                m_Credits = reader.ReadInt();
                goto case 0;

            case 0:
                // version 0
                verboseMobFactions = reader.ReadBool();
                int count    = reader.ReadInt();
                int newcount = (int)GroupTypes.End_Unused;;

                // prepare the new faction status list
                FactionList = new GroupStatus[newcount];

                // initialize the faction status list with the default grouptypes
                for (int j = 0; j < newcount; j++)
                {
                    FactionList[j] = new GroupStatus((GroupTypes)j);
                }

                // now read in the serialized FactionList entries and cross reference to the current GroupTypes
                for (int i = 0; i < count; i++)
                {
                    string gname = reader.ReadString();
                    int    gfac  = reader.ReadInt();

                    // look up the enum by name
                    GroupTypes gtype = GroupTypes.End_Unused;
                    if (!BaseXmlSpawner.TryParse(gname, out gtype))
                    {
                        gtype = GroupTypes.End_Unused;
                    }

                    // try to find the matching entry in the recently constructed faction status list
                    if (gtype != GroupTypes.End_Unused)
                    {
                        for (int j = 0; j < newcount; j++)
                        {
                            GroupStatus g = FactionList[j];
                            if (g.GroupType == gtype)
                            {
                                g.FactionLevel = gfac;
                                break;
                            }
                        }
                    }
                }

                Refractory = reader.ReadTimeSpan();
                TimeSpan remaining = reader.ReadTimeSpan();
                m_EndTime = DateTime.UtcNow + remaining;
                break;
            }
        }
        public void Activate(Mobile from, int state, ArrayList links)
        {
            if (this.Disabled)
            {
                return;
            }

            string status_str = null;

            // assign the lever state
            this.m_LeverState = state;

            if (this.m_LeverState < 0)
            {
                this.m_LeverState = 0;
            }
            if (this.m_LeverState > 1 && this.m_LeverType == leverType.Two_State)
            {
                this.m_LeverState = 1;
            }
            if (this.m_LeverState > 2)
            {
                this.m_LeverState = 2;
            }

            // update the graphic
            this.SetLeverStatic();

            // play the switching sound if possible
            //if (from != null)
            //{
            //	from.PlaySound(m_LeverSound);
            //}
            try
            {
                Effects.PlaySound(this.Location, this.Map, this.m_LeverSound);
            }
            catch
            {
            }

            // if a target object has been specified then apply the property modification
            if (this.m_LeverState == 0 && this.m_TargetItem0 != null && !this.m_TargetItem0.Deleted && this.m_TargetProperty0 != null && this.m_TargetProperty0.Length > 0)
            {
                BaseXmlSpawner.ApplyObjectStringProperties(null, this.m_TargetProperty0, this.m_TargetItem0, from, this, out status_str);
            }
            if (this.m_LeverState == 1 && this.m_TargetItem1 != null && !this.m_TargetItem1.Deleted && this.m_TargetProperty1 != null && this.m_TargetProperty1.Length > 0)
            {
                BaseXmlSpawner.ApplyObjectStringProperties(null, this.m_TargetProperty1, this.m_TargetItem1, from, this, out status_str);
            }
            if (this.m_LeverState == 2 && this.m_TargetItem2 != null && !this.m_TargetItem2.Deleted && this.m_TargetProperty2 != null && this.m_TargetProperty2.Length > 0)
            {
                BaseXmlSpawner.ApplyObjectStringProperties(null, this.m_TargetProperty2, this.m_TargetItem2, from, this, out status_str);
            }

            // if the switch is linked, then activate the link as well
            if (this.Link != null && this.Link is ILinkable)
            {
                if (links == null)
                {
                    links = new ArrayList();
                }
                // activate other linked objects if they have not already been activated
                if (!links.Contains(this))
                {
                    links.Add(this);

                    ((ILinkable)this.Link).Activate(from, state, links);
                }
            }

            // report any problems to staff
            if (status_str != null && from != null && from.IsStaff())
            {
                from.SendMessage("{0}", status_str);
            }
        }
예제 #22
0
        public virtual void OnExit(Mobile m)
        {
            string status_str;

            BaseXmlSpawner.ApplyObjectStringProperties(null, m_TargetProperty0, m_TargetItem0, m, this, out status_str);
        }
예제 #23
0
 public void ExecuteActions(Mobile mob, object target, string actions)
 {
     BaseXmlSpawner.ExecuteActions(mob, target, actions);
 }
        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;
                    }
                }
            }
        }
예제 #25
0
 private void ExecuteAction(Mobile mob, object target, string action)
 {
     BaseXmlSpawner.ExecuteAction(mob, target, action);
 }
예제 #26
0
        // adds components from a multi.txt file to an existing addon
        public static int LoadAddonFromMulti(XmlSpawnerAddon newaddon, string filename, out string status_str)
        {
            status_str = null;

            if (filename == null)
            {
                status_str = "Invalid filename";
                return(0);
            }

            if (newaddon == null)
            {
                status_str = "Invalid addon";
                return(0);
            }

            bool badformat   = false;
            int  ncomponents = 0;

            if (System.IO.File.Exists(filename))
            {
                using (StreamReader sr = new StreamReader(filename))
                {
                    string line;
                    int    linenumber = 0;

                    // Read and process lines from the file until the end of the file is reached.
                    // Individual lines have the format of
                    // itemid x y z visible [hue] ; attachment[,args]
                    // where visible is a 0/1 and hue can be optionally specified for individual itemid entries.
                    while ((line = sr.ReadLine()) != null)
                    {
                        linenumber++;

                        // process the line
                        if (line.Length == 0)
                        {
                            continue;
                        }

                        // first parse out the component specification from any optional attachment specifications

                        string[] specs = line.Split(';');

                        // the component spec will always be first

                        if (specs == null || specs.Length < 1)
                        {
                            continue;
                        }

                        string[] args = specs[0].Trim().Split(' ');

                        AddonComponent newcomponent = null;

                        if (args != null && args.Length >= 5)
                        {
                            int itemid  = -1;
                            int x       = 0;
                            int y       = 0;
                            int z       = 0;
                            int visible = 0;
                            int hue     = -1;

                            try
                            {
                                itemid  = int.Parse(args[0]);
                                x       = int.Parse(args[1]);
                                y       = int.Parse(args[2]);
                                z       = int.Parse(args[3]);
                                visible = int.Parse(args[4]);

                                // handle the optional fields that are not part of the original multi.txt specification
                                if (args.Length > 5)
                                {
                                    hue = int.Parse(args[5]);
                                }
                            }
                            catch { badformat = true; }

                            if (itemid < 0 || badformat)
                            {
                                status_str = String.Format("Error line {0}", linenumber);
                                break;
                            }

                            // create the new component
                            newcomponent = new AddonComponent(itemid);

                            // set the properties according to the specification
                            newcomponent.Visible = (visible == 1);

                            if (hue >= 0)
                            {
                                newcomponent.Hue = hue;
                            }

                            // add it to the addon
                            newaddon.AddComponent(newcomponent, x, y, z);

                            ncomponents++;
                        }

                        // if a valid component was added, then check to see if any additional attachment specifications need to be processed
                        if (newcomponent != null && specs.Length > 1)
                        {
                            for (int j = 1; j < specs.Length; j++)
                            {
                                if (specs[j] == null)
                                {
                                    continue;
                                }

                                string attachstring = specs[j].Trim();

                                Type type = null;
                                try
                                {
                                    type = SpawnerType.GetType(BaseXmlSpawner.ParseObjectType(attachstring));
                                }
                                catch { }

                                // if so then create it
                                if (type != null && type.IsSubclassOf(typeof(XmlAttachment)))
                                {
                                    object newo = XmlSpawner.CreateObject(type, attachstring, false, true);
                                    if (newo is XmlAttachment)
                                    {
                                        // add the attachment to the target
                                        XmlAttach.AttachTo(newcomponent, (XmlAttachment)newo);
                                    }
                                }
                            }
                        }
                    }

                    sr.Close();
                }
            }
            else
            {
                status_str = "No such file : " + filename;
            }

            if (badformat)
            {
                return(0);
            }
            else
            {
                return(ncomponents);
            }
        }
예제 #27
0
        public void Activate(Mobile from, int state, ArrayList links)
        {
            if (Disabled)
            {
                return;
            }

            string status_str = null;

            if (state < 0)
            {
                state = 0;
            }
            if (state > 1)
            {
                state = 1;
            }

            if (base.State != state)
            {
                // apply the offset
                SetSwitchOffset();
            }
            // assign the latch state and start the timer
            base.State = state;

            // update the graphic
            SetSwitchStatic();

            // play the switching sound
            //if (from != null)
            //{
            //	from.PlaySound(m_SwitchSound);
            //}
            try
            {
                Effects.PlaySound(Location, Map, m_SwitchSound);
            }
            catch { }

            // if a target object has been specified then apply the property modification
            if (state == 0 && m_TargetItem0 != null && !m_TargetItem0.Deleted && m_TargetProperty0 != null && m_TargetProperty0.Length > 0)
            {
                BaseXmlSpawner.ApplyObjectStringProperties(null, m_TargetProperty0, m_TargetItem0, null, this, out status_str);
            }
            if (state == 1 && m_TargetItem1 != null && !m_TargetItem1.Deleted && m_TargetProperty1 != null && m_TargetProperty1.Length > 0)
            {
                BaseXmlSpawner.ApplyObjectStringProperties(null, m_TargetProperty1, m_TargetItem1, null, this, out status_str);
            }

            // if the switch is linked, then activate the link as well
            if (Link != null && Link is ILinkable)
            {
                if (links == null)
                {
                    links = new ArrayList();
                }
                // activate other linked objects if they have not already been activated
                if (!links.Contains(this))
                {
                    links.Add(this);

                    ((ILinkable)Link).Activate(from, state, links);
                }
            }

            // report any problems to staff
            if (status_str != null && from != null && from.AccessLevel > AccessLevel.Player)
            {
                from.SendMessage("{0}", status_str);
            }
        }
예제 #28
0
            private Item TryStealItem(Item toSteal, ref bool caught)
            {
                Item stolen = null;

                object root = toSteal.RootParent;

                if (!IsEmptyHanded(m_Thief))
                {
                    m_Thief.SendLocalizedMessage(1005584);                       // Both hands must be free to steal.
                }
                else if (root is Mobile && ((Mobile)root).Player && IsInnocentTo(m_Thief, (Mobile)root) && !IsInGuild(m_Thief))
                {
                    m_Thief.SendLocalizedMessage(1005596);                       // You must be in the thieves guild to steal from other players.
                }
                else if (SuspendOnMurder && root is Mobile && ((Mobile)root).Player && IsInGuild(m_Thief) && m_Thief.Kills > 0)
                {
                    m_Thief.SendLocalizedMessage(502706);                       // You are currently suspended from the thieves guild.
                }
                else if (root is BaseVendor && ((BaseVendor)root).IsInvulnerable)
                {
                    m_Thief.SendLocalizedMessage(1005598);                       // You can't steal from shopkeepers.
                }
                else if (root is PlayerVendor)
                {
                    m_Thief.SendLocalizedMessage(502709);                       // You can't steal from vendors.
                }
                else if (!m_Thief.CanSee(toSteal))
                {
                    m_Thief.SendLocalizedMessage(500237);                       // Target can not be seen.
                }
                else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, toSteal, false, true))
                {
                    m_Thief.SendLocalizedMessage(1048147);                       // Your backpack can't hold anything else.
                }
                #region Sigils
                else if (toSteal is Sigil)
                {
                    PlayerState pl      = PlayerState.Find(m_Thief);
                    Faction     faction = (pl == null ? null : pl.Faction);

                    Sigil sig = (Sigil)toSteal;

                    if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1))
                    {
                        m_Thief.SendLocalizedMessage(502703);    // You must be standing next to an item to steal it.
                    }
                    else if (root != null)                       // not on the ground
                    {
                        m_Thief.SendLocalizedMessage(502710);    // You can't steal that!
                    }
                    else if (faction != null)
                    {
                        if (!m_Thief.CanBeginAction(typeof(IncognitoSpell)))
                        {
                            m_Thief.SendLocalizedMessage(1010581);                               //	You cannot steal the sigil when you are incognito
                        }
                        else if (DisguiseGump.IsDisguised(m_Thief))
                        {
                            m_Thief.SendLocalizedMessage(1010583);                               //	You cannot steal the sigil while disguised
                        }
                        else if (!m_Thief.CanBeginAction(typeof(PolymorphSpell)))
                        {
                            m_Thief.SendLocalizedMessage(1010582);                               //	You cannot steal the sigil while polymorphed
                        }
                        else if (TransformationSpell.UnderTransformation(m_Thief))
                        {
                            m_Thief.SendLocalizedMessage(1061622);                               // You cannot steal the sigil while in that form.
                        }
                        else if (pl.IsLeaving)
                        {
                            m_Thief.SendLocalizedMessage(1005589);                               // You are currently quitting a faction and cannot steal the town sigil
                        }
                        else if (sig.IsBeingCorrupted && sig.LastMonolith.Faction == faction)
                        {
                            m_Thief.SendLocalizedMessage(1005590);                               //	You cannot steal your own sigil
                        }
                        else if (sig.IsPurifying)
                        {
                            m_Thief.SendLocalizedMessage(1005592);                               // You cannot steal this sigil until it has been purified
                        }
                        else if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, 80.0, 80.0))
                        {
                            if (Sigil.ExistsOn(m_Thief))
                            {
                                m_Thief.SendLocalizedMessage(1010258);                                   //	The sigil has gone back to its home location because you already have a sigil.
                            }
                            else if (m_Thief.Backpack == null || !m_Thief.Backpack.CheckHold(m_Thief, sig, false, true))
                            {
                                m_Thief.SendLocalizedMessage(1010259);                                   //	The sigil has gone home because your backpack is full
                            }
                            else
                            {
                                if (sig.IsBeingCorrupted)
                                {
                                    sig.GraceStart = DateTime.Now;                                     // begin grace period
                                }
                                m_Thief.SendLocalizedMessage(1010586);                                 // YOU STOLE THE SIGIL!!!   (woah, call down now)

                                if (sig.LastMonolith != null)
                                {
                                    sig.LastMonolith.Sigil = null;
                                }

                                sig.LastStolen = DateTime.Now;

                                return(sig);
                            }
                        }
                        else
                        {
                            m_Thief.SendLocalizedMessage(1005594);                               //	You do not have enough skill to steal the sigil
                        }
                    }
                    else
                    {
                        m_Thief.SendLocalizedMessage(1005588);                           //	You must join a faction to do that
                    }
                }
                #endregion
                //ARTEGORDONMOD
                // allow stealing of rares on the ground or in containers
                else if ((toSteal.Parent == null || !toSteal.Movable || toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed(root)) && !ItemFlags.GetStealable(toSteal))
                {
                    m_Thief.SendLocalizedMessage(502710);                       // You can't steal that!
                }
                //ARTEGORDONMOD
                // allow stealing of containers
                else if (Core.AOS && toSteal is Container && !ItemFlags.GetStealable(toSteal))
                {
                    m_Thief.SendLocalizedMessage(502710);                       // You can't steal that!
                }
                else if (!m_Thief.InRange(toSteal.GetWorldLocation(), 1))
                {
                    m_Thief.SendLocalizedMessage(502703);                       // You must be standing next to an item to steal it.
                }
                else if (toSteal.Parent is Mobile)
                {
                    m_Thief.SendLocalizedMessage(1005585);                       // You cannot steal items which are equiped.
                }
                else if (root == m_Thief)
                {
                    m_Thief.SendLocalizedMessage(502704);                       // You catch yourself red-handed.
                }
                else if (root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player)
                {
                    m_Thief.SendLocalizedMessage(502710);                       // You can't steal that!
                }
                else if (root is Mobile && !m_Thief.CanBeHarmful((Mobile)root))
                {
                }
                else if (root is Corpse)
                {
                    m_Thief.SendLocalizedMessage(502710);                       // You can't steal that!
                }
                else
                {
                    double w = toSteal.Weight + toSteal.TotalWeight;

                    if (w > 10)
                    {
                        m_Thief.SendMessage("That is too heavy to steal.");
                    }
                    else
                    {
                        if (toSteal.Stackable && toSteal.Amount > 1)
                        {
                            //ARTEGORDON
                            // fix for zero-weight stackables
                            int maxAmount = toSteal.Amount;
                            if (toSteal.Weight > 0)
                            {
                                maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);
                            }

                            if (maxAmount < 1)
                            {
                                maxAmount = 1;
                            }
                            else if (maxAmount > toSteal.Amount)
                            {
                                maxAmount = toSteal.Amount;
                            }

                            int amount = Utility.RandomMinMax(1, maxAmount);

                            if (amount >= toSteal.Amount)
                            {
                                int pileWeight = (int)Math.Ceiling(toSteal.Weight * toSteal.Amount);
                                pileWeight *= 10;

                                if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5))
                                {
                                    stolen = toSteal;
                                }
                            }
                            else
                            {
                                int pileWeight = (int)Math.Ceiling(toSteal.Weight * amount);
                                pileWeight *= 10;

                                if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5))
                                {
                                    stolen          = toSteal.Dupe(amount);
                                    toSteal.Amount -= amount;
                                }
                            }
                        }
                        else
                        {
                            int iw = (int)Math.Ceiling(w);
                            iw *= 10;

                            // ARTEGORDONMOD
                            // Begin mod for ArtifactRarity difficulty scaling
                            // add in an additional difficulty factor for objects with ArtifactRarity
                            // with rarity=1 requiring a minimum of 100 stealing, and rarity 12 requiring a minimum of 118
                            // Note, this is completely independent of weight
                            Type   ptype;
                            string value = BaseXmlSpawner.GetBasicPropertyValue(toSteal, "ArtifactRarity", out ptype);

                            if (ptype == typeof(int) && value != null)
                            {
                                int rarity = 0;
                                try{
                                    rarity = int.Parse(value);
                                } catch {}

                                // rarity difficulty scaling
                                if (rarity > 0)
                                {
                                    iw = (int)Math.Ceiling(120 + rarity * 1.5);
                                }
                            }
                            // End mod for ArtifactRarity difficulty scaling


                            if (m_Thief.CheckTargetSkill(SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5))
                            {
                                stolen = toSteal;
                            }
                        }

                        if (stolen != null)
                        {
                            // ARTEGORDONMOD
                            // Begin mod for stealable rares and other locked down items

                            // set the taken flag to trigger release from any controlling spawner
                            ItemFlags.SetTaken(stolen, true);
                            // clear the stealable flag so that the item can only be stolen once if it is later locked down.
                            ItemFlags.SetStealable(stolen, false);
                            // release it if it was locked down
                            stolen.Movable = true;

                            // End mod for stealable rares and other locked down items

                            m_Thief.SendLocalizedMessage(502724);                               // You succesfully steal the item.
                        }
                        else
                        {
                            m_Thief.SendLocalizedMessage(502723);                               // You fail to steal the item.
                        }
                        caught = (m_Thief.Skills[SkillName.Stealing].Value < Utility.Random(150));
                    }
                }

                return(stolen);
            }