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!

How To ... create race(Tutorial)

thema

Wanderer
Need more info.

Not being a master scripter to begin with , I find it hard to help at all, but if you can post your script so far I can try.

You can't get much help if you just post a vague statement like:

Hi i'm not managing to get the scripts working i'm trying to add a function that teleports the mobile(player) to another place but i don't want a switch function i just want to send him to a location.

You didn't give enough info really. The only reason I managed to put my script together the way I did, was because I was able to test it on my own shard stage by stage, and debug it with the downloadable script compiler before I even put it into action. I won't be able to do that with your script. I will have to try to read it and work it out in my head. Not a thing I'm good at. But at least if you post it I can give it a go. If you check out the BaseRaceGate class I created it only has one teleport per gate, and does not use a case statement at all, so it would seem to be what you need. I know if you use them as is, they work pefectly with any shard that uses a PlayerMobile class that has at least a Race Variable. If BaseRaceGate.cs is not what you're looking for then be more specific.
What isn't working?
What do you need that is different?
Have you indeed added the Race type to your PlayerMobile class?


Thema
 

Ra'Thine

Wanderer
I was more then happy to help Braincrash, I am still just starting to learn this C# myself though.

Before anyone else asks. here is my working PlayerMoble and ElfGate, modified to work with RunUO Beta19R2. It doesn't yet do everything I would like it to. but it's been fun working on it.

PlayerMobile.cs
[code:1]
using System;
using System.Collections;
using Server;
namespace Server.Mobiles
{
public class PlayerMobile : Mobile
{
private ArrayList m_VisList;
private RaceType race; //Create a private RaceType variable it will countain the race of you're character
public PlayerMobile()
{
m_VisList = new ArrayList();
PgRace = RaceType.None; //don't forget to init the private variable
}

public PlayerMobile( Serial s ) : base( s )
{
m_VisList = new ArrayList();
}
public ArrayList VisibilityList
{
get
{
return m_VisList;
}
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
race = (RaceType)reader.ReadInt(); //neither to load it
break;
}
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int)0 );//version
writer.Write((int) race ); // don't forget to save your characters race
}
public override bool CanSee( Mobile m )
{
if ( m is PlayerMobile && ((PlayerMobile)m).m_VisList.Contains( this ) )
return true;
else
return base.CanSee( m );
}
[CommandProperty( AccessLevel.GameMaster )]
public RaceType PgRace
{
get {return race;}
set {race = value;}
}
}
public enum RaceType
{
None, Human, Elf, DrowElf, FrostElf, HalfElf, Dwarf //contain all race you want
}
}
[/code:1]

and here is the modified ElfGate.cs to the Beta19R2 release using scripts.mobiles

