Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

SELECTING A random Value but with a Percentage.

$
0
0

Okay, I have a table called: "monsters" and it has 5 mobs. (rows)

 

Only 1 is a Unique mob with a grade column set to "Unique".

 

The following query will select a random mob (someone entered the dungeon for their specific zone (map))

SELECT * from nrpg_monsters WHERE level >= 1 AND zone = '.$zone_id.' ORDER BY RAND() LIMIT 1

But the problem is, By this logic query, the UNIQUE mob has the same chance to spawn as all the others, lol.  How would I make, let's say the unique mob spawn < 10% with this query? his id is 5.

 

The point im trying to make is,  I use this info to insert it into a monster_active table, so users can actually kill their own mobs and level up/gain exp on my game..   I dont want users to have the same chance to spawn a unique mob as a Normal or Magic mob...


Viewing all articles
Browse latest Browse all 13200

Trending Articles