Home   Help Search Login Register  

Author Topic: addEventHandler "Hit"  (Read 596 times)

0 Members and 1 Guest are viewing this topic.

Swaty

  • Guest
addEventHandler "Hit"
« on: 12 Jan 2005, 16:22:38 »
I am trying to make a truck carrying a group of three soldiers (soldiers G1 to G3, called Group1) to stop when fired upon and the group getting out. However it does not work. What have I missed?

This is what I got in the init in the Ural_1 truck:
this addEventHandler ["Hit",{[G1,G2,G3] orderGetin false; commandstop Ural_1; hint "It works!"}]

This is what I got in the init of G1, leader of Group1:
Group1 = group this; "_x assignAsCargo Ural_1" foreach units Group1; "_x moveInCargo Ural_1" foreach units Group1

I have also tried using a trigger, but it seems like it does not notice that I am shooting at the truck.

Swaty

StonedSoldier

  • Guest
Re:addEventHandler "Hit"
« Reply #1 on: 12 Jan 2005, 16:41:38 »
the way i usually do this;

guys in the back of the truck in the group called truckteam

truckteam setbehaviour "SAFE"

and use a trigger

condition : behaviour truckteam !="SAFE"
activation: {unassignvehicle _x;_x action ["eject",(vehicle _x)]} foreach units truckteam

syntax are be slightly out as im at college at the mo
« Last Edit: 12 Jan 2005, 16:42:27 by StonedSoldier »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:addEventHandler "Hit"
« Reply #2 on: 12 Jan 2005, 16:52:03 »
When you say it doesn't work, what happens?

Can you get an EH to work on just a single soldier standing in a field?    When you are using a new command it is often helpul to get it working on a simple test missionette before trying to slot it into the more complex situation of a real mission.
Plenty of reviewed ArmA missions for you to play

StonedSoldier

  • Guest
Re:addEventHandler "Hit"
« Reply #3 on: 12 Jan 2005, 16:55:51 »
and thats where good old desert island comes in

Swaty

  • Guest
Re:addEventHandler "Hit"
« Reply #4 on: 12 Jan 2005, 17:24:32 »
Well, if I have the
"[G1,G2,G3] orderGetin false; commandstop Ural_1; hint "It works!""
in a areaaffected trigger it works.

It seems like the problem is getting the game to understand I am firing on the truck / something with the addEventHandler "Hit".

Swaty

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Re:addEventHandler "Hit"
« Reply #5 on: 12 Jan 2005, 18:54:21 »
Well, one thing you could do instead of having the hit handler, your could just use getdammage.
The only problem with this would be is if the truck crashes everyone will hope out. So, one way too help this is if you put in

#check
~1
?(getdammage truck == 0):goto"check"
?(Enemydude distance truck > 150):goto"check"
;then put in whatever you want too happen here


That would be one way however if you have a million enemy units for this truck this script will need some tweaking.
« Last Edit: 12 Jan 2005, 18:54:52 by RujiK »
I like your approach, lets see your departure.
Download the New Flashlight Script!

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:addEventHandler "Hit"
« Reply #6 on: 12 Jan 2005, 20:27:23 »
Quote
It seems like the problem is getting the game to understand I am firing on the truck / something with the addEventHandler "Hit".

"Hit" eventhandlers only run when a unit gets hit for a large enough amount of damage (something like more than 5% of it's max life). So vehicles usually don't respond to hit EHs when being hit by bullets, since it takes a ton of bullets to destroy one.

The alternatives have already been stated. You can either create a loop/trigger that checks the damage level of the truck, or you can create a loop/trigger that checks the combatmode of the truck. The second one works because units will always automatically change to "combat" when they see the enemy or are under attack (unless they are in "stealth" mode, or if they are under the player's command!).
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Swaty

  • Guest
Re:addEventHandler "Hit"
« Reply #7 on: 12 Jan 2005, 22:17:47 »
But if I shoot the driver in the head the guys don't pop out either. But then maybe the eventhandler only calculates on the actual truck even when the driver is a part of it?

Swaty

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:addEventHandler "Hit"
« Reply #8 on: 12 Jan 2005, 23:20:32 »
That is what you would expect, yes.
Plenty of reviewed ArmA missions for you to play