Frictional Games Forum (read-only)
If players health is below x, y happens - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: If players health is below x, y happens (/thread-17164.html)



If players health is below x, y happens - ApeCake - 07-21-2012

So I want my player to die "instantly" when hit by a specific monster. And before you ask, no, I will not adjust the settings of the monster in the model editor. I want it to be script only. So I had an idea. If the players health is below 99 (100 is the default right?) it will activate setplayerhealth(0);. But unfortunately, I am terrible with the "if" stuff. What I have right now is

void A(Syntax stuff here)
{
if ((getplayerhealth)==<99)
{
Setplayerhealth(0);

}

It comes up with an expression value error.

Please ignore the spelling errors, the missing syntax and the missing capitals, I am writing this on my pone because my internet doesn't work on my pc anymore.


RE: If players health is below x, y happens - Adny - 07-21-2012

Here's what I made; a timer that checks the players health every 0.2f to see if its less than or equal to 99.


void OnStart()
{
AddTimer("", 0.2f, "CheckHealth");
}

void CheckHealth(string &in asTimer)
{
AddTimer("", 0.2f, "CheckHealth");

if(GetPlayerHealth() <= 99.0f)
{
SetPlayerHealth(0.0f);
}

}