Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / How to use randomize?

Author
Message
Omnomer
13
Years of Service
User Offline
Joined: 12th Mar 2011
Location: a goauld mothership
Posted: 29th Mar 2011 06:21
I know you do something like rnd(3) and you will get 0-3 but how do you convert that into a number you can subtract from hp?

Squirrel!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 29th Mar 2011 09:36
You could try:

HP = 100
a = RND(3) + 1 ` Randomize a number between 1 and 4 (because 3 will give you 0-3)

HP = HP - a

Hope this helps.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Mar 2011 14:55
...or just

HP = HP - rnd(3)



LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 29th Mar 2011 15:50
...or dec HP,(rnd(3) + 1)

Don't you love programming! You can do the same thing several different ways.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Mar 2011 22:41
Quote: "Don't you love programming! You can do the same thing several different ways."

Yes! That's the fun of it. Finding the different ways, then finding the best way!

I think I could write a 3000 line program to increase a number by a random amount, wouldn't be very economic but I bet I could make it interesting!

There's one for the competition thread...

Omnomer
13
Years of Service
User Offline
Joined: 12th Mar 2011
Location: a goauld mothership
Posted: 30th Mar 2011 04:25
Wow thank guys but I figured out what I want to do.

Damage = Rnd(5)
Hp = Hp-5
But thanks for the comments

Squirrel!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 30th Mar 2011 08:43
You probably meant to do this:




Or this:



Omnomer
13
Years of Service
User Offline
Joined: 12th Mar 2011
Location: a goauld mothership
Posted: 31st Mar 2011 03:07
No I didn't

Squirrel!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 31st Mar 2011 04:45 Edited at: 31st Mar 2011 04:46
You want to pick a random damage number from 0 to 5 but always take 5 damage from the players hit points no matter what the random number is... ok it's your game.

Omnomer
13
Years of Service
User Offline
Joined: 12th Mar 2011
Location: a goauld mothership
Posted: 31st Mar 2011 05:11
???...How....???? I'll just use your solution

Squirrel!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 31st Mar 2011 05:12
Quote: "No I didn't"


Omnomer:

The most recent code you posted does not reduce the HP a random amount, it always reduces it by 5. Grog is correct. Your original question was answered three different ways, and you chose to ignore them! You are too funny!

Quote: "it's your game. "

Good luck pal.

Omnomer
13
Years of Service
User Offline
Joined: 12th Mar 2011
Location: a goauld mothership
Posted: 31st Mar 2011 06:13
Gulp...(Ok now lets not skrew this up..."error"DIE... )

(\/) Squirel!!!!!!!!!!!!!!!!
(0o)
''
Non Sequitur M
16
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 1st Apr 2011 22:17 Edited at: 1st Apr 2011 22:28
First, love the Stargate location reference!

Second, if you come on these forums to ask for help. Listen to what experienced coders like Grog and Baxslash have to say.

Third, I would also look into the 'randomize' command, or else you'll get the same sequence of numbers each time your program runs.

[EDIT] I just realized. You wouldn't randomize HP damage for an FPS or RTS... You're doing an RPG aren't you?
*huff* *sets face in hands*
I tried the same thing. I had to start with a Pong remake. That was about 8 years, 7 demos, and 2 programming languages ago. And, I'm just now looking at making an RPG. Which appears to be going swimmingly this time!

If life were like a box of chocolates, I'd know what I would get... The one that got dropped on the floor and put back in the box.

Iye nehvur yoose spehl chehk, ahn mie tippyng izz fiyne.
Omnomer
13
Years of Service
User Offline
Joined: 12th Mar 2011
Location: a goauld mothership
Posted: 2nd Apr 2011 02:37
Ok.

(\/) Squirel!!!!!!!!!!!!!!!!
(0o)
''

Login to post a reply

Server time is: 2024-11-27 22:19:49
Your offset time is: 2024-11-27 22:19:49