Exemplo n.º 1
0
        public override void OnAdded(object parent)
        {
            if (parent is Mobile)
            {
                if (XmlScript.HasTrigger(this, TriggerName.onEquip) && UberScriptTriggers.Trigger(this, (Mobile)parent, TriggerName.onEquip))
                {
                    ((Mobile)parent).AddToBackpack(this); // override, put it in their pack
                    base.OnAdded(parent);
                    return;
                }

                if (Server.Engines.XmlSpawner2.XmlAttach.CheckCanEquip(this, (Mobile)parent))
                {
                    Server.Engines.XmlSpawner2.XmlAttach.CheckOnEquip(this, (Mobile)parent);
                }
                else
                {
                    ((Mobile)parent).AddToBackpack(this);
                }
            }
            else if (parent is Item)
            {
                Item parentItem = (Item)parent;
                if (XmlScript.HasTrigger(this, TriggerName.onAdded))
                {
                    UberScriptTriggers.Trigger(this, parentItem.RootParentEntity as Mobile, TriggerName.onAdded, parentItem);
                }
            }

            base.OnAdded(parent);
        }
Exemplo n.º 2
0
        public RoyalAlchemist()
            : base("")
        {
            Name = "Erasmus";
            Body = 400;
            Hue = 33777;
            SpecialTitle = "Royal Alchemist";
            TitleHue = 1926;

            Blessed = true;

            CantWalk = true;

            SpeechHue = YellHue = 34;

            VirtualArmor = 36;

            AddItem(new Robe(Utility.RandomMetalHue()));
            AddItem(new Sandals(Utility.RandomMetalHue()));

            HairItemID = 8265;
            FacialHairItemID = 8254;

            XmlScript script = new XmlScript("Quests/CrippledKing/alchemist.us");

            XmlAttach.AttachTo(this, script);

            HairHue = Utility.RandomMetalHue();
            FacialHairHue = Utility.RandomMetalHue();
        }
