Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-20-2001, 03:24 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Random Variables

I am doing some mining type stuff for my server and i got the triggeraction stuff working to destroy rocks and stuff. But for the rocks i figure they could leave things behind sometimes like a little diamond or something. And I need help setting it to pick a random variable. So could some one help me. Like ... say it picks a random number between 1-1000 and if you get a 483 it lays a diamond. Could someone please help me.
Reply With Quote
  #2  
Old 09-20-2001, 03:33 AM
Thak2 Thak2 is offline
:]
Join Date: Mar 2001
Location: BC
Posts: 1,344
Thak2 is on a distinguished road
Send a message via AIM to Thak2
use

i = random(0,999);

then have stuff like
if (i >50&&i<101) {
stuffhere;
Reply With Quote
  #3  
Old 09-20-2001, 03:37 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
kool

kool i'll try it thanx ...
Reply With Quote
  #4  
Old 09-20-2001, 03:49 AM
Merlin Merlin is offline
Banned
Merlin's Avatar
Join Date: Jul 2001
Location: Merlin - U S A Malak - United Kingdom
Posts: 2,543
Merlin is on a distinguished road
Send a message via ICQ to Merlin Send a message via AIM to Merlin
you can do it a lot of ways
this.random = random(1,90);
Reply With Quote
  #5  
Old 09-20-2001, 04:14 AM
entravial entravial is offline
Registered User
entravial's Avatar
Join Date: Mar 2001
Posts: 825
entravial is on a distinguished road
Send a message via ICQ to entravial Send a message via AIM to entravial Send a message via Yahoo to entravial
~AlphaFlame~

Quote:
if (i >50&&i<101) {
It would be much simpler to do...

Quote:
if (i in |50,101|){
__________________


If the post says ~AlphaFlame~, that's who's posting. If not, it's Entravial (owner)
Reply With Quote
  #6  
Old 09-21-2001, 07:28 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
ended

what i just ended up doing was ....

this.destroy=random(1,1000);
if (this.destroyed=483) {
putnpc diamond.gif,diamond.txt,32,32;
}

I know the ending probably aint right but i am just explaining what i did and dont care if its wrong ...
Reply With Quote
  #7  
Old 09-21-2001, 08:15 PM
BocoC BocoC is offline
Registered User
BocoC's Avatar
Join Date: Jun 2001
Location: Washington State, USA
Posts: 980
BocoC is on a distinguished road
Send a message via AIM to BocoC Send a message via Yahoo to BocoC
I think there is still a bug in random() in where it doesn't get re-randomized if you don't move...
__________________
-Boco

FLKJH$TRFG*$(&%>FMG >REN<>F ;.kjsd
Reply With Quote
  #8  
Old 09-21-2001, 11:44 PM
CyanideSR71 CyanideSR71 is offline
Registered User
CyanideSR71's Avatar
Join Date: Jun 2001
Location: Canada
Posts: 460
CyanideSR71 is on a distinguished road
Quote:
Originally posted by Kaimetsu
Um... The odds of getting 483 from a random(0,1000) are like 100000000000:1. You better have some patient players.
It's fun to tell him why, Kai!

PHP Code:
this.destroy=int(random(1,1000)); 
if (
this.destroyed=483) { 
putnpc diamond.gif,diamond.txt,32,32

By using random, it finds a random real number between the two numbers you've set. That means that muber could be 4.876658756 or any other number like that, making the odds of getting 483 somewhere around infinity to one. What you want is a random integer number, which only allows numbers without decimals. By putting int() in there, the odds around 1 in 1000 once again.
__________________
Cyanide SR71
Former Shadow Dragon
Co-Owner of what was Murasamune
Reply With Quote
Reply


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

Forum Jump


All times are GMT +2. The time now is 04:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.