Jump to content

Adding speed to a fight php script.


mastercjb

Recommended Posts

I just added shoes as a % booster to fight. So if Person (A) has 10,000 speed, and person (B) has 10,001 but Person (A) has shoe's increasing speed by say 10% then person (A) would hit first.

 

Here is the code im adding it to, I cant seem to code it with the shoes:

 

$yourhp = $user_class->hp;
$theirhp = $attack_person->hp;
?>
<tr><td class="contenthead">Fight House</td></tr>
<tr><td class="contentcontent">You are in a fight with <? echo $attack_person->formattedname ?>.</td></tr>
<tr><td class="contentcontent">
<?
$wait = ($user_class->speed > $attack_person->speed) ? 1 : 0;

while($yourhp > 0 && $theirhp > 0){
$damage = $attack_person->moddedstrength - $user_class->moddeddefense;
$damage = ($damage < 1) ? 1 : $damage;

if($wait == 0){
	$yourhp = $yourhp - $damage;
	echo $attack_person->formattedname . " hit you for " . $damage . " damage using their ".$attack_person->weaponname.". <br>";
} else {
	$wait = 0;
}

if($yourhp > 0) {
	$damage = $user_class->moddedstrength - $attack_person->moddeddefense;
	$damage = ($damage < 1) ? 1 : $damage;
	$theirhp = $theirhp - $damage;
	echo "You hit " . $attack_person->formattedname . " for " . $damage . " damage using your ".$user_class->weaponname.". <br>";
}

Link to comment
https://forums.phpfreaks.com/topic/157518-adding-speed-to-a-fight-php-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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