CODE
function tohit($target)//improve chances of attacking
{
$target1=$target_of_player_user;
$agldiff=$this->agility - $target->agility;
if($agldiff>68)//if you register high enuff for a bonus...
{
switch($agldiff)
{
case $agldiff>=69&$agldiff<=100:
if($target->currentturn=="evasive")
{
$tohitchance=rand(1,100);
if($tohitchance<=40)
{
doDmg();
}
else
{
echo "The blows are easily evaded by the opponent.";
}
}
else
{
if($tohitchance<=80)
{
doDmg();
}
else
{
echo "Even though you miss your blows are nearly too much for your opponent.";
}
}
break;//break ist
case $agldiff>=101&$agldiff<=500:
if($target->currentturn=="evasive")
{
$tohitchance=rand(1,100);
if($tohitchance<=43)
{
doDmg();
}
else
{
echo "The blows are easily evaded by the opponent.";
}
}
else
{
if($tohitchance<=85)
{
doDmg();
}
else
{
echo "Even though you miss your blows are nearly too much for your opponent.";
}
}
break;//break 2nd
case $agldiff>=501&$agldiff<=1000:
if($target->currentturn=="evasive")
{
$tohitchance=rand(1,100);
if($tohitchance<=45)
{
doDmg();
}
else
{
echo "The blows are easily evaded by the opponent.";
}
}
else
{
if($tohitchance<=90)
{
doDmg();
}
else
{
echo "Even though you miss your blows are nearly too much for your opponent.";
}
}
break;//break 3rd
}//switch
}
else
{
if($target->currentturn=="evasive")
{
$tohitchance=rand(1,100);
if($tohitchance<=35)
{
doDmg();
}
else
{
echo "The blows are easily evaded by the opponent.";
}
}
else
{
if($tohitchance<=75)
{
doDmg();
}
else
{
echo "Even though you miss your blows are nearly too much for your opponent.";
}
}
}//end if else for major
}//end function
//---------------------------------
function doDmg($target1)
{
if($target->currentturn=="defend")
{
if($this->strength >= $target1->currentdef)
{
$Dmg=1;
$combo=rand(1,4);
$dmgDone=$combo*$Dmg;
$_SESSION['HP2']-=$dmgDone;
echo "Your physical strikes barely do any damage at all.";
checkDeath();
}
else
{
$Dmg=$this->strength-$target1->currentdef;
$combo=rand(1,4);
$dmgDone=$combo*Dmg;
$dmgDone /2;
$_SESSION['HP2']-=$dmgDone;
echo "You strike your opponent through their guard, doing ".$dmgDone." points of damage. ";
checkDeath();
}
}
else
{
if($this->strength >= $target1->currentdef)
{
$Dmg=1;
$combo=rand(1,4);
$dmgDone=$combo*$Dmg;
$_SESSION['HP2']-=$dmgDone;
echo "Your physical strikes barely do any damage at all.";
checkDeath();
}
else
{
$Dmg=$this->strength - $target1->currentdef;
$combo=rand(1,4);
$dmgDone=$combo*Dmg;
$_SESSION['HP2']-=$dmgDone;
echo "You strike your opponent doing ".$dmgDone." points of damage. ";
checkDeath();
}
}
}
error:
<br /> <b>Fatal error</b>: Call to undefined function dodmg() in <b>/www/uuuq.com/n/i/n/nindoway/htdocs/class_nin.php</b> on line <b>217</b><br />
problem:
as you can see i clearly defined the doDmg() function. i'm not sure exactly why it's saying the function isn't defined.
note that i'm calling the function using AJAX. could that be factor?
