ACE3/addons/vehicle_damage/functions/fnc_handleBail.sqf
johnb432 80b2fa9a05
Vehicle damage - Code cleanup (#9831)
* Cook-off improvements

* More changes

* Update fnc_getVehicleAmmo.sqf

* Better engine fire placement

* Update fnc_detonateAmmunition.sqf

* Update XEH_postInit.sqf

* Update fnc_getVehicleAmmo.sqf

* Update events-framework.md

* Various improvements

* Separate effect handling

* Tweaks

* Update XEH_postInit.sqf

* Prevent double ammo detonation

* Fixed objects not being able to cook-off again

* Added incendiary rounds as source of box cookoff

* Converted enable setting to bool

* Fixed brackets

* Update fnc_cookOff.sqf

* Update CfgEden.hpp

* Removed GVAR(enable), added GVAR(enableFire) back

* Vehicle damage fixes

* Made hitpoint hash common

* Update fnc_addEventHandler.sqf

* Update fnc_medicalDamage.sqf

* Update fnc_handleBail.sqf

* Changed API

* Remove `CBA_fnc_getConfigEntry` as much as possible, as it's 2x slower

* More cleanup

* More cleanup

* Fix merging issues, remove turret tossing

* Update translations

* More cleanup

* Reverted some logic back to original, minor tweaks & fixes

* Fix undefined variable

* Cleanup

* Fixed bad logic

* Update addons/vehicle_damage/script_macros.hpp

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Update addons/vehicle_damage/functions/fnc_handleDamage.sqf

* Update addons/vehicle_damage/stringtable.xml

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Update addons/vehicle_damage/stringtable.xml

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Update addons/vehicle_damage/XEH_postInit.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

---------

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2024-08-20 16:23:21 -03:00

70 lines
1.9 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: tcvm
* Handles whether or not the crew should bail.
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* None
*
* Example:
* cursorObject call ace_vehicle_damage_fnc_handleBail
*
* Public: No
*/
params ["_vehicle"];
TRACE_1("handleBail",_vehicle);
private _isCar = _vehicle isKindOf "Car" && {!(_vehicle isKindOf "Wheeled_APC_F")};
// canFire command is broken, hence the variable
private _canMove = (_vehicle getVariable [QGVAR(canMove), true]) && {alive driver _vehicle};
private _canShoot = (_vehicle getVariable [QGVAR(canShoot), true]) && {alive gunner _vehicle};
_vehicle setVariable [QGVAR(canMove), _canMove];
_vehicle setVariable [QGVAR(canShoot), _canShoot];
private _rand = random 1;
if (_isCar) then {
if (!_canMove) then {
_vehicle call FUNC(abandon);
TRACE_3("car immobile - bailing",_vehicle,_canMove,_isCar);
};
} else {
// If you can't move and you can't shoot, you better GTFO
if (!_canMove && !_canShoot) exitWith {
_vehicle call FUNC(abandon);
TRACE_3("immobile and can't shoot - bailing",_vehicle,_canMove,_canShoot);
};
if (!_canShoot) then {
// 50% chance of bailing out if turret/gun is disabled
if (BAILOUT_CHANCE_SHOOT > _rand) then {
_vehicle call FUNC(abandon);
TRACE_4("can't shoot - bailing",_vehicle,_rand,_canMove,_canShoot);
} else {
_vehicle allowFleeing 1;
TRACE_4("fleeing",_vehicle,_rand,_canMove,_canShoot);
};
};
if (!_canMove) then {
// 80% Chance of bailing out if engine is disabled
if (BAILOUT_CHANCE_MOVE > _rand) then {
_vehicle call FUNC(abandon);
TRACE_4("immobile - bailing",_vehicle,_rand,_canMove,_canShoot);
} else {
TRACE_4("immobile - bunkering",_vehicle,_rand,_canMove,_canShoot);
};
};
};