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!

XmlPoints - pvp dueling and challenge game system [RunUO 2.0]

I was reading over step 9 and it states:

STEP 9:
to display kills and deaths below the players name on mouseover add this to playermobile.cs

CODE

public override void AddNameProperties( ObjectPropertyList list )
{
base.AddNameProperties(list);

XmlPoints a = (XmlPoints)XmlAttach.FindAttachment(this, typeof(XmlPoints));

if (a != null)
{
list.Add(1070722, "Kills {0} / Deaths {1} : Rank={2}", a.Kills, a.Deaths, a.Rank);
}
}

okay, so where do I add this please.
 

ArteGordon

Wanderer
XxPrinceValoxX said:
If I only want to keep the point system and the challenge systems how do I do that?

I'm not exactly clear on what you want to get rid of. Do you want to get rid of the 1 on 1 challenge duels, or the multiplayer challenge games?

You can disable any of the individual duels/games by just commenting out the ir command in the Initialize method of xmlpoints.cs

Code:
			// Server.Commands.Register( "Challenge", AccessLevel.Player, new CommandEventHandler( Challenge_OnCommand ) );

and commenting out the button for them in the PointsGump in xmlpoints.cs

Code:
					// add the challenge button
					//AddLabel( x1 + 30, 190, 55, a.Text(200229) );   // "Challenge"
					//AddButton( x1, 190, 0xFAB, 0xFAD, 400, GumpButtonType.Reply, 0);
 

ArteGordon

Wanderer
Hanse the Insane said:
I was reading over step 9 and it states:

STEP 9:
to display kills and deaths below the players name on mouseover add this to playermobile.cs

CODE

public override void AddNameProperties( ObjectPropertyList list )
{
base.AddNameProperties(list);

XmlPoints a = (XmlPoints)XmlAttach.FindAttachment(this, typeof(XmlPoints));

if (a != null)
{
list.Add(1070722, "Kills {0} / Deaths {1} : Rank={2}", a.Kills, a.Deaths, a.Rank);
}
}

okay, so where do I add this please.


If you havent already added an AddNameProperties override to your playermobile, you can put it anywhere within the class, like here for example

