Zymic Forums

Webmaster resources

Zymic IRC Server

Chat in real time at irc.zymic.com - Learn More

Welcome

Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.

In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.

left Zymic Webmaster ForumsWeb Design & DevelopmentServer Side ScriptingPHP right
  Closed Topic Start new topic
left right
The Seventh Hoka...
post Aug 27 2009, 09:16 PM
Post #1


Member
**

Group: Members
Posts: 90
Joined: 29-May 09
Member No.: 97,073



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?
Go to the top of the page 
 
  + Quote Post
Ed
post Aug 27 2009, 09:23 PM
Post #2


Outrageously Uber Ninja
*******

Group: Administrators
Posts: 2,831
Joined: 11-March 07
From: UK
Member No.: 9



They're type sensitive, from the looks of the error you are calling it as 'dodmg()' rather than 'doDmg()'
Go to the top of the page 
 
  + Quote Post
The Seventh Hoka...
post Aug 27 2009, 10:39 PM
Post #3


Member
**

Group: Members
Posts: 90
Joined: 29-May 09
Member No.: 97,073



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
Go to the top of the page 
 
  + Quote Post
Jacob
post Aug 28 2009, 11:05 AM
Post #4


Outrageously Uber Ninja
*******

Group: Moderators
Posts: 5,140
Joined: 11-May 08
From: Australia
Member No.: 25,876



It would help if you told us what you re-arranged. wink.gif
Go to the top of the page 
 
  + Quote Post
The Seventh Hoka...
post Aug 28 2009, 05:27 PM
Post #5


Member
**

Group: Members
Posts: 90
Joined: 29-May 09
Member No.: 97,073



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.
Go to the top of the page 
 
  + Quote Post
 Closed Topic Start new topic
left right
0 Members:
left right
 


Lo-Fi Version Time is now: 19th May 2013 - 08:43 AM