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!

"Arena on Wheels"

Harmon

Wanderer
"Arena on Wheels"

Code:
	int newZ;
				if ( CheckMovement( d, out newZ ) )
				{
					int x = m_Location.m_X, y = m_Location.m_Y;
					int oldX = x, oldY = y;
					int oldZ = m_Location.m_Z;

					switch ( d & Direction.Mask )
					{
						case Direction.North:      --y; break;
						case Direction.Right: ++x; --y; break;
						case Direction.East:  ++x;      break;
						case Direction.Down:  ++x; ++y; break;
						case Direction.South:      ++y; break;
						case Direction.Left:  --x; ++y; break;
						case Direction.West:  --x;      break;
						case Direction.Up:    --x; --y; break;
					}
				}You can look at this, you can find the direction with this and after the --x or whatever put a check if they are in the duel zone
-Posted by Sorious


So somehow I would check the distance ( x / y ) between the players ( lets say it was 8 tiles ) and if it was more than this i could use those cases which move them back a tile based on direction?? *confused*

My original intent was to make it where they can step out of like 8 tiles of each other
 

Jeff

Lord
Ok PlayerMobile.cs Move method looks like this, let me comment whats going on.

Code:
public override bool Move( Direction d )
		{
			NetState ns = this.NetState;[COLOR="Red"]//Get the netstate for this player
[/COLOR]
			if ( ns != null )//Checks if its null
			{
				GumpCollection gumps = ns.Gumps;[COLOR="Red"]//Get all gumps in the netstate
[/COLOR]
				for ( int i = 0; i < gumps.Count; ++i )[COLOR="Red"]//checks if any are the res gump and 
                                                                                  //if so returns false so u dont run 
                                                                                  //around with the res gump[/COLOR]
				{
					if ( gumps[i] is ResurrectGump )
					{
						if ( Alive )
						{
							CloseGump( typeof( ResurrectGump ) );
						}
						else
						{
							SendLocalizedMessage( 500111 ); [COLOR="Red"]// You are frozen and cannot move.[/COLOR]
							return false;
						}
					}
				}
			}

			TimeSpan speed = ComputeMovementSpeed( d );[COLOR="Red"]//Checks your speed [/COLOR]

			if ( !base.Move( d ) )[COLOR="Red"]//Checks Mobile.cs in the core for allowed movement[/COLOR]
				return false;

			m_NextMovementTime += speed;[COLOR="Red"]//Sets your next move time
                                                                    //I believe this has something 
                                                                    //todo with fastwalk[/COLOR]
			return true;[COLOR="Red"]//Since nothing failed we return true and allow the move[/COLOR]
		}
Now with that done, heres what i would try todo.(All code off the top of my head and untested.)