Exemplo n.º 3
0
        public static void ResetScriptFile(string fileName, out string path)
        {
            ScriptFileMap.TryGetValue(fileName, out path);
            if (path == null)
            {
                path = Path.GetFullPath(Path.Combine(Core.BaseDirectory, ParsedScripts.UberScriptDirectory, fileName));

                if (!File.Exists(path))
                {
                    throw new UberScriptException("Script file did not exist at " + path);
                }
            }
            if (Scripts.ContainsKey(path))
            {
                Scripts.Remove(path);
            }
            foreach (KeyValuePair <string, string> filePair in ScriptFileMap)
            {
                foreach (KeyValuePair <XmlScript, bool> scriptPair in XmlScript.AllScripts)
                {
                    XmlScript script = scriptPair.Key;
                    if (ScriptFileMap.ContainsKey(script.ScriptFile) && ScriptFileMap[script.ScriptFile] == path)
                    {
                        // hacky way to resubscribe the timers if at all possible
                        XmlScript.TimerSubscriptionFlag temp = script.TimerSubscriptions;
                        // unsubscribe them
                        script.TimerSubscriptions = XmlScript.TimerSubscriptionFlag.None;
                        // resubscribe them to what they were previously subscribed to
                        script.TimerSubscriptions = temp;

                        script.UpdateScriptTriggerLookup();
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static void ResetScripts_Command(CommandEventArgs e)
        {
            GumpFileMap = new Dictionary <string, string>();
            Gumps       = new Dictionary <string, UberGumpBase>();

            // should probably ensure all the timer stuff is restarted as appropriate
            UberScriptTimedScripts.ClearSubscriptions();

            List <XmlScript> deletedScripts = new List <XmlScript>();

            foreach (KeyValuePair <XmlScript, bool> scriptPair in XmlScript.AllScripts)
            {
                XmlScript script = scriptPair.Key;
                if (script.Deleted)
                {
                    deletedScripts.Add(script);
                    continue;
                }
                // hacky way to resubscribe the timers if at all possible
                XmlScript.TimerSubscriptionFlag temp = script.TimerSubscriptions;
                // unsubscribe them
                script.TimerSubscriptions = XmlScript.TimerSubscriptionFlag.None;
                // resubscribe them to what they were previously subscribed to
                script.TimerSubscriptions = temp;
            }
            foreach (XmlScript script in deletedScripts)
            {
                XmlScript.AllScripts.Remove(script);
            }
        }
Exemplo n.º 5
0
 public UberScriptTarget(XmlScript script, object source, bool allowGround, bool checkLOS)
     : base(18, allowGround, TargetFlags.None)
 {
     m_Script = script;
     m_Source = source;
     CheckLOS = checkLOS;
 }
Exemplo n.º 6
0
		public UberScriptTarget(XmlScript script, object source, bool allowGround, bool checkLOS)
			: base(18, allowGround, TargetFlags.None)
		{
			m_Script = script;
			m_Source = source;
			CheckLOS = checkLOS;
		}
Exemplo n.º 7
0
 public override void OnMovement(Mobile m, Point3D oldLocation)
 {
     base.OnMovement(m, oldLocation);
     if (XmlScript.HasTrigger(this, TriggerName.onNearbyMove))
     {
         UberScriptTriggers.Trigger(this, m, TriggerName.onNearbyMove);
     }
 }
Exemplo n.º 8
0
 public override bool OnMoveOver(Mobile m)
 {
     if (XmlScript.HasTrigger(this, TriggerName.onMoveOver) && UberScriptTriggers.Trigger(this, m, TriggerName.onMoveOver))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 9
0
 public override void OnSpeech(SpeechEventArgs e)
 {
     if (XmlScript.HasTrigger(this, TriggerName.onSpeech) && UberScriptTriggers.Trigger(this, e.Mobile, TriggerName.onSpeech, null, e.Speech))
     {
         e.Handled = true;
         return;
     }
 }
Exemplo n.º 10
0
 public override void OnDelete()
 {
     if (XmlScript.HasTrigger(this, TriggerName.onDelete))
     {
         UberScriptTriggers.Trigger(this, this.RootParentEntity as Mobile, TriggerName.onDelete);
     }
     base.OnDelete();
 }
Exemplo n.º 11
0
 public ShipRepairTools(int uses)
     : base(uses, 0x1EB8)
 {
     Weight = 1.0;
     if (UberScriptFileName != null)
     {
         XmlScript script = new XmlScript(UberScriptFileName);
         script.Name = "shiprepair";
         XmlAttach.AttachTo(this, script);
     }
 }
Exemplo n.º 12
0
 public static void UnsubscribeScript(XmlScript toRemove)
 {
     EveryTick.Remove(toRemove);
     EveryTenMS.Remove(toRemove);
     EveryTwentyFiveMS.Remove(toRemove);
     EveryFiftyMS.Remove(toRemove);
     EveryTwoFiftyMS.Remove(toRemove);
     EveryOneSecond.Remove(toRemove);
     EveryFiveSeconds.Remove(toRemove);
     EveryOneMinute.Remove(toRemove);
 }
Exemplo n.º 13
0
        public static void SubscribeScript(XmlScript script, List <string> timerTriggers)
        {
            TriggerName triggerName;

            foreach (string timerTrigger in timerTriggers)
            {
                if (!Enum.TryParse(timerTrigger, out triggerName))
                {
                    continue;
                }

                //if (timerTrigger == UberScriptTriggers.ON_TICK && !EveryTick.Contains(script)) EveryTick.Add(script);
                if (triggerName == TriggerName.onTick && !EveryTick.Contains(script))
                {
                    EveryTick.Add(script);
                }
                else if (triggerName == TriggerName.onTenMS && !EveryTenMS.Contains(script))
                {
                    EveryTenMS.Add(script);
                }
                else if (triggerName == TriggerName.onTwentyFiveMS && !EveryTwentyFiveMS.Contains(script))
                {
                    EveryTwentyFiveMS.Add(script);
                }
                else if (triggerName == TriggerName.onFiftyMS && !EveryFiftyMS.Contains(script))
                {
                    EveryFiftyMS.Add(script);
                }
                else if (triggerName == TriggerName.onTwoFiftyMS && !EveryTwoFiftyMS.Contains(script))
                {
                    EveryTwoFiftyMS.Add(script);
                }
                else if (triggerName == TriggerName.onOneSecond && !EveryOneSecond.Contains(script))
                {
                    EveryOneSecond.Add(script);
                }
                else if (triggerName == TriggerName.onFiveSeconds && !EveryFiveSeconds.Contains(script))
                {
                    EveryFiveSeconds.Add(script);
                }
                else if (triggerName == TriggerName.onOneMinute && !EveryOneMinute.Contains(script))
                {
                    EveryOneMinute.Add(script);
                }
            }
        }
Exemplo n.º 14
0
        public void OnExpiration()
        {
            if (XmlScript.HasTrigger(AttachedTo, TriggerName.onExpire))
            {
                UberScriptTriggers.Trigger(AttachedTo, AttachedTo as Mobile, TriggerName.onExpire, AttachedTo as Item);
            }

            // with uberscript, I don't really see the need for this anymore

            /*
             * // now check for any conditions as well
             * // check for any condition that must be met for this entry to be processed
             * if (!BaseXmlSpawner.CheckCondition(ExpireActCondition, null, m_OwnedBy as Mobile))
             * return;
             *
             * BaseXmlSpawner.ExecuteActions(m_OwnedBy as Mobile, null, ExpireAction);
             */
        }
Exemplo n.º 15
0
        private static void EventSink_Speech(SpeechEventArgs args)
        {
            Mobile m = args.Mobile;

            if (m == null)
            {
                return;
            }

            DateTime now = DateTime.Now;

            // check for logging (pseudoseer or counselor)
            if (m.AccessLevel == AccessLevel.Counselor)
            {
                LoggingCustom.LogCounselor(now + "\t" + m.Name + ":\t" + args.Speech);
            }

            if (m.Account != null && PseudoSeerStone.Instance != null &&
                PseudoSeerStone.Instance.PseudoSeers.ContainsKey(m.Account))
            {
                LoggingCustom.LogPseudoseer(now + "\t" + m.Account + "\t" + m.Name + ":\t" + args.Speech);
            }

            if (m is PlayerMobile && ((PlayerMobile)m).Companion)
            {
                LoggingCustom.Log(
                    Path.Combine(new[] { CompanionListGump.LogFileLocation, m.Name + ".txt" }),
                    now + "\t" + m.Name + ":\t" + args.Speech);
                LoggingCustom.LogCompanion(now + "\t" + m.Name + ":\t" + args.Speech);
            }

            if (!args.Blocked)             // might turn it to true if return override encountered
            {
                if (XmlScript.HasTrigger(m, TriggerName.onSay))
                {
                    args.Blocked = Trigger(m, m, TriggerName.onSay, null, args.Speech);
                }
                args.Handled = args.Blocked;
            }
            else if (XmlScript.HasTrigger(m, TriggerName.onSay))
            {
                Trigger(m, m, TriggerName.onSay, null, args.Speech);
            }
        }
Exemplo n.º 16
0
        public static void SubscribeScript(XmlScript script, XmlScript.TimerSubscriptionFlag flags)
        {
            if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.EveryTick) && !EveryTick.Contains(script))
            {
                EveryTick.Add(script);
            }

            if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.TenMS) && !EveryTenMS.Contains(script))
            {
                EveryTenMS.Add(script);
            }

            if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.TwentyFiveMS) && !EveryTwentyFiveMS.Contains(script))
            {
                EveryTwentyFiveMS.Add(script);
            }

            if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.FiftyMS) && !EveryFiftyMS.Contains(script))
            {
                EveryFiftyMS.Add(script);
            }

            if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.TwoFiftyMS) && !EveryTwoFiftyMS.Contains(script))
            {
                EveryTwoFiftyMS.Add(script);
            }

            if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.OneSecond) && !EveryOneSecond.Contains(script))
            {
                EveryOneSecond.Add(script);
            }

            if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.FiveSeconds) && !EveryFiveSeconds.Contains(script))
            {
                EveryFiveSeconds.Add(script);
            }

            if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.OneMinute) && !EveryOneMinute.Contains(script))
            {
                EveryOneMinute.Add(script);
            }
        }
Exemplo n.º 17
0
 protected override void OnTarget(Mobile from, object target)
 {
     Mobile mob = target as Mobile;
     Item item = target as Item;
     if (mob != null)
     {
         from.SendMessage(0x38, "You have attached the script to " + target);
         XmlScript script = new XmlScript(FilePath);
         script.Name = ScriptName;
         XmlAttach.AttachTo(mob, script);
     }
     else if (item != null)
     {
         from.SendMessage(0x38, "You have attached the script to " + target);
         XmlScript script = new XmlScript(FilePath);
         script.Name = ScriptName;
         XmlAttach.AttachTo(item, script);
     }
     else
     {
         from.SendMessage(38, "You can't attach a script to that!");
     }
 }
