http://pokefun.flickhuck4lyfe.info
All of the locations have been created! Not all of them do stuff yet, but volcano is working quite well! Here is a picture of my final map:
Each location has specific monsters. I haven’t gotten to drawing too many of them yet, as I have been busy writing my battle algorithm. Speaking of which, my battle algorithm works! But only for the volcano location. And there are only fire toads to battle. And you don’t get any form of reward if you win. These things are coming. The flee algorithm also works. If you have more HP than the monster, you can flee every time. If you don’t have more HP, then you flee successfully half of the time. The other half of the time, you don’t get away and the monster does damage. I used a random number generator to generate a 1 or a 0 to decide what will happen. The battle algorithm is a little bit cooler. Here is what it looks like:
$attack_ratio1 = ($user_off/$mon_def);
$user_attack_value = ($attack_ratio1 * $user_off);
$num = rand (1,5);
$num1 = (1/$num)*$user_attack_value;
$user_attack_value = ($user_attack_value + $num1)/4;
$mon_new_hp = $mon_hp_cur-$user_attack_value;
To make it more readable, “off” signifies offense, “def” signifies defense, and “mon” means monster. I generate an attack ratio that factors in the opponent’s defense. If the opponent has high defense, then the attack ratio is lower. I then multiply the user’s attack value by the attack ratio to determine a base level of damage to deal. To add an element of chance, I use a random number generator to alter the base damage value. I add some percentage of the damage value back into itself (number to add is between 20% and 100% of the value). I then divide the whole thing by 4 to get a more reasonable number. The last line of code above calculates what the monster’s revised HP is after the attack. There is a similar block of code that calculates the damage done to the player. I’m excited to start making the other locations functional so I can battle more things!
Add a comment