Home   Help Search Login Register  

Author Topic: Surviving underwater  (Read 864 times)

0 Members and 1 Guest are viewing this topic.

pazuzu

  • Guest
Surviving underwater
« on: 07 Jan 2006, 23:45:53 »
Hi, I'm making a mission with the Nimitz carrier. The Nimits has a few holes on deck that players tend to fall through when they are trying to get to a plane. I had the idea of making a simple script using setdammage command with a negative number such as: player setdammage -2. I just copied and pasted this command enough times in the script to allow the player 3 minutes of air so he could get to shore to be rescued. I tried using an eventhandler and also an addaction to each player to see how it worked. I first tried a "Hit" evenhandler but it seemd to act too slow to save me  before I drowned. Also my crude script would setdammage -2 to every player but I only want the player who fell in water to get the setdammage -2 along with a Hint that he has 3 minutes of air.

Could I possibly use the players height as a condition with(Such as below sea level) and use this with the "Hit eventhandler?

And how do I get it only work for the players who fall in water?

Thanks.

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Re:Surviving underwater
« Reply #1 on: 08 Jan 2006, 00:52:36 »
Have you tried the dammaged event handler?
Also if this still will not work you could try making a loop to just set the players dammage to zero until he finally gets in a plane.
« Last Edit: 08 Jan 2006, 00:52:55 by RujiK »
I like your approach, lets see your departure.
Download the New Flashlight Script!

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:Surviving underwater
« Reply #2 on: 08 Jan 2006, 11:12:56 »
You can combine the hit and dammaged event handlers like this (to init field):

Code: [Select]
this addEventHandler [{Hit}, {_this select 0 setDamage 0}];this addEventHandler [{Dammaged}, {_this select 0 setDamage 0}]
Then you'll have an immortal unit. It can very likely be that you only need the dammaged event handler to save a unit from drowning, like RujiK is saying. Take the hit event handler away if it is not needed, I can't test it now by myself.

If you need to have it only for the time the unit is in the water, you need to detect when player is in the water of course, add the event handlers, then remove the event handlers when the player has gotten away from the water.

Second possibility (which I would use because it is simpler to do) instead of adding/removing the event handlers when the unit is in the water or not, is to make a if () then {} condition to both of the event handlers, to detect if the unit is in the water and only then apply the setDamage command.

For detecting if a unit is in the water, I suggest you check out the function library. At a quick look the elevation function by Mr.Peanut might be most usable to this purpose. I haven't tested it though.

One more thing: if you want to keep the damage value the player has gotten before dropping into the water, you would need to use that damage value in the event handler(s). That way the players wouldn't have a way to heal themselfs from battle injuries by simply dropping into the water.
« Last Edit: 08 Jan 2006, 11:39:11 by Baddo »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Surviving underwater
« Reply #3 on: 08 Jan 2006, 13:26:42 »
Quote
That way the players wouldn't have a way to heal themselfs from battle injuries by simply dropping into the water.

"Sir, we are all badly injured, we have no medic and we are only able to crawl"

"Fear not Corporal, for in yonder woods is the fabled stream of divine healing, one dip in there and we will all be well again"

"Sir, are you feeling ok sir?"


Planck
I know a little about a lot, and a lot about a little.

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:Surviving underwater
« Reply #4 on: 10 Jan 2006, 22:40:48 »
 ;D Plank, are you feeling okay?

@the question

IIRC, falling into the water will not actually trigger the "hit" event handler will it? I don't think taking damage from drowning triggers the hit event handler in any way, which would be why pazuzu was having trouble getting the hit EH to trigger.

Also, IIRC, the damage EH is called only once per mission per body part hit, i.e. the head, torso, left leg, right leg... That means that the person can only fall in the water once. Just a warning.

@pazuzu
Quote
Also my crude script would setdammage -2 to every player but I only want the player who fell in water to get the setdammage -2 along with a Hint that he has 3 minutes of air.

Are you using this in multiplayer? EHs are little compatible with mutliplayer so i've been told...
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08