Exemplo n.º 18
0
        public UberGumpTree(Mobile owner, XmlNode current, XmlDocument document, string fileName, XmlScript script = null, TriggerName triggerName = TriggerName.NoTrigger)
            : base(150, 50)
        {
            m_CurrentNode = current;
            m_ParentDocument = document;
            m_Owner = owner;
            m_FileName = fileName;
            m_Script = script;
            m_TriggerName = triggerName;

            Closable = true;
            Disposable = true;
            Dragable = true;
            Resizable = false;
            AddPage(0);

            int height = CalculateHeight(document.FirstChild) + 40;
            AddBackground(0, 0, 168, height, 9300);
            AddLabel(10, 10, 38, "UberGump Tree Elements");
            int penY = 10;
            int buttonID = 0;
            Traverse(document.FirstChild, 10, ref penY, ref buttonID);
        }
Exemplo n.º 19
0
        public override void OnAttach()
        {
            base.OnAttach();
            AllScripts.Add(this, true);

            /*
             * List<string> timerTriggers = ParsedScripts.GetTimerTriggers(ScriptFile, RootNodeIndeces);
             * if (timerTriggers != null)
             * {
             *  // subscribe to timers
             *  UberScriptTimedScripts.SubscribeScript(this, timerTriggers);
             * }
             * */

            UpdateScriptTriggerLookup();

            if (XmlScript.HasTrigger(AttachedTo, TriggerName.onCreate))
            {
                TriggerObject trigObject = new TriggerObject();
                trigObject.TrigName = TriggerName.onCreate;
                trigObject.This     = AttachedTo;
                this.Execute(trigObject, true);
            }

            if (AttachedTo is BaseCreature)
            {
                if (XmlScript.HasTrigger(AttachedTo, TriggerName.onActivate))
                {
                    BaseCreature bc = (BaseCreature)AttachedTo;
                    if (bc.AIObject.m_Timer != null && bc.AIObject.m_Timer.Running)
                    {
                        UberScriptTriggers.Trigger(bc, bc, TriggerName.onActivate);
                    }
                }
            }
        }
Exemplo n.º 20
0
            protected override void OnTarget(Mobile from, object target)
            {
                Mobile mob  = target as Mobile;
                Item   item = target as Item;

                if (mob != null)
                {
                    from.SendMessage(0x38, "You have attached the script to " + target);
                    XmlScript script = new XmlScript(FilePath);
                    script.Name = ScriptName;
                    XmlAttach.AttachTo(mob, script);
                }
                else if (item != null)
                {
                    from.SendMessage(0x38, "You have attached the script to " + target);
                    XmlScript script = new XmlScript(FilePath);
                    script.Name = ScriptName;
                    XmlAttach.AttachTo(item, script);
                }
                else
                {
                    from.SendMessage(38, "You can't attach a script to that!");
                }
            }
Exemplo n.º 21
0
			public static bool NEXTSTAGE(TriggerObject trigObject, XmlScript script, bool wrap)
			{
				if (script == null)
				{
					return false;
				}

				script.ProceedToNextStage = true;

				if (script.Execute(trigObject, false))
				{
					// end of sequence has been reached
					if (wrap)
					{
						script.Stage = -1;
						script.ProceedToNextStage = true;

						return !script.Execute(trigObject, false); // returns false if it hits the end again
					}

					return false;
				}

				return true;
			}
Exemplo n.º 22
0
        public static void AddScriptAttachments(object target, List<string> scriptfiles)
        {
            foreach (string scriptFile in scriptfiles)
            {
                if (scriptFile.Length == 0)
                {
                    continue;
                }

                string scriptName = null;
                string[] splitScriptFileNames = null;
                if (scriptFile.Contains("/"))
                {
                    splitScriptFileNames = scriptFile.Split('/');
                }
                else if (scriptFile.Contains("\\"))
                {
                    splitScriptFileNames = scriptFile.Split('\\');
                }
                else
                {
                    scriptName = scriptFile;
                }

                if (splitScriptFileNames != null)
                {
                    scriptName = splitScriptFileNames[splitScriptFileNames.Length - 1];
                }

                // get everything before the first period (so like test.txt would name it test)
                int periodIndex = scriptName.IndexOf('.');
                if (periodIndex > 0)
                {
                    scriptName = scriptName.Substring(0, periodIndex);
                }
                XmlScript newScript = new XmlScript(scriptFile) {Name = scriptName};
                XmlAttach.AttachTo(target as IEntity, newScript);
            }
        }
Exemplo n.º 23
0
 public UberScriptTarget(XmlScript script, object source)
     : this(script, source, true)
 {
 }
Exemplo n.º 24
0
		public static void Trigger(XmlScript[] scripts, TriggerName triggerName)
		{
			foreach (XmlScript script in scripts)
			{
				script.Execute(
					new TriggerObject
					{
						TrigName = triggerName,
						This = script.AttachedTo
					},
					true);
			}
		}
Exemplo n.º 25
0
		public static void SubscribeScript(XmlScript script, List<string> timerTriggers)
		{
			TriggerName triggerName;

			foreach (string timerTrigger in timerTriggers)
			{
				if (!Enum.TryParse(timerTrigger, out triggerName))
				{
					continue;
				}

				//if (timerTrigger == UberScriptTriggers.ON_TICK && !EveryTick.Contains(script)) EveryTick.Add(script);
				if (triggerName == TriggerName.onTick && !EveryTick.Contains(script))
				{
					EveryTick.Add(script);
				}
				else if (triggerName == TriggerName.onTenMS && !EveryTenMS.Contains(script))
				{
					EveryTenMS.Add(script);
				}
				else if (triggerName == TriggerName.onTwentyFiveMS && !EveryTwentyFiveMS.Contains(script))
				{
					EveryTwentyFiveMS.Add(script);
				}
				else if (triggerName == TriggerName.onFiftyMS && !EveryFiftyMS.Contains(script))
				{
					EveryFiftyMS.Add(script);
				}
				else if (triggerName == TriggerName.onTwoFiftyMS && !EveryTwoFiftyMS.Contains(script))
				{
					EveryTwoFiftyMS.Add(script);
				}
				else if (triggerName == TriggerName.onOneSecond && !EveryOneSecond.Contains(script))
				{
					EveryOneSecond.Add(script);
				}
				else if (triggerName == TriggerName.onFiveSeconds && !EveryFiveSeconds.Contains(script))
				{
					EveryFiveSeconds.Add(script);
				}
				else if (triggerName == TriggerName.onOneMinute && !EveryOneMinute.Contains(script))
				{
					EveryOneMinute.Add(script);
				}
			}
		}
