|
||
|
|||||||
| Custom Script Release Archive This is a pre-script database archive of what our users had released. |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Expert
|
Well everyone.. you've been asking for it for as long as I can remember.. so here it is! Working hallucination!
But before I post the code.. Props goes out to ArteGordan for his keen intuition on packets, without him, this would not have been possible. Description: UPDATE: I've tweaked the system just a bit to use each item's item id rather than a random value, causing it to only change hues rather than displaying random artwork. I've scripted the Hallucination system into an LSD drug form. Effects: The user of the 'LSD' will experience visual effects for a duration of 3 minutes (see timespan under SoberTimer to modify) Code:
public SoberTimer( Mobile from ) : base( TimeSpan.FromMinutes( 3 ) ) Code:
int id = Utility.Random( 1, 1026 ); int hhue = Utility.Random( 2, 1200 ); You'll need to add a property to your PlayerMobile.cs called Hallucinating: Code:
public bool Hallucinating; Code:
[CommandProperty( AccessLevel.GameMaster )]
public bool IsHallucinating
{
get{ return Hallucinating; }
set{ Hallucinating = value; InvalidateProperties(); }
}
..And without further adue: LSD.cs Code:
//Scripted By Vhaldir
//Thanks to ArteGordan for the packet insight
using System;
using System.Collections;
using Server.Multis;
using Server.Items;
using Server.Network;
using Server.Targeting;
using Server.Mobiles;
namespace Server.Items
{
public class LSD : Item
{
private Item m;
[Constructable]
public LSD() : this(1)
{
}
[Constructable]
public LSD(int amount) : base(0xf8e)
{
Stackable=true;
Amount=amount;
Weight = 0.5;
Name = "LSD";
Hue = 0x44;
}
public LSD(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int) 0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
public override void OnDoubleClick( Mobile from )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm.Hallucinating )
{
pm.SendMessage( "You are already under the effect of a hallucinagen" );
}
else
{
this.Consume();
pm.Hallucinating = true;
pm.SendMessage( "You consume the drug and quickly begin to feel its effects" );
HallucinationTimer hallucinationTimer = new HallucinationTimer( from );
hallucinationTimer.Start();
}
}
public static void SendHallucinationItem( IEntity e, int itemID, int speed, int duration, int renderMode, int hue )
{
Map map = e.Map;
if ( map != null )
{
Packet regular = null;
IPooledEnumerable eable = map.GetClientsInRange( e.Location );
foreach ( NetState state in eable )
{
PlayerMobile pm = state.Mobile as PlayerMobile;
state.Mobile.ProcessDelta();
if ( state.Mobile is PlayerMobile )
{
if( pm.Hallucinating )
{
switch ( Utility.Random( 4 ))
{
case 0: pm.FixedParticles( 0x373A, 10, 15, 5018, EffectLayer.Waist ); break;
case 1: pm.FixedParticles( 0x374A, 10, 15, 5018, EffectLayer.Head ); break;
case 2: pm.FixedParticles( 0x375A, 10, 15, 5018, EffectLayer.Waist ); break;
case 3: pm.FixedParticles( 0x376A, 10, 15, 5018, EffectLayer.Head ); break;
}
if ( regular == null )
regular = new LocationEffect( e, itemID, speed, duration, renderMode, hue );
state.Send( regular );
}
}
}
eable.Free();
}
}
public class HallucinationTimer : Timer
{
private Mobile m;
//Timespan between visual changes
public HallucinationTimer( Mobile from ) : base( TimeSpan.FromSeconds( 2 ) )
{
Priority = TimerPriority.OneSecond;
m = from;
}
protected override void OnTick()
{
HallucinationTimer hallucinationTimer = new HallucinationTimer( m );
SoberTimer soberTimer = new SoberTimer( m );
PlayerMobile pm = m as PlayerMobile;
//int id = Utility.Random( 1, 1026 );
int hhue = Utility.Random( 2, 1200 );
if ( pm.Hallucinating )
{
ArrayList targets = new ArrayList();
IPooledEnumerable eable = pm.GetItemsInRange( 50 );
foreach ( Item t in eable )
{
int id = t.ItemID;
if ( t.Visible )
{
targets.Add( t );
SendHallucinationItem( t, id, 5, 5000 , 4410, hhue );
}
}
eable.Free();
hallucinationTimer.Start();
soberTimer.Start();
}
else
{
Stop();
}
}
}
public class SoberTimer : Timer
{
private Mobile m;
public SoberTimer( Mobile from ) : base( TimeSpan.FromMinutes( 3 ) )
{
Priority = TimerPriority.FiveSeconds;
m = from;
}
protected override void OnTick()
{
SoberTimer soberTimer = new SoberTimer( m );
PlayerMobile pm = m as PlayerMobile;
if ( pm.Hallucinating )
{
pm.Hallucinating = false;
pm.SendMessage( "The effects of the drug have worn off." );
Stop();
}
}
}
}
}
ENJOY! Last edited by Vhaldir; 02-08-2006 at 10:10 PM. |
|
|
|
|
#2 (permalink) |
|
ConnectUO Creator
Join Date: Jan 2004
Age: 28
Posts: 4,952
|
You forgot the part about having to mod the PlayerMobile.cs script....
__________________
Jeff Boulanger ConnectUO - Creator/Core Developer Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
|
#3 (permalink) |
|
Forum Expert
Join Date: Sep 2005
Location: UK
Age: 29
Posts: 781
|
and so how about the call back, as i have an old verison of this, but when u use it, it turns you into a ramdom hue, but dont turn you back into you self, thanks
__________________
*+ MW Admin Naturescorpse +* |
|
|
|
|
#5 (permalink) | |
|
Forum Expert
|
Quote:
This is a completely custom version of the LSD and does not contain any hue modifying function pertaining to the consumer. It is purely external visual effects on items surrounding the user. If anyone would like to see additional functionality, please let me know and I'll see what I can come up with. |
|
|
|
|
|
#6 (permalink) |
|
ConnectUO Creator
Join Date: Jan 2004
Age: 28
Posts: 4,952
|
Ok now you need to change your script to match those properties
IsHallucinating isnt the same a Hallucinating ![]()
__________________
Jeff Boulanger ConnectUO - Creator/Core Developer Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
|
#7 (permalink) | |
|
Forum Expert
|
Quote:
the Command property name has nothing to do with the actual value.. it's just a placeholder.. you could call it pickingyournose and it'd still modify the same value.. IsHallucinating is just what is shown in the [props menu it woks fine, i've already tested it thoroughly. |
|
|
|
|
|
#9 (permalink) | |
|
ConnectUO Creator
Join Date: Jan 2004
Age: 28
Posts: 4,952
|
Quote:
Code:
public bool Hallucination ![]()
__________________
Jeff Boulanger ConnectUO - Creator/Core Developer Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
|
|
#10 (permalink) | |
|
Forum Expert
|
Quote:
Hehe, sorry for the misunderstanding.. and as far as programming rules are concerned.. everything I know about programming is self-taught, so I really don't have any rules aside from what I've picked up thus far. I just know what works and what doesn't. So yes.. I might do things like that here and there until I've learned otherwise.. Thanks for the input though, I'll keep that in mind from now on. |
|
|
|
|
|
#11 (permalink) | |
|
ConnectUO Creator
Join Date: Jan 2004
Age: 28
Posts: 4,952
|
Quote:
![]()
__________________
Jeff Boulanger ConnectUO - Creator/Core Developer Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
|
|
#14 (permalink) |
|
Newbie
Join Date: Oct 2005
Posts: 85
|
I get an error when i put
Code:
public bool Hallucinating;
[CommandProperty( AccessLevel.GameMaster )]
public bool IsHallucinating
{
get{ return Hallucinating; }
set{ Hallucinating = value; InvalidateProperties(); }
}
The error says: RunUO - [www.runuo.com] Version 1.0.0, Build 36918 Scripts: Compiling C# scripts...failed (2 errors, 0 warnings) - Error: Scripts\Mobiles\PlayerMobile.cs: CS1518: (line 64, column 10) Expected class, delegate, enum, interface, or struct - Error: Scripts\Mobiles\PlayerMobile.cs: CS1518: (line 67, column 10) Expected class, delegate, enum, interface, or struct Scripts: One or more scripts failed to compile or no script files were found. - Press return to exit, or R to try again. |
|
|
|
|
#15 (permalink) | |
|
Forum Expert
|
Quote:
beneath Code:
public class PlayerMobile : Mobile
{
|
|
|
|
|
|
#16 (permalink) |
|
Join Date: Feb 2005
Age: 28
Posts: 3
|
I would love to try this script but i am a bit dumb on where to put the mods in the playermoblie script like what line number should it be at or where abouts in the script can i place the new code? i have tryed to just toss it in in a couple different place, i got the props part to go in ok but where do i put the public bool ...... part?
|
|
|
|
|
#17 (permalink) |
|
Account Terminated
Join Date: Apr 2004
Location: Titusville PA
Age: 26
Posts: 975
|
This is just my opinion on this so dont take it as posative or negative really. I think this might be best if it caused random hues to all objects including mobiles but would randomly change the body value of all mobiles. So say you eat some LSD all human male players would get a random hue and thier body would become that of a mongbat or a cow or something at random while all mongbats become demon knights or snakes or whatever with a random hue. This change could happen one time per use for body value and you could make it cycle through hues randomly for the duration.
But yeah this is pretty sweet I been wanting to see some type of trip for the LSD and such. |
|
|
|
|
#18 (permalink) |
|
Join Date: Sep 2005
Location: Roxboro, NC, USA
Age: 32
Posts: 139
|
I added this with no problem but Razor/UO Client seems to have a problem with it, or the changing of the hues in a large scale environment with lots of items around all over the place and crashes the client after about 5-6 seconds. Maybe its just mine but any insight into this is appreciated
|
|
|
|
|
#19 (permalink) |
|
my client (4011f) crashes everytime i get hallu and console reports:
Warning: System.NullReferenceException: Object reference not set to an instance of an object. at System.Net.OSSOCK.WSAGetOverlappedResult(IntPtr socketHandle, IntPtr overlapped, UInt32& bytesTransferred, Boolean wait, IntPtr ignored) at System.Net.Sockets.OverlappedAsyncResult.Completio nPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) |
|
|
|
|
|
#20 (permalink) | |
|
Forum Expert
|
Quote:
try patching |
|
|
|
|
|
#21 (permalink) | |
|
Forum Expert
|
Quote:
I haven't had any issues.. are you using an older/slow computer..? Processor/Ram? Is your client fully patched? Last edited by Vhaldir; 02-24-2006 at 08:01 AM. |
|
|
|
|
|
#22 (permalink) |
|
Forum Novice
Join Date: Dec 2004
Age: 26
Posts: 163
|
just curiouse if theres been an update of this script :S
would honestly love to see something like this but in the form of "opium" where you can have a water pipe, to smoke it out of also maybe taking it from the White poppie plant it originates from (if I knew anything about scripting besides modifying scripts, I'd try this lmao) |
|
|
|
|
#23 (permalink) |
|
Join Date: Mar 2005
Age: 31
Posts: 135
|
This is interesting script which I'm thinking of turning into poisonous mushrooms that players can pick up and eat... those overcurious bastards...
anyway... the effects of the drug, are they visible only for the player who uses the drug, or are they visible for everybody in the screen too? |
|
|
|
|
#24 (permalink) |
|
Forum Novice
Join Date: Dec 2004
Age: 26
Posts: 163
|
This is so odd :S I installed this script awhile back ago and it was working, then I went and added a few scripts and now when players go to use this script it hangs for a second then crashes their client (not the server their client) it only recently started to happen and Ive added a few scripts since then, but only one that was for the player mobile.. Here is my LSD script Code:
//Scripted By Vhaldir
//Thanks to ArteGordan for the packet insight
using System;
using System.Collections;
using Server.Multis;
using Server.Items;
using Server.Network;
using Server.Targeting;
using Server.Mobiles;
namespace Server.Items
{
public class OpiumPipe : Item
{
private Item m;
[Constructable]
public OpiumPipe() : this(1)
{
}
[Constructable]
public OpiumPipe(int amount) : base(0x10E9)
{
Weight = 0.5;
Name = "A Small Glass Opium Pipe";
Hue = 1195;
}
public OpiumPipe(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int) 0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
public override void OnDoubleClick( Mobile from )
{
PlayerMobile pm = from as PlayerMobile;
Container pack = from.Backpack;
if( pm == null )
return;
if ( pm.Hallucinating )
{
pm.SendMessage( "You are already under the effect of a hallucinagen" );
}
else
{
if ( pack != null && pack.ConsumeTotal( typeof( Opium ), 1 ) )
{
pm.Hallucinating = true;
pm.SendMessage( "You consume the drug and quickly begin to feel its effects" );
HallucinationTimer hallucinationTimer = new HallucinationTimer( from );
hallucinationTimer.Start();
Effects.PlaySound( pm.Location, pm.Map, 0x291 );
}
}
}
public static void SendHallucinationItem( IEntity e, int itemID, int speed, int duration, int renderMode, int hue )
{
Map map = e.Map;
if ( map != null )
{
Packet regular = null;
IPooledEnumerable eable = map.GetClientsInRange( e.Location );
foreach ( NetState state in eable )
{
PlayerMobile pm = state.Mobile as PlayerMobile;
state.Mobile.ProcessDelta();
if ( state.Mobile is PlayerMobile )
{
if( pm.Hallucinating )
{
switch ( Utility.Random( 4 ))
{
case 0: pm.FixedParticles( 0x37C4, 10, 15, 5018, EffectLayer.Waist ); break;
case 1: pm.FixedParticles( 0x3779, 10, 15, 5018, EffectLayer.Head ); break;
case 2: pm.FixedParticles( 0x37C4, 10, 15, 5018, EffectLayer.Waist ); break;
case 3: pm.FixedParticles( 0x3779, 10, 15, 5018, EffectLayer.Head ); break;
}
if ( regular == null )
regular = new LocationEffect( e, itemID, speed, duration, renderMode, hue );
state.Send( regular );
}
}
}
eable.Free();
}
}
public class HallucinationTimer : Timer
{
private Mobile m;
//Timespan between visual changes
public HallucinationTimer( Mobile from ) : base( TimeSpan.FromSeconds( 2 ) )
{
Priority = TimerPriority.OneSecond;
m = from;
}
protected override void OnTick()
{
HallucinationTimer hallucinationTimer = new HallucinationTimer( m );
SoberTimer soberTimer = new SoberTimer( m );
PlayerMobile pm = m as PlayerMobile;
//int id = Utility.Random( 1, 1026 );
int hhue = Utility.Random( 2, 1200 );
if ( pm.Hallucinating )
{
ArrayList targets = new ArrayList();
IPooledEnumerable eable = pm.GetItemsInRange( 50 );
foreach ( Item t in eable )
{
int id = t.ItemID;
if ( t.Visible )
{
targets.Add( t );
SendHallucinationItem( t, id, 5, 5000 , 4410, hhue );
}
}
eable.Free();
hallucinationTimer.Start();
soberTimer.Start();
}
else
{
Stop();
}
}
}
public class SoberTimer : Timer
{
private Mobile m;
public SoberTimer( Mobile from ) : base( TimeSpan.FromMinutes( 3 ) )
{
Priority = TimerPriority.FiveSeconds;
m = from;
}
protected override void OnTick()
{
SoberTimer soberTimer = new SoberTimer( m );
PlayerMobile pm = m as PlayerMobile;
if ( pm.Hallucinating )
{
pm.Hallucinating = false;
pm.SendMessage( "The effects of the Opium have worn off." );
Stop();
}
}
}
}
}
Code:
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Items;
using Server.Gumps;
using Server.Multis;
using Server.Engines.Help;
using Server.ContextMenus;
using Server.Network;
using Server.Spells;
using Server.Spells.Fifth;
using Server.Spells.Seventh;
using Server.Targeting;
using Server.Engines.Quests;
using Server.Factions;
using Server.Regions;
using Server.Accounting;
namespace Server.Mobiles
{
[Flags]
public enum PlayerFlag // First 16 bits are reserved for default-distro use, start custom flags at 0x00010000
{
None = 0x00000000,
Glassblowing = 0x00000001,
Masonry = 0x00000002,
SandMining = 0x00000004,
StoneMining = 0x00000008,
ToggleMiningStone = 0x00000010,
KarmaLocked = 0x00000020,
AutoRenewInsurance = 0x00000040,
UseOwnFilter = 0x00000080,
PublicMyRunUO = 0x00000100,
PagingSquelched = 0x00000200,
Young = 0x00000400
}
public enum NpcGuild
{
None,
MagesGuild,
WarriorsGuild,
ThievesGuild,
RangersGuild,
HealersGuild,
MinersGuild,
MerchantsGuild,
TinkersGuild,
TailorsGuild,
FishermensGuild,
BardsGuild,
BlacksmithsGuild
}
public enum SolenFriendship
{
None,
Red,
Black
}
public class PlayerMobile : Mobile
{
//////////// <summary>
///Hallucinating Code
///////// </summary>
public bool Hallucinating = false;
[CommandProperty( AccessLevel.GameMaster )]
public bool IsHallucinating
{
get{ return Hallucinating; }
set{ Hallucinating = value; InvalidateProperties(); }
}
///////// <summary>
/// End Hallucinating Code
////////// </summary>
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; } |