Go Back   RunUO - Ultima Online Emulation > RunUO > Core Modifications > Other

Other Cant find a category above, use this one! Core mods not listed above go here!

Reply
 
Thread Tools Display Modes
Old 11-11-2005, 09:08 PM   #1 (permalink)
 
Join Date: Oct 2002
Age: 22
Posts: 4,689
Default More RandomDouble functions

This thread should be removed. This is not supported anymore.

Last edited by XxSP1DERxX; 04-23-2006 at 02:53 AM.
XxSP1DERxX is offline   Reply With Quote
Old 11-12-2005, 10:03 PM   #2 (permalink)
 
Join Date: Oct 2002
Age: 22
Posts: 4,689
Default

I made a few changes to make it more standard to the other RunUO code. Nothing major, or even eventful.
XxSP1DERxX is offline   Reply With Quote
Old 12-28-2005, 04:01 PM   #3 (permalink)
 
Join Date: Oct 2002
Age: 22
Posts: 4,689
Default

The server reverted the thread.. so I updated it. Now this should work properly.
XxSP1DERxX is offline   Reply With Quote
Old 12-28-2005, 04:02 PM   #4 (permalink)
Forum Novice
 
Join Date: Dec 2003
Location: South-Africa
Age: 19
Posts: 165
Default

You rock.
Thanks, its working again!
DaLaw66 is offline   Reply With Quote
Old 03-15-2006, 03:35 AM   #5 (permalink)
 
Join Date: Oct 2002
Age: 22
Posts: 4,689
Default

I updated this code to fix a bug. You can find the updated code OFF-SITE. Please check the original thread for the link.
XxSP1DERxX is offline   Reply With Quote
Old 03-17-2006, 03:31 PM   #6 (permalink)
Forum Expert
 
Sunshine's Avatar
 
Join Date: Mar 2005
Location: Hopefully not near you
Posts: 2,232
Default

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.
Sunshine is offline   Reply With Quote
Old 03-18-2006, 04:15 AM   #7 (permalink)
 
Join Date: Oct 2002
Age: 22
Posts: 4,689
Default

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.
XxSP1DERxX is offline   Reply With Quote
Old 03-18-2006, 05:51 AM   #8 (permalink)
Forum Expert
 
Sunshine's Avatar
 
Join Date: Mar 2005
Location: Hopefully not near you
Posts: 2,232
Default

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 );
    }
   }
  }
 }
}
Not that it is not painful obvious but I am trying to learn and soo new at this I am still green.
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.
Sunshine is offline   Reply With Quote
Old 03-18-2006, 01:00 PM   #9 (permalink)
 
Join Date: Oct 2002
Age: 22
Posts: 4,689
Default

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;
XxSP1DERxX is offline   Reply With Quote
Old 03-18-2006, 01:05 PM   #10 (permalink)
Forum Expert
 
Sunshine's Avatar
 
Join Date: Mar 2005
Location: Hopefully not near you
Posts: 2,232
Default

Ok thanks soo much will try that out..I do appreciate it
__________________
All people have the right to be stupid but some abuse the privilege.
Sunshine is offline   Reply With Quote
Old 03-18-2006, 01:32 PM   #11 (permalink)
Forum Expert
 
Sunshine's Avatar
 
Join Date: Mar 2005
Location: Hopefully not near you
Posts: 2,232
Default

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.
that is the errors ..I been working on this sence I seen your reply even before I posted back....but am now at my wits in ...feeling hopeless please can you help me, anyone?


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;
    }
   }
  }
I just want to make a simple ticket when double clicked the player is given 1 of 3 items equal chance of all of them appearing in the back pack. then ticket dissappears


sounds soo easy but is soo hard
__________________
All people have the right to be stupid but some abuse the privilege.
Sunshine is offline   Reply With Quote
Old 03-18-2006, 01:57 PM   #12 (permalink)
Forum Expert
 
Packer898's Avatar
 
Join Date: Dec 2004
Location: Tulsa, Oklahoma
Age: 35
Posts: 2,378
Send a message via ICQ to Packer898 Send a message via MSN to Packer898
Default

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;
                     }
Now on a different note why are you posting help for this here? This has nothing to do with SP!DERS new random double functions. This should have gone in Script Support instead of here. Im sure that SP!DER is being nice about it but alot of others would be rather upset at the hijack of the thread for something that doesnt have anything to do with the authors post.
__________________
"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.
Packer898 is offline   Reply With Quote
Old 03-18-2006, 02:34 PM   #13 (permalink)
Forum Expert
 
Sunshine's Avatar
 
Join Date: Mar 2005
Location: Hopefully not near you
Posts: 2,232
Default

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.
Sunshine is offline   Reply With Quote
Reply

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 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5