Exemplo n.º 26
0
        public Object SpawnAndReturnObject(ProcessResult lastSiblingResult, TriggerObject trigObject)
        {
            // IF YOU EDIT THIS FUNCTION, BE SURE TO MAKE THE CORRESPONDING CHANGE TO THE Process FUNCTION!
            // this is just like Process, except it returns the spawned object (useful only in StatementNodes such that the object
            // can be assigned to the lefthand side of the statement node
            // e.g.
            // objs.test = orc
            // {
            //    name = goober
            // }
            Object prevSpawnedObject = trigObject.Spawn;
            Object callingObj        = trigObject.Spawn != null ? trigObject.Spawn : trigObject.This;

            if (this.ScriptString != null)
            {
                // it's a spawn node, so we need to spawn an object here
                trigObject.Spawn = SpawnHandlers.Spawn(ScriptString, callingObj);
            }
            if (this.Children.Count > 0)     // there is a special script associated with the spawn
            {
                ProcessChildren(trigObject); // ignore any overrides within spawn definitions
                IEntity spawnedObject = trigObject.Spawn as IEntity;
                if (spawnedObject != null && this.TriggerNodes.Count > 0)
                {
                    XmlScript script = new XmlScript(UberTreeParser.CurrentFileBeingParsed);
                    AddRootNodeIndeces(this, script.RootNodeIndeces);
                    XmlAttach.AttachTo(spawnedObject, script);
                }
            }
            // if it was already given a location in it's children, then don't give it one... otherwise place it
            // on the caller
            Item   callerItem = null;
            Mobile callerMob  = null;

            if (callingObj is Item)
            {
                callerItem = callingObj as Item;
            }
            else if (callingObj is Mobile)
            {
                callerMob = callingObj as Mobile;
            }

            Object o    = trigObject.Spawn;
            Mobile m    = null;
            Item   item = null;

            if (o is Mobile)
            {
                m = (Mobile)o;
            }
            else if (o is Item)
            {
                item = (Item)o;
            }

            if ((m != null && m.Location == Point3D.Zero && m.Map == Map.Internal) || (item != null && item.Location == Point3D.Zero && item.Map == Map.Internal && item.RootParentEntity == null))
            {
                try
                {
                    if (m != null)
                    {
                        if (callerItem != null)
                        {
                            if (callerItem.RootParentEntity != null)
                            {
                                m.MoveToWorld(callerItem.RootParentEntity.Location, callerItem.RootParentEntity.Map);
                            }
                            else
                            {
                                m.MoveToWorld(callerItem.Location, callerItem.Map);
                            }
                        }
                        else if (callerMob != null)
                        {
                            m.MoveToWorld(callerMob.Location, callerMob.Map);
                        }
                        else if (callingObj is IPoint3D)
                        {
                            m.MoveToWorld(new Point3D((IPoint3D)callingObj), Map.Felucca);
                        }
                        else
                        {
                            throw new UberScriptException("Spawn caller (the thing XmlScript is attached to) was neither mobile or item! It was: " + callingObj);
                        }
                        //loc = GetSpawnPosition(requiresurface, packrange, packcoord, spawnpositioning, m);

                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;
                            c.Home = c.Location;
                        }
                        trigObject.Spawn = prevSpawnedObject;
                        return(o);
                    }
                    else if (item != null)
                    {
                        if (callerItem != null)
                        {
                            item.MoveToWorld(callerItem.Location, callerItem.Map);
                        }
                        else if (callerMob != null)
                        {
                            item.MoveToWorld(callerMob.Location, callerMob.Map);
                        }
                        else if (callingObj is IPoint3D)
                        {
                            item.MoveToWorld(new Point3D((IPoint3D)callingObj), Map.Felucca);
                        }
                        else
                        {
                            throw new UberScriptException("Spawn caller (the thing XmlScript is attached to) was neither mobile or item! It was: " + callingObj);
                        }
                        trigObject.Spawn = prevSpawnedObject;
                        return(o);
                    }
                }
                catch (Exception ex) { throw new UberScriptException(String.Format("When spawning {0}", o), ex); }
            }
            else if (m != null && m is BaseCreature)
            {
                BaseCreature c = (BaseCreature)m;
                c.Home = c.Location;
            }

            trigObject.Spawn = prevSpawnedObject;
            return(o);
        }
Exemplo n.º 27
0
        public Object SpawnAndReturnObject(ProcessResult lastSiblingResult, TriggerObject trigObject)
        {
            // IF YOU EDIT THIS FUNCTION, BE SURE TO MAKE THE CORRESPONDING CHANGE TO THE Process FUNCTION!
            // this is just like Process, except it returns the spawned object (useful only in StatementNodes such that the object
            // can be assigned to the lefthand side of the statement node
            // e.g.
            // objs.test = orc
            // {
            //    name = goober
            // }
            Object prevSpawnedObject = trigObject.Spawn;
            Object callingObj = trigObject.Spawn != null ? trigObject.Spawn : trigObject.This;
            if (this.ScriptString != null)
            {
                // it's a spawn node, so we need to spawn an object here
                trigObject.Spawn = SpawnHandlers.Spawn(ScriptString, callingObj);
            }
            if (this.Children.Count > 0) // there is a special script associated with the spawn
            {
                ProcessChildren(trigObject); // ignore any overrides within spawn definitions
                IEntity spawnedObject = trigObject.Spawn as IEntity;
                if (spawnedObject != null && this.TriggerNodes.Count > 0)
                {
                    XmlScript script = new XmlScript(UberTreeParser.CurrentFileBeingParsed);
                    AddRootNodeIndeces(this, script.RootNodeIndeces);
                    XmlAttach.AttachTo(spawnedObject, script);
                }
            }
            // if it was already given a location in it's children, then don't give it one... otherwise place it
            // on the caller
            Item callerItem = null;
            Mobile callerMob = null;
            if (callingObj is Item) { callerItem = callingObj as Item; }
            else if (callingObj is Mobile) { callerMob = callingObj as Mobile; }
            
            Object o = trigObject.Spawn;
            Mobile m = null;
            Item item = null;
            if (o is Mobile) { m = (Mobile)o; }
            else if (o is Item) { item = (Item)o; }

            if ((m != null && m.Location == Point3D.Zero && m.Map == Map.Internal) || (item != null && item.Location == Point3D.Zero && item.Map == Map.Internal && item.RootParentEntity == null))
            {
                try
                {
                    if (m != null)
                    {
                        if (callerItem != null)
                        {
                            if (callerItem.RootParentEntity != null)
                            {
                                m.MoveToWorld(callerItem.RootParentEntity.Location, callerItem.RootParentEntity.Map);
                            }
                            else
                            {
                                m.MoveToWorld(callerItem.Location, callerItem.Map);
                            }
                        }
                        else if (callerMob != null) { m.MoveToWorld(callerMob.Location, callerMob.Map); }
                        else if (callingObj is IPoint3D)
                        {
                            m.MoveToWorld(new Point3D((IPoint3D)callingObj), Map.Felucca);
                        }
                        else throw new UberScriptException("Spawn caller (the thing XmlScript is attached to) was neither mobile or item! It was: " + callingObj);
                        //loc = GetSpawnPosition(requiresurface, packrange, packcoord, spawnpositioning, m);                  

                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;
                            c.Home = c.Location;
                        }
                        trigObject.Spawn = prevSpawnedObject;
                        return o;
                    }
                    else if (item != null)
                    {
                        if (callerItem != null)
                        {
                            item.MoveToWorld(callerItem.Location, callerItem.Map);
                        }
                        else if (callerMob != null)
                        {
                            item.MoveToWorld(callerMob.Location, callerMob.Map);
                        }
                        else if (callingObj is IPoint3D)
                        {
                            item.MoveToWorld(new Point3D((IPoint3D)callingObj), Map.Felucca);
                        }
                        else throw new UberScriptException("Spawn caller (the thing XmlScript is attached to) was neither mobile or item! It was: " + callingObj);
                        trigObject.Spawn = prevSpawnedObject;
                        return o;
                    }
                }
                catch (Exception ex) { throw new UberScriptException(String.Format("When spawning {0}", o), ex); }
            }
            else if (m != null && m is BaseCreature)
            {
                BaseCreature c = (BaseCreature)m;
                c.Home = c.Location;
            }

            trigObject.Spawn = prevSpawnedObject;
            return o;
        }
