GateGuardian Posted February 15, 2008 Share Posted February 15, 2008 <?php $userattack = $POST_['attack']; $userstrength = $POST_['strength']; $mobagility = $POST_['agility']; $mobdefence = $POST_['defence']; $userattacknum = Rand(1,1000); $attackresult = ($userattacknum + $userattack) - ($mobagility * 3); echo $attackresult; if ($attackresult >= 950) { $attacktype = "crit"; } elseif ($attackresult <= 399 ) { $attacktype = "miss"; } elseif ($attackresult <= 949 || $attackresult >= 400) { $attacktype = "norm"; } echo $attacktype; $random1 = rand(1,50); $random2 = rand(1,5); $random3 = rand(1,5); echo $random1; echo $random2; echo $random3; switch ($attacktype){ case "miss": echo "You missed your target!"; break; case "norm": $attackdamage = (($random1 * $userstrength) - $mobdefence) * $random2; echo "You hit the target for: ".$attackdamage."!"; break; case "crit": $attackdamage = ((($random1 * $userstrength) - $mobdefence) * $random2) * $random3; echo "You <b>CRITICALY</b> hit the target for: ".$attackdamage."!"; break; } echo $attackdamage; ?> $attackdamage is always calculated to 0 and when the attacknumber is over 900 it don't regard it as a critical hit help anyone? Link to comment https://forums.phpfreaks.com/topic/91196-php-not-calculating-properly/ Share on other sites More sharing options...
kenrbnsn Posted February 15, 2008 Share Posted February 15, 2008 It's "$_POST" not "$POST_". Ken Link to comment https://forums.phpfreaks.com/topic/91196-php-not-calculating-properly/#findComment-467388 Share on other sites More sharing options...
darkfreaks Posted February 15, 2008 Share Posted February 15, 2008 <?php $userattack = $_POST['attack']; $userstrength = $_POST['strength']; $mobagility = $_POST['agility']; $mobdefence = $_POST['defence']; $userattacknum = Rand(1,1000); $attackresult = ($userattacknum + $userattack) - ($mobagility * 3); echo $attackresult; if ($attackresult >= 950) { $attacktype = "crit"; } elseif ($attackresult <= 399 ) { $attacktype = "miss"; } elseif ($attackresult <= 949 || $attackresult >= 400) { $attacktype = "norm"; } echo $attacktype; $random1 = rand(1,50); $random2 = rand(1,5); $random3 = rand(1,5); echo $random1; echo $random2; echo $random3; switch ($attacktype){ case "miss": echo "You missed your target!"; break; case "norm": $attackdamage = (($random1 * $userstrength) - $mobdefence) * $random2; echo "You hit the target for: ".$attackdamage."!"; break; case "crit": $attackdamage = ((($random1 * $userstrength) - $mobdefence) * $random2) * $random3; echo "You <b>CRITICALY</b> hit the target for: ".$attackdamage."!"; break; } echo $attackdamage; ?> Link to comment https://forums.phpfreaks.com/topic/91196-php-not-calculating-properly/#findComment-467389 Share on other sites More sharing options...
cooldude832 Posted February 15, 2008 Share Posted February 15, 2008 php never calculates wrong it calculates what you give it to calculate so its your fault. Link to comment https://forums.phpfreaks.com/topic/91196-php-not-calculating-properly/#findComment-467391 Share on other sites More sharing options...
GateGuardian Posted February 15, 2008 Author Share Posted February 15, 2008 That is the most stupid mistake ive made haha Need better developing suite then dreamweaver with syntax check Thanks alot guys! Link to comment https://forums.phpfreaks.com/topic/91196-php-not-calculating-properly/#findComment-467394 Share on other sites More sharing options...
darkfreaks Posted February 15, 2008 Share Posted February 15, 2008 i would recomend Jedit or PHP Designer 2007 also your math is abit dodgy try: <?php $userattack = $_POST['attack']; $userstrength = $_POST['strength']; $mobagility = $_POST['agility']; $mobdefence = $_POST['defence']; $userattacknum = Rand(1,1000); $attackresult = ($userattacknum + $userattack) - ($mobagility * 3); echo $attackresult; if ($attackresult >= 950) { $attacktype = "crit"; } elseif ($attackresult <= 399 ) { $attacktype = "miss"; } elseif ($attackresult <= 949 || $attackresult >= 400) { $attacktype = "norm"; } echo $attacktype; $random1 = rand(1,50); $random2 = rand(1,5); $random3 = rand(1,5); echo $random1; echo $random2; echo $random3; switch ($attacktype){ case "miss": echo "You missed your target!"; break; case "norm": $attackdamage = ($random1 * $userstrength - $mobdefence)* $random2; echo "You hit the target for: ".$attackdamage."!"; break; case "crit": $attackdamage =($random1 * $userstrength- $mobdefence) * ($random2 + $random3); echo "You <b>CRITICALY</b> hit the target for: ".$attackdamage."!"; break; } echo $attackdamage; ?> Link to comment https://forums.phpfreaks.com/topic/91196-php-not-calculating-properly/#findComment-467395 Share on other sites More sharing options...
haku Posted February 15, 2008 Share Posted February 15, 2008 I'm into the zend development environment myself. Its the best of all the one's I've tried so far. Link to comment https://forums.phpfreaks.com/topic/91196-php-not-calculating-properly/#findComment-467446 Share on other sites More sharing options...
awpti Posted February 15, 2008 Share Posted February 15, 2008 ZDE is a big, fat, bloated turd. PHP Designer or even DevPHP would be good enough for general usage. I'm a huge fan of PHP Designer. Link to comment https://forums.phpfreaks.com/topic/91196-php-not-calculating-properly/#findComment-467454 Share on other sites More sharing options...
haku Posted February 15, 2008 Share Posted February 15, 2008 I used phpdesigner - its good for the money, but I prefer zend. I like the autocompletion of php functions, and I like it that it logs variables and functions that you have written so that you can autocomplete with them as well. I will have to check out DevPHP, I've never heard of or tried that one. Link to comment https://forums.phpfreaks.com/topic/91196-php-not-calculating-properly/#findComment-467457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.