OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Swaty 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
-
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
-
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.
-
and thats where good old desert island comes in
-
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
-
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.
-
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!).
-
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
-
That is what you would expect, yes.