So I've been working on a multi Tiered map system, each map will be accessible only after obtaining the proper XML attachment from completing a quest. That part I got setup with no problem. Even have made 12 custom maps to start the project and they all work great.

The dead end I'm at, is I can make a custom moongate and inherit base moon gate but how would I tell it to check for an XML attachment to see if the player is allowed to use it? or more so, modify the existing gate system to check for XML attachments based on each entry selection.

If someone could point me in the proper direction that would be awesome. (ideally if a player were to actually complete the full quest line, they will end up with close to 100 XML attachments which grant them access to different maps.
 
@Joshua Don't overthink it too much dude, because the easiest thing to do would be to setup an Xmlspawner that triggers based on the attachments and teleports the player that triggered it to whatever location. You can have it spawn a Moongate if you want (and you can give the Moongate the destination coords in the spawn entry).
 
So I've been working on a multi Tiered map system, each map will be accessible only after obtaining the proper XML attachment from completing a quest. That part I got setup with no problem. Even have made 12 custom maps to start the project and they all work great.

The dead end I'm at, is I can make a custom moongate and inherit base moon gate but how would I tell it to check for an XML attachment to see if the player is allowed to use it? or more so, modify the existing gate system to check for XML attachments based on each entry selection.

If someone could point me in the proper direction that would be awesome. (ideally if a player were to actually complete the full quest line, they will end up with close to 100 XML attachments which grant them access to different maps.

Code:
XmlMyGate gate = (XmlMyGate)XmlAttach.FindAttachment(player, typeof(XmlMyGate));

if (gate == null) return;
if (gate.SomeProperty == true)
{
     // Do the code based on the property
}
// etc.
 
Code:
XmlMyGate gate = (XmlMyGate)XmlAttach.FindAttachment(player, typeof(XmlMyGate));

if (gate == null) return;
if (gate.SomeProperty == true)
{
     // Do the code based on the property
}
// etc.
@Lokai Nice one dude!
Always nice to see multiple ways to skin a cat ;)
 
seriosuly thanks both of you. It never even crossed my mind to spawn a moongate on an XML spawner, that actually opens up a lot more fun things i can do. And I will get started on implementing the above code, and if i run into any errors I will post here. Thanks guys :)
[doublepost=1465653026][/doublepost]The above code is even more helpful since it would be kind of rude to players not to have some form of a gate system to access each map on the fly once they achieve the ability to enter it

"I be like yeah you got access to it , but now you got to run to the next entry point! have fuuuuun! " lol
[doublepost=1465676779][/doublepost]So here are the errors.. lol..

My Attachment Script
Code:
using System;
using Server;
using Server.Items;
using Server.Network;
using Server.Mobiles;

namespace Server.Engines.XmlSpawner2
{
    public class Level1 : XmlAttachment
    {
        private string m_DataValue = null;    // default data

        [CommandProperty( AccessLevel.GameMaster )]
        public string Data { get{ return m_DataValue; } set { m_DataValue = value; } }

        // These are the various ways in which the message attachment can be constructed. 
        // These can be called via the [addatt interface, via scripts, via the spawner ATTACH keyword.
        // Other overloads could be defined to handle other types of arguments
      
        // a serial constructor is REQUIRED
        public Level1(ASerial serial) : base(serial)
        {
        }

        [Attachable]
        public Level1(string name)
        {
            Name = name;
            Data = String.Empty;
        }

        [Attachable]
        public Level1(string name, string data)
        {
            Name = name;
            Data = data;
        }

        [Attachable]
        public Level1(string name, string data, double expiresin)
        {
            Name = name;
            Data = data;

        }

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

            writer.Write( (int) 0 );
            // version 0
            writer.Write((string)m_DataValue);

        }

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

            int version = reader.ReadInt();
            // version 0
            m_DataValue = reader.ReadString();
        }


    }
}

My Gate Script

Code:
using System;
using Server.Gumps;
using Server.Mobiles;
using Server.Engines.XmlSpawner2;

namespace Server.Items
{
    public class Level1 : Item
    {
        [Constructable]
        public Level1() : base( 0x3660 ) 
        {
            Movable = false;
            Name = " Teleport Map ";
            Hue =55;
            Light = LightType.Circle300;
        }

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

