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!

Adding members to internal classes/objects

Mithril

Sorceror
Adding members to internal classes/objects

Is there a way to add methods/members to the internal classes/objects?

For example, if I wanted to add a custom member to Mobile, would that be possible now or in the future? Been trying a few different ways to see if I could do it, but no luck yet.

Any insight would be most helpful :)
 

fenris

Wanderer
:?: You mean to create a new NPC for example?
if this is your question the answer is yes, it is possible.

i've just created a new NPC named "Banker", he was pretty much a copy of town crier, but it worked nicely!!!

i created a file named "Banker.cs" in the mobile folder and inserted the folowing script to it:

using System;
using Server.Items;

namespace Server.Scripts.Mobiles
{
public class Banker : Mobile
{
[Constructable]
public Banker()
{
InitStats( 100, 100, 25 );

Title = "the banker";
Name = "Harold";
Body = 0x190;
Female = false;
Hue = Utility.RandomSkinHue();

AddItem( new FancyShirt( Utility.RandomBlueHue() ) );

Item pants;

switch ( Utility.Random( 2 ) )
{
case 0: pants = new LongPants(); break;
default: case 1: pants = new ShortPants(); break;
}

pants.Hue = Utility.RandomGreenHue();

AddItem( pants );

Item boots;

switch ( Utility.Random( 2 ) )
{
case 0: boots = new Boots(); break;
default: case 1: boots = new ThighBoots(); break;
}

AddItem( boots );

Item hair = new Item( Utility.RandomList( 0x203B, 0x2049, 0x2048, 0x204A ) );

hair.Hue = Utility.RandomNondyedHue();
hair.Layer = Layer.Hair;
hair.Movable = false;

AddItem( hair );
}

public Banker( 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();
}
}
}

then i ran RunUO, once inside just type "[add banker" and voila! :D
i hope this was your doubt
 

Zippy

Razor Creator
I think what he means is a way to acctack a new method or property to mobile itself, so that it could be used on Players for example....


There is currently no way to do this via Scripts, but "we" are considering a few different ways to allow this, look for this possibly in the next release (But, you know, I never make promises...)
 
Top