public void Dispose() { if (ResponseTimer != null) { ResponseTimer.Dispose(); ResponseTimer = null; } }
public virtual void OnSpeech( SpeechEventArgs e ) { //Check Response if( e.Mobile.Alive && e.Mobile.InRange( m_Mobile.Location, 3 ) && m_Mobile.Body.IsHuman ) { if (!(m_Mobile is BaseHire) && !(m_Mobile is BaseEscortable)) { m_Mobile.Direction = m_Mobile.GetDirectionTo(e.Mobile); Timer m_timer = new ResponseTimer(m_Mobile, e, this); m_timer.Start(); } if (e.HasKeyword(0x9D) && WasNamed(e.Speech)) // *move* { if (m_Mobile.Combatant != null) { // I am too busy fighting to deal with thee! int OldHue = m_Mobile.SpeechHue; m_Mobile.SpeechHue = 0x3B2; m_Mobile.Say(true, "I am too busy fighting to deal with thee!"); m_Mobile.SpeechHue = OldHue; //m_Mobile.PublicOverheadMessage( MessageType.Regular, 0x3B2, 501482 ); } else { // Excuse me? int OldHue = m_Mobile.SpeechHue; m_Mobile.SpeechHue = 0x3B2; m_Mobile.Say(true, "Excuse me?"); m_Mobile.SpeechHue = OldHue; //m_Mobile.PublicOverheadMessage( MessageType.Regular, 0x3B2, 501516 ); WalkRandomInHome(2, 2, 1); } } else if (e.HasKeyword(0x9E) && WasNamed(e.Speech)) // *time* { if (m_Mobile.Combatant != null) { // I am too busy fighting to deal with thee! int OldHue = m_Mobile.SpeechHue; m_Mobile.SpeechHue = 0x3B2; m_Mobile.Say(true, "I am too busy fighting to deal with thee!"); m_Mobile.SpeechHue = OldHue; //m_Mobile.PublicOverheadMessage( MessageType.Regular, 0x3B2, 501482 ); } else { int generalNumber; string exactTime; Clock.GetTime(m_Mobile, out generalNumber, out exactTime); int OldHue = m_Mobile.SpeechHue; m_Mobile.SpeechHue = 0x3B2; switch (generalNumber - 1042950) { case 0: m_Mobile.Say(true, "'Tis the witching hour. 12 Midnight."); break; case 1: m_Mobile.Say(true, "It's the middle of the night"); break; case 2: m_Mobile.Say(true, "It's early in the morning"); break; case 3: m_Mobile.Say(true, "It's late in the morning"); break; case 4: m_Mobile.Say(true, "It's around noon"); break; case 5: m_Mobile.Say(true, "It's the afternoon"); break; case 6: m_Mobile.Say(true, "It's early in the evening"); break; case 7: m_Mobile.Say(true, "It's late at night"); break; } m_Mobile.SpeechHue = OldHue; //m_Mobile.PublicOverheadMessage( MessageType.Regular, 0x3B2, generalNumber ); } } else if (e.HasKeyword(0x6C) && WasNamed(e.Speech)) // *train { if (m_Mobile.Combatant != null) { // I am too busy fighting to deal with thee! int OldHue = m_Mobile.SpeechHue; m_Mobile.SpeechHue = 0x3B2; m_Mobile.Say(true, "I am too busy fighting to deal with thee!"); m_Mobile.SpeechHue = OldHue; //m_Mobile.PublicOverheadMessage( MessageType.Regular, 0x3B2, 501482 ); } else { bool foundSomething = false; Skills ourSkills = m_Mobile.Skills; Skills theirSkills = e.Mobile.Skills; for (int i = 0; i < ourSkills.Length && i < theirSkills.Length; ++i) { Skill skill = ourSkills[i]; Skill theirSkill = theirSkills[i]; if (skill != null && theirSkill != null && skill.Base >= 60.0 && m_Mobile.CheckTeach(skill.SkillName, e.Mobile)) { double toTeach = skill.Base / 3.0; if (toTeach > 42.0) toTeach = 42.0; if (toTeach > theirSkill.Base) { int number = 1043059 + i; if (number > 1043107) continue; if (!foundSomething) m_Mobile.Say(true, "I can train the following:"); // I can train the following: //m_Mobile.Say( number ); switch (i) { case 0: m_Mobile.Say(true, "alchemy"); break; case 1: m_Mobile.Say(true, "anatomy"); break; case 2: m_Mobile.Say(true, "animal lore"); break; case 3: m_Mobile.Say(true, "item identification"); break; case 4: m_Mobile.Say(true, "armslore"); break; case 5: m_Mobile.Say(true, "parrying"); break; case 6: m_Mobile.Say(true, "begging"); break; case 7: m_Mobile.Say(true, "blacksmithy"); break; case 8: m_Mobile.Say(true, "fletching"); break; case 9: m_Mobile.Say(true, "peacemaking"); break; case 10: m_Mobile.Say(true, "camping"); break; case 11: m_Mobile.Say(true, "carpentry"); break; case 12: m_Mobile.Say(true, "cartography"); break; case 13: m_Mobile.Say(true, "cooking"); break; case 14: m_Mobile.Say(true, "detecting hidden"); break; case 15: m_Mobile.Say(true, "discordance"); break; case 16: m_Mobile.Say(true, "evaluate intelligence"); break; case 17: m_Mobile.Say(true, "healing"); break; case 18: m_Mobile.Say(true, "fishing"); break; case 19: m_Mobile.Say(true, "forensic evaluation"); break; case 20: m_Mobile.Say(true, "herding"); break; case 21: m_Mobile.Say(true, "hiding"); break; case 22: m_Mobile.Say(true, "provoking"); break; case 23: m_Mobile.Say(true, "inscription"); break; case 24: m_Mobile.Say(true, "lockpicking"); break; case 25: m_Mobile.Say(true, "magery"); break; case 26: m_Mobile.Say(true, "resist spells"); break; case 27: m_Mobile.Say(true, "tactics"); break; case 28: m_Mobile.Say(true, "snooping"); break; case 29: m_Mobile.Say(true, "musicianship"); break; case 30: m_Mobile.Say(true, "poisoning"); break; case 31: m_Mobile.Say(true, "archery"); break; case 32: m_Mobile.Say(true, "spirit speak"); break; case 33: m_Mobile.Say(true, "stealing"); break; case 34: m_Mobile.Say(true, "tailoring"); break; case 35: m_Mobile.Say(true, "taming"); break; case 36: m_Mobile.Say(true, "taste identification"); break; case 37: m_Mobile.Say(true, "tinkering"); break; case 38: m_Mobile.Say(true, "tracking"); break; case 39: m_Mobile.Say(true, "veterinary"); break; case 40: m_Mobile.Say(true, "swordsmanship"); break; case 41: m_Mobile.Say(true, "maces"); break; case 42: m_Mobile.Say(true, "fencing"); break; case 43: m_Mobile.Say(true, "wrestling"); break; case 44: m_Mobile.Say(true, "lumberjacking"); break; case 45: m_Mobile.Say(true, "mining"); break; //case 46: m_Mobile.Say(true, "meditation"); break; //case 47: m_Mobile.Say(true, "stealth"); break; case 48: m_Mobile.Say(true, "disarming traps"); break; } foundSomething = true; } } } if (!foundSomething) m_Mobile.Say(true, "Alas, I cannot teach thee anything."); // Alas, I cannot teach thee anything. e.Handled = true; } } else { SkillName toTrain = (SkillName)(-1); for (int i = 0; toTrain == (SkillName)(-1) && i < e.Keywords.Length; ++i) { int keyword = e.Keywords[i]; if (keyword == 0x154) { toTrain = SkillName.Anatomy; } else if (keyword >= 0x6D && keyword <= 0x9C) { int index = keyword - 0x6D; if (index >= 0 && index < m_KeywordTable.Length) toTrain = m_KeywordTable[index]; } } if (toTrain != (SkillName)(-1) && WasNamed(e.Speech)) { if (m_Mobile.Combatant != null) { // I am too busy fighting to deal with thee! int OldHue = m_Mobile.SpeechHue; m_Mobile.SpeechHue = 0x3B2; m_Mobile.Say(true, "I am too busy fighting to deal with thee!"); m_Mobile.SpeechHue = OldHue; e.Handled = true; //m_Mobile.PublicOverheadMessage( MessageType.Regular, 0x3B2, 501482 ); //m_Mobile.Say(true, "I am too busy fighting to deal with thee!"); } else { Skills skills = m_Mobile.Skills; Skill skill = skills[toTrain]; if (skill == null || skill.Base < 60.0 || !m_Mobile.CheckTeach(toTrain, e.Mobile)) { m_Mobile.Say(true, "'Tis not something I can teach thee of."); // 'Tis not something I can teach thee of. e.Handled = true; } else { m_Mobile.Teach(toTrain, e.Mobile, 0, false); e.Handled = true; } } } } } if( m_Mobile.Controlled && m_Mobile.Commandable ) { m_Mobile.DebugSay( "Listening..." ); bool isOwner = (e.Mobile == m_Mobile.ControlMaster); bool isFriend = (!isOwner && m_Mobile.IsPetFriend( e.Mobile )); if( e.Mobile.Alive && (isOwner || isFriend) ) { m_Mobile.DebugSay( "It's from my master" ); int[] keywords = e.Keywords; string speech = e.Speech; // First, check the all* /*for( int i = 0; i < keywords.Length; ++i ) { int keyword = keywords[i]; switch( keyword ) { case 0x164: // all come { if( !isOwner ) break; if( m_Mobile.CheckControlChance( e.Mobile ) ) { m_Mobile.ControlTarget = null; m_Mobile.ControlOrder = OrderType.Come; } return; } case 0x165: // all follow { BeginPickTarget( e.Mobile, OrderType.Follow ); return; } case 0x166: // all guard case 0x16B: // all guard me { if( !isOwner ) break; if( m_Mobile.CheckControlChance( e.Mobile ) ) { m_Mobile.ControlTarget = null; m_Mobile.ControlOrder = OrderType.Guard; } return; } case 0x167: // all stop { if( m_Mobile.CheckControlChance( e.Mobile ) ) { m_Mobile.ControlTarget = null; m_Mobile.ControlOrder = OrderType.Stop; } return; } case 0x168: // all kill case 0x169: // all attack { if( !isOwner ) break; BeginPickTarget( e.Mobile, OrderType.Attack ); return; } case 0x16C: // all follow me { if( m_Mobile.CheckControlChance( e.Mobile ) ) { m_Mobile.ControlTarget = e.Mobile; m_Mobile.ControlOrder = OrderType.Follow; } return; } case 0x170: // all stay { if( m_Mobile.CheckControlChance( e.Mobile ) ) { m_Mobile.ControlTarget = null; m_Mobile.ControlOrder = OrderType.Stay; } return; } } }*/ // No all*, so check *command for( int i = 0; i < keywords.Length; ++i ) { int keyword = keywords[i]; switch( keyword ) { case 0x155: // *come { if( !isOwner ) break; if( WasNamed( speech ) && m_Mobile.CheckControlChance( e.Mobile ) && !e.Handled ) { if (m_Mobile is BaseHire) m_Mobile.Say(true, "Very well."); m_Mobile.ControlTarget = null; m_Mobile.ControlOrder = OrderType.Come; e.Handled = true; } return; } case 0x156: // *drop { if( !isOwner ) break; if( !m_Mobile.IsDeadPet && !m_Mobile.Summoned && WasNamed( speech ) && m_Mobile.CheckControlChance( e.Mobile ) && !e.Handled ) { if (m_Mobile is BaseHire) m_Mobile.Say(true, "Very well."); m_Mobile.ControlTarget = null; m_Mobile.ControlOrder = OrderType.Drop; e.Handled = true; } return; } case 0x15A: // *follow { if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile) && !e.Handled) { if (m_Mobile is BaseHire) m_Mobile.Say(true, "Who shall I follow?"); BeginPickTarget(e.Mobile, OrderType.Follow); e.Handled = true; } return; } case 0x15B: // *friend { if( !isOwner ) break; if( WasNamed( speech ) && m_Mobile.CheckControlChance( e.Mobile ) && !e.Handled) { if( m_Mobile.Summoned ) e.Mobile.SendAsciiMessage( "Summoned creatures are loyal only to their summoners." ); // Summoned creatures are loyal only to their summoners. else if (e.Mobile.HasTrade) e.Mobile.SendAsciiMessage(" You cannot friend a pet with a trade pending."); // You cannot friend a pet with a trade pending else { if (m_Mobile is BaseHire) m_Mobile.Say(true, "I shall obey this person's orders as if they were your own."); BeginPickTarget(e.Mobile, OrderType.Friend); } e.Handled = true; } return; } case 0x15C: // *guard { if( !isOwner ) break; if( !m_Mobile.IsDeadPet && WasNamed( speech ) && m_Mobile.CheckControlChance( e.Mobile ) && !e.Handled ) { if (m_Mobile is BaseHire) m_Mobile.Say(true, "Very well."); m_Mobile.ControlTarget = null; m_Mobile.ControlOrder = OrderType.Guard; e.Handled = true; } return; } case 0x15D: // *kill case 0x15E: // *attack { if( !isOwner ) break; if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile) && !e.Handled) { if (m_Mobile is BaseHire) m_Mobile.Say(true, "Who should I attack?"); BeginPickTarget(e.Mobile, OrderType.Attack); e.Handled = true; } return; } case 0x15F: // *patrol { if( !isOwner ) break; if( WasNamed( speech ) && m_Mobile.CheckControlChance( e.Mobile ) && !e.Handled ) { if (m_Mobile is BaseHire) m_Mobile.Say(true, "Patrolling."); m_Mobile.ControlTarget = null; m_Mobile.ControlOrder = OrderType.Patrol; e.Handled = true; } return; } case 0x161: // *stop { if( WasNamed( speech ) && m_Mobile.CheckControlChance( e.Mobile ) && !e.Handled ) { if (m_Mobile is BaseHire) m_Mobile.Say(true, "Very well."); m_Mobile.ControlTarget = null; m_Mobile.ControlOrder = OrderType.Stop; e.Handled = true; } return; } case 0x163: // *follow me { if( WasNamed( speech ) && m_Mobile.CheckControlChance( e.Mobile ) && !e.Handled) { if (m_Mobile is BaseHire) m_Mobile.Say(true, "Very well."); m_Mobile.ControlTarget = e.Mobile; m_Mobile.ControlOrder = OrderType.Follow; e.Handled = true; } return; } case 0x16D: // *release { if( !isOwner ) break; if( WasNamed( speech ) && m_Mobile.CheckControlChance( e.Mobile ) && !e.Handled) { /*if( !m_Mobile.Summoned ) { e.Mobile.SendGump( new Gumps.ConfirmReleaseGump( e.Mobile, m_Mobile ) ); } else {*/ if (m_Mobile is BaseHire) m_Mobile.Say(true, "I thank thee for thy kindness!"); m_Mobile.ControlTarget = null; m_Mobile.ControlOrder = OrderType.Release; e.Handled = true; //} } return; } case 0x16E: // *transfer { if( !isOwner ) break; if( !m_Mobile.IsDeadPet && WasNamed( speech ) && m_Mobile.CheckControlChance( e.Mobile ) && !e.Handled ) { /*if( m_Mobile.Summoned ) e.Mobile.SendAsciiMessage( "You cannot transfer ownership of a summoned creature." ); // You cannot transfer ownership of a summoned creature. else */ if (e.Mobile.HasTrade) e.Mobile.SendAsciiMessage("You cannot transfer a pet with a trade pending."); // You cannot transfer a pet with a trade pending else { if (m_Mobile is BaseHire) m_Mobile.Say(true, "Whom do you wish me to work for?"); BeginPickTarget(e.Mobile, OrderType.Transfer); } e.Handled = true; } return; } case 0x16F: // *stay { if( WasNamed( speech ) && m_Mobile.CheckControlChance( e.Mobile ) && !e.Handled) { if (m_Mobile is BaseHire) m_Mobile.Say(true, "Very well."); m_Mobile.ControlTarget = null; m_Mobile.ControlOrder = OrderType.Stay; e.Handled = true; } return; } } } } } else { if( e.Mobile.AccessLevel >= AccessLevel.GameMaster ) { m_Mobile.DebugSay( "It's from a GM" ); if( m_Mobile.FindMyName( e.Speech, true ) ) { string[] str = e.Speech.Split( ' ' ); int i; for( i=0; i < str.Length; i++ ) { string word = str[i]; if( Insensitive.Equals( word, "obey" ) ) { m_Mobile.SetControlMaster( e.Mobile ); if( m_Mobile.Summoned ) m_Mobile.SummonMaster = e.Mobile; return; } } } } } }