OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: dalton on 17 Jan 2005, 14:57:28

Title: checking if player is dead
Post by: dalton on 17 Jan 2005, 14:57:28
i want a script that checks if the player is dead, and if he isnt then i want setdammage 0. would that be like this?:

Code: [Select]
?(alive playername): setdammage 0
Title: Re:checking if player is dead
Post by: dalton on 17 Jan 2005, 15:00:58
or maybe its something like this?

Code: [Select]
?(player dammage<1):player setdammage 0
Title: Re:checking if player is dead
Post by: Baddo on 17 Jan 2005, 15:34:34
I understand that you want the script to give player's health back if he's just injured, right?

Put it in a trigger.

Condition: player damage > 0

On activation: player setdammage 0

And type of the trigger should be repeatedly.

Not tested, but it should work that way. I don't know how it works if the player's damage reaches 1. Is he dead then or does this keep him still alive?

Test it.

Where you are going to use this... Hmm...

  ::)

EDIT

The answer to your first question:

?(alive playername): setdammage 0

should be

?(alive player) : player setdammage 0

in a _script_.

But use the trigger method, if you just want to check if player is injured and heal him.
Title: Re:checking if player is dead
Post by: macguba on 17 Jan 2005, 17:03:38
Once the player is dead, that's it, mission over.    You can bring the unit back to life if you like, but you won't be able to control it.

You can use

player addEventHandler [{Hit}, {_this select 0 setDammage 0}]

and I also add a setDammage 0 loop in a wee script.     But the trigger should also work.
Title: Re:checking if player is dead
Post by: RujiK on 17 Jan 2005, 18:19:51
Making a player unkillable is impossible with OFP's scripting unless you use special units.
This is because there is no condition in the "OnPlayerKilled.sqs" that rechecks if the player is killed.

However if you want your player too be invincible change his Type in the mission.sqm file from "SoldierGB" (Example) too "SoldierGCheat". SoldierGCheat is a special unit that cannot be accessed in game unless you have special addons.

However this unit is almost impossible too kill and really doesnt even need a heal script.
Title: Re:checking if player is dead
Post by: Baddo on 17 Jan 2005, 18:41:59
The addeventhandler is much better.

But the 'Hit' event handler does not help if you want to also heal from falling, drowning or car accident injuries.

We can combine it with a 'Dammaged' event handler. Put this to unit's initialization field:

Code: [Select]
this addEventHandler [{Hit}, {_this select 0 setDammage 0}];this addEventHandler [{Dammaged}, {_this select 0 setDammage 0}]
and go running in the sea.

This whole conversation is unnecessary, there should not be any usage to a healing method like we are discussing... maybe in cutscenes but not otherwise.

 ;D
Title: Re:checking if player is dead
Post by: Baddo on 17 Jan 2005, 18:59:27
Making a player unkillable is impossible with OFP's scripting unless you use special units.
This is because there is no condition in the "OnPlayerKilled.sqs" that rechecks if the player is killed.

However if you want your player too be invincible change his Type in the mission.sqm file from "SoldierGB" (Example) too "SoldierGCheat". SoldierGCheat is a special unit that cannot be accessed in game unless you have special addons.

However this unit is almost impossible too kill and really doesnt even need a heal script.

Combination of event handlers 'Hit' and 'Dammaged':

Code: [Select]
this addEventHandler [{Hit}, {_this select 0 setDammage 0}];this addEventHandler [{Dammaged}, {_this select 0 setDammage 0}]
seems to make the unit unkillable.

Test it and confirm if you didn't find a way to get the unit killed. I didn't.
Title: Re:checking if player is dead
Post by: Merc on 17 Jan 2005, 19:25:45
Code: [Select]
this addEventHandler [{Hit}, {_this select 0 setDammage 0}];this addEventHandler [{Dammaged}, {_this select 0 setDammage 0}]

I tested it and I have to say that I didn't die. I had 4 groups of Russian soldiers shooting at me and I didn't die. It was fun.  ;D
Title: Re:checking if player is dead
Post by: Merc on 17 Jan 2005, 19:29:45
Code: [Select]
this addEventHandler [{Hit}, {_this select 0 setDammage 0}];this addEventHandler [{Dammaged}, {_this select 0 setDammage 0}]

I tested it. I had 4 groups of Russian soldiers shooting at me and I didn't die. It was fun.  ;D
Title: Re:checking if player is dead
Post by: dalton on 17 Jan 2005, 21:48:33
Once the player is dead, that's it, mission over.    You can bring the unit back to life if you like, but you won't be able to control it.

You can use

player addEventHandler [{Hit}, {_this select 0 setDammage 0}]

and I also add a setDammage 0 loop in a wee script.     But the trigger should also work.
its a multiplayer mission, they become little birdies when they die
Title: Re:checking if player is dead
Post by: THobson on 17 Jan 2005, 22:48:57
Have you tried detonating a satchel charge at your feet?  I guess that could be fun too.  

I have not made the player invincible, but I have done it to AI.  They go a long way up with a satchel charge under them.
Title: Re:checking if player is dead
Post by: RujiK on 17 Jan 2005, 23:14:14
this addEventHandler [{Hit}, {_this select 0 setDammage 0}];this addEventHandler [{Dammaged}, {_this select 0 setDammage 0}]

Wow, that works.
I had forgotten about the eventhandler dammage entirely.

I tried even creating five laserguidedbomb explosions, and I still did not die.

(Nor did the death cam script start running)