mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
function to normalize dependant hitpoints
This commit is contained in:
parent
b16267539c
commit
10f56cc4c3
@ -5,6 +5,7 @@ ADDON = false;
|
||||
PREP(addRepairActions);
|
||||
PREP(doRepair);
|
||||
PREP(getWheelHitPointsWithSelections);
|
||||
PREP(normalizeHitPoints);
|
||||
PREP(removeWheel);
|
||||
PREP(repairVehicle);
|
||||
PREP(replaceWheel);
|
||||
|
55
addons/repair/functions/fnc_normalizeHitPoints.sqf
Normal file
55
addons/repair/functions/fnc_normalizeHitPoints.sqf
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Used to normalize dependant hitpoints. May overwrite some global variables that are named like hitpoints or "Total" though...
|
||||
*
|
||||
* Arguments:
|
||||
* 0: A local vehicle with hitpoints. (Object)
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_vehicle";
|
||||
|
||||
_vehicle = _this select 0;
|
||||
|
||||
// can't execute all commands if the vehicle isn't local. exit here.
|
||||
if !(local _vehicle) exitWith {};
|
||||
|
||||
private ["_hitPoints", "_config"];
|
||||
|
||||
_hitPoints = [_vehicle] call EFUNC(common,getHitPoints);
|
||||
|
||||
_config = configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints";
|
||||
|
||||
// define global variables. Needed to parse the depends config entries. Also find dependent hitpoints.
|
||||
|
||||
private ["_dependentHitPoints", "_dependentHitPointScripts"];
|
||||
|
||||
_dependentHitPoints = [];
|
||||
_dependentHitPointScripts = [];
|
||||
|
||||
Total = damage _vehicle;
|
||||
|
||||
{
|
||||
missionNamespace setVariable [_x, _vehicle getHitPointDamage _x];
|
||||
|
||||
if (isText (_config >> _x >> "depends")) then {
|
||||
_dependentHitPoints pushBack _x;
|
||||
_dependentHitPointScripts pushBack compile getText (_config >> _x >> "depends");
|
||||
};
|
||||
|
||||
} forEach _hitPoints;
|
||||
|
||||
// apply normalized damage to all dependand hitpoints
|
||||
|
||||
{
|
||||
private "_damage";
|
||||
|
||||
_damage = call (_dependentHitPointScripts select _forEachIndex);
|
||||
|
||||
_vehicle setHitPointDamage [_x, _damage];
|
||||
|
||||
} forEach _dependentHitPoints;
|
Loading…
Reference in New Issue
Block a user