OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Optik on 03 Aug 2008, 02:04:39

Title: Immortal player?
Post by: Optik on 03 Aug 2008, 02:04:39
Hey everyone.

I was wondering if it is possible to make the player immune to attacks (bullets, shells etc).

I have tried the "dammaged" eventhandler and it works fine in combination with some scripts but when I get a headshot or another kind of fatal hit, game is over  :scratch:

Would also like to say that in this case weapons should do real damage to the player's comrades and only make him immune.

This is singleplayer btw

Thanks for any insight  :good:
Title: Re: Immortal player?
Post by: edge2 on 03 Aug 2008, 02:56:31
Well AFAIK the only way to get something like that is with eventhandlers
P.S. I put an attachement (ripped it off from TKC) Maybe you can check this out to see how this one works ;)
Title: Re: Immortal player?
Post by: Optik on 03 Aug 2008, 03:25:05
Thanks  :D

Didn't work for me however, same problem. If the hit is a fatal one (a headshot for example), he dies ^^
Title: Re: Immortal player?
Post by: bedges on 03 Aug 2008, 10:44:34
Firstly, welcome to OFPEC!

The damaged eventhandler is a start, but you also need the killed eventhandler for those fatal wounds, e.g.

Code: [Select]
handlername_hit = player addeventhandler ["hit", {player setdamage 0}]
handlername_killed = player addeventhandler ["killed", {player setdamage 0}]

Bear in mind that the eventhandler is not always fast enough to catch the fatal wounding, and the game may end even though the outro animation shows the player's unit running around healthy... just another of OFP's quirks.

Once again welcome.  :good:
Title: Re: Immortal player?
Post by: Optik on 03 Aug 2008, 13:10:23
Thanks for the welcome  :D

I've been a member a couple of years ago, but lost my login/pass. Anyways I was leeching off this forum for the last 4-5 months for info (I feel bad now  :dry:)

Thanks, I'll try this right now

edit: one question

Is it faster to put commands directly in the init field, or to call for a script?
Title: Re: Immortal player?
Post by: bedges on 03 Aug 2008, 17:58:16
Personally I think it's better practice to use a script, since it can be made more flexible. You can switch it on or off, you can pass it variables, etc etc. and it's much easier to read an external script than scroll along a single textbox within the editor interface. Speed of implementation doesn't really come into it.