View Single Post
Old 02-10-2006, 04:36 PM   #1 (permalink)
tejster24
Connection Reset by Peer
 
Join Date: Jan 2003
Posts: 676
Default Guild Chat using \

I've programmed guild chat using \ for my personal shard, and thought it might be a good idea to share.
The code really does need cleaning up, and I'm planning to do that in a day or two. I have not implemented Alliance chat. At the moment, this is just changed to Guild chat, as the functions necessary for checking alliances are not in the core (as far as I can see, if anyone knows otherwise, please tell me).

There are two files to modify.

File 1: Network\PacketHandlers.cs
Find:
Code:
	public enum MessageType
	{
		Regular = 0x00,
		System = 0x01,
		Emote = 0x02,
		Label = 0x06,
		Focus = 0x07,
		Whisper = 0x08,
		Yell = 0x09,
		Spell = 0x0A,
		Encoded = 0xC0
	}
Replace with:
Code:
	public enum MessageType
	{
		Regular = 0x00,
		System = 0x01,
		Emote = 0x02,
		Label = 0x06,
		Focus = 0x07,
		Whisper = 0x08,
		Yell = 0x09,
		Spell = 0x0A,
		Guild = 0x0D,
		Alliance = 0x0E,
		Encoded = 0xC0
	}
File 2: Network\Mobile.cs
Find:
Code:
			switch ( type )
			{
				case MessageType.Regular: m_SpeechHue = hue; break;
				case MessageType.Emote: m_EmoteHue = hue; break;
				case MessageType.Whisper: m_WhisperHue = hue; range = 1; break;
				case MessageType.Yell: m_YellHue = hue; range = 18; break;
				default: type = MessageType.Regular; break;
			}
Replace with:
Code:
			switch ( type )
			{
				case MessageType.Regular: m_SpeechHue = hue; break;
				case MessageType.Emote: m_EmoteHue = hue; break;
				case MessageType.Whisper: m_WhisperHue = hue; range = 1; break;
				case MessageType.Yell: m_YellHue = hue; range = 18; break;
				case MessageType.Guild: break;
				case MessageType.Alliance: type = MessageType.Guild; break;
				default: type = MessageType.Regular; break;
			}
Find:
Code:
			SpeechEventArgs regArgs = new SpeechEventArgs( this, text, type, hue, keywords );

			EventSink.InvokeSpeech( regArgs );
			m_Region.OnSpeech( regArgs );
			OnSaid( regArgs );
Replace with:
Code:
			SpeechEventArgs regArgs = new SpeechEventArgs( this, text, type, hue, keywords );

			if ( type == MessageType.Guild )
			{
				if ( this.Guild != null )
				{
					BaseGuild guild = this.Guild;
					foreach ( Mobile m in World.Mobiles.Values )
					{
						if ( m.Player )
						{
							if ( m.Guild == guild )
							{
								m.OnSpeech( regArgs );

								NetState ns = m.NetState;

								Packet regp = null;

								if ( ns != null )
								{
									if ( regp == null )
										regp = new UnicodeMessage( m_Serial, Body, type, hue, 3, m_Language, Name, text );

									ns.Send( regp );
								}

							}
						}
					}
				}

				return;
			}

			EventSink.InvokeSpeech( regArgs );
			m_Region.OnSpeech( regArgs );
			OnSaid( regArgs );
This should provide working guild chat. It has been rigously tested on my server, but I make no guarantees that it won't eat your world save, or something (even though it doesn't touch it ).

If you find any bugs or have any ideas for improvements, please inform me.

Remember that using a modified core means that you may not recieve script support!

Last edited by tejster24; 02-11-2006 at 09:09 PM.
tejster24 is offline   Reply With Quote