Code:
	public class PlayerMobile : Mobile
	{
[color=red]// <-------- put it here[/color]
		public DateTime LastEmoteTime = DateTime.MinValue;
 
Thank you for taking the time to help me, I did as you stated, yet this error came up:

RunUO - [www.runuo.com] Version 2.0, Build 2357.32527
Core: Running on .NET Framework Version 2.0.50727
Core: Optimizing for 2 processors
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
Errors:
+ Mobiles/PlayerMobile.cs:
CS1514: Line 77: { expected
CS1519: Line 91: Invalid token '{' in class, struct, or interface member dec
laration
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 

ArteGordon

Wanderer
Kolo said:
ok, i install it, but there is any tutorial how to set up this system?

If you have gone through the installation steps, then it is already set up. You can duel or start games by either issuing the commands in the command list in the first post (such as [challenge), or you can do it from the points gump that you can open up using the [checkpoints command.
 

ArteGordon

Wanderer
Hanse the Insane said:
Thank you for taking the time to help me, I did as you stated, yet this error came up:

RunUO - [www.runuo.com] Version 2.0, Build 2357.32527
Core: Running on .NET Framework Version 2.0.50727
Core: Optimizing for 2 processors
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
Errors:
+ Mobiles/PlayerMobile.cs:
CS1514: Line 77: { expected
CS1519: Line 91: Invalid token '{' in class, struct, or interface member dec
laration
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

post the first part of your playermobile.cs
 

ArteGordon

Wanderer
XxPrinceValoxX said:
how do I change the places for the 1v1 chalenge?
at the beginning of XmlPoints.cs you will find this

Code:
		public static DuelLocationEntry[] DuelLocations = new DuelLocationEntry[]
			{
				new DuelLocationEntry("Jhelom Fighting Pit", 1398, 3742, -21, Map.Felucca, 14),
				new DuelLocationEntry("Luna Grand Arena", 940, 637, -90, Map.Malas, 4),
		};

You can change or add entries as you like.
 

Johabius

Knight
An error was encountered while loading a saved object

Hi Arte. Ran into a little problem when I restarted my server this afternoon, error report in debug mode:

Code:
RunUO - [www.runuo.com] Version 2.0, Build 2368.38595
Core: Running on .NET Framework Version 2.0.50727
Core: Running with arguments: -debug
Scripts: Compiling C# scripts...done (0 errors, 0 warnings)
Scripts: Compiling VB.NET scripts...no files found.
Scripts: Verifying...done (2297 items, 569 mobiles)
Regions: Loading...done
World: Loading...An error was encountered while loading a saved object
 - Type: Server.Engines.XmlSpawner2.ChallengeRegionStone
 - Serial: 0x400149B5
Delete the object? (y/n)
Delete all objects of that type? (y/n)
After pressing return an exception will be thrown and the server will terminate

Error:
System.Exception: Load failed (items=True, mobiles=False, guilds=False, type=Ser
ver.Engines.XmlSpawner2.ChallengeRegionStone, serial=0x400149B5) ---> System.Nul
lReferenceException: Object reference not set to an instance of an object.
   at Server.Region.Register()
   at Server.Engines.XmlSpawner2.ChallengeRegionStone.RefreshRegions() in c:\Doc
uments and Settings\Compaq_Owner\Desktop\RunUOShit\RunUO2SVN\Scripts\Customs\XML
Points\ChallengeRegionStone.cs:line 148
   at Server.Engines.XmlSpawner2.ChallengeRegionStone.Deserialize(GenericReader
reader) in c:\Documents and Settings\Compaq_Owner\Desktop\RunUOShit\RunUO2SVN\Sc
ripts\Customs\XMLPoints\ChallengeRegionStone.cs:line 282
   at Server.World.Load()
   --- End of inner exception stack trace ---
   at Server.World.Load()
   at Server.ScriptCompiler.Compile(Boolean debug, Boolean cache)
   at Server.Core.Main(String[] args)
This exception is fatal, press return to exit
Here's the ChallengeRegionStone file:
Code:
using System;
using Server;
using Server.Mobiles;
using Server.Items;
using Server.Regions;
using System.Collections;

namespace Server.Engines.XmlSpawner2
{

    public class ChallengeRegionStone : Item
    {

        public Map m_ChallengeMap;
        private string m_ChallengeRegionName;
        private ChallengeGameRegion m_ChallengeRegion;                    // challenge region
        private MusicName m_Music;
        private int m_Priority;
        private Rectangle3D [] m_ChallengeArea;
        private string m_CopiedRegion;
        private bool m_Disable;

        [CommandProperty( AccessLevel.GameMaster )]
        public Rectangle3D [] ChallengeArea
        {
            get { return m_ChallengeArea; }
            set { m_ChallengeArea = value;}
        }

        [CommandProperty( AccessLevel.GameMaster )]
        public bool DisableGuards
        {
            get { return m_Disable; }
            set 
            { 
                m_Disable = value;
                if(m_ChallengeRegion != null)
                {
                    m_ChallengeRegion.Unregister();
                    m_ChallengeRegion.Disabled = m_Disable;
                    m_ChallengeRegion.Register();
                }
            }
        }
        
        [CommandProperty( AccessLevel.GameMaster )]
        public string ChallengeRegionName
        {
            get { return m_ChallengeRegionName; }
            set
            { 
                m_ChallengeRegionName = value; 

                RefreshRegions();
            }
        }

        [CommandProperty( AccessLevel.GameMaster )]
        public ChallengeGameRegion ChallengeRegion
        {
            get { return m_ChallengeRegion; }
        }
        
        [CommandProperty( AccessLevel.GameMaster )]
        public Map ChallengeMap
        {
            get { return m_ChallengeMap; }
            set { 
                m_ChallengeMap = value; 

                RefreshRegions();
            }
        }
        
        [CommandProperty( AccessLevel.GameMaster )]
        public MusicName ChallengeMusic
        {
            get { return m_Music; }
            set { 
                m_Music = value;
                if(m_ChallengeRegion != null)
                {
                    m_ChallengeRegion.Unregister();
                    m_ChallengeRegion.Music = m_Music;
                    m_ChallengeRegion.Register();
                }
            }
        }
        
        [CommandProperty( AccessLevel.GameMaster )]
        public int ChallengePriority
        {
            get { return m_Priority; }
            set {
                m_Priority = value;
                
                RefreshRegions();
            }
        }
        
        [CommandProperty( AccessLevel.GameMaster )]
        public string CopyRegion
        {
            get {
                return m_CopiedRegion;
            }
            set {
                if(value == null)
                {
                    m_CopiedRegion = null;
                } else
                {

                    // find the named region
                    Region r = this.Map.Regions[value];
                    
                    if(r != null)
                    {
                        m_CopiedRegion = value;

                        // copy the coords, map, and music from that region
                        m_ChallengeMap = r.Map;
                        m_Music = r.Music;
                        m_Priority = r.Priority;
                        m_ChallengeArea = r.Area;

                        RefreshRegions();

    
                    }
                }
            }
        }

        public void RefreshRegions()
        {

            if (m_ChallengeRegion != null)
            {
                m_ChallengeRegion.Unregister();
            }
            // define a new one based on the named region
            m_ChallengeRegion = new ChallengeGameRegion(m_ChallengeRegionName, m_ChallengeMap, m_Priority, m_ChallengeArea);
            // update the new region properties with current values
            m_ChallengeRegion.Music = m_Music;
            m_ChallengeRegion.Disabled = m_Disable;

            m_ChallengeRegion.Register();
        }

        [Constructable]
        public ChallengeRegionStone() : base ( 0xED4 )
        {
            Visible = false;
            Movable = false;
            Name = "Challenge Region Stone";

            ChallengeRegionName = "Challenge Game Region";

            ChallengePriority = 0x90;             // high priority

            m_ChallengeMap = this.Map;
            
        }

        public ChallengeRegionStone( Serial serial ) : base( serial )
        {
        }

        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );

            writer.Write( (int) 2 ); // version
            // version 2
            // updated for RunUO 2.0 region changes in 3D region coordinates
            // version 1
            writer.Write( m_Disable );
            // version 0
            writer.Write( (int)m_Music );
            writer.Write( m_Priority );
            // removed in version 2
            //writer.Write(m_ChallengeArea);

            writer.Write( m_ChallengeRegionName );
            if (m_ChallengeMap != null)
            {
                writer.Write(m_ChallengeMap.Name);
            }
            else
            {
                writer.Write(String.Empty);
            }
            writer.Write( m_CopiedRegion );

            // do the coord list
            if (m_ChallengeRegion != null && m_ChallengeRegion.Area != null && m_ChallengeRegion.Area.Length > 0)
            {
                writer.Write(m_ChallengeRegion.Area.Length);

                for (int i = 0; i < m_ChallengeRegion.Area.Length; i++)
                {
                    writer.Write(m_ChallengeRegion.Area[i].Start);
                    writer.Write(m_ChallengeRegion.Area[i].End);
                }
            }
            else
            {
                writer.Write((int)0);
            }
        }
        
        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);
            
            list.Add( 1062613, m_ChallengeRegionName);
        }



        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            m_ChallengeArea = new Rectangle3D[0];

            switch ( version )
            {
                case 2:
                case 1:
                {
                    m_Disable = reader.ReadBool();
                    goto case 0;
                }
                case 0:
                {
                    m_Music = (MusicName)reader.ReadInt();
                    m_Priority = reader.ReadInt();
                    if (version < 2)
                    {
                        // old region area
                        reader.ReadRect2D();
                    }
                    m_ChallengeRegionName = reader.ReadString();
                    string mapname = reader.ReadString();
                    try{
                       m_ChallengeMap = Map.Parse(mapname);
                    } catch {}
                    m_CopiedRegion = reader.ReadString();

                    // do the coord list
                        int count = reader.ReadInt();
                        if (count > 0)
                        {
                            // the old version used 2D rectangles for the region area.  The new version uses 3D
                            if (version < 2)
                            {
                                Rectangle2D[] area = new Rectangle2D[count];
                                for (int i = 0; i < count; i++)
                                {
                                    area[i] = reader.ReadRect2D();
                                }
                                m_ChallengeArea = Region.ConvertTo3D(area);
                            }
                            else
                            {
                                m_ChallengeArea = new Rectangle3D[count];
                                for (int i = 0; i < count; i++)
                                {
                                    m_ChallengeArea[i] = new Rectangle3D(reader.ReadPoint3D(), reader.ReadPoint3D());
                                }
                            }
                        }
                    break;
                }
            }

            // refresh the region
            RefreshRegions();
        }

        public static Region FindRegion(string name)
        {
            if (Region.Regions == null)    return null;

            foreach (Region region in Region.Regions)
            {
                if (string.Compare(region.Name, name, true) == 0)
                {
                    return region;
                }
            }

            return null;
        }

        public override void OnDoubleClick( Mobile m )
        {
            if( m != null && m.AccessLevel >= AccessLevel.GameMaster)
            {
                m.SendMessage("Define the Challenge area");
                DefineChallengeArea ( m );
            }
        }


        public void DefineChallengeArea( Mobile m )
        {
            BoundingBoxPicker.Begin( m, new BoundingBoxCallback( ChallengeRegionArea_Callback ), this );
        }

        private static void ChallengeRegionArea_Callback( Mobile from, Map map, Point3D start, Point3D end, object state )
        {
            // assign these coords to the region
            ChallengeRegionStone s = state as ChallengeRegionStone;

            if (s != null && from != null)
            {
                s.m_ChallengeArea = new Rectangle3D[1];
                s.m_ChallengeArea[0] = Region.ConvertTo3D(new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1));
                s.m_ChallengeMap = map;

                s.CopyRegion = null;

                s.RefreshRegions();

            }
        }

        public override void OnDelete()
        {
            if( m_ChallengeRegion != null )
                m_ChallengeRegion.Unregister();

            base.OnDelete();
        }
    }
}
 

