Home   Help Search Login Register  

Author Topic: Immortal player?  (Read 1179 times)

0 Members and 1 Guest are viewing this topic.

Offline Optik

  • Members
  • *
Immortal player?
« 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:

Offline edge2

  • Members
  • *
  • Ha!
Re: Immortal player?
« Reply #1 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 ;)
Turning CS kiddies into OFP grunts

Offline Optik

  • Members
  • *
Re: Immortal player?
« Reply #2 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 ^^

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Immortal player?
« Reply #3 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:
« Last Edit: 03 Aug 2008, 10:47:38 by bedges »

Offline Optik

  • Members
  • *
Re: Immortal player?
« Reply #4 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?
« Last Edit: 03 Aug 2008, 13:13:57 by Optik »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Immortal player?
« Reply #5 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.