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!

Any Sample Scripts

I

infinity

Guest
Any Sample Scripts

Can anybody paste a sample script. Been working on c# but wanted to c a sample script.
 
S

Sum Yung Guy

Guest
[code:1] public override void OnDoubleClick( Mobile from )
{
Eat( from );
}

public void Eat( Mobile from )
{
// Play a random "eat" sound
from.PlaySound( Utility.Random( 0x3A, 3 ) );

// Consume one item
--Amount;

if ( Amount == 0 )
Delete(); // Nothing left to eat
}[/code:1]
 

krrios

Administrator
From the reagent stone:

[code:1] public RegStone() : base( 0xED4 )
{
Movable = false;
Hue = 0x2D1;
Name = "a reagent stone";
}

public override void OnDoubleClick( Mobile from )
{
BagOfReagents regBag = new BagOfReagents( 50 );

Container pack = from.Backpack;

if ( pack == null || !pack.TryDropItem( from, regBag, false ) )
regBag.Delete();
}[/code:1]

From the scissors item:

[code:1] public override void OnDoubleClick( Mobile from )
{
from.SendLocalizedMessage( 502434 ); // What should I use these scissors on?

from.Target = new InternalTarget( this );
}

private class InternalTarget : Target
{
private Scissors m_Item;

public InternalTarget( Scissors item ) : base( 1, false, TargetFlags.None )
{
m_Item = item;
}

protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Item.Deleted ) return;

if ( targeted is IScissorable )
{
IScissorable obj = (IScissorable)targeted;

if ( obj.Scissor( from, m_Item ) )
from.PlaySound( 0x248 );
}
else
{
from.SendLocalizedMessage( 502440 ); // Scissors can not be used on that to produce anything.
}
}
}[/code:1]
 
W

Wasted

Guest
what about functions? anything like

void test ( int argc, char * argv[] , Mobile from) {
from.SystemMessage("Argument #1: " + argv[1]);
};
 
W

Wasted

Guest
i know zip hehe

I didnt try to design the "function" concept model hehe, just tryed to figure out how it'd work.....
so in pseudo code

returntype functionname (Mobile from, args) {
...code...
return ?;
}

like this?

quick question: are u osi's former lead gm?
 

Jediman

Sorceror
Nice, Im liking this version of scripting. I wonder if I can port some Java Scripts over to this version :) I think until a certain other emu gets a little stable and the code base is faster, my mail system will be scripted in for RunUO, considering it seems alot more superior in more than just ways of scripting :)
 

Zippy

Razor Creator
Wasted:
Yes, you will be able to have your own functions... but in C#, functions have to be in classes....

I can't really answer your question better until you ask something a bit more specific....
 
H

Hotdog

Guest
Nice object oriented code. :D

Let me see if my logic is correct? I will use the scissor as a reference.
There are two lines of code that stand out for me.

The first is
private class InternalTarget : Target

Does this mean that any object that will be targetable will inherit form the Target base class?

The second
if ( targeted is IScissorable )

Does this mean that any object that scissors can be used on must implement the IScissorable interface?

This brings me to my final question.
Do you have documentation of the class libraries and interfaces?
If so would they be available in the Beta or in the fianl release?

Now I really can't wait to take a look at the Beta. :D
 

krrios

Administrator
First question: Close, but not quite. It's not an object that's targetable, you create your own target classes which inherit from the Target base class.

Second question: Yes.

Final question: There's not much in the way of documentation yet. Until there is, I suppose the scripts will be good for learning.
 

krrios

Administrator
Here's a sample spell script (energy bolt). Internal target excluded, simply calls the Target function.

[code:1] public EnergyBoltSpell( Mobile caster, Server.Items.SpellScroll scroll ) : base( caster, scroll, "Energy Bolt", "Corp Por", SpellCircle.Sixth, Reagent.BlackPearl, Reagent.Nightshade )
{
}

public override void OnCast()
{
Caster.Target = new InternalTarget( this );
}

public void Target( Mobile m )
{
if ( !Caster.CanSee( m ) )
{
Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
}
else if ( Caster.HarmfulCheck( m ) && CheckSequence() )
{
// Base damage 20-50
double damage = Utility.Random( 20, 30 );

if ( CheckResisted( m ) )
{ // Resisted, take half damage
damage *= 0.5;

m.SendLocalizedMessage( 501783 ); // You feel yourself resisting magical energy.
}

// Scale damage based on evalint and resist
damage *= GetDamageScalar( m );

// Deal the damage
m.Damage( (int) damage );

if ( Caster != m )
Caster.Direction = Caster.GetDirectionTo( m ); // Turn to them

// Do the effects
Caster.PlaySound( 0x20A );
Effects.SendMovingEffect( Caster, m, 0x379F, 7, 0, false, true );
}

FinishSequence();
}[/code:1]
 
Top