Go Back   RunUO - Ultima Online Emulation > RunUO > Custom Script Release Archive

Custom Script Release Archive This is a pre-script database archive of what our users had released.

 
 
Thread Tools Display Modes
Old 11-03-2005, 10:56 AM   #1 (permalink)
Forum Novice
 
alambik's Avatar
 
Join Date: Apr 2003
Age: 32
Posts: 248
Arrow Switch & Levers interface

Here are two files for your switch and levers. By implementing them, you can make an action on anything (Item, Addon, Multi, Mobile...).

First file is a switch. You can easily transform it into a lever for example.
The other file is an interface allowing to define the actions on the target when switching on or off.

Here how to implement new actions:

- Add a the "switchable" intervace to the targeted object class

Example: a lift built as an addon.
Code:
	public class Lift : BaseAddon , Switchable
	{
- Implement the 2 following methods corresponding to the actions to do:
Code:
bool On(Mobile from)
...

bool Off(Mobile from)
...
- Add the switch ingame
Code:
[add switch
- Add the created target object
Example:
Code:
[add lift
- In the properties of the switch, make the "Target" field pointing on the created target object you just added

Some example of implementation:
A lift that go up/down
A light that switch on/off
A remote bomb
A trap activator/deactivator

Advantages:
- You can see the switch.
- You can activate something even if it's very very far away.

Last edited by alambik; 10-22-2007 at 10:47 PM.
alambik is offline  
Old 11-03-2005, 11:16 AM   #2 (permalink)
Forum Expert
 
LordHogFred's Avatar
 
Join Date: Jan 2004
Location: UK, Essex
Age: 20
Posts: 1,166
Default

Wow this looks great .
I'll have to get this on my shard when I get home, something like this could be invaluable to making customs dungeons, houses and decoration.
__________________
It is not the hand that creates worlds,
It is the mind controlling it !

The New Dawn Network
LordHogFred is offline  
Old 11-03-2005, 11:49 AM   #3 (permalink)
Forum Expert
 
Lucid Nagual's Avatar
 
Join Date: Nov 2004
Location: Beyond the Gates of Hell
Age: 37
Posts: 3,509
Thumbs up

Sweet! I'll have to check it out ........thx
__________________
Leader of the Anti-OSI Movement. Inventing a new game experience in an EA Games-free environment.

Don Juan Matus "The basic difference between an ordinary man and a warrior is that a warrior takes everything as a challenge, while an ordinary man takes everything as a blessing or as a curse."


My Customs:
Lucid Nagual is offline  
Old 11-03-2005, 05:27 PM   #4 (permalink)
 
Join Date: May 2005
Location: london
Age: 21
Posts: 898
Send a message via MSN to etherkye
Default

switches XD

thank you so much.
etherkye is offline  
Old 11-03-2005, 05:43 PM   #5 (permalink)
Forum Expert
 
Join Date: May 2004
Age: 29
Posts: 358
Default

!!!!

Good deal!
MetallicSomber is offline  
Old 11-08-2005, 11:27 AM   #6 (permalink)
 
Join Date: Sep 2005
Location: Roxboro, NC, USA
Age: 32
Posts: 139
Default

ooooo Elevator go up......Elevator go down Woohoo
Excellent
dashiznit_76 is offline  
Old 11-09-2005, 05:44 AM   #7 (permalink)
Forum Novice
 
alambik's Avatar
 
Join Date: Apr 2003
Age: 32
Posts: 248
Default TechnoLift

As an example, that comes from a SF/MedFan cross-over shard, here is a "TechnoLift".

How to make it work:

1) Add the TechnoLift:
[add technolift

2) Modify the properties
[props on the technolift
Choose: --> "AddOn" --> "ViewProperties"
Modify the following fields:
UpPosition : Up state position
DownPosition : Down state position
UpMap : Up state map
DownMap : Down state map

3) Add a switch and link it to the TechnoLift addon:
[add Switch
[props on the switch
Modify the field:
Target : select the TechnoLift

4) Optional:
If you want the switch to move with the lift:
[props on the TechnoLift
Choose: --> "AddOn" --> "ViewProperties"
Modify the field:
TheSwitch: target the switch you created


Some UO cyber-shards are currently developped.
I hope they will offer a new original sight to uo :-)
Enjoy!

Last edited by alambik; 10-22-2007 at 10:47 PM.
alambik is offline  
Old 11-22-2005, 01:44 PM   #8 (permalink)
Forum Novice
 
Join Date: Jan 2004
Location: Flint Michigan
Age: 36
Posts: 216
Default

Anyone else get this to work? I followed the instructions, changed all the props as indicated but its not moving. Anyone else?
__________________
I f it aint Broken Then Dont Fix It
Quote:
Dont run you will only die tierd.
:D
tink is offline  
Old 11-22-2005, 03:29 PM   #9 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default

(tink means the technolift.cs)
Jarrod is offline  
Old 11-23-2005, 05:28 AM   #10 (permalink)
Forum Novice
 
alambik's Avatar
 
Join Date: Apr 2003
Age: 32
Posts: 248
Default

I removed the in game state propety access from the script.
(for information of internal functionality: state values significatons are 1 for moving up , -1 for moving down, 0 for waiting switch to be switched: this prevent the switch to be used many time while going up or down)
Seems it confused some people.
Please don't PM me, just answer here.

I've retested the "TechnoLift" example as described, I encountered no pb.

The important thing is that you wan reuse Switchable for anything.
"TechnoLift" is just here as an exemple of "Switchable" interface.

(by the way, I've seen RunUO team are naming inteface with a "I" at the beginning, so if you want to be consistent, should be named "ISwitchable")
alambik is offline  
Old 11-23-2005, 08:09 AM   #11 (permalink)
Forum Expert
 
Viago's Avatar
 
Join Date: Jun 2004
Location: Maine, USA
Age: 25
Posts: 2,703
Send a message via ICQ to Viago Send a message via AIM to Viago Send a message via MSN to Viago Send a message via Yahoo to Viago
Default

Quote:
Originally Posted by LordHogFred
Wow this looks great .
I'll have to get this on my shard when I get home, something like this could be invaluable to making customs dungeons, houses and decoration.
my thoughts exactly.
Viago is offline  
Old 11-23-2005, 02:31 PM   #12 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default

Sorry for the PM yesterday, I normally do not PM anyone, but I thought you had perhaps overlooked something.

the lift is created with state 0 by default

On returns Off

Off says "if state is NOT equal 0 then begin"

As the state is 0 by default, the lift does not, and will not move.

If you set the state to 1 manually after creating the lift, when you activate it, it will move up or down twice in a row.

i.e. it is at 0, and should be moved up to 25 z
you click the switch
the lift moves up to 25 z
the lift reappears at 0 z and moves back up to 25 z again

the same applies for moving down.

unless of course you have modified your switch.cs

Ill mess around with the lift a bit and post the results.
Jarrod is offline  
Old 11-23-2005, 03:23 PM   #13 (permalink)
Forum Expert
 
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
Default

with this version all you do is set the UP Z and DOWN Z. link the switch to it, and the rest takes care of itself.

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

namespace Server.Items
{
	public class Lift : BaseAddon , Switchable
	{

		private Item m_Switch;
		[CommandProperty( AccessLevel.GameMaster )]
		public Item TheSwitch
		{ get{ return m_Switch; } set{ m_Switch = value; } }

		private Point3D m_UpPosition;
		[CommandProperty( AccessLevel.GameMaster )]
		public Point3D UpPosition
		{ get{ return m_UpPosition; } set{ m_UpPosition = value; } }

		private Point3D m_DownPosition;
		[CommandProperty( AccessLevel.GameMaster )]
		public Point3D DownPosition
		{ get{ return m_DownPosition; } set{ m_DownPosition = value; } }

		private int m_Sound;
		[CommandProperty( AccessLevel.GameMaster )]
		public int Sound
		{ get{ return m_Sound; } set{ m_Sound = value; } }

		private int m_State;
		[CommandProperty( AccessLevel.GameMaster )]
		public int State
		{ get{ return m_State; } set{ m_State = value; } }

		[Constructable]
		public Lift()
		{
			AddComponent( new AddonComponent( 1997 ), 0, 0, 0 );
			Name="a lever";
			m_Sound=1301;
			m_State=1;
			m_UpPosition=Location;
			m_DownPosition=Location;
		}

		public bool On( Mobile from )
		{
			if (m_State != 1)
			{
				m_State=1;
				new InternalTimer(this,m_State,from,((from.Z-1 == Z) && (from.X == X) && (from.Y == Y))).Start();
				
				return true;
			}
			return false;
		}

		public bool Off( Mobile from )
		{
			if (m_State != 2)
			{
				m_State=2;
				new InternalTimer(this,m_State,from,((from.Z-1 == Z) && (from.X == X) && (from.Y == Y))).Start();
				
				return true;
			}
			return false;		
		}

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

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

			writer.Write( (int) 0 ); // version
			writer.Write( m_UpPosition );
			writer.Write( m_DownPosition );
			writer.Write( m_Sound );
			writer.Write( m_State );
			writer.Write( m_Switch );
		}

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

			int version = reader.ReadInt();
			m_UpPosition = reader.ReadPoint3D();
			m_DownPosition = reader.ReadPoint3D();
			m_Sound = reader.ReadInt();
			m_State = reader.ReadInt();
			m_Switch = reader.ReadItem();
		}

		private class InternalTimer : Timer
		{
			private Lift m_Lift;
			private int m_Counter;
			private int m_Offset;
			private Mobile m_Target;
			private bool m_MoveMobile;

			public InternalTimer( Lift Lift, int offset, Mobile target, bool moveMobile ) : base( TimeSpan.FromSeconds( 0 ), TimeSpan.FromSeconds( 0.1 ) )
			{
				m_Lift = Lift;
				m_Target = target;
				m_Offset = offset;
				m_Counter = 0;
				m_MoveMobile = moveMobile;
				Effects.PlaySound( m_Lift.Location, m_Lift.Map, m_Lift.Sound );
			}

			protected override void OnTick()
			{
				if (m_Offset == 1) // its down, now moving up
				{
					if (m_Lift.Z < m_Lift.UpPosition.Z) m_Lift.Z = m_Lift.Z + 1;
					if ( m_MoveMobile )
						m_Target.MoveToWorld( new Point3D(m_Lift.X, m_Lift.Y, m_Lift.Z+1), m_Lift.Map=m_Lift.Map);
					if (m_Lift.Z >= m_Lift.UpPosition.Z)
						Stop();
					 
				}
				if (m_Offset == 2) // its up, now moving down
				{
					if (m_Lift.Z > m_Lift.DownPosition.Z) m_Lift.Z = m_Lift.Z - 1;
					if ( m_MoveMobile )
						m_Target.MoveToWorld( new Point3D(m_Lift.X, m_Lift.Y, m_Lift.Z+1), m_Lift.Map=m_Lift.Map);
					if (m_Lift.Z <= m_Lift.DownPosition.Z)
						Stop();
					 
				}
		
			}
		}

	}
}
Jarrod is offline  
Old 11-24-2005, 11:03 AM   #14 (permalink)
Forum Novice
 
alambik's Avatar
 
Join Date: Apr 2003
Age: 32
Posts: 248
Default

About "state", you were right.
To "fix", just initialize the attribute to "-1" for example.
(script has been updated).

About the use, it was not intended to work as you said.

The aim was to create a lift that you take for example to go in an underground...

Up, the lift is somewhere, at the earth level.
Down, you arrive in a donjon (somewhere in another place, and, why not, another map).

The effect of this is that you really feel you go progressivly underground using this lift (not like an "instant" teleporter). So it is important to define Up location & map, and Down location & map.

But your script is good for the lifts that does not "teleport" elsewhere. Good work.

;-) Thanks
alambik is offline  
Old 12-17-2005, 01:50 PM   #15 (permalink)
 
Join Date: Dec 2005
Posts: 62
Default

im trying to make a door be switchable and im not sure what to add with the

HTML Code:
bool On( Mobile from ) ;
          bool Off( Mobile from ) ;
	}
I dont know what the corresponding to the actions to do are.

im getting errors like this

HTML Code:
RunUO - [www.runuo.com] Version 1.0.0, Build 36918
Scripts: Compiling C# scripts...failed (2 errors, 0 warnings)
 - Error: Scripts\Customs\TheDoor.cs: CS0535: (line 3, column 15) 'Server.Items.
TheDoor' does not implement interface member 'Server.Items.Switchable.On(Server.
Mobile)'
 - Error: Scripts\Customs\TheDoor.cs: CS0535: (line 3, column 15) 'Server.Items.
TheDoor' does not implement interface member 'Server.Items.Switchable.Off(Server
.Mobile)'
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.

Last edited by Ali G; 12-17-2005 at 01:53 PM.
Ali G is offline  
Old 12-17-2005, 06:54 PM   #16 (permalink)
Forum Novice
 
alambik's Avatar
 
Join Date: Apr 2003
Age: 32
Posts: 248
Default

Please don't PM me the same thing that you just posted.
See answer in PM.
alambik is offline  
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5