Jump to content

Recommended Posts

Hey, just having some trouble with the variables $agility and $eagility losing their set initial values (in this case 5 and 8 respectively) when in the following code:

 

$agility = $ag1;
$eagility = $ag2;

while ($hitpoints >= 1 and $ehitpoints >= 1)
{
	if ($agility >= $eagility)
		{
			$ehitpoints = $ehitpoints - $strength;
			echo $ehitpoints . " you <br>";
			$eagility = $eagility + $ag2;

		}
	else
		{
			$hitpoints = $hitpoints - $estrength;
			echo $hitpoints . " enemy <br>";
			$agility = $agility + $ag1;
		}
}

 

the $ag1 and $ag2 variables seem to have the same problem, however $hitpoints, $ehitpoints and $estrength seem to be holding the correct values...Any help on this matter would be much appreciated! Thanks in advance.

 

EDIT: To clarify this the values seem to be set to either 0 or null when called, both before and after the line that should edit the value (ie. $agility = $agility + $ag1;).

while ($hitpoints >= 1 and $ehitpoints >= 1)

Change too:

while ($hitpoints >= 1 && $ehitpoints >= 1)

 

For the i don't see much point in adding the $eagility with the variable that it is set to.

 

It is impossible for your variables to be losing their values.

 

----------

 

Try echoing the $ag1, $ag2 variables.

Are they even set further up the code?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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