Jump to content

rand() question


Cetanu

Recommended Posts

I am currently designing an RPG system for my friend, and in order for members to fight random creatures, I figured I could generate a random number (using rand() ) and then give a definition for an enemy to the numbers it generates.

 

How do I define the random numbers generated by rand()? Say it generates 11, how do I tell it to output that 11 = an enemy of some type?

Link to comment
https://forums.phpfreaks.com/topic/171247-rand-question/
Share on other sites

You can try declare the result. Let say if the random no is 11.

 

$enemy = rand();
if $enemy == "11"{
// then the enemy appear
}

 

Oh, okay. I'll give that a try, seems promising. A lot of declaration though.  :D

 

Any other suggestions (I'm gonna go try that ^ )

Link to comment
https://forums.phpfreaks.com/topic/171247-rand-question/#findComment-903038
Share on other sites

That DOES work. I love it. It's a lot of fun and very amusing...

...this is my test:

http://mythscape.freezoka.com/chrisrpg/testenemy.php

 

 

XD

 

 

I am thinking of allowing members to choose a type of enemy to look for, and then generate numbers between a certain point. Then I can define things easier, but does anyone know a way to define them less-tediously?

Link to comment
https://forums.phpfreaks.com/topic/171247-rand-question/#findComment-903086
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.