ArteGordon

Wanderer
Johabius said:
Hi Arte. Ran into a little problem when I restarted my server this afternoon, error report in debug mode:

Code:
RunUO - [www.runuo.com] Version 2.0, Build 2368.38595
Core: Running on .NET Framework Version 2.0.50727
Core: Running with arguments: -debug
Scripts: Compiling C# scripts...done (0 errors, 0 warnings)
Scripts: Compiling VB.NET scripts...no files found.
Scripts: Verifying...done (2297 items, 569 mobiles)
Regions: Loading...done
World: Loading...An error was encountered while loading a saved object
 - Type: Server.Engines.XmlSpawner2.ChallengeRegionStone
 - Serial: 0x400149B5
Delete the object? (y/n)
Delete all objects of that type? (y/n)
After pressing return an exception will be thrown and the server will terminate

Error:
System.Exception: Load failed (items=True, mobiles=False, guilds=False, type=Ser
ver.Engines.XmlSpawner2.ChallengeRegionStone, serial=0x400149B5) ---> System.Nul
lReferenceException: Object reference not set to an instance of an object.
   at Server.Region.Register()
   at Server.Engines.XmlSpawner2.ChallengeRegionStone.RefreshRegions() in c:\Doc
uments and Settings\Compaq_Owner\Desktop\RunUOShit\RunUO2SVN\Scripts\Customs\XML
Points\ChallengeRegionStone.cs:line 148
   at Server.Engines.XmlSpawner2.ChallengeRegionStone.Deserialize(GenericReader
reader) in c:\Documents and Settings\Compaq_Owner\Desktop\RunUOShit\RunUO2SVN\Sc
ripts\Customs\XMLPoints\ChallengeRegionStone.cs:line 282
   at Server.World.Load()
   --- End of inner exception stack trace ---
   at Server.World.Load()
   at Server.ScriptCompiler.Compile(Boolean debug, Boolean cache)
   at Server.Core.Main(String[] args)
