Creature Question

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
Huezzer
Posts: 72
Joined: Mon Jan 31, 2011 7:47 pm

Creature Question

Post by Huezzer »

Hey all!, I've got a fast question about the creatures thing. How it is possible with a code to just make some of the creatures to "fight able" in one speciall place

Like this: I'm in the Forest and I don't want to make it able to kill a jellyfish in the Forest just in the Water(name of the place). I've started to do this in the database (Location) but don't kno how i can go forward.

if playerinfo3[location] = Forest <---- If this is right, I don't know how to continue..Anyway I don't know really :S Sorry

Thanks, Huezzer
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Creature Question

Post by Jackolantern »

Just add the location the monster is supposed to be fought at in the SQL query:

Code: Select all

SELECT * FROM `monsters` WHERE `location` = `$currentLocation` 
Add in whatever else you want to search by into the SQL query. For example, to pull up only 1 monster within 5 levels of the player, you would do something like this:

Code: Select all

$minLevel = $playerLevel - 5;
$maxLevel = $playerLevel + 5;
$sql = "SELECT * FROM `monsters` WHERE `location` = `$currentlocation` AND `level` >= $minLevel AND `level` <= $maxLevel ORDER BY RAND() LIMIT 1";
$sql2 = mysql_query($sql);
$sql3 = mysql_fetch_assoc($sql2); 
Then you will have one random monster, fightable only in the current location, within 5 levels of the player.
The indelible lord of tl;dr
Post Reply

Return to “Advanced Help and Support”