Exemplo n.º 28
0
			public static bool NEXTSTAGE(TriggerObject trigObject, XmlScript script)
			{
				return NEXTSTAGE(trigObject, script, false);
			}
Exemplo n.º 29
0
		public UberScriptTarget(XmlScript script, object source)
			: this(script, source, true)
		{ }
Exemplo n.º 30
0
			public static Item DUPE(TriggerObject trigObject, Item copy, bool inBag, int amount, bool dupeContents)
			{
				Container pack = null;

				if (inBag)
				{
					if (copy.Parent is Container)
					{
						pack = (Container)copy.Parent;
					}
					else if (copy.Parent is Mobile)
					{
						pack = ((Mobile)copy.Parent).Backpack;
					}
				}

				Type t = copy.GetType();
				Item output = null;

				//ConstructorInfo[] info = t.GetConstructors();

				ConstructorInfo c = t.GetConstructor(Type.EmptyTypes);

				bool done = false;

				if (c != null)
				{
					for (int i = 0; i < amount; i++)
					{
						object o = c.Invoke(null);

						if (!(o is Item))
						{
							continue;
						}

						Item newItem = (Item)o;
						Dupe.CopyProperties(newItem, copy); //copy.Dupe( item, copy.Amount );
						copy.OnAfterDuped(newItem);
						newItem.Parent = null;

						var scripts = XmlAttach.GetScripts(copy);

						if (scripts != null)
						{
							foreach (XmlScript script in scripts)
							{
								XmlScript copiedScript = new XmlScript(script.ScriptFile)
								{
									Name = script.Name,
									Enabled = script.Enabled
								};

								XmlAttach.AttachTo(newItem, copiedScript);
							}
						}

						if (pack != null)
						{
							pack.DropItem(newItem);
						}
						else
						{
							if (copy.RootParentEntity == null)
							{
								newItem.MoveToWorld(copy.Location, copy.Map);
							}
							else
							{
								newItem.MoveToWorld(copy.RootParentEntity.Location, copy.RootParentEntity.Map);
							}
						}

						if (newItem is Container && dupeContents)
						{
							Container newContainer = (Container)newItem;

							foreach (Item inItem in copy.Items)
							{
								newContainer.AddItem(DUPE(trigObject, inItem, false, 1, true));
							}
						}

						newItem.InvalidateProperties();
						output = newItem;
					}

					done = true;
				}

				if (!done)
				{
					throw new UberScriptException("DUPE command: tried to dupe object without 0 arg constructor!: " + copy);
				}

				return output;
			}
Exemplo n.º 31
0
			public static XmlScript ADDSCRIPT(TriggerObject trigObject, IEntity entity, string fileName, string name)
			{
				if (entity == null || fileName == null) // it's ok for name to be null
				{
					return null;
				}

				XmlScript script = new XmlScript(fileName)
				{
					Name = name
				};

				XmlAttach.AttachTo(entity, script);

				return script;
			}
Exemplo n.º 32
0
 public ShipCannon(BaseBoat boat, Point3D offset, ShipCannonDirection dir) : base(boat, offset, null) 
 {
     m_CannonDirection = dir;
     SetFacing(boat.Facing);
     if (UberScriptFileName != null)
     {
         XmlScript script = new XmlScript(UberScriptFileName);
         script.Name = "cannon";
         XmlAttach.AttachTo(this, script);
     }
     boat.BoatComponents.Add(this);
     CanBeChoppedDateTime = DateTime.UtcNow + TimeSpan.FromMinutes(1.0);
 }
Exemplo n.º 33
0
			public static XmlAttachment NEWATTACHMENT(TriggerObject trigObj, string attachmenttype, string name)
			{
				attachmenttype = attachmenttype.ToLower().Trim();

				XmlAttachment attachment = null;

				switch (attachmenttype)
				{
					case "xmlvalue":
						attachment = new XmlValue("", 0);
						break;
					case "xmllocalvariable":
						attachment = new XmlLocalVariable("");
						break;
					case "xmlscript":
						attachment = new XmlScript();
						break;
					case "xmlteam":
						attachment = new XmlTeam();
						break;
					case "xmldouble":
						attachment = new XmlDouble("", 0.0);
						break;
					case "xmlgroup":
						attachment = new XmlGroup();
						break;
					case "xmlslayer":
						attachment = new XmlSlayer("orcslaying", name);
						break;
					case "xmldate":
						attachment = new XmlDate("");
						break;
					case "xmlcorpseaction":
						attachment = new XmlCorpseAction();
						break;
					case "xmldeathaction":
						attachment = new XmlDeathAction();
						break;
					case "xmluse":
						attachment = new XmlUse();
						break;
					case "xmlonhit":
						attachment = new XmlOnHit();
						break;
					case "xmladdfame":
						attachment = new XmlAddFame(0);
						break;
					case "xmladdkarma":
						attachment = new XmlAddKarma(0);
						break;
					case "xmldex":
						attachment = new XmlDex();
						break;
					case "xmldialog":
						attachment = new XmlDialog();
						break;
					case "xmlenemymastery":
						attachment = new XmlEnemyMastery("");
						break;
					case "xmlfire":
						attachment = new XmlFire(1);
						break;
					case "xmlfreeze":
						attachment = new XmlFreeze();
						break;
					case "xmlhue":
						attachment = new XmlHue(0);
						break;
					case "xmllifedrain":
						attachment = new XmlLifeDrain(1);
						break;
					case "xmllightning":
						attachment = new XmlLightning(1);
						break;
					case "xmlmagicword":
						attachment = new XmlMagicWord();
						break;
					case "xmlmanadrain":
						attachment = new XmlManaDrain(1);
						break;
					case "xmlmessage":
						attachment = new XmlMessage("");
						break;
					case "xmlsaveitem":
						attachment = new XmlSaveItem();
						break;
					case "xmlskill":
						attachment = new XmlSkill("", "wrestling");
						break;
					case "xmlsound":
						attachment = new XmlSound();
						break;
					case "xmlstamdrain":
						attachment = new XmlStamDrain(1);
						break;
					case "xmlstr":
						attachment = new XmlStr();
						break;
					case "xmlint":
						attachment = new XmlInt();
						break;
				}

				if (attachment == null)
				{
					throw new UberScriptException("NEWATTACHMENT error: " + attachmenttype + " is not an available xmlattachment!");
				}

				if (attachment.Name == "" && name == null) // those attachments that require a name
				{
					return attachment;
				}

				attachment.Name = name;

				return attachment;
			}
