Cetanu Posted August 21, 2009 Share Posted August 21, 2009 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 More sharing options...
Jacks89 Posted August 21, 2009 Share Posted August 21, 2009 You can try declare the result. Let say if the random no is 11. $enemy = rand(); if $enemy == "11"{ // then the enemy appear } Link to comment https://forums.phpfreaks.com/topic/171247-rand-question/#findComment-903035 Share on other sites More sharing options...
Cetanu Posted August 21, 2009 Author Share Posted August 21, 2009 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. 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 More sharing options...
Cetanu Posted August 21, 2009 Author Share Posted August 21, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.