        public override bool OnMoveOver( Mobile m )
        {
           
            Level1 gate = (Level1)XmlAttach.FindAttachment(m, typeof(Level1));
            
            if (gate == null) return;
            if (gate.Level1 == true)
            {
                if( m is PlayerMobile )
                {
                    PlayerMobile pm = (PlayerMobile)m;

                    if (m.Map.CanFit(m.Location, 16, false, false))
                    {
                        m.Location = new Point3D(3505, 2575, 18);
                        m.Map = Map.Trammel;
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
                else
                {
                    return true;
                }
            }
        }
            // etc.
           
           
       
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );

            writer.Write( (int) 0 ); // version
        }

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

            int version = reader.ReadInt();
        }
    }
}

The compilation Error

Code:
Errors:
+ Aincrad/Teleport System/Level1.cs:
    CS0030: Line 26: Cannot convert type 'Server.Engines.XmlSpawner2.XmlAttachment' to 'Server.Items.Level1'
    CS0126: Line 28: An object of a type convertible to 'bool' is required
    CS1061: Line 29: 'Server.Items.Level1' does not contain a definition for 'Level1' and no extension method 'Level1' accepting a first argument of type 'Server.Items.Level1' could be found (are you missing a using directive or an assembly reference?)
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.


I'm not sure where it went south at.
 
Fixed
Code:
An object of a type convertible to 'bool' is required
by setting return false; ,
now onto the next part...
 
This will make more sense if you give the 2 items different names. Don't call them both Level1. Besides, I think your attachment can serve multiple purposes if it can hold all the levels, and just look for a property on it to see if it matches. The property can be an integer called Level, and your script can just check to see if the Level is greater than or equal to it.

Like:
Code:
namespace Server.Items
{
    public class Level1Gate : Item
    {

And:
Code:
namespace Server.Engines.XmlSpawner2
{
    public class GateAttachment : XmlAttachment
    {

Now, in your Gate script:

Code:
            GateAttachment gate = (GateAttachment)XmlAttach.FindAttachment(m, typeof(GateAttachment));
          
            if (gate == null) return false;
            if (gate.Level >= 1)
            {
 
Applied the above information, still compile errors. Getting closer.

Regarding the compile error, I suppose I could do

if (gate.Level == "1") but that doesn't really work.
probably something simple.

Code:
Errors:
+ Aincrad/Teleport System/Level1Gate.cs:
    CS0019: Line 29: Operator '==' cannot be applied to operands of type 'string' and 'int'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

Here is the current gate script:
Code:
using System;
using Server.Gumps;
using Server.Mobiles;
using Server.Engines.XmlSpawner2;

namespace Server.Items
{
    public class Level1Gate  : Item
    {
        [Constructable]
        public Level1Gate () : base( 0x3660 )
        {
            Movable = false;
            Name = " Teleport Map ";
            Hue =55;
            Light = LightType.Circle300;
        }

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

        public override bool OnMoveOver( Mobile m )
        {  
            GateAttachment gate = (GateAttachment)XmlAttach.FindAttachment(m, typeof(GateAttachment));
          
           
            if (gate == null) return false;
            if (gate.Level == 1)
            {
                if( m is PlayerMobile )
                {
                    PlayerMobile pm = (PlayerMobile)m;

                    if (m.Map.CanFit(m.Location, 16, false, false))
                    {
                        m.Location = new Point3D(3505, 2575, 18);
                        m.Map = Map.Trammel;
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
                else
                {
                    return true;
                }
            }
        }
            // etc.
          
          
      
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );

            writer.Write( (int) 0 ); // version
        }

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

            int version = reader.ReadInt();
        }
    }
}

Here is the Current Attachment Script, fixed the missing definition error by actually defining Level but fixing it lead to the next error I'm getting now.

Code:
using System;
using Server;
using Server.Items;
using Server.Network;
using Server.Mobiles;

namespace Server.Engines.XmlSpawner2
{
    public class GateAttachment : XmlAttachment
    {
        private string m_LevelValue = null;    // default data

        [CommandProperty( AccessLevel.GameMaster )]
        public string Level { get{ return m_LevelValue; } set { m_LevelValue = value; } }

        // These are the various ways in which the message attachment can be constructed.
        // These can be called via the [addatt interface, via scripts, via the spawner ATTACH keyword.
        // Other overloads could be defined to handle other types of arguments
     
