Help - Search - Members - Calendar
Full Version: Another Mysterious Error
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
The Seventh Hokage
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?
Ed
They're type sensitive, from the looks of the error you are calling it as 'dodmg()' rather than 'doDmg()'
The Seventh Hokage
QUOTE(Ed @ Aug 27 2009, 09:23 PM) *
They're type sensitive, from the looks of the error you are calling it as 'dodmg()' rather than 'doDmg()'


i checked that at first i thought maybe i made a mistake somewhere but i don't think that it's it. reason beign it worked at first. then i rearranged a few things now it doesn.t
NaRzY
It would help if you told us what you re-arranged. wink.gif
The Seventh Hokage
there's thousands of lines of code. basically. im designing a webpage that simulates an rpg battle. at suggestion i decided to use object oriented php coding.

in an effort to minimize the code i would have to write i created functions and included the functions where they were needed, the thing is, because the files were all on seperate pages, simply including them didn't work.

for instance if i create an object in one page and try to access it's properties on another page that included said objects definitions... it wouldn't work for me.

I've fallen back into a combination of using session variables with the objects to achieve the desired effect and thereby save me anymore of a head ache.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.