ElfGate.cs
[code:1]
/* Script: Elf Gate
Author: Ra'Thine
Special Thanks To: Thema, David and others on the Race Gate Tutorial thread at RunUO.com/Discussion
Mobile: Used with the player mobile defined in RunUO beta 18 */
using System;
using Server;
using Server.Items;
namespace Server.Mobiles
{
public class ElfGate : Item
{
private bool m_Active, m_Creatures;
private Point3D m_PointDest;
private Map m_MapDest;
[CommandProperty( AccessLevel.GameMaster )]
public bool Active
{
get { return m_Active; }
set { m_Active = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public Point3D PointDest
{
get { return m_PointDest; }
set { m_PointDest = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public Map MapDest
{
get { return m_MapDest; }
set { m_MapDest = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool Creatures
{
get { return m_Creatures; }
set { m_Creatures = value; }
}
[Constructable]
public ElfGate() : this( new Point3D( 0, 0, 0 ), null, false )
{
}
[Constructable]
public ElfGate( Point3D pointDest, Map mapDest ) : this( pointDest, mapDest, false )
{
}
[Constructable]
public ElfGate( Point3D pointDest, Map mapDest, bool creatures ) : base( 0x0F6D)
{
Visible = true;
Movable = false;
Hue = 0x2F5;
Light = LightType.Circle300;
Name = "ElfGate";

m_Active = true;
m_PointDest = new Point3D( 1100, 1280, 5 ); // You can edit this to any location you wish the char to be teleported after using the gate.
m_MapDest = mapDest;
m_Creatures = creatures;
}
public override void OnSingleClick( Mobile from )
{
LabelTo( from, "Elf Gate" ); // ElfGate
if ( m_Active )
{
if ( m_MapDest != null && m_PointDest != Point3D.Zero )
LabelTo( from, "{0} [{1}]", m_PointDest, m_MapDest );
else if ( m_MapDest != null )
LabelTo( from, "[{0}]", m_MapDest );
else if ( m_PointDest != Point3D.Zero )
LabelTo( from, m_PointDest.ToString() );
}
else
{
LabelTo( from, "(inactive)" );
}
}
public override bool OnMoveOver( Mobile m )
{
Mobile somemobile = m;
PlayerMobile someperso = somemobile as PlayerMobile;
if ( someperso != null )
{
if ( someperso.PgRace == RaceType.None )
{
someperso.Hue = 0x2F5;
someperso.PgRace = RaceType.Elf; // Give him the race of the gate
// someperso.Title = "the [Elf]"; // I like the line below better
someperso.Name = someperso.Name + " the Elf";
// someperso.BodyValue = 0x3B; // Dragon Body, not used for an elf, just an example
Item hair = new Item( Utility.RandomList( 0x203C, 0x203D ) );
hair.Hue = Utility.RandomList( 0x45E, 0x462, 0x466 );
hair.Layer = Layer.Hair;
hair.Movable = false;
someperso.AddItem( hair );
Item beard = someperso.FindItemOnLayer( Layer.FacialHair );
if ( beard != null ) beard.Delete(); // Removes Beard
// Item beard = new Item( 0x203E ); // Long Beard this will be for the Dwarf gate.
// beard.Hue = hair.Hue;
// beard.Layer = Layer.FacialHair;
// beard.Movable = false;
// AddItem( beard );
// someperso.STR -= 5; // stats don't work
// someperso.MaxSTR = 95;
// someperso.DEX += 10;
// someperso.MaxDEX = 110;
// someperso.INT += 10;
// someperso.MaxINT = 110;
someperso.Skills[SkillName.Tactics].Base += 10;
someperso.Skills[SkillName.Tactics].Cap = 110;
someperso.Skills[SkillName.Swords].Base += 5;
someperso.Skills[SkillName.Swords].Cap = 105;
someperso.Skills[SkillName.Archery].Base += 5;
someperso.Skills[SkillName.Archery].Cap = 105;
someperso.SendMessage("You are now an Elf!");
}
else someperso.SendMessage("Be satisfied with your race!");
}
if ( m_Active )
{
if ( !m_Creatures && !m.Player )
return true;
Map map = m_MapDest;
if ( map == null )
map = m.Map;
Point3D p = m_PointDest;
if ( p == Point3D.Zero )
p = m.Location;
Server.Mobiles.BaseCreature.TeleportPets( m, p, map );
if ( m_MapDest != null )
m.Map = m_MapDest;
if ( m_PointDest != Point3D.Zero )
m.Location = m_PointDest;
return false;
}
return true;
}
public ElfGate( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 1 ); // version
writer.Write( m_Creatures );
writer.Write( m_Active );
writer.Write( m_PointDest );
writer.Write( m_MapDest );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 1:
{
m_Creatures = reader.ReadBool();
goto case 0;
}
case 0:
{
m_Active = reader.ReadBool();
m_PointDest = reader.ReadPoint3D();
m_MapDest = reader.ReadMap();
break;
}
}
}
}
}
[/code:1]
 

Ra'Thine

Wanderer
Well onto new things a race gate should do. I have been trying to set stats the way I want them with my elfgate, and yet they still remain commented out as they do not work. Here is what I am trying.

[code:1]
// someperso.STR -= 5; // stats don't work
// someperso.MaxSTR = 95;
// someperso.DEX += 10;
// someperso.MaxDEX = 110;
// someperso.INT += 10;
// someperso.MaxINT = 110;
[/code:1]

Should I be doing this more like I am in the code below?
[code:1]
someperso.Stats[StatName.STR].Cap ==95;
[/code:1]

If not am I somewhere close?
 

braincrash

Sorceror
Hi am playing with this:

[code:1]someperso.InitStats( 100, 100, 25 );
someperso.StatCap == 300;
// someperso.Stats[StatType.Str].Cap = 150;[/code:1]

But when i pause my mouse over StatCap it shows:

[property] int Mobile.StatCap

Do i have to say that i want a int value if so how can i do it. the script if the one from Ra'Thine
 

thema

Wanderer
I'm at a bit of a loss really chaps.

If you look at my BaseRaceGate.cs
I set stats in the OnMoveOver event using the Mobile.InitStats function. I imagine if you check the Mobile class you may find more functions in there that you can use.

[code:1]someperso.InitStats(75, 115, 40); //set the character's (STR, DEX, INT)
[/code:1]



Thema
 

Nagash

Sorceror
I was making a version of Ra`thine`s race gate for Beta20 and I got an errror, can someone please tell me what I did wrong?

This is the code for PlayerMobile.cs:
[code:1]
using System;
using System.Collections;
using Server;
using Server.Misc;

namespace Server.Mobiles
{
public class PlayerMobile : Mobile
{
private class CountAndTimeStamp
{
private int m_Count;
private DateTime m_Stamp;

public CountAndTimeStamp()
{
}

public DateTime TimeStamp { get{ return m_Stamp; } }
public int Count
{
get { return m_Count; }
set { m_Count = value; m_Stamp = DateTime.Now; }
}
}

private ArrayList m_VisList;
private RaceType race; //Create a private RaceType variable it will countain the race of you're character
private Hashtable m_AntiMacroTable;

public PlayerMobile()
{
m_VisList = new ArrayList();
m_AntiMacroTable = new Hashtable();
PgRace = RaceType.None; //don't forget to init the private variable
}

public PlayerMobile( Serial s ) : base( s )
{
m_VisList = new ArrayList();
m_AntiMacroTable = new Hashtable();
}

public ArrayList VisibilityList
{
get
{
return m_VisList;
}
}

public bool AntiMacroCheck( Skill skill, object obj )
{
if ( obj == null || m_AntiMacroTable == null || this.AccessLevel != AccessLevel.Player )
return true;

Hashtable tbl = (Hashtable)m_AntiMacroTable[skill];
if ( tbl == null )
m_AntiMacroTable[skill] = tbl = new Hashtable();

CountAndTimeStamp count = (CountAndTimeStamp)tbl[obj];
if ( count != null )
{
if ( count.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
{
count.Count = 1;
return true;
}
else
{
++count.Count;
if ( count.Count <= SkillCheck.Allowance )
return true;
else
return false;
}
}
else
{
tbl[obj] = count = new CountAndTimeStamp();
count.Count = 1;

return true;
}
}

public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
race = (RaceType)reader.ReadInt(); //neither to load it
break;
}
}
}

public override void Serialize( GenericWriter writer )
{
//cleanup our anti-macro table
foreach ( Hashtable t in m_AntiMacroTable.Values )
{
ArrayList remove = new ArrayList();
foreach ( CountAndTimeStamp time in t.Values )
{
if ( time.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
remove.Add( time );
}

for (int i=0;i<remove.Count;++i)
t.Remove( remove );
}

base.Serialize( writer );

writer.Write( (int)0 );//version
writer.Write((int) race ); // don't forget to save your characters race
}

public override bool CanSee( Mobile m )
{
if ( m is PlayerMobile && ((PlayerMobile)m).m_VisList.Contains( this ) )
return true;
else
return base.CanSee( m );
}

}
[CommandProperty( AccessLevel.GameMaster )]
public RaceType PgRace
{
get {return race;}
set {race = value;}
}
public enum RaceType
{
None, Human, Elf, DrowElf, FrostElf, HalfElf, Dwarf //contain all race you want
}
}

[/code:1]
This is the error that I get:
[code:1]
(line133, column20)Expected class, delegate, enum, interface or struct
[/code:1]
And this is the line where the error just over RaceType:
[code:1]
public RaceType PgRace
[/code:1]

What I did wrong?
 

thema

Wanderer
I'm only guessing.

Are you enumerating RaceType in the right place?

It seems that the script isn't finding it.

Thema
 

Ra'Thine

Wanderer
Nagash, that playermobile was definately working in beta19 and beta19r2 I have not yet tested it in beta20. I just downloaded beta20 and I will check out the error and try to post my fix. in the mean time look everyone elses work over, because my script is the result of all the posting and help from this tutorial
 

Ra'Thine

Wanderer
Alright. I have done everything I can think of and I am still getting errors. So much for updating to beta 20. but here is my error message followed by the scripts.

Here is my error message.
[code:1]
Scripts: Compiling...failed (2 errors, 0 warnings)
- Error: Scripts\RaceGate\ElfGate.cs: CS0246: (line 86, column 29) The type or
namespace name 'RaceType' could not be found (are you missing a using directive
or an assembly reference?)
- Error: Scripts\RaceGate\ElfGate.cs: CS0246: (line 89, column 31) The type or
namespace name 'RaceType' could not be found (are you missing a using directive
or an assembly reference?)
Scripts: One or more scripts failed to compile
[/code:1]

Here is my PlayerMobile.cs
[code:1]
using System;
using System.Collections;
using Server;
using Server.Misc;

namespace Server.Mobiles
{
public class PlayerMobile : Mobile
{
private class CountAndTimeStamp
{
private int m_Count;
private DateTime m_Stamp;

public CountAndTimeStamp()
{
}

public DateTime TimeStamp { get{ return m_Stamp; } }
public int Count
{
get { return m_Count; }
set { m_Count = value; m_Stamp = DateTime.Now; }
}
}
private Hashtable m_AntiMacroTable;
private ArrayList m_VisList = new ArrayList(); // Added for jail system
private Point3D m_JailExitLocation = new Point3D( 0,0,0 ) ; // Added for jail system
private Map m_JailExitMap = Map.Trammel ; // Added for jail system
private RaceType race; // Added for race system

public PlayerMobile()
{
m_VisList = new ArrayList();
PgRace = RaceType.None; // Added for race system
m_AntiMacroTable = new Hashtable();
}

public PlayerMobile( Serial s ) : base( s )
{
m_VisList = new ArrayList();
m_AntiMacroTable = new Hashtable();
}
[CommandProperty( AccessLevel.Counselor )] // Added for jail system
public Point3D JailExitLocation // Added for jail system
{ // Added for jail system
get // Added for jail system
{ // Added for jail system
return m_JailExitLocation ; // Added for jail system
} // Added for jail system
set // Added for jail system
{ // Added for jail system
m_JailExitLocation = value ; // Added for jail system
} // Added for jail system
} // Added for jail system
// Added for jail system
[CommandProperty( AccessLevel.Counselor )] // Added for jail system
public Map JailExitMap // Added for jail system
{ // Added for jail system
get // Added for jail system
{ // Added for jail system
return m_JailExitMap ; // Added for jail system
} // Added for jail system
set // Added for jail system
{ // Added for jail system
m_JailExitMap = value ; // Added for jail system
} // Added for jail system
} // Added for jail system
public ArrayList VisibilityList
{
get
{
return m_VisList;
}
}

public bool AntiMacroCheck( Skill skill, object obj )
{
if ( obj == null || m_AntiMacroTable == null || this.AccessLevel != AccessLevel.Player )
return true;

Hashtable tbl = (Hashtable)m_AntiMacroTable[skill];
if ( tbl == null )
m_AntiMacroTable[skill] = tbl = new Hashtable();

CountAndTimeStamp count = (CountAndTimeStamp)tbl[obj];
if ( count != null )
{
if ( count.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
{
count.Count = 1;
return true;
}
else
{
++count.Count;
if ( count.Count <= SkillCheck.Allowance )
return true;
else
return false;
}
}
else
{
tbl[obj] = count = new CountAndTimeStamp();
count.Count = 1;

return true;
}
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch( version ) // Added for jail system
{ // Added for jail system
case 0: // Added for jail system
race = (RaceType)reader.ReadInt(); // Added for race system
break ; // Added for jail system
case 1: // Added for jail system
m_JailExitLocation = reader.ReadPoint3D() ; // Added for jail system
m_JailExitMap = reader.ReadMap() ; // Added for jail system
break ; // Added for jail system
default: // Added for jail system
break ; // Added for jail system
} // Added for jail system
}

public override void Serialize( GenericWriter writer )
{
//cleanup our anti-macro table
foreach ( Hashtable t in m_AntiMacroTable.Values )
{
ArrayList remove = new ArrayList();
foreach ( CountAndTimeStamp time in t.Values )
{
if ( time.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
remove.Add( time );
}

for (int i=0;i<remove.Count;++i)
t.Remove( remove );
}
base.Serialize( writer );
writer.Write( (int)0 ); // Version
writer.Write((int) race ); // Added for race system
writer.Write( m_JailExitLocation ) ; // Added for jail system
writer.Write( m_JailExitMap ) ; // Added for jail system
}
public enum RaceType // Added for race system
{ // Added for race system
None, Human, Elf, DrowElf, FrostElf, HalfElf, Dwarf // Added for race system
}
[CommandProperty( AccessLevel.GameMaster )] // Added for race system
public RaceType PgRace // Added for race system
{ // Added for race system
get {return race;} // Added for race system
set {race = value;} // Added for race system
} // Added for race system // Added for race system
public override bool CanSee( Mobile m )
{
if ( m is PlayerMobile && ((PlayerMobile)m).m_VisList.Contains( this ) )
return true;
else
return base.CanSee( m );
}
}
}
[/code:1]

and now for the ElfGate.cs
[code:1]
/* Script: Elf Gate
Author: Ra'Thine
Special Thanks To: Thema, David and others on the Race Gate Tutorial thread at RunUO.com/Discussion
Mobile: Used with the player mobile defined in RunUO beta 18 */
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Misc;
namespace Server.Mobiles
{
public class ElfGate : Item
{
private bool m_Active, m_Creatures;
private Point3D m_PointDest;
private Map m_MapDest;
[CommandProperty( AccessLevel.GameMaster )]
public bool Active
{
get { return m_Active; }
set { m_Active = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public Point3D PointDest
{
get { return m_PointDest; }
set { m_PointDest = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public Map MapDest
{
get { return m_MapDest; }
set { m_MapDest = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool Creatures
{
get { return m_Creatures; }
set { m_Creatures = value; }
}
[Constructable]
public ElfGate() : this( new Point3D( 0, 0, 0 ), null, false )
{
}
[Constructable]
public ElfGate( Point3D pointDest, Map mapDest ) : this( pointDest, mapDest, false )
{
}
[Constructable]
public ElfGate( Point3D pointDest, Map mapDest, bool creatures ) : base( 0x0F6D)
{
Visible = true;
Movable = false;
Hue = 0x2F5;
Light = LightType.Circle300;
Name = "ElfGate";

m_Active = true;
m_PointDest = new Point3D( 1100, 1280, 5 ); // You can edit this to any location you wish the char to be teleported after using the gate.
m_MapDest = mapDest;
m_Creatures = creatures;
}
public override void OnSingleClick( Mobile from )
{
LabelTo( from, "Elf Gate" ); // ElfGate
if ( m_Active )
{
if ( m_MapDest != null && m_PointDest != Point3D.Zero )
LabelTo( from, "{0} [{1}]", m_PointDest, m_MapDest );
else if ( m_MapDest != null )
LabelTo( from, "[{0}]", m_MapDest );
else if ( m_PointDest != Point3D.Zero )
LabelTo( from, m_PointDest.ToString() );
}
else
{
LabelTo( from, "(inactive)" );
}
}
public override bool OnMoveOver( Mobile m )
{
Mobile somemobile = m;
PlayerMobile someperso = somemobile as PlayerMobile;
if ( someperso != null )
{
if ( someperso.PgRace == RaceType.None )
{
someperso.Hue = 0x2F5;
someperso.PgRace = RaceType.Elf; // Give him the race of the gate
// someperso.Title = "the [Elf]"; // I like the line below better
someperso.Name = someperso.Name + " the Elf";
// someperso.BodyValue = 0x3B; // Dragon Body, not used for an elf, just an example
Item hair = new Item( Utility.RandomList( 0x203C, 0x203D ) );
hair.Hue = Utility.RandomList( 0x45E, 0x462, 0x466 );
hair.Layer = Layer.Hair;
hair.Movable = false;
someperso.AddItem( hair );
Item beard = someperso.FindItemOnLayer( Layer.FacialHair );
if ( beard != null ) beard.Delete(); // Removes Beard
// Item beard = new Item( 0x203E ); // Long Beard this will be for the Dwarf gate.
// beard.Hue = hair.Hue;
// beard.Layer = Layer.FacialHair;
// beard.Movable = false;
// AddItem( beard );
// someperso.STR -= 5; // stats don't work
// someperso.MaxSTR = 95;
// someperso.DEX += 10;
// someperso.MaxDEX = 110;
// someperso.INT += 10;
// someperso.MaxINT = 110;
someperso.Skills[SkillName.Tactics].Base += 10;
someperso.Skills[SkillName.Tactics].Cap = 110;
someperso.Skills[SkillName.Swords].Base += 5;
someperso.Skills[SkillName.Swords].Cap = 105;
someperso.Skills[SkillName.Archery].Base += 5;
someperso.Skills[SkillName.Archery].Cap = 105;
someperso.SendMessage("You are now an Elf!");
}
else someperso.SendMessage("Be satisfied with your race!");
}


if ( m_Active )
{
if ( !m_Creatures && !m.Player )
return true;
Map map = m_MapDest;
if ( map == null )
map = m.Map;
Point3D p = m_PointDest;
if ( p == Point3D.Zero )
p = m.Location;
Server.Mobiles.BaseCreature.TeleportPets( m, p, map );
if ( m_MapDest != null )
m.Map = m_MapDest;
if ( m_PointDest != Point3D.Zero )
m.Location = m_PointDest;
return false;
}
return true;
}
public ElfGate( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 1 ); // version
writer.Write( m_Creatures );
writer.Write( m_Active );
writer.Write( m_PointDest );
writer.Write( m_MapDest );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 1:
{
m_Creatures = reader.ReadBool();
goto case 0;
}
case 0:
{
m_Active = reader.ReadBool();
m_PointDest = reader.ReadPoint3D();
m_MapDest = reader.ReadMap();
break;
}
}
}
}
}
[/code:1]
Down to only to errors returned, I don't feel too bad.
 

Phantom

Knight
[code:1] if ( someperso.PgRace == RaceType.None )
{
someperso.Hue = 0x2F5;
someperso.PgRace = RaceType.Elf; // Give him the race of the gate [/code:1]

You never declared RaceType in the elf gate, it doesn't magicaly know what your talking about :)
 

Ra'Thine

Wanderer
Thats a beautiful cut and paste of my code, and thank you so much for showing some way of fixing my error. and if I never declared it, thenwhy does it work in Beta 19R2?

Do you mean something like this?
[code:1]
someperso.PgRace==RaceType.None;
if ( someperso.PgRace == RaceType.None )
{
someperso.Hue = 0x2F5;
someperso.PgRace = RaceType.Elf; // Give him the race of the gate
[/code:1]
 

thema

Wanderer
It may be the namespaces

Try using:

[code:1]
using System;
using Server;
using Server.Items;
using Server.Mobiles;

namespace Server.Scripts
{

[/code:1]

at the top.

Thema
 

Ra'Thine

Wanderer
thema, the playermobile for the current releases of RunUO use Server.Mobiles as does my playermobile, a modified PlayerMobile of Beta 20. If I use server.scripts in my gate, when the playermobile is using server.mobiles. It will not work. but is does seem I am missing
[code:1]
using Server.Mobiles
[/code:1]
from what your suggesting. I'll try adding that and see what happens.
 

thema

Wanderer
I had the same problem.

I only posted this because I had exactly the same problem.

When I changed the header to the one shown it all worked fine.
I too am using Modified Beta20 PlayerMobiles.

Thema.
 

Ra'Thine

Wanderer
I tried Thema, that did not help meat all. I added the using Server.Mobiles and changed the namespace Server.Mobiles to namespace Server.Scripts andback again. and nothing. I still get the error.
 

Nagash

Sorceror
I had already done that before posting, I also tried a mix with using .Races, items, and whatever possible
I also tried to define de PgRace in many ways and every spot that would be avaliable for the line of error, but that also didn`t helped me much. I just can`t understand what does the system expects that is missing in the script. I guess that is the problem of it.
 

Ra'Thine

Wanderer
Well it isn't my fix but its a fix. All hail Cyfil. The modified Beta 20 Player Mobile that works with my Race Gates.

PlayerMobile.cs
[code:1]
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Items;
using Server.Mobiles;
using Server.Network;

namespace Server.Mobiles
{

public enum RaceType
{
None, Human, Elf, HalfElf, FrostElf, DrowElf, Werewold, Hobbit, Dragon //all the races available
}

public class PlayerMobile : Mobile
{


private class CountAndTimeStamp
{
private int m_Count;
private DateTime m_Stamp;

public CountAndTimeStamp()
{
}

public DateTime TimeStamp { get{ return m_Stamp; } }
public int Count
{
get { return m_Count; }
set { m_Count = value; m_Stamp = DateTime.Now; }
}
}
private RaceType race; //Create a private RaceType variable it will countain the race of you're character
private ArrayList m_VisList;
private Hashtable m_AntiMacroTable;

public PlayerMobile()
{
m_VisList = new ArrayList();
m_AntiMacroTable = new Hashtable();
PgRace = RaceType.None; //don't forget to init the private variable
}

public PlayerMobile( Serial s ) : base( s )
{
m_VisList = new ArrayList();
m_AntiMacroTable = new Hashtable();
}

public ArrayList VisibilityList
{
get
{
return m_VisList;
}
}

[CommandProperty( AccessLevel.GameMaster )]
public RaceType PgRace
{
get {return race;}
set {race = value;}
}

public override void OnSingleClick( Mobile from )
{
from.LocalOverheadMessage( MessageType.Regular, 0, false, String.Format( "{0} the {1}", Name, PgRace ) );
}

public bool AntiMacroCheck( Skill skill, object obj )
{
if ( obj == null || m_AntiMacroTable == null || this.AccessLevel != AccessLevel.Player )
return true;

Hashtable tbl = (Hashtable)m_AntiMacroTable[skill];
if ( tbl == null )
m_AntiMacroTable[skill] = tbl = new Hashtable();

CountAndTimeStamp count = (CountAndTimeStamp)tbl[obj];
if ( count != null )
{
if ( count.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
{
count.Count = 1;
return true;
}
else
{
++count.Count;
if ( count.Count <= SkillCheck.Allowance )
return true;
else
return false;
}
}
else
{
tbl[obj] = count = new CountAndTimeStamp();
count.Count = 1;

return true;
}
}

public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
race = (RaceType)reader.ReadInt(); //neither to load it
break;
}
}
}

public override void Serialize( GenericWriter writer )
{
//cleanup our anti-macro table
foreach ( Hashtable t in m_AntiMacroTable.Values )
{
ArrayList remove = new ArrayList();
foreach ( CountAndTimeStamp time in t.Values )
{
if ( time.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
remove.Add( time );
}

for (int i=0;i<remove.Count;++i)
t.Remove( remove );
}

base.Serialize( writer );

writer.Write( (int)0 );//version
writer.Write((int) race ); // don't forget to save you're characters race
}

public override bool CanSee( Mobile m )
{
if ( m is PlayerMobile && ((PlayerMobile)m).m_VisList.Contains( this ) )
return true;
else
return base.CanSee( m );
}
}
}
[/code:1]
 

thema

Wanderer
For those who want a little more.

Here's my BaseRaceGate Class and PlayerMobile class.

Both are working fine with Beta20 and the playerMobile class also has space for classes, alignments, levels, experience points.


BaseRaceGate
[code:1]
using System;
using Server;
using Server.Items;
using Server.Mobiles;

namespace Server.Scripts
{
public abstract class BaseRaceGate : Item
{
private bool m_Active, m_Creatures;
private Point3D m_PointDest;
private Map m_MapDest;
private RaceType m_Race; // private RaceType PgRace;

[CommandProperty( AccessLevel.GameMaster )]
public bool Active
{
get { return m_Active; }
set { m_Active = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public RaceType Race
{
get { return m_Race; } // get { return PgRace; }
set { m_Race = value; } // set { PgRace = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public Point3D PointDest
{
get { return m_PointDest; }
set { m_PointDest = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public Map MapDest
{
get { return m_MapDest; }
set { m_MapDest = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public bool Creatures
{
get { return m_Creatures; }
set { m_Creatures = value; }
}

public BaseRaceGate( Point3D pointDest, Map mapDest, bool creatures ) : base( 0x0F6C)
{
Visible = true;
Movable = false;
Hue = 0x047f;
Light = LightType.Circle300;
Name = "Human";

m_Race = RaceType.Human;
m_Active = true;
m_PointDest = new Point3D( 1069, 1025, 5 );
m_MapDest = Map.Felucca;
m_Creatures = creatures;
}

public override void OnSingleClick( Mobile from )
{
LabelTo( from, Name ); // RaceGate

if ( m_Active )
{
if ( m_MapDest != null && m_PointDest != Point3D.Zero )
LabelTo( from, "{0} [{1}]", m_PointDest, m_MapDest );
else if ( m_MapDest != null )
LabelTo( from, "[{0}]", m_MapDest );
else if ( m_PointDest != Point3D.Zero )
LabelTo( from, m_PointDest.ToString() );
}
else
{
LabelTo( from, "(inactive)" );
}
}

public override bool OnMoveOver( Mobile m )
{
Mobile somemobile = m;

PlayerMobile someperso = somemobile as PlayerMobile; // MyMobile someperso = somemobile as MyMobile;

if ( someperso != null )
{
if ( someperso.m_Race == RaceType.None ) // if ( someperso.PgRace == RaceType.None )

{
switch ( someperso.Str )
{
case 95:
{
someperso.InitStats(75, 115, 40); //set the charater's stats
break;
}
case 85:
{
someperso.InitStats(65, 40, 95); //set the charater's stats
break;
}
case 60:
{
someperso.InitStats(40, 40, 40); //set the charater's stats
break;
}
}
someperso.m_Race = m_Race; // someperso.PgRace = PgRace;
someperso.Name += " the " + Name;
someperso.SendMessage("You are now a {0}!", Name);
}
else someperso.SendMessage("Be satisfied with your race!");
}

if ( m_Active )
{
if ( !m_Creatures && !m.Player )
return true;

Map map = m_MapDest;

if ( map == null )
map = m.Map;

Point3D p = m_PointDest;

if ( p == Point3D.Zero )
p = m.Location;

Server.Mobiles.BaseCreature.TeleportPets( m, p, map );

if ( m_MapDest != null )
m.Map = m_MapDest;

if ( m_PointDest != Point3D.Zero )
m.Location = m_PointDest;

return false;
}

return true;
}

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

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

writer.Write( (int) 2 ); // version

writer.Write( (int)m_Race );
writer.Write( m_Creatures );

writer.Write( m_Active );
writer.Write( m_PointDest );
writer.Write( m_MapDest );
}

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

int version = reader.ReadInt();

switch ( version )
{
case 2:
{
m_Race = (RaceType)reader.ReadInt();
goto case 1;
}
case 1:
{
m_Creatures = reader.ReadBool();

goto case 0;
}
case 0:
{
m_Active = reader.ReadBool();
m_PointDest = reader.ReadPoint3D();
m_MapDest = reader.ReadMap();

break;
}
}
}
}
}
[/code:1]


PlayerMobile version for shards upgrading from the RunUO PlayerMobile Class, or with no players, or who don't mind wiping clean.

[code:1]
using System;
using System.Collections;
using Server;
using Server.Misc;

namespace Server.Mobiles
{
public enum RaceType
{
None,
Human, HalfElf, Elf, Avariel, Dwarf, Halfling, Kender, Gnome,
SpiderGnome, Drow, Orc, Orog, Dwergar, Vampire, Lich, Skeleton
}

public enum ClassType
{
None, Fighter, Mage, Cleric, Thief, Bard, Druid
}

public enum AlignmentType
{
None, LawfulGood, Good, ChaoticGood, LawfulNeutral, TrueNeutral, ChaoticNeutral, LawfulEvil, Evil, ChaoticEvil
}

public class PlayerMobile : Mobile
{
private class CountAndTimeStamp
{
private int m_Count;
private DateTime m_Stamp;

public CountAndTimeStamp()
{
}

public DateTime TimeStamp { get{ return m_Stamp; } }
public int Count
{
get { return m_Count; }
set { m_Count = value; m_Stamp = DateTime.Now; }
}
}

private ArrayList m_VisList;
private Hashtable m_AntiMacroTable;

public RaceType m_Race = RaceType.None;
public ClassType m_Class = ClassType.None;
public AlignmentType m_Alignment = AlignmentType.None;
public int m_Level = 1;
public int m_CurrentExperience = 0;
public int m_ExperienceNeeded = 1000;


[CommandProperty( AccessLevel.GameMaster )]
public RaceType Race
{
get { return m_Race; }
set { m_Race = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public ClassType Class
{
get { return m_Class; }
set { m_Class = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public AlignmentType Alignment
{
get { return m_Alignment; }
set { m_Alignment = value; }
}

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

[CommandProperty( AccessLevel.GameMaster )]
public int CurrentExperience
{
get { return m_CurrentExperience; }
set { m_CurrentExperience = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public int ExperienceNeeded
{
get { return m_ExperienceNeeded; }
set { m_ExperienceNeeded = value; }
}

public PlayerMobile()
{
m_VisList = new ArrayList();
m_AntiMacroTable = new Hashtable();
}

public PlayerMobile( Serial s ) : base( s )
{
m_VisList = new ArrayList();
m_AntiMacroTable = new Hashtable();
}

public ArrayList VisibilityList
{
get
{
return m_VisList;
}
}

public bool AntiMacroCheck( Skill skill, object obj )
{
if ( obj == null || m_AntiMacroTable == null || this.AccessLevel != AccessLevel.Player )
return true;

Hashtable tbl = (Hashtable)m_AntiMacroTable[skill];
if ( tbl == null )
m_AntiMacroTable[skill] = tbl = new Hashtable();

CountAndTimeStamp count = (CountAndTimeStamp)tbl[obj];
if ( count != null )
{
if ( count.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
{
count.Count = 1;
return true;
}
else
{
++count.Count;
if ( count.Count <= SkillCheck.Allowance )
return true;
else
return false;
}
}
else
{
tbl[obj] = count = new CountAndTimeStamp();
count.Count = 1;

return true;
}
}

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

foreach ( Hashtable t in m_AntiMacroTable.Values )
{
ArrayList remove = new ArrayList();
foreach ( CountAndTimeStamp time in t.Values )
{
if ( time.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
remove.Add( time );
}

for (int i=0;i<remove.Count;++i)
t.Remove( remove );
}

writer.Write( (int) 0 );
writer.Write( (int)m_Race );
writer.Write( (int)m_Class );
writer.Write( (int)m_Alignment );
writer.Write( (int)m_Level );
writer.Write( (int)m_CurrentExperience );
writer.Write( (int)m_ExperienceNeeded );
}

public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();

m_Race = (RaceType)reader.ReadInt();
m_Class = (ClassType)reader.ReadInt();
m_Alignment = (AlignmentType)reader.ReadInt();
m_Level = reader.ReadInt();
m_CurrentExperience = reader.ReadInt();
m_ExperienceNeeded = reader.ReadInt();
}

public override bool CanSee( Mobile m )
{
if ( m is PlayerMobile && ((PlayerMobile)m).m_VisList.Contains( this ) )
return true;
else
return base.CanSee( m );
}
}
}
[/code:1]

PlayerMobile properly serilised for those moving up from the an earlier PlayerMobile class posted here.

[code:1]
using System;
using System.Collections;
using Server;
using Server.Misc;

namespace Server.Mobiles
{
public enum RaceType
{
None,
Human, HalfElf, Elf, Avariel, Dwarf, Halfling, Kender, Gnome,
SpiderGnome, Drow, Orc, Orog, Dwergar, Vampire, Lich, Skeleton
}

public enum ClassType
{
None, Fighter, Mage, Cleric, Thief, Bard, Druid
}

public enum AlignmentType
{
None, LawfulGood, Good, ChaoticGood, LawfulNeutral, TrueNeutral, ChaoticNeutral, LawfulEvil, Evil, ChaoticEvil
}

public class PlayerMobile : Mobile
{
private class CountAndTimeStamp
{
private int m_Count;
private DateTime m_Stamp;

public CountAndTimeStamp()
{
}

public DateTime TimeStamp { get{ return m_Stamp; } }
public int Count
{
get { return m_Count; }
set { m_Count = value; m_Stamp = DateTime.Now; }
}
}

private ArrayList m_VisList;
private Hashtable m_AntiMacroTable;

public RaceType m_Race = RaceType.None;
public ClassType m_Class = ClassType.None;
public AlignmentType m_Alignment = AlignmentType.None;
public int m_Level = 1;
public int m_CurrentExperience = 0;
public int m_ExperienceNeeded = 1000;


[CommandProperty( AccessLevel.GameMaster )]
public RaceType Race
{
get { return m_Race; }
set { m_Race = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public ClassType Class
{
get { return m_Class; }
set { m_Class = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public AlignmentType Alignment
{
get { return m_Alignment; }
set { m_Alignment = value; }
}

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

[CommandProperty( AccessLevel.GameMaster )]
public int CurrentExperience
{
get { return m_CurrentExperience; }
set { m_CurrentExperience = value; }
}

[CommandProperty( AccessLevel.GameMaster )]
public int ExperienceNeeded
{
get { return m_ExperienceNeeded; }
set { m_ExperienceNeeded = value; }
}

public PlayerMobile()
{
m_VisList = new ArrayList();
m_AntiMacroTable = new Hashtable();
}

public PlayerMobile( Serial s ) : base( s )
{
m_VisList = new ArrayList();
m_AntiMacroTable = new Hashtable();
}

public ArrayList VisibilityList
{
get
{
return m_VisList;
}
}

public bool AntiMacroCheck( Skill skill, object obj )
{
if ( obj == null || m_AntiMacroTable == null || this.AccessLevel != AccessLevel.Player )
return true;

Hashtable tbl = (Hashtable)m_AntiMacroTable[skill];
if ( tbl == null )
m_AntiMacroTable[skill] = tbl = new Hashtable();

CountAndTimeStamp count = (CountAndTimeStamp)tbl[obj];
if ( count != null )
{
if ( count.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
{
count.Count = 1;
return true;
}
else
{
++count.Count;
if ( count.Count <= SkillCheck.Allowance )
return true;
else
return false;
}
}
else
{
tbl[obj] = count = new CountAndTimeStamp();
count.Count = 1;

return true;
}
}

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

foreach ( Hashtable t in m_AntiMacroTable.Values )
{
ArrayList remove = new ArrayList();
foreach ( CountAndTimeStamp time in t.Values )
{
if ( time.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now )
remove.Add( time );
}

for (int i=0;i<remove.Count;++i)
t.Remove( remove );
}

writer.Write( (int) 1 );
writer.Write( (int)m_Class );
writer.Write( (int)m_Alignment );
writer.Write( (int)m_Level );
writer.Write( (int)m_CurrentExperience );
writer.Write( (int)m_ExperienceNeeded );
writer.Write( (int)m_Race );
}

public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();

switch ( version )
{
case 1:
{
m_Class = (ClassType)reader.ReadInt();
m_Alignment = (AlignmentType)reader.ReadInt();
m_Level = reader.ReadInt();
m_CurrentExperience = reader.ReadInt();
m_ExperienceNeeded = reader.ReadInt();
goto case 0;
}
case 0:
{
m_Race = (RaceType)reader.ReadInt();
break;
}

}
}

public override bool CanSee( Mobile m )
{
if ( m is PlayerMobile && ((PlayerMobile)m).m_VisList.Contains( this ) )
return true;
else
return base.CanSee( m );
}
}
}
[/code:1]

Finally an example of how to use the class.

Elfgate.cs

[code:1]
using System;
using Server;
using Server.Items;
using Server.Mobiles;

namespace Server.Scripts
{
public class ElfGate : BaseRaceGate
{
[Constructable]
public ElfGate() : base( new Point3D( 0, 0, 0 ), Map.Felucca, false )
{
Hue = 0x0491;
Name = "Elf";
Race = RaceType.Elf;
PointDest = new Point3D( 1325, 284, 5 );
}

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

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();
}
}
}
[/code:1]

If even more is needed it is simple to everride the OnMoveOver event. or better yet, add the needed extras to the BaseRaceGate class.

Thema
 
Top