mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Skip Depends Hitpoints - Use HitPoints selPos for wheels
Stuff Normalize Depends - Skip Glass Repair Fix spawned wheel/track not having correct damage getHitpointString robustness, hatchback fuelHitpoint, fix count errors - Formatting local -> private Fix Stuff
This commit is contained in:
parent
839c022b84
commit
ab769757d9
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
|
|
||||||
local _isEngineer = _unit getVariable ["ACE_isEngineer", getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "engineer") == 1];
|
private _isEngineer = _unit getVariable ["ACE_isEngineer", getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "engineer") == 1];
|
||||||
//Handle ace_repair modules setting this to a number
|
//Handle ace_repair modules setting this to a number
|
||||||
if ((typeName _isEngineer) == "SCALAR") then {_isEngineer = _isEngineer > 0};
|
if ((typeName _isEngineer) == "SCALAR") then {_isEngineer = _isEngineer > 0};
|
||||||
|
|
||||||
|
@ -405,6 +405,6 @@ class CfgVehicles {
|
|||||||
GVAR(hitpointPositions[]) = { {"HitEngine", {0, 0.5, -0.7}}, {"HitFuel", {0, 0, -0.5}} };
|
GVAR(hitpointPositions[]) = { {"HitEngine", {0, 0.5, -0.7}}, {"HitFuel", {0, 0, -0.5}} };
|
||||||
};
|
};
|
||||||
class Hatchback_01_base_F: Car_F {
|
class Hatchback_01_base_F: Car_F {
|
||||||
GVAR(hitpointPositions[]) = {{"HitBody", {0, 0.7, -0.5}}};
|
GVAR(hitpointPositions[]) = {{"HitBody", {0, 0.7, -0.5}}, {"HitFuel", {0, -1.75, -0.75}}};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -13,13 +13,14 @@
|
|||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_vehicle"];
|
if (!hasInterface) exitWith {};
|
||||||
TRACE_1("params", _vehicle);
|
|
||||||
|
|
||||||
private ["_type", "_initializedClasses", "_condition", "_statement", "_action", "_processedHitPoints", "_hitPointsAddedNames", "_hitPointsAddedStrings", "_hitPointsAddedAmount"];
|
params ["_vehicle"];
|
||||||
|
TRACE_2("params", _vehicle,typeOf _vehicle);
|
||||||
|
|
||||||
|
private["_action", "_childHitPoint", "_condition", "_groupsConfig", "_hitPoint", "_hitPointsAddedAmount", "_hitPointsAddedNames", "_hitPointsAddedStrings", "_icon", "_initializedClasses", "_name", "_position", "_positionsConfig", "_processedHitPoints", "_selection", "_statement", "_target", "_type"];
|
||||||
|
|
||||||
_type = typeOf _vehicle;
|
_type = typeOf _vehicle;
|
||||||
|
|
||||||
@ -51,32 +52,43 @@ _processedHitpoints = [];
|
|||||||
|
|
||||||
_icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa";
|
_icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa";
|
||||||
|
|
||||||
|
_position = compile format ["_target selectionPosition ['%1', 'HitPoints'];", _selection];
|
||||||
|
|
||||||
|
TRACE_3("Adding Wheel Actions",_hitpoint,_forEachIndex,_selection);
|
||||||
|
|
||||||
// An action to remove the wheel is required
|
// An action to remove the wheel is required
|
||||||
_name = format ["Remove_%1_%2", _forEachIndex, _hitpoint];
|
_name = format ["Remove_%1_%2", _forEachIndex, _hitpoint];
|
||||||
_text = localize LSTRING(RemoveWheel);
|
_text = localize LSTRING(RemoveWheel);
|
||||||
TRACE_4("Adding Wheel Actions",_name,_forEachIndex,_selection,_text);
|
|
||||||
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(canRepair)};
|
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(canRepair)};
|
||||||
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(repair)};
|
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "RemoveWheel"] call DFUNC(repair)};
|
||||||
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _selection, 2] call EFUNC(interact_menu,createAction);
|
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 2] call EFUNC(interact_menu,createAction);
|
||||||
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
||||||
|
|
||||||
// An action to replace the wheel is required
|
// An action to replace the wheel is required
|
||||||
_name = format ["Replace_%1_%2", _forEachIndex, _selection];
|
_name = format ["Replace_%1_%2", _forEachIndex, _hitpoint];
|
||||||
_text = localize LSTRING(ReplaceWheel);
|
_text = localize LSTRING(ReplaceWheel);
|
||||||
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "ReplaceWheel"] call DFUNC(canRepair)};
|
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "ReplaceWheel"] call DFUNC(canRepair)};
|
||||||
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "ReplaceWheel"] call DFUNC(repair)};
|
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "ReplaceWheel"] call DFUNC(repair)};
|
||||||
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _selection, 2] call EFUNC(interact_menu,createAction);
|
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 2] call EFUNC(interact_menu,createAction);
|
||||||
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
||||||
} else {
|
} else {
|
||||||
|
//Skip glass hitpoints
|
||||||
|
if (((toLower _hitPoint) find "glass") != -1) exitWith {
|
||||||
|
TRACE_3("Skipping Glass",_hitpoint,_forEachIndex,_selection);
|
||||||
|
};
|
||||||
// Empty selections don't exist
|
// Empty selections don't exist
|
||||||
// Empty hitpoints don't contain enough information
|
// Empty hitpoints don't contain enough information
|
||||||
if (_selection isEqualTo "") exitWith {};
|
if (_selection isEqualTo "") exitWith { TRACE_3("Selection Empty",_hitpoint,_forEachIndex,_selection); };
|
||||||
if (_hitpoint isEqualTo "") exitWith {};
|
if (_hitpoint isEqualTo "") exitWith { TRACE_3("Hitpoint Empty",_hitpoint,_forEachIndex,_selection); };
|
||||||
|
//Depends hitpoints shouldn't be modified directly (will be normalized)
|
||||||
|
if (isText (configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _hitpoint >> "depends")) exitWith {
|
||||||
|
TRACE_3("Skip Depends",_hitpoint,_forEachIndex,_selection);
|
||||||
|
};
|
||||||
|
|
||||||
// Associated hitpoints can be grouped via config to produce a single repair action
|
// Associated hitpoints can be grouped via config to produce a single repair action
|
||||||
_groupsConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointGroups);
|
_groupsConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointGroups);
|
||||||
if (isArray _groupsConfig) then {
|
|
||||||
_childHitPoint = false;
|
_childHitPoint = false;
|
||||||
|
if (isArray _groupsConfig) then {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
if (_hitpoint == _x) exitWith {
|
if (_hitpoint == _x) exitWith {
|
||||||
@ -89,7 +101,8 @@ _processedHitpoints = [];
|
|||||||
if (_childHitPoint) exitWith { TRACE_3("childHitpoint",_hitpoint,_forEachIndex,_selection); };
|
if (_childHitPoint) exitWith { TRACE_3("childHitpoint",_hitpoint,_forEachIndex,_selection); };
|
||||||
|
|
||||||
// Find the action position
|
// Find the action position
|
||||||
_position = _vehicle selectionPosition [_selection,"HitPoints"];
|
_position = compile format ["_target selectionPosition ['%1', 'HitPoints'];", _selection];
|
||||||
|
|
||||||
// Custom position can be defined via config for associated hitpoint
|
// Custom position can be defined via config for associated hitpoint
|
||||||
_positionsConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointPositions);
|
_positionsConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointPositions);
|
||||||
if (isArray _positionsConfig) then {
|
if (isArray _positionsConfig) then {
|
||||||
@ -100,7 +113,7 @@ _processedHitpoints = [];
|
|||||||
_position = _pos; // Position in model space
|
_position = _pos; // Position in model space
|
||||||
};
|
};
|
||||||
if (typeName _pos == "STRING") exitWith {
|
if (typeName _pos == "STRING") exitWith {
|
||||||
_position = _vehicle selectionPosition [_pos,"HitPoints"]; // Selection name
|
_position = compile format ["_target selectionPosition ['%1', 'HitPoints'];", _pos];
|
||||||
};
|
};
|
||||||
ACE_LOGERROR_3("Invalid custom position %1 of hitpoint %2 in vehicle %3.",_position,_hitpoint,_type);
|
ACE_LOGERROR_3("Invalid custom position %1 of hitpoint %2 in vehicle %3.",_position,_hitpoint,_type);
|
||||||
};
|
};
|
||||||
@ -125,13 +138,13 @@ _processedHitpoints = [];
|
|||||||
} else {
|
} else {
|
||||||
_position = [1.75, 0, -1.75];
|
_position = [1.75, 0, -1.75];
|
||||||
};
|
};
|
||||||
TRACE_5("Adding RepairTrack",_name,_forEachIndex,_selection,_text,_position);
|
TRACE_4("Adding RepairTrack",_hitpoint,_forEachIndex,_selection,_text);
|
||||||
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "RepairTrack"] call DFUNC(canRepair)};
|
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "RepairTrack"] call DFUNC(canRepair)};
|
||||||
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "RepairTrack"] call DFUNC(repair)};
|
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "RepairTrack"] call DFUNC(repair)};
|
||||||
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 4] call EFUNC(interact_menu,createAction);
|
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 4] call EFUNC(interact_menu,createAction);
|
||||||
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
||||||
} else {
|
} else {
|
||||||
TRACE_5("Adding MiscRepair",_name,_forEachIndex,_selection,_text,_position);
|
TRACE_4("Adding MiscRepair",_hitpoint,_forEachIndex,_selection,_text);
|
||||||
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "MiscRepair"] call DFUNC(canRepair)};
|
_condition = {[_this select 1, _this select 0, _this select 2 select 0, "MiscRepair"] call DFUNC(canRepair)};
|
||||||
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "MiscRepair"] call DFUNC(repair)};
|
_statement = {[_this select 1, _this select 0, _this select 2 select 0, "MiscRepair"] call DFUNC(repair)};
|
||||||
_action = [_name, _text, _icon, _statement, _condition, {}, [_forEachIndex], _position, 5] call EFUNC(interact_menu,createAction);
|
_action = [_name, _text, _icon, _statement, _condition, {}, [_forEachIndex], _position, 5] call EFUNC(interact_menu,createAction);
|
||||||
|
@ -21,22 +21,22 @@
|
|||||||
params ["_caller", "_target", "_hitPoint", "_className"];
|
params ["_caller", "_target", "_hitPoint", "_className"];
|
||||||
TRACE_4("params",_caller,_target,_hitPoint,_className);
|
TRACE_4("params",_caller,_target,_hitPoint,_className);
|
||||||
|
|
||||||
private ["_config", "_engineerRequired", "_items", "_locations", "_return", "_condition", "_vehicleStateCondition", "_settingName", "_settingItemsArray"];
|
private ["_config", "_engineerRequired", "_items", "_return", "_condition", "_vehicleStateCondition", "_settingName", "_settingItemsArray"];
|
||||||
|
|
||||||
_config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className);
|
_config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className);
|
||||||
if !(isClass _config) exitwith {false}; // or go for a default?
|
if !(isClass _config) exitWith {false}; // or go for a default?
|
||||||
if(isEngineOn _target) exitwith {false};
|
if(isEngineOn _target) exitWith {false};
|
||||||
|
|
||||||
_engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
|
_engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
|
||||||
getNumber (_config >> "requiredEngineer");
|
getNumber (_config >> "requiredEngineer");
|
||||||
} else {
|
} else {
|
||||||
// Check for required class
|
// Check for required class
|
||||||
if (isText (_config >> "requiredEngineer")) exitwith {
|
if (isText (_config >> "requiredEngineer")) exitWith {
|
||||||
missionNamespace getVariable [(getText (_config >> "requiredEngineer")), 0];
|
missionNamespace getVariable [(getText (_config >> "requiredEngineer")), 0];
|
||||||
};
|
};
|
||||||
0;
|
0;
|
||||||
};
|
};
|
||||||
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitwith {false};
|
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitWith {false};
|
||||||
|
|
||||||
//Items can be an array of required items or a string to a ACE_Setting array
|
//Items can be an array of required items or a string to a ACE_Setting array
|
||||||
_items = if (isArray (_config >> "items")) then {
|
_items = if (isArray (_config >> "items")) then {
|
||||||
@ -49,12 +49,12 @@ _items = if (isArray (_config >> "items")) then {
|
|||||||
};
|
};
|
||||||
_settingItemsArray select (missionNamespace getVariable _settingName);
|
_settingItemsArray select (missionNamespace getVariable _settingName);
|
||||||
};
|
};
|
||||||
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitwith {false};
|
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false};
|
||||||
|
|
||||||
_return = true;
|
_return = true;
|
||||||
if (getText (_config >> "condition") != "") then {
|
if (getText (_config >> "condition") != "") then {
|
||||||
_condition = getText (_config >> "condition");
|
_condition = getText (_config >> "condition");
|
||||||
if (isnil _condition) then {
|
if (isNil _condition) then {
|
||||||
_condition = compile _condition;
|
_condition = compile _condition;
|
||||||
} else {
|
} else {
|
||||||
_condition = missionNamespace getVariable _condition;
|
_condition = missionNamespace getVariable _condition;
|
||||||
@ -66,25 +66,25 @@ if (getText (_config >> "condition") != "") then {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!_return) exitwith {false};
|
if (!_return) exitWith {false};
|
||||||
|
|
||||||
// _vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
|
// _vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
|
||||||
// missionNamespace getVariable [getText(_config >> "vehicleStateCondition"), 0]
|
// missionNamespace getVariable [getText(_config >> "vehicleStateCondition"), 0]
|
||||||
// } else {
|
// } else {
|
||||||
// getNumber(_config >> "vehicleStateCondition")
|
// getNumber(_config >> "vehicleStateCondition")
|
||||||
// };
|
// };
|
||||||
// if (_vehicleStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitwith {false};
|
// if (_vehicleStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitWith {false};
|
||||||
|
|
||||||
local _repairLocations = getArray (_config >> "repairLocations");
|
private _repairLocations = getArray (_config >> "repairLocations");
|
||||||
if (!("All" in _repairLocations)) then {
|
if (!("All" in _repairLocations)) then {
|
||||||
local _repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
|
private _repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
|
||||||
local _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
|
private _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
|
||||||
{
|
{
|
||||||
if (_x == "field") exitwith {_return = true;};
|
if (_x == "field") exitWith {_return = true;};
|
||||||
if (_x == "RepairFacility" && _repairFacility) exitwith {_return = true;};
|
if (_x == "RepairFacility" && _repairFacility) exitWith {_return = true;};
|
||||||
if (_x == "RepairVehicle" && _repairVeh) exitwith {_return = true;};
|
if (_x == "RepairVehicle" && _repairVeh) exitWith {_return = true;};
|
||||||
if !(isnil _x) exitwith {
|
if !(isNil _x) exitWith {
|
||||||
local _val = missionNamespace getVariable _x;
|
private _val = missionNamespace getVariable _x;
|
||||||
if (typeName _val == "SCALAR") then {
|
if (typeName _val == "SCALAR") then {
|
||||||
_return = switch (_val) do {
|
_return = switch (_val) do {
|
||||||
case 0: {true}; //useAnywhere
|
case 0: {true}; //useAnywhere
|
||||||
@ -97,12 +97,12 @@ if (!("All" in _repairLocations)) then {
|
|||||||
};
|
};
|
||||||
} forEach _repairLocations;
|
} forEach _repairLocations;
|
||||||
};
|
};
|
||||||
if (!_return) exitwith {false};
|
if (!_return) exitWith {false};
|
||||||
|
|
||||||
//Check that there are required objects nearby
|
//Check that there are required objects nearby
|
||||||
local _requiredObjects = getArray (_config >> "claimObjects");
|
private _requiredObjects = getArray (_config >> "claimObjects");
|
||||||
if (!(_requiredObjects isEqualTo [])) then {
|
if (!(_requiredObjects isEqualTo [])) then {
|
||||||
local _objectsAvailable = [_caller, 5, _requiredObjects] call FUNC(getClaimObjects);
|
private _objectsAvailable = [_caller, 5, _requiredObjects] call FUNC(getClaimObjects);
|
||||||
if (_objectsAvailable isEqualTo []) then {
|
if (_objectsAvailable isEqualTo []) then {
|
||||||
TRACE_2("Missing Required Objects",_requiredObjects,_objectsAvailable);
|
TRACE_2("Missing Required Objects",_requiredObjects,_objectsAvailable);
|
||||||
_return = false
|
_return = false
|
||||||
|
@ -19,10 +19,9 @@
|
|||||||
|
|
||||||
params ["_unit", "_vehicle", "_hitPoint"];
|
params ["_unit", "_vehicle", "_hitPoint"];
|
||||||
TRACE_3("params",_unit,_vehicle,_hitPoint);
|
TRACE_3("params",_unit,_vehicle,_hitPoint);
|
||||||
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
|
|
||||||
// get current hitpoint damage
|
// get current hitpoint damage
|
||||||
private "_hitPointDamage";
|
private _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||||
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
|
||||||
|
|
||||||
// can't remove destroyed or already removed wheel
|
// can't remove destroyed or already removed wheel
|
||||||
if (_hitPointDamage >= 1) exitWith {};
|
if (_hitPointDamage >= 1) exitWith {};
|
||||||
@ -30,10 +29,9 @@ if (_hitPointDamage >= 1) exitWith {};
|
|||||||
// don't die by spawning / moving the wheel
|
// don't die by spawning / moving the wheel
|
||||||
["fixCollision", _unit] call EFUNC(common,localEvent);
|
["fixCollision", _unit] call EFUNC(common,localEvent);
|
||||||
|
|
||||||
// spawn wheel
|
// spawn track
|
||||||
private "_wheel";
|
private _newTrack = ["ACE_Track", getPosASL _unit, _hitPointDamage] call FUNC(spawnObject);
|
||||||
_wheel = ["ACE_Track", getPosASL _unit] call FUNC(spawnObject);
|
TRACE_2("new track created",_newTrack,damage _newTrack);
|
||||||
_wheel setdamage _hitPointDamage;
|
|
||||||
|
|
||||||
// raise event to set the new hitpoint damage
|
// raise event to set the new hitpoint damage
|
||||||
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, 1]] call EFUNC(common,targetEvent);
|
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, 1]] call EFUNC(common,targetEvent);
|
||||||
|
@ -19,10 +19,9 @@
|
|||||||
|
|
||||||
params ["_unit", "_vehicle", "_hitPoint"];
|
params ["_unit", "_vehicle", "_hitPoint"];
|
||||||
TRACE_3("params",_unit,_vehicle,_hitPoint);
|
TRACE_3("params",_unit,_vehicle,_hitPoint);
|
||||||
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
|
|
||||||
// get current hitpoint damage
|
// get current hitpoint damage
|
||||||
private "_hitPointDamage";
|
private _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||||
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
|
||||||
|
|
||||||
// can't remove destroyed or already removed wheel
|
// can't remove destroyed or already removed wheel
|
||||||
if (_hitPointDamage >= 1) exitWith {};
|
if (_hitPointDamage >= 1) exitWith {};
|
||||||
@ -31,9 +30,8 @@ if (_hitPointDamage >= 1) exitWith {};
|
|||||||
["fixCollision", _unit] call EFUNC(common,localEvent);
|
["fixCollision", _unit] call EFUNC(common,localEvent);
|
||||||
|
|
||||||
// spawn wheel
|
// spawn wheel
|
||||||
private "_wheel";
|
private _newWheel = ["ACE_Wheel", getPosASL _unit, _hitPointDamage] call FUNC(spawnObject);
|
||||||
_wheel = ["ACE_Wheel", getPosASL _unit] call FUNC(spawnObject);
|
TRACE_2("new wheel created",_newWheel,damage _newWheel);
|
||||||
_wheel setdamage _hitPointDamage;
|
|
||||||
|
|
||||||
// raise event to set the new hitpoint damage
|
// raise event to set the new hitpoint damage
|
||||||
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, 1]] call EFUNC(common,targetEvent);
|
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, 1]] call EFUNC(common,targetEvent);
|
||||||
|
@ -20,16 +20,16 @@
|
|||||||
params ["_unit", "_vehicle", "_hitPointIndex"];
|
params ["_unit", "_vehicle", "_hitPointIndex"];
|
||||||
TRACE_3("params",_unit,_vehicle,_hitPointIndex);
|
TRACE_3("params",_unit,_vehicle,_hitPointIndex);
|
||||||
|
|
||||||
local _postRepairDamageMin = [_unit] call FUNC(getPostRepairDamage);
|
private _postRepairDamageMin = [_unit] call FUNC(getPostRepairDamage);
|
||||||
|
|
||||||
(getAllHitPointsDamage _vehicle) params ["_allHitPoints"];
|
(getAllHitPointsDamage _vehicle) params ["_allHitPoints"];
|
||||||
local _hitPointClassname = _allHitPoints select _hitPointIndex;
|
private _hitPointClassname = _allHitPoints select _hitPointIndex;
|
||||||
|
|
||||||
// get current hitpoint damage
|
// get current hitpoint damage
|
||||||
local _hitPointCurDamage = _vehicle getHitIndex _hitPointIndex;
|
private _hitPointCurDamage = _vehicle getHitIndex _hitPointIndex;
|
||||||
|
|
||||||
// repair a max of 0.5, don't use negative values for damage
|
// repair a max of 0.5, don't use negative values for damage
|
||||||
local _hitPointNewDamage = (_hitPointCurDamage - 0.5) max _postRepairDamageMin;
|
private _hitPointNewDamage = (_hitPointCurDamage - 0.5) max _postRepairDamageMin;
|
||||||
|
|
||||||
if (_hitPointNewDamage < _hitPointCurDamage) then {
|
if (_hitPointNewDamage < _hitPointCurDamage) then {
|
||||||
// raise event to set the new hitpoint damage
|
// raise event to set the new hitpoint damage
|
||||||
@ -39,7 +39,7 @@ if (_hitPointNewDamage < _hitPointCurDamage) then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Get hitpoint groups if available
|
// Get hitpoint groups if available
|
||||||
local _hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(hitpointGroups);
|
private _hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(hitpointGroups);
|
||||||
if (isArray _hitpointGroupConfig) then {
|
if (isArray _hitpointGroupConfig) then {
|
||||||
// Retrieve hitpoint subgroup if current hitpoint is main hitpoint of a group
|
// Retrieve hitpoint subgroup if current hitpoint is main hitpoint of a group
|
||||||
{
|
{
|
||||||
@ -47,12 +47,12 @@ if (isArray _hitpointGroupConfig) then {
|
|||||||
// Exit using found hitpoint group if this hitpoint is leader of any
|
// Exit using found hitpoint group if this hitpoint is leader of any
|
||||||
if (_masterHitpoint == _hitPointClassname) exitWith {
|
if (_masterHitpoint == _hitPointClassname) exitWith {
|
||||||
{
|
{
|
||||||
local _subHitIndex = _allHitPoints find _x; //convert hitpoint classname to index
|
private _subHitIndex = _allHitPoints find _x; //convert hitpoint classname to index
|
||||||
if (_subHitIndex == -1) then {
|
if (_subHitIndex == -1) then {
|
||||||
ACE_LOGERROR_2("Invalid hitpoint %1 in hitpointGroups of %2",_x,_vehicle);
|
ACE_LOGERROR_2("Invalid hitpoint %1 in hitpointGroups of %2",_x,_vehicle);
|
||||||
} else {
|
} else {
|
||||||
local _subPointCurDamage = _vehicle getHitIndex _hitPointIndex;
|
private _subPointCurDamage = _vehicle getHitIndex _hitPointIndex;
|
||||||
local _subPointNewDamage = (_subPointCurDamage - 0.5) max _postRepairDamageMin;
|
private _subPointNewDamage = (_subPointCurDamage - 0.5) max _postRepairDamageMin;
|
||||||
if (_subPointNewDamage < _subPointCurDamage) then {
|
if (_subPointNewDamage < _subPointCurDamage) then {
|
||||||
TRACE_3("repairing sub point", _vehicle, _subHitIndex, _subPointNewDamage);
|
TRACE_3("repairing sub point", _vehicle, _subHitIndex, _subPointNewDamage);
|
||||||
["setVehicleHitPointDamage", _vehicle, [_vehicle, _subHitIndex, _subPointNewDamage]] call EFUNC(common,targetEvent);
|
["setVehicleHitPointDamage", _vehicle, [_vehicle, _subHitIndex, _subPointNewDamage]] call EFUNC(common,targetEvent);
|
||||||
@ -66,8 +66,8 @@ if (isArray _hitpointGroupConfig) then {
|
|||||||
// display text message if enabled
|
// display text message if enabled
|
||||||
if (GVAR(DisplayTextOnRepair)) then {
|
if (GVAR(DisplayTextOnRepair)) then {
|
||||||
// Find localized string
|
// Find localized string
|
||||||
local _textLocalized = localize ([LSTRING(RepairedHitPointFully), LSTRING(RepairedHitPointPartially)] select (_hitPointCurDamage > 0));
|
private _textLocalized = localize ([LSTRING(RepairedHitPointFully), LSTRING(RepairedHitPointPartially)] select (_hitPointCurDamage > 0));
|
||||||
local _textDefault = localize ([LSTRING(RepairedFully), LSTRING(RepairedPartially)] select (_hitPointCurDamage > 0));
|
private _textDefault = localize ([LSTRING(RepairedFully), LSTRING(RepairedPartially)] select (_hitPointCurDamage > 0));
|
||||||
([_hitPointClassname, _textLocalized, _textDefault] call FUNC(getHitPointString)) params ["_text"];
|
([_hitPointClassname, _textLocalized, _textDefault] call FUNC(getHitPointString)) params ["_text"];
|
||||||
|
|
||||||
// Display text
|
// Display text
|
||||||
|
@ -33,8 +33,8 @@ if ((isNull _track) || {!([_unit, _track, ["isNotDragging", "isNotCarrying", "is
|
|||||||
if ((damage _track) >= 1) exitWith {};
|
if ((damage _track) >= 1) exitWith {};
|
||||||
|
|
||||||
// get current hitpoint damage
|
// get current hitpoint damage
|
||||||
local _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
private _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||||
local _damageRepaired = (1 - (damage _track)) / 4; // require 4 tracks to fully replace one side
|
private _damageRepaired = (1 - (damage _track)) / 4; // require 4 tracks to fully replace one side
|
||||||
|
|
||||||
// don't die by spawning / moving the wheel
|
// don't die by spawning / moving the wheel
|
||||||
_hitPointDamage = (_hitPointDamage - _damageRepaired) min 0;
|
_hitPointDamage = (_hitPointDamage - _damageRepaired) min 0;
|
||||||
|
@ -30,13 +30,13 @@ if ((isNull _track) || {!([_unit, _track, ["isNotDragging", "isNotCarrying", "is
|
|||||||
};
|
};
|
||||||
|
|
||||||
// get current hitpoint damage
|
// get current hitpoint damage
|
||||||
local _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
private _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||||
|
|
||||||
// can't replace not destroyed wheel
|
// can't replace not destroyed wheel
|
||||||
if (_hitPointDamage < 1) exitWith {};
|
if (_hitPointDamage < 1) exitWith {};
|
||||||
|
|
||||||
// get track's damage
|
// get track's damage
|
||||||
local _newHitPointDamage = damage _track;
|
private _newHitPointDamage = damage _track;
|
||||||
|
|
||||||
// can't replace with a destroyed wheel
|
// can't replace with a destroyed wheel
|
||||||
if (_newHitPointDamage >= 1) exitWith {};
|
if (_newHitPointDamage >= 1) exitWith {};
|
||||||
|
@ -30,13 +30,13 @@ if ((isNull _wheel) || {!([_unit, _wheel, ["isNotDragging", "isNotCarrying", "is
|
|||||||
};
|
};
|
||||||
|
|
||||||
// get current hitpoint damage
|
// get current hitpoint damage
|
||||||
local _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
private _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||||
|
|
||||||
// can't replace not destroyed wheel
|
// can't replace not destroyed wheel
|
||||||
if (_hitPointDamage < 1) exitWith {};
|
if (_hitPointDamage < 1) exitWith {};
|
||||||
|
|
||||||
// get replacement wheel's damage
|
// get replacement wheel's damage
|
||||||
local _newHitPointDamage = damage _wheel;
|
private _newHitPointDamage = damage _wheel;
|
||||||
|
|
||||||
// can't replace a destroyed wheel
|
// can't replace a destroyed wheel
|
||||||
if (_newHitPointDamage >= 1) exitWith {};
|
if (_newHitPointDamage >= 1) exitWith {};
|
||||||
|
@ -20,14 +20,14 @@
|
|||||||
params ["_unit", "_maxRange", "_objectsToClaim"];
|
params ["_unit", "_maxRange", "_objectsToClaim"];
|
||||||
TRACE_3("params",_unit,_maxRange,_objectsToClaim);
|
TRACE_3("params",_unit,_maxRange,_objectsToClaim);
|
||||||
|
|
||||||
local _return = [];
|
private _return = [];
|
||||||
|
|
||||||
{
|
{
|
||||||
local _requiredList = _x; //eg ["ace_track", "ace_track"]
|
private _requiredList = _x; //eg ["ace_track", "ace_track"]
|
||||||
local _ableToAquire = []; //will be array of ojbects
|
private _ableToAquire = []; //will be array of ojbects
|
||||||
{
|
{
|
||||||
local _nearObjects = nearestObjects [_unit, [_x], _maxRange];
|
private _nearObjects = nearestObjects [_unit, [_x], _maxRange];
|
||||||
local _canClaimObject = objNull;
|
private _canClaimObject = objNull;
|
||||||
{
|
{
|
||||||
if ((!(_x in _ableToAquire))
|
if ((!(_x in _ableToAquire))
|
||||||
&& {[_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)}
|
&& {[_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)}
|
||||||
@ -39,6 +39,7 @@ local _return = [];
|
|||||||
} forEach _x;
|
} forEach _x;
|
||||||
TRACE_2("Check required equals available",_requiredList,_ableToAquire);
|
TRACE_2("Check required equals available",_requiredList,_ableToAquire);
|
||||||
if ((count _ableToAquire) == (count _requiredList)) exitWith {_return = _ableToAquire};
|
if ((count _ableToAquire) == (count _requiredList)) exitWith {_return = _ableToAquire};
|
||||||
|
false
|
||||||
} count _objectsToClaim;
|
} count _objectsToClaim;
|
||||||
|
|
||||||
_return
|
_return
|
||||||
|
@ -13,15 +13,16 @@
|
|||||||
* 1: Added Hitpoint (default: [])
|
* 1: Added Hitpoint (default: [])
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_getHitPointString
|
* ["HitFuel", "Repairing %1 ...", "Repairing HitFuel"] call ace_repair_fnc_getHitPointString
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_track", "_trackNames", "_trackStrings", "_trackAmount", "_text", "_toFind", "_trackIndex", "_combinedString"];
|
|
||||||
params ["_hitPoint", "_textLocalized", "_textDefault", ["_trackArray", []]];
|
params ["_hitPoint", "_textLocalized", "_textDefault", ["_trackArray", []]];
|
||||||
|
|
||||||
|
private ["_track", "_trackNames", "_trackStrings", "_trackAmount", "_text", "_toFind", "_trackIndex", "_combinedString"];
|
||||||
|
|
||||||
_track = if (count _trackArray > 0) then {true} else {false};
|
_track = if (count _trackArray > 0) then {true} else {false};
|
||||||
_trackNames = [];
|
_trackNames = [];
|
||||||
_trackStrings = [];
|
_trackStrings = [];
|
||||||
@ -37,7 +38,7 @@ if (_track) then {
|
|||||||
_text = LSTRING(Hit);
|
_text = LSTRING(Hit);
|
||||||
|
|
||||||
// Remove "Hit" from hitpoint name if one exists
|
// Remove "Hit" from hitpoint name if one exists
|
||||||
_toFind = if (_hitPoint find "Hit" == 0) then {
|
_toFind = if ((toLower _hitPoint) find "hit" == 0) then {
|
||||||
[_hitPoint, 3] call CBA_fnc_substr
|
[_hitPoint, 3] call CBA_fnc_substr
|
||||||
} else {
|
} else {
|
||||||
_hitPoint
|
_hitPoint
|
||||||
@ -83,6 +84,7 @@ for "_i" from 0 to (count _hitPoint) do {
|
|||||||
|
|
||||||
// Don't display part name if no string is found in stringtable
|
// Don't display part name if no string is found in stringtable
|
||||||
if (_text == LSTRING(Hit)) then {
|
if (_text == LSTRING(Hit)) then {
|
||||||
|
if (_hitPoint != "") then { ACE_LOGWARNING_1("Hitpoint [%1] - could not be localized", _hitPoint); };
|
||||||
_text = _textDefault;
|
_text = _textDefault;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ params ["_unit"];
|
|||||||
TRACE_1("params",_unit);
|
TRACE_1("params",_unit);
|
||||||
// TODO when near repair station, full repair?
|
// TODO when near repair station, full repair?
|
||||||
|
|
||||||
if (([_unit] call FUNC(isInRepairFacility) || {[_unit] call FUNC(isNearRepairVehicle)})) exitwith {0};
|
if (([_unit] call FUNC(isInRepairFacility) || {[_unit] call FUNC(isNearRepairVehicle)})) exitWith {0};
|
||||||
|
|
||||||
if ([_unit, GVAR(engineerSetting_Repair) + 1] call FUNC(isEngineer)) exitWith {GVAR(repairDamageThreshold_Engineer)};
|
if ([_unit, GVAR(engineerSetting_Repair) + 1] call FUNC(isEngineer)) exitWith {GVAR(repairDamageThreshold_Engineer)};
|
||||||
if ([_unit, GVAR(engineerSetting_Repair)] call FUNC(isEngineer)) exitWith {GVAR(repairDamageThreshold)};
|
if ([_unit, GVAR(engineerSetting_Repair)] call FUNC(isEngineer)) exitWith {GVAR(repairDamageThreshold)};
|
||||||
|
@ -23,10 +23,10 @@ private ["_return"];
|
|||||||
|
|
||||||
_return = true;
|
_return = true;
|
||||||
{
|
{
|
||||||
if (typeName _x == "ARRAY" && {({[_unit, _x] call EFUNC(common,hasItem)} count _x == 0)}) exitwith {
|
if (typeName _x == "ARRAY" && {({[_unit, _x] call EFUNC(common,hasItem)} count _x == 0)}) exitWith {
|
||||||
_return = false;
|
_return = false;
|
||||||
};
|
};
|
||||||
if (typeName _x == "STRING" && {!([_unit, _x] call EFUNC(common,hasItem))}) exitwith {
|
if (typeName _x == "STRING" && {!([_unit, _x] call EFUNC(common,hasItem))}) exitWith {
|
||||||
_return = false;
|
_return = false;
|
||||||
};
|
};
|
||||||
} forEach _items;
|
} forEach _items;
|
||||||
|
@ -26,7 +26,7 @@ _repairFacility = [];
|
|||||||
|
|
||||||
_objects = (lineIntersectsWith [_object modelToWorldVisual [0, 0, (_position select 2)], _object modelToWorldVisual [0, 0, (_position select 2) +10], _object]);
|
_objects = (lineIntersectsWith [_object modelToWorldVisual [0, 0, (_position select 2)], _object modelToWorldVisual [0, 0, (_position select 2) +10], _object]);
|
||||||
{
|
{
|
||||||
if (((typeOf _x) in _repairFacility) || (_x getVariable ["ACE_isRepairFacility",0]) > 0) exitwith {
|
if (((typeOf _x) in _repairFacility) || (_x getVariable ["ACE_isRepairFacility",0]) > 0) exitWith {
|
||||||
_isInBuilding = true;
|
_isInBuilding = true;
|
||||||
};
|
};
|
||||||
} forEach _objects;
|
} forEach _objects;
|
||||||
@ -34,7 +34,7 @@ _objects = (lineIntersectsWith [_object modelToWorldVisual [0, 0, (_position sel
|
|||||||
if (!_isInBuilding) then {
|
if (!_isInBuilding) then {
|
||||||
_objects = position _object nearObjects 7.5;
|
_objects = position _object nearObjects 7.5;
|
||||||
{
|
{
|
||||||
if (((typeOf _x) in _repairFacility) || (_x getVariable ["ACE_isRepairFacility",0]) > 0) exitwith {
|
if (((typeOf _x) in _repairFacility) || (_x getVariable ["ACE_isRepairFacility",0]) > 0) exitWith {
|
||||||
_isInBuilding = true;
|
_isInBuilding = true;
|
||||||
};
|
};
|
||||||
} forEach _objects;
|
} forEach _objects;
|
||||||
|
@ -24,7 +24,7 @@ _nearObjects = nearestObjects [_unit, ["Air","LandVehicle"], 20];
|
|||||||
|
|
||||||
_return = false;
|
_return = false;
|
||||||
{
|
{
|
||||||
if ([_x] call FUNC(isRepairVehicle)) exitwith {_return = true;};
|
if ([_x] call FUNC(isRepairVehicle)) exitWith {_return = true;};
|
||||||
} forEach _nearObjects;
|
} forEach _nearObjects;
|
||||||
|
|
||||||
_return;
|
_return;
|
||||||
|
@ -18,6 +18,6 @@
|
|||||||
params ["_vehicle"];
|
params ["_vehicle"];
|
||||||
TRACE_1("params",_vehicle);
|
TRACE_1("params",_vehicle);
|
||||||
|
|
||||||
if (_vehicle isKindOf "CAManBase") exitwith {false};
|
if (_vehicle isKindOf "CAManBase") exitWith {false};
|
||||||
|
|
||||||
((_vehicle getVariable ["ACE_isRepairVehicle", getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(canRepair))]) > 0);
|
((_vehicle getVariable ["ACE_isRepairVehicle", getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(canRepair))]) > 0);
|
||||||
|
@ -41,5 +41,6 @@ if (!isNull _logic) then {
|
|||||||
// Add spare parts
|
// Add spare parts
|
||||||
{
|
{
|
||||||
[_x, _amount, _part, true] call FUNC(addSpareParts);
|
[_x, _amount, _part, true] call FUNC(addSpareParts);
|
||||||
|
false
|
||||||
} count _list;
|
} count _list;
|
||||||
};
|
};
|
||||||
|
@ -16,33 +16,45 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_vehicle"];
|
params ["_vehicle"];
|
||||||
TRACE_1("params",_vehicle);
|
TRACE_2("params",_vehicle, typeOf _vehicle);
|
||||||
|
|
||||||
// Can't execute all commands if the vehicle isn't local, exit if that's so
|
// Can't execute all commands if the vehicle isn't local, exit if that's so
|
||||||
if !(local _vehicle) exitWith {};
|
if !(local _vehicle) exitWith {ACE_LOGERROR_1("Vehicle Not Local %1", _vehicle);};
|
||||||
|
|
||||||
private ["_hitPoints", "_config", "_dependentHitPoints", "_dependentHitPointScripts", "_damage"];
|
(getAllHitPointsDamage _vehicle) params [["_allHitPoints", []]];
|
||||||
|
|
||||||
_hitPoints = [_vehicle] call EFUNC(common,getHitPoints);
|
private _config = configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints";
|
||||||
_config = configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints";
|
|
||||||
|
|
||||||
// define global variables. Needed to parse the depends config entries. Also find dependent hitpoints.
|
private _realHitPoints = [];
|
||||||
|
private _dependentHitPoints = [];
|
||||||
_dependentHitPoints = [];
|
private _dependentHitPointScripts = [];
|
||||||
_dependentHitPointScripts = [];
|
|
||||||
|
|
||||||
Total = damage _vehicle;
|
|
||||||
|
|
||||||
|
// Find dependent hitpoints
|
||||||
{
|
{
|
||||||
missionNamespace setVariable [_x, _vehicle getHitPointDamage _x];
|
if ((_x != "") && {isClass (_config >> _x)} && {!(_x in _realHitPoints)}) then {
|
||||||
|
_realHitPoints pushBack _x;
|
||||||
if (isText (_config >> _x >> "depends")) then {
|
if (isText (_config >> _x >> "depends")) then {
|
||||||
_dependentHitPoints pushBack _x;
|
_dependentHitPoints pushBack _x;
|
||||||
_dependentHitPointScripts pushBack compile getText (_config >> _x >> "depends");
|
_dependentHitPointScripts pushBack compile getText (_config >> _x >> "depends");
|
||||||
};
|
};
|
||||||
} forEach _hitPoints;
|
};
|
||||||
|
} forEach _allHitPoints;
|
||||||
|
|
||||||
|
TRACE_2("",_realHitPoints,_dependentHitPoints);
|
||||||
|
|
||||||
|
// Don't bother setting variables if no depends on vehicle:
|
||||||
|
if (_dependentHitPoints isEqualTo []) exitWith {};
|
||||||
|
|
||||||
|
|
||||||
|
// Define global variables
|
||||||
|
Total = damage _vehicle;
|
||||||
|
{
|
||||||
|
missionNamespace setVariable [_x, _vehicle getHitPointDamage _x];
|
||||||
|
} forEach _realHitPoints;
|
||||||
|
|
||||||
// apply normalized damage to all dependand hitpoints
|
// apply normalized damage to all dependand hitpoints
|
||||||
{
|
{
|
||||||
_damage = call (_dependentHitPointScripts select _forEachIndex);
|
private _damage = call (_dependentHitPointScripts select _forEachIndex);
|
||||||
|
TRACE_2("setting depend hitpoint", _x, _damage);
|
||||||
_vehicle setHitPointDamage [_x, _damage];
|
_vehicle setHitPointDamage [_x, _damage];
|
||||||
} forEach _dependentHitPoints;
|
} forEach _dependentHitPoints;
|
||||||
|
@ -21,22 +21,22 @@
|
|||||||
params ["_caller", "_target", "_hitPoint", "_className"];
|
params ["_caller", "_target", "_hitPoint", "_className"];
|
||||||
TRACE_4("params",_calller,_target,_hitPoint,_className);
|
TRACE_4("params",_calller,_target,_hitPoint,_className);
|
||||||
|
|
||||||
private["_callbackProgress", "_callerAnim", "_calller", "_condition", "_config", "_consumeItems", "_displayText", "_engineerRequired", "_iconDisplayed", "_items", "_locations", "_repairTime", "_repairTimeConfig", "_return", "_usersOfItems", "_vehicleStateCondition", "_wpn", "_settingName", "_settingItemsArray", "_hitPointClassname"];
|
private["_callbackProgress", "_callerAnim", "_calller", "_condition", "_config", "_consumeItems", "_displayText", "_engineerRequired", "_iconDisplayed", "_items", "_repairTime", "_repairTimeConfig", "_return", "_usersOfItems", "_vehicleStateCondition", "_wpn", "_settingName", "_settingItemsArray", "_hitPointClassname"];
|
||||||
|
|
||||||
_config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className);
|
_config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className);
|
||||||
if !(isClass _config) exitwith {false}; // or go for a default?
|
if !(isClass _config) exitWith {false}; // or go for a default?
|
||||||
|
|
||||||
_engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
|
_engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
|
||||||
getNumber (_config >> "requiredEngineer");
|
getNumber (_config >> "requiredEngineer");
|
||||||
} else {
|
} else {
|
||||||
// Check for required class
|
// Check for required class
|
||||||
if (isText (_config >> "requiredEngineer")) exitwith {
|
if (isText (_config >> "requiredEngineer")) exitWith {
|
||||||
missionNamespace getVariable [(getText (_config >> "requiredEngineer")), 0];
|
missionNamespace getVariable [(getText (_config >> "requiredEngineer")), 0];
|
||||||
};
|
};
|
||||||
0;
|
0;
|
||||||
};
|
};
|
||||||
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitwith {false};
|
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitWith {false};
|
||||||
if (isEngineOn _target) exitwith {false};
|
if (isEngineOn _target) exitWith {false};
|
||||||
|
|
||||||
//Items can be an array of required items or a string to a ACE_Setting array
|
//Items can be an array of required items or a string to a ACE_Setting array
|
||||||
_items = if (isArray (_config >> "items")) then {
|
_items = if (isArray (_config >> "items")) then {
|
||||||
@ -49,12 +49,12 @@ _items = if (isArray (_config >> "items")) then {
|
|||||||
};
|
};
|
||||||
_settingItemsArray select (missionNamespace getVariable _settingName);
|
_settingItemsArray select (missionNamespace getVariable _settingName);
|
||||||
};
|
};
|
||||||
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitwith {false};
|
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false};
|
||||||
|
|
||||||
_return = true;
|
_return = true;
|
||||||
if (getText (_config >> "condition") != "") then {
|
if (getText (_config >> "condition") != "") then {
|
||||||
_condition = getText (_config >> "condition");
|
_condition = getText (_config >> "condition");
|
||||||
if (isnil _condition) then {
|
if (isNil _condition) then {
|
||||||
_condition = compile _condition;
|
_condition = compile _condition;
|
||||||
} else {
|
} else {
|
||||||
_condition = missionNamespace getVariable _condition;
|
_condition = missionNamespace getVariable _condition;
|
||||||
@ -65,25 +65,25 @@ if (getText (_config >> "condition") != "") then {
|
|||||||
_return = [_caller, _target, _hitPoint, _className] call _condition;
|
_return = [_caller, _target, _hitPoint, _className] call _condition;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
if (!_return) exitwith {false};
|
if (!_return) exitWith {false};
|
||||||
|
|
||||||
// _vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
|
// _vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
|
||||||
// missionNamespace getVariable [getText(_config >> "vehicleStateCondition"), 0]
|
// missionNamespace getVariable [getText(_config >> "vehicleStateCondition"), 0]
|
||||||
// } else {
|
// } else {
|
||||||
// getNumber(_config >> "vehicleStateCondition")
|
// getNumber(_config >> "vehicleStateCondition")
|
||||||
// };
|
// };
|
||||||
// if (_vehicleStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitwith {false};
|
// if (_vehicleStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitWith {false};
|
||||||
|
|
||||||
local _repairLocations = getArray (_config >> "repairLocations");
|
private _repairLocations = getArray (_config >> "repairLocations");
|
||||||
if (!("All" in _repairLocations)) then {
|
if (!("All" in _repairLocations)) then {
|
||||||
local _repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
|
private _repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
|
||||||
local _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
|
private _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
|
||||||
{
|
{
|
||||||
if (_x == "field") exitwith {_return = true;};
|
if (_x == "field") exitWith {_return = true;};
|
||||||
if (_x == "RepairFacility" && _repairFacility) exitwith {_return = true;};
|
if (_x == "RepairFacility" && _repairFacility) exitWith {_return = true;};
|
||||||
if (_x == "RepairVehicle" && _repairVeh) exitwith {_return = true;};
|
if (_x == "RepairVehicle" && _repairVeh) exitWith {_return = true;};
|
||||||
if !(isnil _x) exitwith {
|
if !(isNil _x) exitWith {
|
||||||
local _val = missionNamespace getVariable _x;
|
private _val = missionNamespace getVariable _x;
|
||||||
if (typeName _val == "SCALAR") then {
|
if (typeName _val == "SCALAR") then {
|
||||||
_return = switch (_val) do {
|
_return = switch (_val) do {
|
||||||
case 0: {true}; //useAnywhere
|
case 0: {true}; //useAnywhere
|
||||||
@ -97,8 +97,8 @@ if (!("All" in _repairLocations)) then {
|
|||||||
} forEach _repairLocations;
|
} forEach _repairLocations;
|
||||||
};
|
};
|
||||||
|
|
||||||
local _requiredObjects = getArray (_config >> "claimObjects");
|
private _requiredObjects = getArray (_config >> "claimObjects");
|
||||||
local _claimObjectsAvailable = [];
|
private _claimObjectsAvailable = [];
|
||||||
if (!(_requiredObjects isEqualTo [])) then {
|
if (!(_requiredObjects isEqualTo [])) then {
|
||||||
_claimObjectsAvailable = [_caller, 5, _requiredObjects] call FUNC(getClaimObjects);
|
_claimObjectsAvailable = [_caller, 5, _requiredObjects] call FUNC(getClaimObjects);
|
||||||
if (_claimObjectsAvailable isEqualTo []) then {
|
if (_claimObjectsAvailable isEqualTo []) then {
|
||||||
@ -107,7 +107,7 @@ if (!(_requiredObjects isEqualTo [])) then {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if !(_return && alive _target) exitwith {false};
|
if !(_return && alive _target) exitWith {false};
|
||||||
//Last exitWith: repair_success or repair_failure will be run
|
//Last exitWith: repair_success or repair_failure will be run
|
||||||
|
|
||||||
//Claim required objects
|
//Claim required objects
|
||||||
@ -120,7 +120,7 @@ _consumeItems = if (isNumber (_config >> "itemConsumed")) then {
|
|||||||
getNumber (_config >> "itemConsumed");
|
getNumber (_config >> "itemConsumed");
|
||||||
} else {
|
} else {
|
||||||
// Check for required class
|
// Check for required class
|
||||||
if (isText (_config >> "itemConsumed")) exitwith {
|
if (isText (_config >> "itemConsumed")) exitWith {
|
||||||
missionNamespace getVariable [(getText (_config >> "itemConsumed")), 0];
|
missionNamespace getVariable [(getText (_config >> "itemConsumed")), 0];
|
||||||
};
|
};
|
||||||
0;
|
0;
|
||||||
@ -174,14 +174,14 @@ if (vehicle _caller == _caller && {_callerAnim != ""}) then {
|
|||||||
_repairTime = if (isNumber (_config >> "repairingTime")) then {
|
_repairTime = if (isNumber (_config >> "repairingTime")) then {
|
||||||
getNumber (_config >> "repairingTime");
|
getNumber (_config >> "repairingTime");
|
||||||
} else {
|
} else {
|
||||||
if (isText (_config >> "repairingTime")) exitwith {
|
if (isText (_config >> "repairingTime")) exitWith {
|
||||||
_repairTimeConfig = getText(_config >> "repairingTime");
|
_repairTimeConfig = getText(_config >> "repairingTime");
|
||||||
if (isnil _repairTimeConfig) then {
|
if (isNil _repairTimeConfig) then {
|
||||||
_repairTimeConfig = compile _repairTimeConfig;
|
_repairTimeConfig = compile _repairTimeConfig;
|
||||||
} else {
|
} else {
|
||||||
_repairTimeConfig = missionNamespace getVariable _repairTimeConfig;
|
_repairTimeConfig = missionNamespace getVariable _repairTimeConfig;
|
||||||
};
|
};
|
||||||
if (typeName _repairTimeConfig == "SCALAR") exitwith {
|
if (typeName _repairTimeConfig == "SCALAR") exitWith {
|
||||||
_repairTimeConfig;
|
_repairTimeConfig;
|
||||||
};
|
};
|
||||||
[_caller, _target, _hitPoint, _className] call _repairTimeConfig;
|
[_caller, _target, _hitPoint, _className] call _repairTimeConfig;
|
||||||
@ -197,7 +197,8 @@ _hitPointClassname = if ((typeName _hitPoint) == "STRING") then {
|
|||||||
((getAllHitPointsDamage _target) select 0) select _hitPoint
|
((getAllHitPointsDamage _target) select 0) select _hitPoint
|
||||||
};
|
};
|
||||||
_processText = getText (_config >> "displayNameProgress");
|
_processText = getText (_config >> "displayNameProgress");
|
||||||
([_hitPointClassname, _processText, _processText] call FUNC(getHitPointString)) params ["_text"];
|
private _backupText = format [localize LSTRING(RepairingHitPoint), _hitPointClassname];
|
||||||
|
([_hitPointClassname, _processText, _backupText] call FUNC(getHitPointString)) params ["_text"];
|
||||||
|
|
||||||
TRACE_4("display",_hitPoint,_hitPointClassname,_processText,_text);
|
TRACE_4("display",_hitPoint,_hitPointClassname,_processText,_text);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_vehicle", "_hitPointIndex", "_hitPointDamage"];
|
params ["_vehicle", "_hitPointIndex", "_hitPointDamage"];
|
||||||
TRACE_3("params",_vehicle,_hitPointIndex,_hitPointDamage);
|
TRACE_4("params",_vehicle,typeOf _vehicle,_hitPointIndex,_hitPointDamage);
|
||||||
|
|
||||||
private["_damageNew", "_damageOld", "_hitPointDamageRepaired", "_hitPointDamageSumOld", "_realHitpointCount", "_selectionName"];
|
private["_damageNew", "_damageOld", "_hitPointDamageRepaired", "_hitPointDamageSumOld", "_realHitpointCount", "_selectionName"];
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ _hitPointDamageRepaired = 0; //positive for repairs : newSum = (oldSum - repaire
|
|||||||
if ((!isNil {_vehicle getHit _selectionName}) && {_x != ""}) then {
|
if ((!isNil {_vehicle getHit _selectionName}) && {_x != ""}) then {
|
||||||
_realHitpointCount = _realHitpointCount + 1;
|
_realHitpointCount = _realHitpointCount + 1;
|
||||||
|
|
||||||
if ((!(_x in IGNORED_HITPOINTS)) && {!isText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints" >> _x >> "depends")}) then {
|
if ((((toLower _x) find "glass") == -1) && {!isText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints" >> _x >> "depends")}) then {
|
||||||
_hitPointDamageSumOld = _hitPointDamageSumOld + (_allHitPointDamages select _forEachIndex);
|
_hitPointDamageSumOld = _hitPointDamageSumOld + (_allHitPointDamages select _forEachIndex);
|
||||||
if (_forEachIndex == _hitPointIndex) then {
|
if (_forEachIndex == _hitPointIndex) then {
|
||||||
_hitPointDamageRepaired = (_allHitPointDamages select _forEachIndex) - _hitPointDamage;
|
_hitPointDamageRepaired = (_allHitPointDamages select _forEachIndex) - _hitPointDamage;
|
||||||
@ -80,4 +80,4 @@ _allHitPointDamages set [_hitPointIndex, _hitPointDamage];
|
|||||||
} forEach _allHitPointDamages;
|
} forEach _allHitPointDamages;
|
||||||
|
|
||||||
// normalize hitpoints
|
// normalize hitpoints
|
||||||
// [_vehicle] call FUNC(normalizeHitPoints);
|
[_vehicle] call FUNC(normalizeHitPoints);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* 2: Damage <NUMBER>
|
* 2: Damage <NUMBER>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* The new object <OBJECT>
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* ["classname", [0, 0, 0], 1] call ace_repair_fnc_spawnObject
|
* ["classname", [0, 0, 0], 1] call ace_repair_fnc_spawnObject
|
||||||
@ -23,10 +23,12 @@ TRACE_3("params",_item,_position,_damage);
|
|||||||
// randomized end position
|
// randomized end position
|
||||||
_position = _position vectorAdd [1 - random 2, 1 - random 2, 0];
|
_position = _position vectorAdd [1 - random 2, 1 - random 2, 0];
|
||||||
|
|
||||||
_item = createVehicle [_item, _position, [], 0, "NONE"];
|
private _newObject = createVehicle [_item, _position, [], 0, "NONE"];
|
||||||
_item setPosASL _position;
|
_newObject setPosASL _position;
|
||||||
|
|
||||||
["fixCollision", _item] call EFUNC(common,localEvent);
|
_newObject setDamage _damage;
|
||||||
["fixPosition", _item] call EFUNC(common,localEvent);
|
|
||||||
|
|
||||||
_item setDamage _damage;
|
["fixCollision", _newObject] call EFUNC(common,localEvent);
|
||||||
|
["fixPosition", _newObject] call EFUNC(common,localEvent);
|
||||||
|
|
||||||
|
_newObject
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
params ["_unit", "_item"];
|
params ["_unit", "_item"];
|
||||||
TRACE_2("params",_unit,_item);
|
TRACE_2("params",_unit,_item);
|
||||||
|
|
||||||
if ([_unit, _item] call EFUNC(common,hasItem)) exitwith {
|
if ([_unit, _item] call EFUNC(common,hasItem)) exitWith {
|
||||||
[[_unit, _item], QUOTE(EFUNC(common,useItem)), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
|
[[_unit, _item], QUOTE(EFUNC(common,useItem)), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
|
||||||
[true, _unit];
|
[true, _unit];
|
||||||
};
|
};
|
||||||
|
@ -27,14 +27,14 @@ _itemsUsedBy = [];
|
|||||||
if (typeName _x == "ARRAY") then {
|
if (typeName _x == "ARRAY") then {
|
||||||
{
|
{
|
||||||
_itemUsedInfo = [_unit, _x] call FUNC(useItem);
|
_itemUsedInfo = [_unit, _x] call FUNC(useItem);
|
||||||
if (_itemUsedInfo select 0) exitwith { _itemsUsedBy pushback [(_itemUsedInfo select 1), _x]};
|
if (_itemUsedInfo select 0) exitWith { _itemsUsedBy pushback [(_itemUsedInfo select 1), _x]};
|
||||||
} forEach _x;
|
} forEach _x;
|
||||||
};
|
};
|
||||||
|
|
||||||
// handle required item
|
// handle required item
|
||||||
if (typeName _x == "STRING") then {
|
if (typeName _x == "STRING") then {
|
||||||
_itemUsedInfo = [_unit, _x] call FUNC(useItem);
|
_itemUsedInfo = [_unit, _x] call FUNC(useItem);
|
||||||
if (_itemUsedInfo select 0) exitwith { _itemsUsedBy pushback [(_itemUsedInfo select 1), _x]};
|
if (_itemUsedInfo select 0) exitWith { _itemsUsedBy pushback [(_itemUsedInfo select 1), _x]};
|
||||||
};
|
};
|
||||||
} forEach _items;
|
} forEach _items;
|
||||||
|
|
||||||
|
@ -13,6 +13,4 @@
|
|||||||
|
|
||||||
#include "\z\ace\addons\main\script_macros.hpp"
|
#include "\z\ace\addons\main\script_macros.hpp"
|
||||||
|
|
||||||
|
|
||||||
#define IGNORED_HITPOINTS ["HitGlass1", "HitGlass2", "HitGlass3", "HitGlass4", "HitGlass5", "HitGlass6", "HitGlass7", "HitGlass8", "HitGlass9", "HitGlass10", "HitGlass11", "HitGlass12", "HitGlass13", "HitGlass14", "HitGlass15", "HitRGlass", "HitLGlass", "Glass_1_hitpoint", "Glass_2_hitpoint", "Glass_3_hitpoint", "Glass_4_hitpoint", "Glass_5_hitpoint", "Glass_6_hitpoint", "Glass_7_hitpoint", "Glass_8_hitpoint", "Glass_9_hitpoint", "Glass_10_hitpoint", "Glass_11_hitpoint", "Glass_12_hitpoint", "Glass_13_hitpoint", "Glass_14_hitpoint", "Glass_15_hitpoint", "Glass_16_hitpoint", "Glass_17_hitpoint", "Glass_18_hitpoint", "Glass_19_hitpoint", "Glass_20_hitpoint"]
|
|
||||||
#define TRACK_HITPOINTS ["HitLTrack", "HitRTrack"]
|
#define TRACK_HITPOINTS ["HitLTrack", "HitRTrack"]
|
||||||
|
Loading…
Reference in New Issue
Block a user