The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random function
Author Message
Lazarus
Master
**

Posts: 352
Likes Given: 11
Likes Received: 7 in 6 posts
Joined: Jun 2012
Reputation: 1

Hybris Ultima Online

Post: #1
Random function
Hi! First: Sry for my english.

Me and my developer are doing some new special moves.
I've do ALL, the script works but I need a help in the random.

I want to hit someting when I have 100 fencing and do a random of 10 [10% chance] and i want to change everytime i need. It's in a IF.

I have this and I should work
IF ((<FENCING> =100.0) && (RAND(10)=1)

RAND(10)=1 IS RLY 10%?
RAND(2)=1 IS 50%?

It's okay the IF? what do you exchange in?
what function I can use for RANDOM's?

rly thanks ^_^

[Image: 2hy9q0y.png]
07-11-2012 05:49 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #2
RE: Random function
Comparisons for equality require two equal signs.
07-11-2012 06:14 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #3
RE: Random function
IF ((<FENCING> == 100.0) && (<EVAL RAND(10)> == 1)

The rightmost statement can be written in this way : (<R(10)> == 1)
So you can skip to write "eval" before random everytime!
07-11-2012 07:07 AM
Find all posts by this user Like Post Quote this message in a reply
Lazarus
Master
**

Posts: 352
Likes Given: 11
Likes Received: 7 in 6 posts
Joined: Jun 2012
Reputation: 1

Hybris Ultima Online

Post: #4
RE: Random function
(07-11-2012 06:14 AM)RanXerox Wrote:  Comparisons for equality require two equal signs.

That's sure? I can use 1 only and works too ^_^ in all my scripts.
A friend that's studing programation tells me that and works fine because Sphere it's a old system... o.o
thanks ^_ ^



Thanks darksun! i'll try the R(10) ^_^

[Image: 2hy9q0y.png]
(This post was last modified: 07-11-2012 07:27 AM by Lazarus.)
07-11-2012 07:24 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #5
RE: Random function
Regarding the single versus double equal sign... If you don't want to follow my advice and script properly then feel free to ignore my advice. Following the advice of people who do not know sphere programming seems foolish.

R(10) produces a random number between 0 and 10 does it not? In which case a single match is more like 9%... to be certain you can do <R1,10>
07-11-2012 07:44 AM
Find all posts by this user Like Post Quote this message in a reply
Anarch Cassius
Master
**

Posts: 273
Likes Given: 19
Likes Received: 10 in 9 posts
Joined: Mar 2012
Reputation: 2



Post: #6
RE: Random function
"A friend that's studing programation tells me that and works fine because Sphere it's a old system... o.o"

Yeah, most of the time. Point is its not a habit you want to get in to.
07-11-2012 07:45 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #7
RE: Random function
07-11-2012 07:47 AM
Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #8
RE: Random function
Rand(10) can be 0 1 2 3 4 5 6 7 8 9 10
Rand(2) can be 0 1 2

<R10> = Rand(10)
But
<R1,10> can be 1 2 3 4 5 6 7 8 9 10

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
07-11-2012 09:38 AM
Find all posts by this user Like Post Quote this message in a reply
Lazarus
Master
**

Posts: 352
Likes Given: 11
Likes Received: 7 in 6 posts
Joined: Jun 2012
Reputation: 1

Hybris Ultima Online

Post: #9
RE: Random function
(07-11-2012 07:07 AM)darksun84 Wrote:  IF ((<FENCING> == 100.0) && (<EVAL RAND(10)> == 1)

The rightmost statement can be written in this way : (<R(10)> == 1)
So you can skip to write "eval" before random everytime!

What is the EVAL used for?


Ok Extreme, Rand(9) = 1 it's 10% chance, rly? Tongue

Thanks to all! ;Big Grin

[Image: 2hy9q0y.png]
07-11-2012 12:39 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #10
RE: Random function
EVAL works to make strings become numbers, calculations etc...
Like this:
Code:
LOCAL.EXP += <EVAL (<FAME>*10)/100> // It will ADD 10% of the FAME to LOCAL.EXP
And used to do some operations like the RAND(X)
If you try
Code:
IF RAND(10) == 1 // Wrong, will not work.
or
Code:
IF STRLEN(<SRC.NAME>) // Wrong, will not work too.
The right usage is <EVAL RAND(10)> and <EVAL STRLEN(<SRC.NAME>)>
You should use <R1,10> instead <EVAL RAND(9)>

Edit: use <R1,10> == 1 // 10%

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
(This post was last modified: 07-11-2012 01:06 PM by Extreme.)
07-11-2012 01:05 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)