RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

old attack messages

Peterson

Wanderer
old attack messages

This is my first script :) . Just replace this file with your current AttackMessage.cs, what this does is makes it so when someone, or something is being attacked, players within 16 tiles of the player/monster gets a message saying "you see blah attacking blah!" However it only gives this message to players who are not attacking the person or being attacked. the people being attacked, and attacking still get the normal message above the head if they are attacking another player.
 

Attachments

  • AttackMessage.cs
    2.1 KB · Views: 77

Packer898

Knight
I take it this was for version 1.0? It wouldnt compile on 2.0. I changed the arraylist to work with 2.0 and changed the forloop also. The way you had it set it, with !aggressor.Player, it would only display the message if neither aggressor or aggressed was a playermobile. Anyway.

[2.0] RC1 version:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Network;

namespace Server.Misc
{
	public class AttackMessage
	{
		private const string AggressorFormat = "You are attacking {0}!";
		private const string AggressedFormat = "{0} is attacking you!";
		private const string ViewerFormat = "You see {0} attacking {1}!";
		private const int Hue = 0x22;
		
		private static TimeSpan Delay = TimeSpan.FromMinutes( 1.0 );

		public static void Initialize()
		{
			EventSink.AggressiveAction += new AggressiveActionEventHandler( EventSink_AggressiveAction );
		}

		public static void EventSink_AggressiveAction( AggressiveActionEventArgs e )
		{
			Mobile aggressor = e.Aggressor;
			Mobile aggressed = e.Aggressed;
			
			if ( !CheckAggressions( aggressor, aggressed ) )
			{
				if(aggressed.Player)
					aggressor.LocalOverheadMessage( MessageType.Regular, Hue, true, String.Format( AggressorFormat, aggressed.Name ) );
				if(aggressor.Player)
					aggressed.LocalOverheadMessage( MessageType.Regular, Hue, true, String.Format( AggressedFormat, aggressor.Name ) );
				
				foreach ( Mobile m in aggressor.GetMobilesInRange( 16 ) )
				{
					if( aggressor.Player && aggressed.Player )
						m.SendMessage(String.Format("You see {0} attacking {1}!", aggressor.Name, aggressed.Name));
				}
			}
		}

		public static bool CheckAggressions( Mobile m1, Mobile m2 )
		{
			List<AggressorInfo> list = m1.Aggressors;

			for ( int i = 0; i < list.Count; ++i )
			{
				AggressorInfo info = (AggressorInfo)list[i];

				if ( info.Attacker == m2 && DateTime.Now < (info.LastCombatTime + Delay) )
					return true;
			}

			list = m2.Aggressors;

			for ( int i = 0; i < list.Count; ++i )
			{
				AggressorInfo info = (AggressorInfo)list[i];

				if ( info.Attacker == m1 && DateTime.Now < (info.LastCombatTime + Delay) )
					return true;
			}
			return false;
		}
	}
}
 
Top