|
||
|
|||||||
| Custom Script Release Archive This is a pre-script database archive of what our users had released. |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Novice
Join Date: Apr 2003
Age: 32
Posts: 248
|
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
{
Code:
bool On(Mobile from) ... bool Off(Mobile from) ... Code:
[add switch Example: Code:
[add lift 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. |
|
|
|
|
#2 (permalink) |
|
Forum Expert
Join Date: Jan 2004
Location: UK, Essex
Age: 20
Posts: 1,166
|
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 |
|
|
|
|
#3 (permalink) |
|
Forum Expert
Join Date: Nov 2004
Location: Beyond the Gates of Hell
Age: 37
Posts: 3,509
|
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:
|
|
|
|
|
#7 (permalink) |
|
Forum Novice
Join Date: Apr 2003
Age: 32
Posts: 248
|
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. |
|
|
|
|
#8 (permalink) | |
|
Forum Novice
Join Date: Jan 2004
Location: Flint Michigan
Age: 36
Posts: 216
|
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:
|
|
|
|
|
|
#10 (permalink) |
|
Forum Novice
Join Date: Apr 2003
Age: 32
Posts: 248
|
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") |
|
|
|
|
#12 (permalink) |
|
Forum Expert
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
|
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. |
|
|
|
|
#13 (permalink) |
|
Forum Expert
Join Date: Oct 2002
Location: Germany (american though)
Age: 33
Posts: 957
|
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();
}
}
}
}
}
|
|
|
|
|
#14 (permalink) |
|
Forum Novice
Join Date: Apr 2003
Age: 32
Posts: 248
|
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 |
|
|
|
|
#15 (permalink) |
|
Join Date: Dec 2005
Posts: 62
|
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 ) ;
}
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. |
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|