This exception is fatal, press return to exit

I'll take a look at that.

(edit)

there may some issue with registering regions during the world loads, so I would make this mod.

Around line 282 at the end of the Deserialize method in challengeregionstone.cs, change this
Code:
			// refresh the region
			RefreshRegions();
		}
to this

Code:
			// refresh the region
			Timer.DelayCall(TimeSpan.Zero, new TimerCallback(RefreshRegions));
		}
 

Johabius

Knight
ArteGordon said:
I'll take a look at that.

(edit)

there may some issue with registering regions during the world loads, so I would make this mod.

Around line 282 at the end of the Deserialize method in challengeregionstone.cs, change this
Code:
            // refresh the region
            RefreshRegions();
        }
to this

Code:
            // refresh the region
            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(RefreshRegions));
        }
Thanks Arte! Giving that a try right now.
*starts up server*
Works like a charm, thank you!:)
 

ArteGordon

Wanderer
Kolo said:
hmn... when i trying to use any of challenge games i see:
Code:
Unable to set up (...)

what is the rest of the message? Does it say that they must be in a challenge game region or that there is already a game in progress in the region?
 

Kolo

Wanderer
for example "Unable to set up CTFChallenge" when i use [CTFChallenge (this same error with others games). When i use [challenge i see error like "No XmlPoints support"
I make all steps in XMLpoints, and all steps in XMLspawner without steps 3rd,4th,5th,10th and 12th
 

ArteGordon

Wanderer
Kolo said:
for example "Unable to set up CTFChallenge" when i use [CTFChallenge (this same error with others games). When i use [challenge i see error like "No XmlPoints support"
I make all steps in XMLpoints, and all steps in XMLspawner without steps 3rd,4th,5th,10th and 12th

ah. That means that you havent added the XmlPoints attachment to existing players. Just issue the

[addallpoints

command and you should be set.
 

Kolo

Wanderer
ArteGordon said:
ah. That means that you havent added the XmlPoints attachment to existing players. Just issue the

[addallpoints

command and you should be set.

ok thanks again, now its works fine
 
Top