Exemplo n.º 34
0
		public static void UnsubscribeScript(XmlScript toRemove)
		{
			EveryTick.Remove(toRemove);
			EveryTenMS.Remove(toRemove);
			EveryTwentyFiveMS.Remove(toRemove);
			EveryFiftyMS.Remove(toRemove);
			EveryTwoFiftyMS.Remove(toRemove);
			EveryOneSecond.Remove(toRemove);
			EveryFiveSeconds.Remove(toRemove);
			EveryOneMinute.Remove(toRemove);
		}
Exemplo n.º 35
0
        override public ProcessResult Process(ProcessResult lastSiblingResult, TriggerObject trigObject) // lastSiblingResult used for conditionals
        {
            // IF YOU EDIT THIS FUNCTION, BE SURE TO MAKE THE CORRESPONDING CHANGE TO THE SpawnAndReturnObject FUNCTION!
            Object prevSpawnedObject = trigObject.Spawn;
            Object callingObj        = trigObject.Spawn != null ? trigObject.Spawn : trigObject.This;

            if (this.ScriptString != null)
            {
                // it's a spawn node, so we need to spawn an object here
                Object caller = trigObject.Spawn != null ? trigObject.Spawn : trigObject.This;
                trigObject.Spawn = SpawnHandlers.Spawn(ScriptString, caller);
            }
            if (this.Children.Count > 0)                                // there is a special script assoctiated with the spawn
            {
                ProcessResult lastResult = ProcessChildren(trigObject); // ignore any returns in spawn definition
                if (lastResult == ProcessResult.EndOfSequence)
                {
                    return(lastResult); // we are processing a sequence
                }
                IEntity spawnedObject = trigObject.Spawn as IEntity;
                if (spawnedObject != null && this.TriggerNodes.Count > 0)
                {
                    XmlScript script = new XmlScript(UberTreeParser.CurrentFileBeingParsed);
                    // script.RootNodeIndeces.Add(0); // NO DON'T DO THIS// always has the initial 0 for the top root node (which always exists)
                    AddRootNodeIndeces(this, script.RootNodeIndeces);
                    XmlAttach.AttachTo(spawnedObject, script);
                }
            }
            // if it was already given a location in it's children, then don't give it one... otherwise place it
            // on the caller
            Item   callerItem = null;
            Mobile callerMob  = null;

            if (callingObj is Item)
            {
                callerItem = callingObj as Item;
            }
            else if (callingObj is Mobile)
            {
                callerMob = callingObj as Mobile;
            }

            Object o    = trigObject.Spawn;
            Mobile m    = null;
            Item   item = null;

            if (o is Mobile)
            {
                m = (Mobile)o;
            }
            else if (o is Item)
            {
                item = (Item)o;
            }

            if ((m != null && m.Location == Point3D.Zero && m.Map == Map.Internal) || (item != null && item.Location == Point3D.Zero && item.Map == Map.Internal && item.RootParentEntity == null))
            {
                try
                {
                    if (m != null)
                    {
                        if (callerItem != null)
                        {
                            if (callerItem.RootParentEntity != null)
                            {
                                m.MoveToWorld(callerItem.RootParentEntity.Location, callerItem.RootParentEntity.Map);
                            }
                            else
                            {
                                m.MoveToWorld(callerItem.Location, callerItem.Map);
                            }
                        }
                        else if (callerMob != null)
                        {
                            m.MoveToWorld(callerMob.Location, callerMob.Map);
                        }
                        else if (callingObj is IPoint3D)
                        {
                            m.MoveToWorld(new Point3D((IPoint3D)callingObj), Map.Felucca);
                        }
                        else
                        {
                            throw new UberScriptException("Spawn caller (the thing XmlScript is attached to) was neither mobile or item! It was: " + callingObj);
                        }
                        //loc = GetSpawnPosition(requiresurface, packrange, packcoord, spawnpositioning, m);

                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;
                            c.Home = c.Location;
                        }
                        trigObject.Spawn = prevSpawnedObject;
                        return(ProcessResult.None);
                    }
                    else if (item != null)
                    {
                        if (callerItem != null)
                        {
                            item.MoveToWorld(callerItem.Location, callerItem.Map);
                        }
                        else if (callerMob != null)
                        {
                            item.MoveToWorld(callerMob.Location, callerMob.Map);
                        }
                        else if (callingObj is IPoint3D)
                        {
                            item.MoveToWorld(new Point3D((IPoint3D)callingObj), Map.Felucca);
                        }
                        else
                        {
                            throw new UberScriptException("Spawn caller (the thing XmlScript is attached to) was neither mobile or item! It was: " + callingObj);
                        }
                        trigObject.Spawn = prevSpawnedObject;
                        return(ProcessResult.None);
                    }
                }
                catch (Exception ex) { throw new UberScriptException(String.Format("When spawning {0}", o), ex); }
            }
            else if (m != null && m is BaseCreature)
            {
                BaseCreature c = (BaseCreature)m;
                c.Home = c.Location;
            }
            trigObject.Spawn = prevSpawnedObject;
            return(ProcessResult.None);
        }
