Copy link to clipboard
Copied
Hello, i'm having a major problem, i simply have no idea what is wrong, but i do know it's not supposed to be like this here's the relevant code:
Player stats
Player[1] = [30] //Max HP
Player[2] = [10] //Max MP
Player[3] = [2] //Num HP pots
Player[4] = [2] //Num MP pots
/*
Other insignificant values
*/
Player[9] = [30] //Current HP
Player[10] = [30] //Current MP
Faulty part of function PlayerTurn();
function Hp (e: MouseEvent) {
if (Player[3] > 0) //Checking if player has Health potions
{
trace(Player[1]); //outputs to 30
trace(Player[9]); //outputs to 30
if (Player[1] == Player[9]) //Apparently this isn't equal, it should be but isn't. I think this may be related to the issue, but that is further down.
{
//OUTPUT TEXT
}
else
{
Player[3]--; //Reducing number of health potions
PlayerHeal = Math.round(Player[1] * 0.5); //Neccesary middle operation, i'm outputting this in a textbox later.
Player[9] = Player[9] + PlayerHeal; //This is were the problem lies
/*
This is where the problem lies
you see; the answer to this is 3015
it SHOULD be 45 and i have no clue why.
if i subtract 1 then add 1 it becomes correct,
but i want to know why this happens.
*/
//RECALCULATE HEALTH BAR
//OUTPUT TEXT
}
}
//OUTPUT TEXT
}
I'm still quite new in AS3, but this goes against everything I've learned, i can't really figure out what's wrong. but i do know 3030HP is wrong, when it should be 45.
Player[9] = Number(Player[9]) + Number(PlayerHeal); // Convert the contents to numbers.
Copy link to clipboard
Copied
Player[9] = Number(Player[9]) + Number(PlayerHeal); // Convert the contents to numbers.
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
You're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now