doc. caliban 34 Posted April 15, 2020 I have a portable generator and 4 work lights in a location. I want the lights to go out if the generator is shot. This kills the lights: private _lamps = nearestObjects [generator, ["Lamps_base_F"], 50]; { for "_i" from 0 to count getAllHitPointsDamage _x -1 do { _x setHitIndex [_i, 0.97]; }; } forEach _lamps; I want to use the "hit" event handler or a trigger to run that code when the generator is shot. I'd like it to be as few moving parts as possible, like if the whole thing could be contained in the generator's init, I have so many other things I'm doing with the mission that I'm losing productive time trying to keep figuring this one out on my own. Any help is appreciated! -Doc OK, figured out where to place the code in the EH. Seems obvious now, but I've never used one before. Place this in the generator's init field, give the generator the variable name "generator", and set the distance to whatever you want. The work lights in that range will go out. this addeventhandler ["hitPart", { _lamps = nearestObjects [generator, ["Lamps_base_F"], 50]; { for "_i" from 0 to count getAllHitPointsDamage _x -1 do { _x setHitIndex [_i, 0.97]; }; } forEach _lamps; }]; Share this post Link to post Share on other sites
Harzach 2507 Posted April 15, 2020 this addEventHandler ["HitPart", { (_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"]; { _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 [_target, [ "Lamps_base_F" ], 50]; }]; *edit* -- Ah, you got it. Essentially the same code. Share this post Link to post Share on other sites