Exemplo n.º 36
0
			public static UberScriptSpot RUNSCRIPT(TriggerObject trigObject, IPoint3D p, string filename)
			{
				UberScriptSpot spot = new UberScriptSpot
				{
					Location = new Point3D(p.X, p.Y, p.Z),
					Map = (p is IEntity ? ((IEntity)p).Map : Map.Felucca)
				};

				XmlScript script = new XmlScript(filename);

				if (!ParsedScripts.ScriptFileMap.ContainsKey(filename.ToLower()))
				{
					// it failed to parse the script, so delete the plate, return null
					spot.Delete();
					return null;
				}

				XmlAttach.AttachTo(spot, script);

				TriggerObject newTrigObject = new TriggerObject
				{
					This = spot,
					TrigMob = trigObject.TrigMob,
					TrigItem = trigObject.TrigItem,
					Spell = trigObject.Spell,
					Damage = trigObject.Damage,
					Speech = trigObject.Speech,
					Targeted = trigObject.Targeted
				};

				//newTrigObject.TriggerName = trigObject.TriggerName;
				script.Execute(newTrigObject, false);

				return spot;
			}
Exemplo n.º 37
0
        override public ProcessResult Process(ProcessResult lastSiblingResult, TriggerObject trigObject) // lastSiblingResult used for conditionals
        {
            // IF YOU EDIT THIS FUNCTION, BE SURE TO MAKE THE CORRESPONDING CHANGE TO THE SpawnAndReturnObject FUNCTION!
            Object prevSpawnedObject = trigObject.Spawn;
            Object callingObj = trigObject.Spawn != null ? trigObject.Spawn : trigObject.This;
            if (this.ScriptString != null)
            {
                // it's a spawn node, so we need to spawn an object here
                Object caller = trigObject.Spawn != null ? trigObject.Spawn : trigObject.This;
                trigObject.Spawn = SpawnHandlers.Spawn(ScriptString, caller);
            }
            if (this.Children.Count > 0) // there is a special script assoctiated with the spawn
            {
                ProcessResult lastResult = ProcessChildren(trigObject); // ignore any returns in spawn definition
                if (lastResult == ProcessResult.EndOfSequence)
                {
                    return lastResult; // we are processing a sequence
                }
                IEntity spawnedObject = trigObject.Spawn as IEntity;
                if (spawnedObject != null && this.TriggerNodes.Count > 0)
                {
                    XmlScript script = new XmlScript(UberTreeParser.CurrentFileBeingParsed);
                    // script.RootNodeIndeces.Add(0); // NO DON'T DO THIS// always has the initial 0 for the top root node (which always exists)
                    AddRootNodeIndeces(this, script.RootNodeIndeces);
                    XmlAttach.AttachTo(spawnedObject, script);
                }
            }
            // if it was already given a location in it's children, then don't give it one... otherwise place it
            // on the caller
            Item callerItem = null;
            Mobile callerMob = null;
            if (callingObj is Item) { callerItem = callingObj as Item; }
            else if (callingObj is Mobile) { callerMob = callingObj as Mobile; }

            Object o = trigObject.Spawn;
            Mobile m = null;
            Item item = null;
            if (o is Mobile) { m = (Mobile)o; }
            else if (o is Item) { item = (Item)o; }

            if ((m != null && m.Location == Point3D.Zero && m.Map == Map.Internal) || (item != null && item.Location == Point3D.Zero && item.Map == Map.Internal && item.RootParentEntity == null))
            {
                try
                {
                    if (m != null)
                    {
                        if (callerItem != null)
                        {
                            if (callerItem.RootParentEntity != null)
                            {
                                m.MoveToWorld(callerItem.RootParentEntity.Location, callerItem.RootParentEntity.Map);
                            }
                            else
                            {
                                m.MoveToWorld(callerItem.Location, callerItem.Map);
                            }
                        }
                        else if (callerMob != null) { m.MoveToWorld(callerMob.Location, callerMob.Map); }
                        else if (callingObj is IPoint3D)
                        {
                            m.MoveToWorld(new Point3D((IPoint3D)callingObj), Map.Felucca);
                        }
                        else throw new UberScriptException("Spawn caller (the thing XmlScript is attached to) was neither mobile or item! It was: " + callingObj);
                        //loc = GetSpawnPosition(requiresurface, packrange, packcoord, spawnpositioning, m);                  

                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;
                            c.Home = c.Location;
                        }
                        trigObject.Spawn = prevSpawnedObject;
                        return ProcessResult.None;
                    }
                    else if (item != null)
                    {
                        if (callerItem != null)
                        {
                            item.MoveToWorld(callerItem.Location, callerItem.Map);
                        }
                        else if (callerMob != null)
                        {
                            item.MoveToWorld(callerMob.Location, callerMob.Map);
                        }
                        else if (callingObj is IPoint3D)
                        {
                            item.MoveToWorld(new Point3D((IPoint3D)callingObj), Map.Felucca);
                        }
                        else throw new UberScriptException("Spawn caller (the thing XmlScript is attached to) was neither mobile or item! It was: " + callingObj);
                        trigObject.Spawn = prevSpawnedObject;
                        return ProcessResult.None;
                    }
                }
                catch (Exception ex) { throw new UberScriptException(String.Format("When spawning {0}", o), ex); }
            }
            else if (m != null && m is BaseCreature)
            {
                BaseCreature c = (BaseCreature)m;
                c.Home = c.Location;
            }
            trigObject.Spawn = prevSpawnedObject;
            return ProcessResult.None;
        }
Exemplo n.º 38
0
			public static void SUBSCRIBETIMER(TriggerObject trigObject, XmlScript script, string time)
			{
				if (script == null)
				{
					return;
				}

				if (time == null)
				{
					time = String.Empty;
				}

				switch (time.ToLower())
				{
					case "everytick":
						script.TimerSubscribe = XmlScript.TimerSubscriptionFlag.EveryTick;
						break;
					case "tenms":
						script.TimerSubscribe = XmlScript.TimerSubscriptionFlag.TenMS;
						break;
					case "twentyfivems":
						script.TimerSubscribe = XmlScript.TimerSubscriptionFlag.TwentyFiveMS;
						break;
					case "fiftyms":
						script.TimerSubscribe = XmlScript.TimerSubscriptionFlag.FiftyMS;
						break;
					case "twofiftyms":
						script.TimerSubscribe = XmlScript.TimerSubscriptionFlag.TwoFiftyMS;
						break;
					case "onesecond":
						script.TimerSubscribe = XmlScript.TimerSubscriptionFlag.OneSecond;
						break;
					case "fiveseconds":
						script.TimerSubscribe = XmlScript.TimerSubscriptionFlag.FiveSeconds;
						break;
					case "oneminute":
						script.TimerSubscribe = XmlScript.TimerSubscriptionFlag.OneMinute;
						break;
					default:
						throw new UberScriptException(
							"SUBSCRIBETIMER function had invalid time string--expected EveryTick, TenMS, TwentyFiveMS, FiftyMS, TwoFiftyMS, OneSecond, FiveSeconds, or OneMinute");
				}
			}
