public TalkingBaseVendor( string title ) : base(title) { // add the XmlDialog attachment m_DialogAttachment = new XmlDialog((string)null); XmlAttach.AttachTo(this, m_DialogAttachment); }
public TalkingBaseCreature(AIType ai, FightMode mode, int iRangePerception, int iRangeFight, double dActiveSpeed, double dPassiveSpeed) : base(ai, mode, iRangePerception, iRangeFight, dActiveSpeed, dPassiveSpeed) { // add the XmlDialog attachment m_DialogAttachment = new XmlDialog((string)null); XmlAttach.AttachTo(this, m_DialogAttachment); }
protected override void OnTarget( Mobile from, object targeted ) { string filename = m_e.GetString(0); if(filename == null || filename.Length <= 0) { from.SendMessage("must specify a load filename"); return; } // load the XmlDialog attachment XmlDialog xa = XmlAttach.FindAttachment(targeted, typeof(XmlDialog)) as XmlDialog; if(xa != null) { xa.DoLoadNPC(from, filename); } else { // doesnt have a dialog attachment, so add and load xa = new XmlDialog(filename); XmlAttach.AttachTo(targeted, xa); } }
public InternalTimer( XmlDialog npc, TimeSpan delay, Mobile trigmob ) : base(delay, delay) { Priority = TimerPriority.OneSecond; m_npc = npc; m_trigmob = trigmob; m_delay = delay; }
public ConfirmSaveGump(XmlDialog dialog, DataSet ds, string filename, string configname, bool updateconfig) : base(0, 0) { m_dialog = dialog; m_ds = ds; m_filename = filename; m_configname = configname; m_updateconfig = updateconfig; Closable = false; Dragable = true; AddPage( 0 ); AddBackground( 10, 200, 200, 130, 5054 ); AddLabel( 20, 210, 33, String.Format("{0} exists.",filename) ); AddLabel( 20, 230, 33, String.Format("Overwrite?",filename) ); AddRadio( 35, 255, 9721, 9724, false, 1 ); // accept/yes radio AddRadio( 135, 255, 9721, 9724, true, 2 ); // decline/no radio AddHtmlLocalized(72, 255, 200, 30, 1049016, 0x7fff , false , false ); // Yes AddHtmlLocalized(172, 255, 200, 30, 1049017, 0x7fff , false , false ); // No AddButton( 80, 289, 2130, 2129, 3, GumpButtonType.Reply, 0 ); // Okay button }
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); if(version < 5) { // have to add the XmlDialog attachment m_DialogAttachment = new XmlDialog((string)null); XmlAttach.AttachTo(this, m_DialogAttachment); } switch ( version ) { case 7: m_EItemID = reader.ReadInt(); m_Duration = reader.ReadInt(); m_Offset = reader.ReadPoint3D(); m_EHue = reader.ReadInt(); goto case 6; case 6: TalkText = reader.ReadString(); break; case 5: { break; } case 4: { int count = reader.ReadInt(); SpeechEntries = new ArrayList(); for(int i = 0; i<count;i++) { XmlDialog.SpeechEntry newentry = new XmlDialog.SpeechEntry(); newentry.Condition = reader.ReadString(); SpeechEntries.Add(newentry); } goto case 3; } case 3: { TriggerOnCarried = reader.ReadString(); NoTriggerOnCarried = reader.ReadString(); goto case 2; } case 2: { SpeechPace = reader.ReadInt(); int count = reader.ReadInt(); if(version < 4) { SpeechEntries = new ArrayList(); } for(int i = 0; i<count;i++) { if(version < 4) { XmlDialog.SpeechEntry newentry = new XmlDialog.SpeechEntry(); newentry.PrePause = reader.ReadInt(); newentry.LockConversation = reader.ReadBool(); newentry.AllowNPCTrigger = reader.ReadBool(); newentry.SpeechStyle = (MessageType)reader.ReadInt(); SpeechEntries.Add(newentry); } else { XmlDialog.SpeechEntry newentry = (XmlDialog.SpeechEntry)SpeechEntries[i]; newentry.PrePause = reader.ReadInt(); newentry.LockConversation = reader.ReadBool(); newentry.AllowNPCTrigger = reader.ReadBool(); newentry.SpeechStyle = (MessageType)reader.ReadInt(); } } goto case 1; } case 1: { ActivePlayer = reader.ReadMobile(); goto case 0; } case 0: { IsActive = reader.ReadBool(); ResetTime = reader.ReadTimeSpan(); LastInteraction = reader.ReadDateTime(); AllowGhostTrig = reader.ReadBool(); ProximityRange = reader.ReadInt(); Running = reader.ReadBool(); ConfigFile = reader.ReadString(); int count = reader.ReadInt(); if(version < 2) { SpeechEntries = new ArrayList(); } for(int i = 0; i<count;i++) { if(version < 2) { XmlDialog.SpeechEntry newentry = new XmlDialog.SpeechEntry(); newentry.EntryNumber = reader.ReadInt(); newentry.ID = reader.ReadInt(); newentry.Text = reader.ReadString(); newentry.Keywords = reader.ReadString(); newentry.Action = reader.ReadString(); newentry.DependsOn = reader.ReadInt().ToString(); newentry.Pause = reader.ReadInt(); SpeechEntries.Add(newentry); } else { XmlDialog.SpeechEntry newentry = (XmlDialog.SpeechEntry)SpeechEntries[i]; newentry.EntryNumber = reader.ReadInt(); newentry.ID = reader.ReadInt(); newentry.Text = reader.ReadString(); newentry.Keywords = reader.ReadString(); newentry.Action = reader.ReadString(); newentry.DependsOn = reader.ReadInt().ToString(); newentry.Pause = reader.ReadInt(); } } // read in the current entry number. Note this will also set the current entry EntryNumber = reader.ReadInt(); // restart the timer if it was active bool isrunning = reader.ReadBool(); if(isrunning) { Mobile trigmob = reader.ReadMobile(); TimeSpan delay = reader.ReadTimeSpan(); if(DialogAttachment != null) DialogAttachment.DoTimer(delay,trigmob); } break; } } }
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; }
public XmlEditDialogGump( Mobile from, bool firststart, XmlDialog dialog, int selected, int displayfrom, string savefilename, bool selectall, bool [] selectionlist, int X, int Y ) : base(X,Y) { if(from == null || dialog == null) return; m_Dialog = dialog; m_From = from; m_SelectionList = selectionlist; if(m_SelectionList == null) { m_SelectionList = new bool[MaxEntries]; } SaveFilename = savefilename; DisplayFrom = displayfrom; Selected = selected; // fill the list with the XmlDialog entries m_SearchList = dialog.SpeechEntries; // prepare the page int height = 500; AddPage( 0 ); AddBackground( 0, 0, 755, height, 5054 ); AddAlphaRegion( 0, 0, 755, height ); // add the separators AddImageTiled( 10, 80, 735, 4, 0xBB9 ); AddImageTiled( 10, height -212, 735, 4, 0xBB9 ); AddImageTiled( 10, height -60, 735, 4, 0xBB9 ); // add the xmldialog properties int y = 5; int w = 140; int x = 5; int lw = 0; // the dialog name AddImageTiled( x, y, w, 21, 0x23F4 ); // get the name of the object this is attached to if(m_Dialog.AttachedTo is Item) { Name = ((Item)m_Dialog.AttachedTo).Name; } else if(m_Dialog.AttachedTo is Mobile) { Name = ((Mobile)m_Dialog.AttachedTo).Name; } if(Name == null && m_Dialog.AttachedTo != null) { Name = m_Dialog.AttachedTo.GetType().Name; } AddLabelCropped( x, y, w, 21, 0, Name ); x += w + lw + 20; w = 40; lw = 90; // add the proximity range AddLabel( x, y, 0x384, "ProximityRange" ); AddImageTiled( x+lw, y, w, 21, 0xBBC ); AddTextEntry( x+lw, y, w, 21, 0, 140, m_Dialog.ProximityRange.ToString() ); x += w + lw + 20; w = 100; lw = 60; // reset time AddLabel( x, y, 0x384, "ResetTime" ); AddImageTiled( x+lw, y, w, 21, 0xBBC ); AddTextEntry( x+lw, y, w, 21, 0, 141, m_Dialog.ResetTime.ToString() ); x += w + lw + 20; w = 40; lw = 65; // speech pace AddLabel( x, y, 0x384, "SpeechPace" ); AddImageTiled( x+lw, y, w, 21, 0xBBC ); AddTextEntry( x+lw, y, w, 21, 0, 142, m_Dialog.SpeechPace.ToString() ); x += w + lw + 20; w = 30; lw = 55; // allow ghost triggering AddLabel( x, y, 0x384, "GhostTrig" ); AddCheck( x+lw, y, 0xD2, 0xD3, m_Dialog.AllowGhostTrig, 260); // add the triggeroncarried y += 27; w = 600; x = 10; lw = 100; AddLabel( 10, y, 0x384, "TrigOnCarried" ); AddImageTiled( x + lw, y, w, 21, 0xBBC ); AddTextEntry( x+lw, y, w, 21, 0, 150, TruncateLabel(m_Dialog.TriggerOnCarried) ); AddButton( 720, y, 0xFAB, 0xFAD, 5005, GumpButtonType.Reply, 0 ); // add the notriggeroncarried y += 22; w = 600; x = 10; lw = 100; AddLabel( x, y, 0x384, "NoTrigOnCarried" ); AddImageTiled( x+lw, y, w, 21, 0xBBC ); AddTextEntry(x + lw, y, w, 21, 0, 151, TruncateLabel(m_Dialog.NoTriggerOnCarried)); AddButton( 720, y, 0xFAB, 0xFAD, 5006, GumpButtonType.Reply, 0 ); y = 88; // column labels AddLabel( 10, y, 0x384, "Edit" ); AddLabel( 45, y, 0x384, "#" ); AddLabel( 95, y, 0x384, "ID" ); AddLabel( 145, y, 0x384, "Depends" ); AddLabel( 195, y, 0x384, "Keywords" ); AddLabel( 295, y, 0x384, "Text" ); AddLabel( 540, y, 0x384, "Action" ); AddLabel( 602, y, 0x384, "Condition" ); AddLabel( 664, y, 0x384, "Gump" ); // display the select-all-displayed toggle AddButton( 730, y, 0xD2, 0xD3, 3999, GumpButtonType.Reply, 0 ); y -= 10; for ( int i = 0; i < MaxEntries; i++ ) { int index = i + DisplayFrom; if(m_SearchList == null || index >= m_SearchList.Count) break; int page = (int)(i/MaxEntriesPerPage); if(i%MaxEntriesPerPage == 0) { AddPage(page+1); // add highlighted page button //AddImageTiled( 235+page*25, 448, 25, 25, 0xBBC ); //AddImage( 238+page*25, 450, 0x8B1+page ); } // background for search results area AddImageTiled( 235, y + 22 * (i%MaxEntriesPerPage) + 30, 386, 23, 0x52 ); AddImageTiled( 236, y + 22 * (i%MaxEntriesPerPage) + 31, 384, 21, 0xBBC ); XmlDialog.SpeechEntry s = (XmlDialog.SpeechEntry)m_SearchList[index]; if(s == null) continue; int texthue = 0; bool sel=false; if(m_SelectionList != null && i < m_SelectionList.Length) { sel = m_SelectionList[i]; } // entries with the selection box checked are highlighted in red if(sel) texthue = 33; // the selected entry is highlighted in green if(i == Selected) texthue = 68; x = 10; w = 35; // add the Edit button for each entry AddButton( 10, y + 22 * (i%MaxEntriesPerPage) + 30, 0xFAE, 0xFAF, 1000+i, GumpButtonType.Reply, 0 ); x += w; w = 50; // display the entry number AddImageTiled( x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0xBBC ); AddLabel( x, y + 22 * (i%MaxEntriesPerPage) + 31, texthue, s.EntryNumber.ToString() ); x += w; w = 50; // display the entry ID AddImageTiled( x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0x23F4 ); AddLabel( x, y + 22 * (i%MaxEntriesPerPage) + 31, texthue, s.ID.ToString() ); x += w; w = 50; // display the entry dependson AddImageTiled( x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0xBBC ); AddLabel( x, y + 22 * (i%MaxEntriesPerPage) + 31, texthue, s.DependsOn ); x += w; w = 100; // display the entry keywords AddImageTiled( x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0x23F4 ); AddLabelCropped( x, y + 22 * (i%MaxEntriesPerPage) + 31, w-5, 21, texthue, TruncateLabel(s.Keywords) ); x += w; w = 245; // display the entry text AddImageTiled( x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0xBBC ); AddLabelCropped( x, y + 22 * (i%MaxEntriesPerPage) + 31, w-5, 21, texthue, TruncateLabel(s.Text) ); x += w; w = 62; // display the action text AddImageTiled( x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0x23F4 ); AddLabelCropped( x, y + 22 * (i%MaxEntriesPerPage) + 31, w-5, 21, texthue, TruncateLabel(s.Action) ); x += w; w = 62; // display the condition text AddImageTiled( x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0xBBC ); AddLabelCropped( x, y + 22 * (i%MaxEntriesPerPage) + 31, w-5, 21, texthue, TruncateLabel(s.Condition) ); x += w; w = 62; // display the gump text AddImageTiled( x, y + 22 * (i%MaxEntriesPerPage) + 31, w, 21, 0x23F4 ); AddLabelCropped( x, y + 22 * (i%MaxEntriesPerPage) + 31, w-5, 21, texthue, TruncateLabel(s.Gump) ); // display the selection button AddButton( 730, y + 22 * (i%MaxEntriesPerPage) + 32, (sel? 0xD3:0xD2), (sel? 0xD2:0xD3), 4000+i, GumpButtonType.Reply, 0 ); } // display the selected entry information for editing XmlDialog.SpeechEntry sentry = null; if(Selected >= 0 && Selected + DisplayFrom >= 0 && Selected + DisplayFrom < m_SearchList.Count) { sentry = (XmlDialog.SpeechEntry)m_SearchList[Selected+ DisplayFrom]; } if(sentry != null) { y = height - 200; // add the entry parameters lw = 15; w = 40; x = 10; int spacing = 11; // entry number AddLabel( x, y, 0x384, "#" ); AddImageTiled( x+lw, y, w, 21, 0xBBC ); AddTextEntry( x+lw, y, w, 21, 0, 200, sentry.EntryNumber.ToString() ); x += w + lw + spacing; w = 40; lw = 17; // ID number AddLabel( x, y, 0x384, "ID" ); AddImageTiled( x+lw, y, w, 21, 0xBBC ); AddTextEntry( x+lw, y, w, 21, 0, 201, sentry.ID.ToString() ); x += w + lw + spacing; w = 40; lw = 65; // depends on AddLabel( x, y, 0x384, "DependsOn" ); AddImageTiled( x+lw, y, w, 21, 0xBBC ); AddTextEntry( x+lw, y, w, 21, 0, 202, sentry.DependsOn ); x += w + lw + spacing; w = 35; lw = 57; // prepause AddLabel( x, y, 0x384, "PrePause" ); AddImageTiled( x+lw, y, w, 21, 0xBBC ); AddTextEntry( x+lw, y, w, 21, 0, 203, sentry.PrePause.ToString() ); x += w + lw + spacing; w = 35; lw = 37; // pause AddLabel( x, y, 0x384, "Pause" ); AddImageTiled( x+lw, y, w, 21, 0xBBC ); AddTextEntry( x+lw, y, w, 21, 0, 204, sentry.Pause.ToString() ); x += w + lw + spacing; w = 37; lw = 26; // speech hue AddLabel( x, y, 0x384, "Hue" ); AddImageTiled( x+lw, y, w, 21, 0xBBC ); AddTextEntry( x+lw, y, w, 21, 0, 205, sentry.SpeechHue.ToString() ); x += w + lw + spacing; w = 20; lw = 52; // lock conversation AddLabel(x, y, 0x384, "IgnoreCar"); AddCheck(x + lw, y, 0xD2, 0xD3, sentry.IgnoreCarried, 252); x += w + lw + spacing; w = 20; lw = 42; // lock conversation AddLabel( x, y, 0x384, "LockOn" ); AddCheck( x+lw, y, 0xD2, 0xD3, sentry.LockConversation, 250); x += w + lw + spacing; w = 20; lw = 54; // npctrigger AddLabel( x, y, 0x384, "AllowNPC" ); AddCheck( x+lw, y, 0xD2, 0xD3, sentry.AllowNPCTrigger, 251); w = 650; x = 70; y += 27; // add the keyword entry AddLabel( 10, y, 0x384, "Keywords" ); AddImageTiled( x, y, w, 21, 0xBBC ); AddTextEntry( x+1, y, w, 21, 0, 101, sentry.Keywords ); AddButton( 720, y, 0xFAB, 0xFAD, 5001, GumpButtonType.Reply, 0 ); y += 22; // add the text entry AddLabel( 10, y, 0x384, "Text" ); AddImageTiled( x, y, w, 21, 0xBBC ); AddTextEntry( x+1, y, w, 21, 0, 100, sentry.Text ); AddButton( 720, y, 0xFAB, 0xFAD, 5000, GumpButtonType.Reply, 0 ); y += 22; // add the condition string entry AddLabel( 10, y, 0x384, "Condition" ); AddImageTiled( x, y, w, 21, 0xBBC ); AddTextEntry( x+1, y, w, 21, 0, 102, sentry.Condition ); AddButton( 720, y, 0xFAB, 0xFAD, 5002, GumpButtonType.Reply, 0 ); y += 22; // add the action string entry AddLabel( 10, y, 0x384, "Action" ); AddImageTiled( x, y, w, 21, 0xBBC ); AddTextEntry( x+1, y, w, 21, 0, 103, sentry.Action ); AddButton( 720, y, 0xFAB, 0xFAD, 5003, GumpButtonType.Reply, 0 ); y += 22; // add the gump string entry AddLabel( 10, y, 0x384, "Gump" ); AddImageTiled( x, y, w, 21, 0xBBC ); AddTextEntry( x+1, y, w, 21, 0, 104, sentry.Gump ); AddButton( 720, y, 0xFAB, 0xFAD, 5004, GumpButtonType.Reply, 0 ); } y = height - 50; AddLabel( 10, y, 0x384, "Config:" ); AddImageTiled( 50, y , 120, 19, 0x23F4 ); AddLabel( 50, y, 0, m_Dialog.ConfigFile ); if(from.AccessLevel >= XmlSpawner.DiskAccessLevel) { // add the save entry AddButton( 185, y , 0xFA8, 0xFAA, 159, GumpButtonType.Reply, 0 ); AddLabel( 218, y , 0x384, "Save to file:" ); AddImageTiled( 300, y , 180, 19, 0xBBC ); AddTextEntry( 300, y, 180, 19, 0, 300, SaveFilename ); } // display the item list if(m_SearchList != null) { AddLabel( 495, y, 68, String.Format("{0} Entries",m_SearchList.Count) ); int last = DisplayFrom + MaxEntries < m_SearchList.Count ? DisplayFrom + MaxEntries : m_SearchList.Count; if(last > 0) AddLabel( 595, y, 68, String.Format("Displaying {0}-{1}",DisplayFrom, last -1) ); } y = height - 25; // add run status display if(m_Dialog.Running) { AddButton( 10, y-5, 0x2A4E, 0x2A3A, 100, GumpButtonType.Reply, 0 ); AddLabel( 43, y, 0x384, "On" ); } else { AddButton( 10, y-5, 0x2A62, 0x2A3A, 100, GumpButtonType.Reply, 0 ); AddLabel( 43, y, 0x384, "Off" ); } // add the Refresh/Sort button AddButton( 80, y, 0xFAB, 0xFAD, 700, GumpButtonType.Reply, 0 ); AddLabel( 113, y, 0x384, "Refresh" ); // add the Add button AddButton( 185, y, 0xFAB, 0xFAD, 155, GumpButtonType.Reply, 0 ); AddLabel( 218, y, 0x384, "Add" ); // add the Delete button AddButton( 255, y, 0xFB1, 0xFB3, 156, GumpButtonType.Reply, 0 ); AddLabel( 283, y, 0x384, "Delete" ); // add the page buttons for(int i = 0;i<(int)(MaxEntries/MaxEntriesPerPage);i++) { AddButton( 513+i*25, y, 0x8B1+i, 0x8B1+i, 0, GumpButtonType.Page, 1+i ); } // add the advance pageblock buttons AddButton( 510+25*(int)(MaxEntries/MaxEntriesPerPage), y, 0x15E1, 0x15E5, 201, GumpButtonType.Reply, 0 ); // block forward AddButton( 490, y, 0x15E3, 0x15E7, 202, GumpButtonType.Reply, 0 ); // block backward // add the displayfrom entry AddLabel( 555, y, 0x384, "Display" ); AddImageTiled( 595, y, 60, 21, 0xBBC ); AddTextEntry( 595, y, 60, 21, 0, 400, DisplayFrom.ToString() ); AddButton( 655, y, 0xFAB, 0xFAD, 9998, GumpButtonType.Reply, 0 ); //AddLabel( 610, y, 0x384, "Select All" ); // display the select-all toggle //AddButton( 670, y, (SelectAll? 0xD3:0xD2), (SelectAll? 0xD2:0xD3), 3998, GumpButtonType.Reply, 0 ); }
public override void OnResponse( NetState state, RelayInfo info ) { if(info == null || state == null || state.Mobile == null) return; int radiostate = -1; if(info.Switches.Length > 0) { radiostate = info.Switches[0]; } switch(info.ButtonID) { default: { if(radiostate == 1) { // accept // add the attachment XmlDialog xd = new XmlDialog(); XmlAttach.AttachTo(state.Mobile, m_Targeted, xd); // open the editing gump state.Mobile.SendGump( new XmlEditDialogGump(state.Mobile, true, xd, -1, 0, null, false, null, 0, 0)); } break; } } }