Game Development Community

help, my oponents hp doesnt lower

by MD · in Torque Developer Network · 11/16/2009 (4:32 am) · 2 replies

its a text game atm on some other game, but basically

heres what it does, example

he has 10hp so

you hit a 3! -HP7-
You hit a 2! -HP8-
You hit a 1! -HP9-

why isnt it remembering how muhc it hit, thanks guys
function Fighting()
{
%randomHitlvl1 = getRandom (1,3);
$turtlehp =10- %randomHitlvl1;
if($turtlehp >= 5)
	{
      %mymsg = "You hit a" SPC %randomHitlvl1 @ "!  HP-"SPC $turtlehp @"-";
      Say(%isLocal,%mymsg);
Schedule(5000,0,"Fighting","");
}
if($turtlehp <= 4)
	{
      %mymsg = "You hit a" SPC %randomHitlvl1 @ "  HP-" SPC $turtlehp @"-";
      Say(%isLocal,%mymsg);
Schedule(5000,0,"Fighting","");
}
if($turtlehp = 0)
{
      %mymsg = "enemy Defeated.";
      Say(%isLocal,%mymsg);
}
}

#1
11/16/2009 (12:55 pm)
Hi, your problem is with this line:
$turtlehp =10- %randomHitlvl1;

here you set the turtleHP to 10 minus the randomhit each time.
what you want to do is something like this:
$turtlehp = $turtlehp - %randomHitlvl1;

In addition you need to set the $turtlehp to 10 where you create the turtle.

Also you should probably rewrite the line
if($turtlehp <= 4) as this line will trigger also when the turtle is defeated.
#2
11/20/2009 (8:40 pm)
thanks man :)