Exemplo n.º 39
0
        public static void ResetScripts_Command(CommandEventArgs e)
        {
            // first reset the gumps
            ParsedGumps.GumpFileMap = new Dictionary <string, string>();
            ParsedGumps.Gumps       = new Dictionary <string, UberGumpBase>();

            List <XmlScript> deletedScripts = new List <XmlScript>();

            if (e.Arguments.Length == 0)
            {
                ScriptFileMap = new Dictionary <string, string>();
                Scripts       = new Dictionary <string, RootNode>();

                // should probably ensure all the timer stuff is restarted as appropriate
                UberScriptTimedScripts.ClearSubscriptions();
                UberScriptFunctions.Methods.StopAllLineEffectTimers();
                UberScriptFunctions.Methods.StopAllLineScriptTimers();

                foreach (KeyValuePair <XmlScript, bool> scriptPair in XmlScript.AllScripts)
                {
                    XmlScript script = scriptPair.Key;
                    if (script.Deleted || script.AttachedTo == null || script.AttachedTo.Deleted)
                    {
                        deletedScripts.Add(script);
                        continue;
                    }
                    // hacky way to resubscribe the timers if at all possible
                    XmlScript.TimerSubscriptionFlag temp = script.TimerSubscriptions;
                    // unsubscribe them
                    script.TimerSubscriptions = XmlScript.TimerSubscriptionFlag.None;
                    // resubscribe them to what they were previously subscribed to
                    script.TimerSubscriptions = temp;

                    script.UpdateScriptTriggerLookup();
                }
                foreach (XmlScript script in deletedScripts)
                {
                    XmlScript.AllScripts.Remove(script);
                }
                if (e.Mobile != null)
                {
                    e.Mobile.SendMessage("All scripts have been reset.");
                }
            }
            else
            {
                try
                {
                    // first, always clear out deleted scripts
                    foreach (KeyValuePair <XmlScript, bool> scriptPair in XmlScript.AllScripts)
                    {
                        XmlScript script = scriptPair.Key;
                        if (script.Deleted)
                        {
                            deletedScripts.Add(script);
                            continue;
                        }
                    }
                    foreach (XmlScript script in deletedScripts)
                    {
                        XmlScript.AllScripts.Remove(script);
                    }

                    string fileName = e.Arguments[0].ToLower();
                    string path     = Path.GetFullPath(Path.Combine(Core.BaseDirectory, ParsedScripts.UberScriptDirectory, fileName));;

                    if (Directory.Exists(path))
                    {
                        // reset all uberscripts in that directory, allow to toggle subdirectory reset too
                        bool resetSubdirectories = (e.Arguments.Length > 1 && e.Arguments[1].ToLower() == "true");
                        foreach (string file in Directory.GetFiles(path, "*.*", resetSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly))
                        {
                            ResetScriptFile(file, out path);
                            e.Mobile.SendMessage("All scripts connected to " + path + " were reset.");
                        }
                        if (e.Mobile != null)
                        {
                            e.Mobile.SendMessage("All scripts INSIDE the DIRECTORY " + fileName + (resetSubdirectories ? " AND its SUBDIRECTORIES" : "") + " were reset.");
                        }
                    }
                    else
                    {
                        ResetScriptFile(fileName, out path);
                        if (e.Mobile != null)
                        {
                            e.Mobile.SendMessage("All scripts connected to " + path + " were reset.");
                        }
                    }
                }
                catch (Exception except)
                {
                    if (e.Mobile != null)
                    {
                        e.Mobile.SendMessage("Exception caught: " + except.Message);
                    }
                }
            }
        }
Exemplo n.º 40
0
        public UberGumpEditorGump(Mobile owner, XmlNode currentNode, XmlDocument xmlDocument, string fileName,
                                    XmlScript script = null, TriggerName triggerName = TriggerName.NoTrigger)
            : base(300, 50)
		{
			m_Owner = owner;
            m_CurrentNode = currentNode;
            m_ParentDocument = xmlDocument;
            m_FileName = fileName;
            m_Script = script;
            m_TriggerName = triggerName;
            Closable = true;
            Dragable = true;

			InitializeGump();
		}
Exemplo n.º 41
0
			public static void LINESCRIPT(
				TriggerObject trigObject, IPoint3D from, IPoint3D to, string scriptFile, TimeSpan delay, Map map)
			{
				if (from == null || to == null || scriptFile == null || map == null || map == Map.Internal)
				{
					return;
				}

				UberScriptItem scriptSpot = new UberScriptItem();
				XmlScript newScript = new XmlScript(scriptFile)
				{
					Name = "line"
				};

				scriptSpot.MoveToWorld(new Point3D(from), map);

				XmlAttach.AttachTo(scriptSpot, newScript);

				if (from.X == to.X && from.Y == to.Y)
				{
					newScript.Execute(trigObject, false);
					scriptSpot.Delete();
					return;
				}

				LineScriptTimer timer = new LineScriptTimer(from, to, map, scriptSpot, trigObject, delay);
				timer.Start();

				AllLineScriptTimers.Add(timer);
			}
Exemplo n.º 42
0
		public static void SubscribeScript(XmlScript script, XmlScript.TimerSubscriptionFlag flags)
		{
			if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.EveryTick) && !EveryTick.Contains(script))
			{
				EveryTick.Add(script);
			}

			if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.TenMS) && !EveryTenMS.Contains(script))
			{
				EveryTenMS.Add(script);
			}

			if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.TwentyFiveMS) && !EveryTwentyFiveMS.Contains(script))
			{
				EveryTwentyFiveMS.Add(script);
			}

			if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.FiftyMS) && !EveryFiftyMS.Contains(script))
			{
				EveryFiftyMS.Add(script);
			}

			if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.TwoFiftyMS) && !EveryTwoFiftyMS.Contains(script))
			{
				EveryTwoFiftyMS.Add(script);
			}

			if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.OneSecond) && !EveryOneSecond.Contains(script))
			{
				EveryOneSecond.Add(script);
			}

			if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.FiveSeconds) && !EveryFiveSeconds.Contains(script))
			{
				EveryFiveSeconds.Add(script);
			}

			if (flags.HasFlag(XmlScript.TimerSubscriptionFlag.OneMinute) && !EveryOneMinute.Contains(script))
			{
				EveryOneMinute.Add(script);
			}
		}