Code:
		public override bool Move( Direction d )
		{
			NetState ns = this.NetState;

			if ( ns != null )
			{
				GumpCollection gumps = ns.Gumps;

				for ( int i = 0; i < gumps.Count; ++i )
				{
					if ( gumps[i] is ResurrectGump )
					{
						if ( Alive )
						{
							CloseGump( typeof( ResurrectGump ) );
						}
						else
						{
							SendLocalizedMessage( 500111 ); // You are frozen and cannot move.
							return false;
						}
					}
				}
			}

			TimeSpan speed = ComputeMovementSpeed( d );

			if ( !base.Move( d ) )
				return false;

			m_NextMovementTime += speed;

           [COLOR="Red"] int yOffset = 0;
            int xOffset = 0;
            if( Server.Customs.OnSiteDueling.OnSiteCore.IsInDuel( m ) )
            {
                Server.Customs.OnSiteDueling.OnSiteCore.Duel duel = Server.Customs.OnSiteDueling.OnSiteCore.GetDuel( m );

                if( duel.Started )
                {
                    switch( d & Direction.Mask )
                    {
                        case Direction.North:
                            {
                                --yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.Right:
                            {
                                ++xOffset;
                                --yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.East:
                            {
                                ++xOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.Down:
                            {
                                ++xOffset;
                                ++yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.South:
                            {
                                ++yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.Left:
                            {
                                --xOffset;
                                ++yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.West:
                            {
                                --xOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.Up:
                            {
                                --xOffset;
                                --yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                    }
                }
            } [/COLOR]             

			return true;
		}

                [COLOR="Red"]//Check algorithm (prolly not the best to use but it will work for the time being.[/COLOR]
                [COLOR="Red"]public bool FartherThenDistance( Mobile one, Mobile two, int distance )
                {
                    if( ( one.Location.X - two.Location.X ) >= distance ||
                    ( one.Location.X - two.Location.X ) <= -distance ||
                    ( one.Location.Y - two.Location.Y ) >= distance ||
                    ( one.Location.Y - two.Location.Y ) <= -distance )
                        return false;
                    return true;  
                }
[/COLOR]

All added code is highlighted red, Please ask questions about anything you dont understand. I would comment it but its hard todo in the thread post screen :)
 

Harmon

Wanderer
Omg... sorious actually you went to the length of scripting the whole thing... You should open a donation on paypal, I'm sure many of the people you help would gladly support you.

-If I have any problems I'll post back, thx lots bro
 

Jeff

Lord
Harmon said:
Omg... sorious actually you went to the length of scripting the whole thing... You should open a donation on paypal, I'm sure many of the people you help would gladly support you.

-If I have any problems I'll post back, thx lots bro
hahaha *thinks about it* nawwww :)
 

Harmon

Wanderer
I'm really confused...

What seems to be defined perfectly, it gives me the error "The type Duel does not exist in ___(server.etc.)" Using the line:

Server.Customs.OnSiteDueling.OnSiteCore.Duel duel =

Server.Customs.OnSiteDueling.OnSiteCore.GetDuel( m );

And it goes on saying can not find "duel.."

Strange...?
 

Jeff

Lord
can u post the exact errors? and your playmobile.cs

You can also try adding
using Server.Customs.OnSiteDueling;

To the top of PlayerMobile.cs

thne instead of Server.Customs.etc

Just use

OnSiteCore.GetDuel
and
OnSiteCore.IsInDuel
 

Harmon

Wanderer
I'm sorry I have to keep bugging you, but I just can't read the script on your level:

No overload for FartherThenDistance takes '5' arguments

FartherThenDistance( Mobile one, Mobile two, int distance )

FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );

They dont have the same number of arguments, and I have no idea how ot make them agree... : )
 

Jeff

Lord
Harmon said:
I'm sorry I have to keep bugging you, but I just can't read the script on your level:

No overload for FartherThenDistance takes '5' arguments

FartherThenDistance( Mobile one, Mobile two, int distance )

FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );

They dont have the same number of arguments, and I have no idea how ot make them agree... : )
oversight on my part sry

Code:
                public bool FartherThenDistance( Mobile one, Mobile two, int distance, int xOffset, int yOffset )
                {
                    if( ( ( one.Location.X + xOffset ) - two.Location.X ) >= distance ||
                    ( one.Location.X + xOffset )  - two.Location.X ) <= -distance ||
                    ( one.Location.Y + yOffset ) - two.Location.Y ) >= distance ||
                    ( one.Location.Y + yOffset )  - two.Location.Y ) <= -distance )
                        return false;
                    return true;  
                }
 

Harmon

Wanderer
Your method does kick in when they are more than 8 tiles away... but when this happens the player will just slide around like they are on ice... instead of being put back into their original space...


Any ideas man... you've brought me so far... I would hate** to see all this code go to waste, I just can't for the life of me figure out why it is doing this

I did add break; after all the cases if that makes a diff.
 

Jeff

Lord
Harmon said:
Your method does kick in when they are more than 8 tiles away... but when this happens the player will just slide around like they are on ice... instead of being put back into their original space...


Any ideas man... you've brought me so far... I would hate** to see all this code go to waste, I just can't for the life of me figure out why it is doing this

I did add break; after all the cases if that makes a diff.
return acts as a break in the same, lemme take a look....
 

Harmon

Wanderer
It just almost seems as if it moves them in the oppisite direction, I'm just lost bro, thx for takin' a look
 

Jeff

Lord
ok, I see the issue man, but i dont know how to get around it yet

The issue is base.Move accually moves you, then you declare false and it seems as if it messes shit up. Looking at this now its even alot more difficult then I had though, so gimmie a little bit to work on it.
 

Jeff

Lord
ok try this. im not sure if this will work but its worth a shot

