Jump to content

Recommended Posts

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...

Edited by Monkuar

Don't know if this is a very intuitive approach to this issue but it seems to work fine?

//Unique Bosses/etc....
$randmobchance = mt_rand(0, 100); 
if ($randmobchance <= 5) //5% to Grab a Unique mob...
{ 
$spawnmobs = $db->query('SELECT * from nrpg_monsters WHERE level >= 1 AND zone = '.$zone_id.' AND grade="Unique" ORDER BY RAND() LIMIT 1')
}else{
$spawnmobs = $db->query('SELECT * from nrpg_monsters WHERE level >= 1 AND zone = '.$zone_id.' AND grade!= "Unique" ORDER BY RAND() LIMIT 1')
}
Edited by Monkuar
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.