        // a serial constructor is REQUIRED
        public GateAttachment (ASerial serial) : base(serial)
        {
        }

        [Attachable]
        public GateAttachment (string name)
        {
            Name = name;
            Level = String.Empty;
        }

        [Attachable]
        public GateAttachment (string name, string level)
        {
            Name = name;
            Level = level;
        }

        [Attachable]
        public GateAttachment (string name, string level, double expiresin)
        {
            Name = name;
            Level = level;

        }

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

            writer.Write( (int) 0 );
            // version 0
            writer.Write((string)m_LevelValue);

        }

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

            int version = reader.ReadInt();
            // version 0
            m_LevelValue = reader.ReadString();
        }


    }
}
[doublepost=1465827664][/doublepost]To note I did attempt

Code:
 if (gate.Level >= 1)

but got the same compile error
 
In your GateAttachment, you need to make Level and m_LevelValue both type Integer instead of string. All associated values would have to be changed accordingly. Set it to zero, and not null, to start also.
 
Oy this is painful, so back to the same error after removing string and converting all entries in GetAttachment to Int,

Code:
Errors:
+ Aincrad/Teleport System/Level1Gate.cs:
    CS0019: Line 28: Operator '==' cannot be applied to operands of type 'Server.Engines.XmlSpawner2.GateAttachment' and 'int'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

Adjusted Attachment Code
Code:
using System;
using Server;
using Server.Items;
using Server.Network;
using Server.Mobiles;

namespace Server.Engines.XmlSpawner2
{
    public class GateAttachment : XmlAttachment
    {
        private int m_Level = 1;
       
        [CommandProperty( AccessLevel.GameMaster )]
        public int Level { get { return m_Level; } set { m_Level  = Level; } }

        public GateAttachment(ASerial serial) : base(serial)
        {
        }

        [Attachable]
        public GateAttachment()
        {
        }

        [Attachable]
        public GateAttachment(int level)
        {
            m_Level = level;
        }
       
        [Attachable]
        public GateAttachment(int level, double duration)
        {
            m_Level = level;
        }
       
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize(writer);

            writer.Write( (int) 0 );
            // version 0
            writer.Write((int)m_Level);

        }

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

            int version = reader.ReadInt();
            // version 0
            m_Level = reader.ReadInt();
        }
       
    }
}

Current Gate Code
Code:
using System;
using Server.Gumps;
using Server.Mobiles;
using Server.Engines.XmlSpawner2;

namespace Server.Items
{
    public class Level1Gate  : Item
    {
        [Constructable]
        public Level1Gate () : base( 0x3660 ) 
        {
            Movable = false;
            Name = " Teleport Map ";
            Hue =55;
            Light = LightType.Circle300;
        }

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

        public override bool OnMoveOver( Mobile m )
        {   
            GateAttachment gate = (GateAttachment)XmlAttach.FindAttachment(m, typeof(GateAttachment));
           
            
            if (gate == 0) return false;
            if (gate.Level == 1)
            {
                if( m is PlayerMobile )
                {
                    PlayerMobile pm = (PlayerMobile)m;

                    if (m.Map.CanFit(m.Location, 16, false, false))
                    {
                        m.Location = new Point3D(3505, 2575, 18);
                        m.Map = Map.Trammel;
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
                else
                {
                    return true;
                }
            }
        }
            // etc.
           
           
       
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );

            writer.Write( (int) 0 ); // version
        }

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

            int version = reader.ReadInt();
        }
    }
}
 
I did that before and got this error. I did it again to get the error again so i could copy it here.

Code:
Errors:
+ Aincrad/Teleport System/Level1Gate.cs:
    CS0161: Line 23: 'Server.Items.Level1Gate.OnMoveOver(Server.Mobile)': not all code paths return a value
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 
Oh jeeeze! that was the missing link... I seriously thought I accounted for all the values.. Thank you Lokai! I agree with your signature, no greater satisfaction then knowing why you failed.
[doublepost=1465848979][/doublepost]Tested it and it worked exactly as it should. This is perfect.. Finally I can start working on the master quest that will take people above and beyond floors (maps). I only wish there were more of me, it's very time consuming and tiring doing this myself but i enjoy it :)
 
Back