Code:
        public override bool Move( Direction d )
        {
            NetState ns = this.NetState;

            if( ns != null )
            {
                GumpCollection gumps = ns.Gumps;

                for( int i = 0; i < gumps.Count; ++i )
                {
                    if( gumps[i] is ResurrectGump )
                    {
                        if( Alive )
                        {
                            CloseGump( typeof( ResurrectGump ) );
                        }
                        else
                        {
                            SendLocalizedMessage( 500111 ); // You are frozen and cannot move.
                            return false;
                        }
                    }
                }
            }

            TimeSpan speed = ComputeMovementSpeed( d );

            if( !base.Move( d ) )
                return false;

            m_NextMovementTime += speed;

            if( OnSiteCore.IsInDuel( m ) )
            {
                Duel duel = OnSiteCore.GetDuel( m );

                if( duel.Started )
                {
                    if( duel.Attacker == this )
                        return FartherThenDistance( this, duel.Defender, 8 );
                    else
                        return FartherThenDistance( this, duel.Attacker, 8 );
                }
            }

            return true;
        }

        public bool FartherThenDistance( Mobile one, Mobile two, int distance )
        {
                    if( ( ( one.Location.X ) - two.Location.X ) >= distance ||
                    ( ( one.Location.X  ) - two.Location.X ) <= -distance ||
                    ( ( one.Location.Y ) - two.Location.Y ) >= distance ||
                    ( ( one.Location.Y ) - two.Location.Y ) <= -distance )
                        return false;

                    return true;  
        }
 

Harmon

Wanderer
Well... same issue, the char just slides around, thx for all your help Sor, I will never forget it :D

If at all possible would you be able to just kill person who runs away???
 

milt

Knight
Harmon if you tell me everything that you did after you installed the PvPKit so we can have the same files I will work on this for you. I wouldn't see why it doesn't work, so I would have to further investigate in game.

What exactly do you mean "slide around"? When you get 8 tiles away do you just like get your X's and Y's switched around? When you are at the northmost point of the duel, and you step the 8th tile north, which way do you go? How many X's or Y's away? With more info I can help you.
 

Harmon

Wanderer
milt said:
Harmon if you tell me everything that you did after you installed the PvPKit so we can have the same files I will work on this for you. I wouldn't see why it doesn't work, so I would have to further investigate in game.

What exactly do you mean "slide around"? When you get 8 tiles away do you just like get your X's and Y's switched around? When you are at the northmost point of the duel, and you step the 8th tile north, which way do you go? How many X's or Y's away? With more info I can help you.

Thx bro, I love how people in the community reach out to help others.

When I walk beyond 8 spaces, it seems as it moves me forward, either way I go, I've tried changing the x/y's but no luck...

-W/ what i'm doing all you need is a default OnSiteDuel file, all that you need to edit is the PlayerMobile.cs:

At the top of PM.cs:


Code:
using Server.Customs.OnSiteDueling;

Find the following in PM.cs and replace:

Code:
public override bool Move( Direction d )
		{
			NetState ns = this.NetState;

			if ( ns != null )
			{
				GumpCollection gumps = ns.Gumps;

				for ( int i = 0; i < gumps.Count; ++i )
				{
					if ( gumps[i] is ResurrectGump )
					{
						if ( Alive )
						{
							CloseGump( typeof( ResurrectGump ) );
						}
						else
						{
							SendLocalizedMessage( 500111 ); // You are frozen and cannot move.
							return false;
						}
					}
				}
			}

			TimeSpan speed = ComputeMovementSpeed( d );

			if ( !base.Move( d ) )
				return false;

			m_NextMovementTime += speed;
			
			 int yOffset = 0;
            int xOffset = 0;
            if( OnSiteCore.IsInDuel( this ) )
            {
                Duel duel = OnSiteCore.GetDuel( this );

                if( duel.Started )
                {
                    switch( d & Direction.Mask )
                    {
                        case Direction.North:
                            {
                                --yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.Right:
                            {
                                ++xOffset;
                                --yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.East:
                            {
                                ++xOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.Down:
                            {
                                ++xOffset;
                                ++yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.South:
                            {
                                ++yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.Left:
                            {
                                --xOffset;
                                ++yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.West:
                            {
                                --xOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                        case Direction.Up:
                            {
                                --xOffset;
                                --yOffset;
                                if( duel.Attacker == this )
                                    return FartherThenDistance( this, duel.Defender, 8, xOffset, yOffset );
                                else
                                    return FartherThenDistance( this, duel.Attacker, 8, xOffset, yOffset );
                            }
                    }
                }
            }              

			return true;
		}

Under that:

Code:
//Check algorithm (prolly not the best to use but it will work for the time being.
                public bool FartherThenDistance( Mobile one, Mobile two, int distance, int xOffset, int yOffset )
                {
                    if( ( one.Location.X - two.Location.X ) >= distance ||
                    ( one.Location.X - two.Location.X ) <= -distance ||
                    ( one.Location.Y - two.Location.Y ) >= distance ||
                    ( one.Location.Y - two.Location.Y ) <= -distance )
                        return false;
                    return true;  
                }
 
Top