R3vo 2654 Posted February 1, 2015 Hey folks, I once again need your help with a small script. In my mission, the player shall destroy two transformer with a silenced M14 EBR. What I tried to far looks like this. But it doesn't fire when the transformer gets hit. My guess is, that the damaged done to it, is too low. [color="#FF8040"]transf1 [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#FF0000"]9314[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]21143[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]nearestObject[/b][/color] [color="#FF0000"]1599395[/color][color="#8B3E2F"][b];[/b][/color] transf2 [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#FF0000"]9314[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]21143[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]nearestObject[/b][/color] [color="#FF0000"]1599396[/color][color="#8B3E2F"][b];[/b][/color] transf1 [color="#191970"][b]addEventHandler[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"HitPart"[/color][color="#8B3E2F"][b],[/b][/color] [color="#8B3E2F"][b]{[/b][/color]transf1 [color="#191970"][b]setDamage[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] transf2 [color="#191970"][b]addEventHandler[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"HitPart"[/color][color="#8B3E2F"][b],[/b][/color] [color="#8B3E2F"][b]{[/b][/color]transf2 [color="#191970"][b]setDamage[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#191970"][b]while[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]do[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#191970"][b]if[/b][/color][color="#8B3E2F"][b]([/b][/color][color="#8B3E2F"][b]![/b][/color][color="#191970"][b]alive[/b][/color] transf1 [color="#8B3E2F"][b]&[/b][/color][color="#8B3E2F"][b]&[/b][/color] [color="#8B3E2F"][b]![/b][/color][color="#191970"][b]alive[/b][/color] transf2[color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#000000"]_x[/color] [color="#191970"][b]setHit[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"light_1_hitpoint"[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]0.97[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#000000"]_x[/color] [color="#191970"][b]setHit[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"light_2_hitpoint"[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]0.97[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#000000"]_x[/color] [color="#191970"][b]setHit[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"light_3_hitpoint"[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]0.97[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#000000"]_x[/color] [color="#191970"][b]setHit[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"light_4_hitpoint"[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]0.97[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]forEach[/b][/color] [color="#191970"][b]nearestObjects[/b][/color] [color="#8B3E2F"][b][[/b][/color]transf1[color="#8B3E2F"][b],[/b][/color] [color="#8B3E2F"][b][[/b][/color] [color="#7A7A7A"]"Lamps_base_F"[/color][color="#8B3E2F"][b],[/b][/color] [color="#7A7A7A"]"PowerLines_base_F"[/color][color="#8B3E2F"][b],[/b][/color] [color="#7A7A7A"]"PowerLines_Small_base_F"[/color] [color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]1500[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#191970"][b]sleep[/b][/color] [color="#FF0000"]5[/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [/color] Made with KK's SQF to BBCode Converter The while-loop just checks if the transformers are alive, and if not, it cuts the light in the area. Thank in advance R3vo Share this post Link to post Share on other sites
f2k sel 164 Posted February 1, 2015 There are some objects that can't have an eventhandler attached to them and it looks like the transformer is one of them. You could try pre-damaging it so that one or two shots will destroy it transf1 setDamage 0.999 although it makes it weak against everything not just bullets. Share this post Link to post Share on other sites
baermitumlaut 62 Posted February 1, 2015 I experimented a bit and it looks like no matter what, the event handler doesn't trigger. I suspect this is related to it being a map object (you can't detect it with cursorTarget for example). I would recommend you to do a workaround, for example the "classic" exploding barrels. You can find suitable barrels under Objects (Containers). You could now add an event handler on the barrel instead if the transformer, for example like this: this addEventHandler ["HandleDamage", { if (_this select 2 > 1) then { _charge = "APERSMine_Range_Ammo" createVehicle (getPos (_this select 0)); deleteVehicle (_this select 0); transf1 setDamage 1; transf2 setDamage 1; _charge setDamage 1; { _x setHit ["light_1_hitpoint", 0.97]; _x setHit ["light_2_hitpoint", 0.97]; _x setHit ["light_3_hitpoint", 0.97]; _x setHit ["light_4_hitpoint", 0.97]; } forEach nearestObjects [transf1, [ "Lamps_base_F", "PowerLines_base_F", "PowerLines_Small_base_F" ], 1500]; }; }]; Alternatively you could park a fuel truck nearby and let that explode in a similar way. I also turned the lights off within that event handler, so you won't need a while loop and save some resources. Share this post Link to post Share on other sites
R3vo 2654 Posted February 1, 2015 (edited) I also turned the lights off within that event handler, so you won't need a while loop and save some resources. Yeh lol, why didn't I think of that :D However, the exploding barrel or fuel truck won't work since it's a stealth mission, otherwise I would just use explosives. I'm going to try pre-damaging it and see how that works out. Thanks for your help guys ;) EDIT: Okay I did a differnt approach now which suits my needs. [color="#FF8040"][color="#8B3E2F"][b]([/b][/color][color="#191970"][b]damage[/b][/color] transf1[color="#8B3E2F"][b])[/b][/color] [color="#8B3E2F"][b]>[/b][/color] [color="#FF0000"]0.03[/color] [color="#8B3E2F"][b]&[/b][/color][color="#8B3E2F"][b]&[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]damage[/b][/color] transf1[color="#8B3E2F"][b])[/b][/color] [color="#8B3E2F"][b]>[/b][/color] [color="#FF0000"]0.03[/color][/color] Made with KK's SQF to BBCode Converter That's the condition for the task to be succeeded. Now the player only needs to fire 4 or 5 rounds on each transformer ...and voilà , lights are out ;) Thanks for that tip Edited February 1, 2015 by R3vo Share this post Link to post Share on other sites