Using Player Health to determine status attributes

PhoenixAgent003
03 Dec 2012, 04:32
Okay, so the way my game is set up, a health system was set up. But the kicker is the player starts out severely wounded (at half health to be precise.) So I devised a revised health system in which "health" is an integer attribute, but not a status attribute.

Instead, I want a status attribute (ironically named "Status") that summarizes the player's general state of well being.

i.e.
player health = 100, Status= Excellent

player health = 99-80, Status = good

player health =40-20, Status = Wounded

And so on an so forth. Problem is, I've been trying to set up the script to change "Status" depending on health, but so far everything I've tried has either resulted in the player's Status being blank or constantly being "Excellent". Despite the fact that they have half health.

Help?

Pertex
03 Dec 2012, 08:14
Wow, your turnscript looks a bit strange :D

    <script><![CDATA[
if (player.Health > health_max) {
player.Health = player.Health = health_max
}
]]></script>


Try this:


    <script><![CDATA[
if (player.Health > player.health_max) {
player.Health = player.health_max
}
if (player.Health=player.health_max) {
player.Status="Excellent"
} else if (player.Health>=80){
player.Status="Good"
} else {
player.Status="Wounded"
}
]]></script>

jaynabonne
03 Dec 2012, 15:45
I was going to recommend a "changed" script for Health, and I see that you have a changed script, but it's for Status, in which you set Status based on Health. So basically, when you change Status... then you change Status. This could possibly lead to an infinite regress...

Perhaps you want "changedStatus" to be "changedHealth"? That way, when the Health variable gets set to a new value, the Status one will be updated automatically. And, of course, you need to flesh out that function, along the lines of what Pertex laid out.