|
||
|
|||||||
| Other Cant find a category above, use this one! Core mods not listed above go here! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#6 (permalink) |
|
Forum Expert
Join Date: Mar 2005
Location: Hopefully not near you
Posts: 2,232
|
Thank you for offering the information, I was doing a search for how to add random drops when you double click a deed.
If you know of a place where I can find more information to help me to create the random drop on double click of a deed( then it would disappear) please point me in the direction. I am not afraid to try and to come back and offer what I have and ask for help. But I have done many searches here and can not seem to find what would be simular. Thank you for your time and effort. It is apprecated
__________________
All people have the right to be stupid but some abuse the privilege.
|
|
|
|
|
|
#7 (permalink) |
|
Join Date: Oct 2002
Age: 22
Posts: 4,689
|
If you want to get a random chance, lets say 20%, you would do this
if ( 0.20 > Utility.RandomDouble() ) { 20% chance stuff goes here } else { 80% chance stuff goes here } All basic percent chances are based on that format. |
|
|
|
|
|
#8 (permalink) |
|
Forum Expert
Join Date: Mar 2005
Location: Hopefully not near you
Posts: 2,232
|
hmm not sure as I have more than 2 things ..
I was thinking the switch ( Utility.Random( 29 )) { case 0: PackItem( new item() ); break; case 1: PackItem( new item() ); break; case 2: PackItem( new item() ); break; } But I am not figuring it out correctly..here is what I have so far I just want the deed to allow them to double click it and randomly get 1 of 3 things Code:
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server.Gumps;
namespace Server.Items
{
public class PinataTicket : Item
{
private Mobile m_Owner;
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Owner
{
get{ return m_Owner; }
set{ m_Owner = value; }
}
[Constructable]
public PinataTicket() : base( 0x14EF )
{
Weight = 1.0;
LootType = LootType.Blessed;
}
public override bool DisplayLootType{ get{ return false; } }
public PinataTicket( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( (Mobile) m_Owner );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
m_Owner = reader.ReadMobile();
break;
}
}
if ( Name == "Pinata Ticket" )
Name = null;
}
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
private class InternalTarget : Target
{
private PinataTicket m_Ticket;
public InternalTarget( PinataTicket ) : base( 2, false, TargetFlags.None )
{
m_Ticket = ticket;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted == m_Ticket )
if ( m_Ticket.Deleted )
return;
int number = 0;
Item item = null;
Item item2 = null;
switch ( info.ButtonID )
if ( item != null )
{
m_Ticket.Delete();
m_From.SendLocalizedMessage( number );
m_From.AddToBackpack( item );
if ( item2 != null )
m_From.AddToBackpack( item2 );
}
}
}
}
}
I am modifying or trying to mod the new player ticket...it is the only base I could find that came close
__________________
All people have the right to be stupid but some abuse the privilege.
|
|
|
|
|
|
#9 (permalink) |
|
Join Date: Oct 2002
Age: 22
Posts: 4,689
|
there are multiple ways to approach this..
If you want an even chance for 6 objects to be used, you would do switch ( Utility.Random( 6 ) ) { case 0: blah blah; break; case 1: blah blah; break; .... case 5: blah blah; break; } if you want a 20% chance for one thing, a 40% chance for another, and a 30% chance for a third, and the rest for a fourth, you would do it like this double random = Utility.RandomDouble(); if ( 0.20 > random ) blah blah; else if ( 0.60 > random ) blah blah; else if ( 0.90 > random ) blah blah; else blah blah; |
|
|
|
|
|
#11 (permalink) |
|
Forum Expert
Join Date: Mar 2005
Location: Hopefully not near you
Posts: 2,232
|
Code:
RunUO - [www.runuo.com] Version 1.0.0, Build 36918 Scripts: Compiling C# scripts...failed (4 errors, 31 warnings) - Error: Scripts\Custom\PinataTicket.cs: CS0103: (line 73, column 35) The name 'PackItem' does not exist in the class or namespace 'Server.Items.PinataTicket' - Error: Scripts\Custom\PinataTicket.cs: CS0103: (line 74, column 35) The name 'PackItem' does not exist in the class or namespace 'Server.Items.PinataTicket' - Error: Scripts\Custom\PinataTicket.cs: CS0103: (line 75, column 34) The name 'PackItem' does not exist in the class or namespace 'Server.Items.PinataTicket' - Error: Scripts\Custom\PinataTicket.cs: CS1501: (line 79, column 17) No overlo ad for method 'Target' takes '0' arguments Scripts: One or more scripts failed to compile or no script files were found. - Press return to exit, or R to try again. Code:
using System;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Targeting;
using Server.Gumps;
namespace Server.Items
{
public class PinataTicket : Item
{
private Mobile m_Owner;
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Owner
{
get{ return m_Owner; }
set{ m_Owner = value; }
}
[Constructable]
public PinataTicket() : base( 0x14EF )
{
Weight = 1.0;
LootType = LootType.Blessed;
}
public override bool DisplayLootType{ get{ return false; } }
public PinataTicket( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( (Mobile) m_Owner );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
m_Owner = reader.ReadMobile();
break;
}
}
if ( Name == "Pinata Ticket" )
Name = null;
}
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
switch ( Utility.Random( 3 ) )
{
case 0: PackItem(new Pinatagold() ); break;
case 1: PackItem(new Pinata() ); break;
case 2: PackItem(new Pinatatoken() ); break;
} }
private class InternalTarget : Target
{
private PinataTicket m_Ticket;
}
}
}
sounds soo easy but is soo hard
__________________
All people have the right to be stupid but some abuse the privilege.
|
|
|
|
|
|
#12 (permalink) |
|
Forum Expert
|
Try this instead...
Code:
switch ( Utility.Random( 3 ) )
{
case 0: from.AddToBackpack(new Pinatagold() ); break;
case 1: from.AddToBackpack(new Pinata() ); break;
case 2: from.AddToBackpack(new Pinatatoken() ); break;
}
__________________
"We sometimes congratulate ourselves at the moment of waking from a troubled dream; it may be so the moment after death." ~Nathaniel Hawthorne Last edited by Packer898; 03-18-2006 at 02:01 PM. |
|
|
|
|
|
#13 (permalink) |
|
Forum Expert
Join Date: Mar 2005
Location: Hopefully not near you
Posts: 2,232
|
thank you for your offer of help
Yes spider was very kind in helping me with another double click thing I was looking for. It was not my intent to hyjack or upset anyone. But I am grateful for the help I recieved and in the future will be more careful where I ask things. I am sorry but I thank you for your kindness in helping and not flaming me.
__________________
All people have the right to be stupid but some abuse the privilege.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|