DAGGER ARMANET 172 Posted November 5, 2015 Hey all, curious if anyone knows of a solid way to make units invincible while inside vehicles (specifically helicopters and airplanes) but once outside a vehicle they are vunerable as usual. However keep in mind that while the unit in the vehicle would be invincible, the vehicle itself would not be invincible. Scenario: I want to be able to have my group survive helo crashes, and or have pilots in f18s be able to be hit by a SAM but not instantly die and have time to eject. The goal here is to improve the mission flow without respawns etc. thanks so much for any help you guys may have. Any solution would be considered, addon, init line, sqf, etc etc. Share this post Link to post Share on other sites
schadler17 36 Posted November 5, 2015 This should work. It will detect any vehicle not just helicopters/planes and needs to be looped somehow. But that'll put you in the right direction. _unit = this select 0; if (vehicle _unit != player) then { _unit addEventHandler ["HandleDamage", {0}]; }; Share this post Link to post Share on other sites
haleks 8203 Posted November 5, 2015 There're plenty ways to do that, what units should be handled : from the player's group? All units? Wich vehicle? All vehicles? If we knew more we could point you to the best solution : an eventHandler on vehicles, or a loop checking for a specific array of units etc... EDIT : Misread the OP... One solution, assuming all units start in the helo and are in the player's group : { _x allowdamage false; waitUntil {vehicle _x == _x}; _x allowdamage true; } forEach units group player; 1 Share this post Link to post Share on other sites
HorribleGoat 1464 Posted November 5, 2015 addon wise if you want to make your own modified vehicle classes theres this value:crewCrashProtection = 0.05; /// multiplier of damage to crew of the vehicle => low number means better protectionWhich could help with helo crashing down and suchthere is alsocrewVulnerable = 1 (true) / 0 (false) but I dont recall what kind of effect this had. Share this post Link to post Share on other sites
tinter 184 Posted November 6, 2015 Using get in and get out event handlers would probably be the best approach. 2 Share this post Link to post Share on other sites
schadler17 36 Posted November 6, 2015 Using get in and get out event handlers would probably be the best approach. Wasn't even thinking, even when using an EH lmao. The only issue I see with this script is if the vehicle blows up, you'd need to kill the crew, which isn't really hard either. Share this post Link to post Share on other sites
bull_a 44 Posted November 7, 2015 (edited) _unit = _this select 0; _unit addEventHandler ["HandleDamage",{ _unit = _this select 0; _vehicle = vehicle _unit; if !(_unit == _vehicle) then {0}; }]; I would use this method. What does it do? - for any unit, adds a HandleDamage event handler - whenever the unit is hit, checks if it is in a vehicle -- if unit in vehicle, no damage -- if unit not in vehicle, damage is normal - a unit can be in any vehicle - works if a player gets in a vehicle multiple times (the above methods do not do this) Kinds regards, Bull Edit: For handling vehicle destruction and crew ejection use the following: _vehicle = _this select 0; _vehicle addEventHandler ["HandleDamage",{ _vehicle = _this select 0; _damage = getDamage _vehicle; if (_damage >= 1) then { {moveOut _x} forEach crew _vehicle; }; }; Edit #2: Fixed top code, returned wrong variable, and corrected a typo (Added ']'). Edited November 9, 2015 by bull_a 2 Share this post Link to post Share on other sites
terox 314 Posted November 7, 2015 bull_a's option is by far the best system to use, handledamage EH that checks if you are in a vehicle or not 3 Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted November 8, 2015 As an alternative approach - correct me if I'm wrong, but afaik - if you don't set a trigger area, the trigger should work for every unit on the map: _trigger = createTrigger ["EmptyDetector", [0, 0, 0]]; _trigger setTriggerStatements [ "player != vehicle player", "player allowDamage false", "player allowDamage true" ]; Nevertheless, I agree with terox on bull_a's solution. Share this post Link to post Share on other sites
killzone_kid 1326 Posted November 8, 2015 bull_a's option is by far the best system to use, handledamage EH that checks if you are in a vehicle or not Except none of you have tried his solution, have you? It is even missing the closing ]. The correct way of doing this would be: _unit addEventHandler ["HandleDamage", { _unit = _this select 0; if (vehicle _unit != _unit) then {0}; }]; Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted November 8, 2015 Except none of you have tried his solution, have you? It is even missing the closing ]. The correct way of doing this would be: Touché! Nevertheless, I guess we all agreed on the principle, regardless the copy-paste-ability. 1 Share this post Link to post Share on other sites
killzone_kid 1326 Posted November 8, 2015 Touché! Nevertheless, I guess we all agreed on the principle, regardless the copy-paste-ability. Yep, the most humane way of doing this would be via "HandleDamage" EH. The only problem here is when someone is on parachute or on a quadbike, then it would look mighty weird that you cannot kill exposed player. Share this post Link to post Share on other sites
haleks 8203 Posted November 8, 2015 I think this is defined by the "isOpen" config entry (can't remember if it's the exact name) right? In that case we just need to go fetch that value in the config whenever (vehicle _unit != _unit) and filter those vehicles if need be. EDIT : or maybe I'm confused with attenuationEffectType - wich could be used all the same to determine if a vehicle is open or not. Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted November 8, 2015 The only problem here is when someone is on parachute or on a quadbike, then it would look mighty weird that you cannot kill exposed player. Dunno if even with the quadbike that's the very intention actually. With the parachute, I agree, that shouldn't count into the "invulnerable in vehicle" case. But consider it not a bug, but rather a feature, since shooting paratroopers is a war crime. ;) Share this post Link to post Share on other sites
bull_a 44 Posted November 8, 2015 Yep, the most humane way of doing this would be via "HandleDamage" EH. The only problem here is when someone is on parachute or on a quadbike, then it would look mighty weird that you cannot kill exposed player. You can always add a vehicle black list: _unit = _this select 0; _unit addEventHandler ["HandleDamage",{ _unit = _this select 0; _vehicle = vehicle _unit; _checkVehicles = ["B_Parachute", ...]; if !((_unit == _vehicle) && (_vehicle in _checkVehicles)) then {0}; }]; Regards, Bull Share this post Link to post Share on other sites
killzone_kid 1326 Posted November 8, 2015 You can always add a vehicle black list: _unit = _this select 0; _unit addEventHandler ["HandleDamage",{ _unit = _this select 0; _vehicle = vehicle _unit; _checkVehicles = ["B_Parachute", ...]; if !((_unit == _vehicle) && (_vehicle in _checkVehicles)) exitWith {0}; }]; Regards, Bull Seriously dude, check your code before posting. Same mistake as in the 1st code, you cannot use exitWith in main scope of EH, as simple as that. The EH scope should receive the damage value, it simply cannot read it if you exit that scope. 1 1 Share this post Link to post Share on other sites