private ConvoTimer GetConvo(Mobile m) { if (m_ConvoList != null) { for (int i = 0; i < m_ConvoList.Count; i++) { ConvoTimer ct = (ConvoTimer)m_ConvoList[i]; if (ct.Mobile == m) { return(ct); } } } return(null); }
private ConvoTimer StartConvo(Mobile m) { /* --from convinit.frg, seems unneeded w/proper use of greetings.frg * Fragment f = (Fragment)m_Frg[InitFragment]; * if ( f != null ) * { * string str = f.GetString( this, pc, "@InternalConvinit" ); * if ( str != null ) * Say( String.Format( str, m.Name, this.Name, "", "", "" ) ); * } */ if (m_ConvoList == null) { m_ConvoList = new ArrayList(1); } ConvoTimer ct = new ConvoTimer(this, m); m_ConvoList.Add(ct); ct.Start(); return(ct); }
private ConvoTimer StartConvo(Mobile m) { /* --from convinit.frg, seems unneeded w/proper use of greetings.frg Fragment f = (Fragment)m_Frg[InitFragment]; if ( f != null ) { string str = f.GetString( this, pc, "@InternalConvinit" ); if ( str != null ) Say( String.Format( str, m.Name, this.Name, "", "", "" ) ); } */ if (m_ConvoList == null) m_ConvoList = new ArrayList(1); ConvoTimer ct = new ConvoTimer(this, m); m_ConvoList.Add(ct); ct.Start(); return ct; }
public override void OnSpeech(SpeechEventArgs e) { Mobile pc = e.Mobile; if (base.HandlesOnSpeech(pc)) { base.OnSpeech(e); } if (Enabled && !e.Handled && !e.Blocked && pc != null && pc.Player && pc.Alive && (int)GetDistanceToSqrt(pc) < 4 && InLOS(pc) && pc != ControlMaster) { string said = e.Speech; string str = null; if (said == null) { return; } ConvoTimer ct = GetConvo(pc); if (ct == null) { bool convo = false; Fragment f = (Fragment)m_Frg[GreetingFragment]; if (f != null) { str = f.GetString(this, pc, said); convo = str != null && str.Length > 0; } if (!convo && this.Name != null) { convo = said.ToLower().IndexOf(this.Name.ToLower()) != -1; } if (convo) { DebugSay("They are talking to me!"); ct = StartConvo(pc); if (str == null) { str = "Hail, traveler."; } if (!OnConvoStart(pc)) { str = null; } } else { DebugSay("I dont think they are talking to me."); } } else { m_List.Clear(); if (m_Job != JobFragment.None) { m_List.Add((int)m_Job); } GetConvoFragments(m_List); if (m_List.Count > 0) { for (int i = 0; i < m_List.Count && str == null; i++) { Fragment f = (Fragment)m_Frg[(int)m_List[i]]; if (f != null) { str = f.GetString(this, pc, said); } } } if (str == null) { Fragment f = (Fragment)m_Frg[EndFragment]; Console.WriteLine(string.Format("Ligne 921 on a Fragment: {0}.", f)); if (f != null) { str = f.GetString(this, pc, said); } if (str == null) { f = (Fragment)m_Frg[DefaultFragment]; if (f != null && Utility.Random(4) == 0) { str = f.GetString(this, pc, said); } } else { DebugSay("They ended the conversation"); if (this.FocusMob == pc) { this.FocusMob = null; } ct.Stop(); if (m_ConvoList != null) { m_ConvoList.Remove(ct); } } } else if (this.AIObject != null) { ct.Refresh(); if (this.AIObject.Action == ActionType.Wander || this.AIObject.Action == ActionType.Interact) { this.AIObject.Action = ActionType.Interact; this.FocusMob = pc; } } } if (str != null && str.Length > 0) { string town = this.Region.Name; // : "wilderness"; if (town == null || town.Length <= 1) { town = "great wide open"; } string job = this.Title != null && this.Title.StartsWith("the") ? this.Title.Substring(5) : m_Job.ToString(); Say(String.Format(str, pc != null ? pc.Name : "someone", this.Name, job, town, "")); e.Handled = true; } } }