mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
commit
ca0cfc9bbf
addons
common/functions
repair
ACE_Repair.hppCfgVehicles.hppXEH_preInit.sqf
functions
fnc_addRepairActions.sqffnc_addSpareParts.sqffnc_canMiscRepair.sqffnc_canRepair.sqffnc_canRepairTrack.sqffnc_canReplaceTrack.sqffnc_canReplaceWheel.sqffnc_doFullRepair.sqffnc_doRemoveTrack.sqffnc_doRemoveWheel.sqffnc_doRepair.sqffnc_doRepairTrack.sqffnc_doReplaceTrack.sqffnc_doReplaceWheel.sqffnc_getClaimObjects.sqffnc_getHitPointString.sqffnc_getPostRepairDamage.sqffnc_getWheelHitPointsWithSelections.sqffnc_hasItems.sqffnc_isEngineer.sqffnc_isInRepairFacility.sqffnc_isNearRepairVehicle.sqffnc_isRepairVehicle.sqffnc_moduleAddSpareParts.sqffnc_moduleAssignEngineer.sqffnc_moduleAssignRepairFacility.sqffnc_moduleAssignRepairVehicle.sqffnc_moduleRepairSettings.sqffnc_normalizeHitPoints.sqffnc_repair.sqffnc_repair_failure.sqffnc_repair_success.sqffnc_setHitPointDamage.sqffnc_spawnObject.sqffnc_useItem.sqffnc_useItems.sqf
script_component.hpp@ -24,7 +24,7 @@ _hitPointsWithSelections = getAllHitPointsDamage _vehicle;
|
||||
|
||||
// get correct format on vehicles without any hitpoints
|
||||
if (_hitPointsWithSelections isEqualTo []) then {
|
||||
_hitPointsWithSelections = [[],[],[]];
|
||||
_hitPointsWithSelections = [[],[],[]];
|
||||
};
|
||||
|
||||
_hitPointsWithSelections resize 2;
|
||||
|
@ -8,10 +8,17 @@
|
||||
* Return Value:
|
||||
* is the unit an engineer <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_common_fnc_isEngineer
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
_unit getVariable ["ACE_isEngineer", getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "engineer") == 1] // return
|
||||
private _isEngineer = _unit getVariable ["ACE_isEngineer", getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "engineer") == 1];
|
||||
//Handle ace_repair modules setting this to a number
|
||||
if ((typeName _isEngineer) == "SCALAR") then {_isEngineer = _isEngineer > 0};
|
||||
|
||||
_isEngineer
|
||||
|
@ -4,14 +4,15 @@ class ACE_Repair {
|
||||
displayName = CSTRING(ReplaceWheel);
|
||||
displayNameProgress = CSTRING(ReplacingWheel);
|
||||
|
||||
locations[] = {"All"};
|
||||
repairLocations[] = {"All"};
|
||||
requiredEngineer = QGVAR(engineerSetting_Wheel);
|
||||
repairingTime = 10;
|
||||
repairingTimeSelfCoef = 1;
|
||||
items = QGVAR(wheelRepairRequiredItems);
|
||||
condition = QUOTE(call FUNC(canReplaceWheel));
|
||||
itemConsumed = 0;
|
||||
|
||||
claimObjects[] = {{"ACE_Wheel"}};
|
||||
|
||||
callbackSuccess = QUOTE(call FUNC(doReplaceWheel));
|
||||
callbackFailure = "";
|
||||
callbackProgress = "";
|
||||
@ -27,6 +28,7 @@ class ACE_Repair {
|
||||
displayNameProgress = CSTRING(RemovingWheel);
|
||||
condition = QUOTE(call FUNC(canRemove));
|
||||
callbackSuccess = QUOTE(call FUNC(doRemoveWheel));
|
||||
claimObjects[] = {};
|
||||
};
|
||||
class MiscRepair: ReplaceWheel {
|
||||
displayName = CSTRING(Repairing); // let's make empty string an auto generated string
|
||||
@ -36,6 +38,7 @@ class ACE_Repair {
|
||||
repairingTime = 15;
|
||||
callbackSuccess = QUOTE(call FUNC(doRepair));
|
||||
items[] = {"ToolKit"};
|
||||
claimObjects[] = {};
|
||||
};
|
||||
class RepairTrack: MiscRepair {
|
||||
displayName = CSTRING(Repairing);
|
||||
@ -43,6 +46,7 @@ class ACE_Repair {
|
||||
condition = QUOTE(call FUNC(canRepairTrack));
|
||||
callbackSuccess = QUOTE(call FUNC(doRepairTrack));
|
||||
requiredEngineer = QGVAR(engineerSetting_Wheel);
|
||||
claimObjects[] = {{"ACE_Track"}};
|
||||
};
|
||||
class RemoveTrack: MiscRepair {
|
||||
displayName = CSTRING(RemoveTrack);
|
||||
@ -57,6 +61,7 @@ class ACE_Repair {
|
||||
condition = QUOTE(call FUNC(canReplaceTrack));
|
||||
callbackSuccess = QUOTE(call FUNC(doReplaceTrack));
|
||||
requiredEngineer = QGVAR(engineerSetting_Wheel);
|
||||
claimObjects[] = {{"ACE_Track"}};
|
||||
};
|
||||
class FullRepair: MiscRepair {
|
||||
displayName = CSTRING(fullRepair);
|
||||
|
@ -404,4 +404,7 @@ class CfgVehicles {
|
||||
class B_Quadbike_01_F: Quadbike_01_base_F {
|
||||
GVAR(hitpointPositions[]) = { {"HitEngine", {0, 0.5, -0.7}}, {"HitFuel", {0, 0, -0.5}} };
|
||||
};
|
||||
class Hatchback_01_base_F: Car_F {
|
||||
GVAR(hitpointPositions[]) = {{"HitBody", {0, 0.7, -0.5}}, {"HitFuel", {0, -1.75, -0.75}}};
|
||||
};
|
||||
};
|
||||
|
@ -17,6 +17,7 @@ PREP(doRepair);
|
||||
PREP(doRepairTrack);
|
||||
PREP(doReplaceTrack);
|
||||
PREP(doReplaceWheel);
|
||||
PREP(getClaimObjects);
|
||||
PREP(getHitPointString);
|
||||
PREP(getPostRepairDamage);
|
||||
PREP(getWheelHitPointsWithSelections);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Author: commy2, SilentSpike
|
||||
* Checks if the vehicles class already has the actions initialized, otherwise add all available repair options. Calleed from init EH.
|
||||
*
|
||||
* Arguments:
|
||||
@ -15,10 +15,12 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_vehicle"];
|
||||
TRACE_1("params", _vehicle);
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
private ["_type", "_initializedClasses", "_condition", "_statement", "_action"];
|
||||
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;
|
||||
|
||||
@ -28,143 +30,141 @@ _initializedClasses = GETMVAR(GVAR(initializedClasses),[]);
|
||||
if (_type in _initializedClasses) exitWith {};
|
||||
|
||||
// get all hitpoints and selections
|
||||
([_vehicle] call EFUNC(common,getHitPointsWithSelections)) params ["_hitPoints", "_hitPointsSelections"];
|
||||
(getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]];
|
||||
|
||||
if (_hitSelections isEqualTo []) exitWith { ACE_LOGERROR_1("No hit selections (%1)", _type); };
|
||||
|
||||
// get hitpoints of wheels with their selections
|
||||
([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitPointSelections"];
|
||||
([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"];
|
||||
|
||||
|
||||
private ["_hitPointsAddedNames", "_hitPointsAddedStrings", "_hitPointsAddedAmount"];
|
||||
_hitPointsAddedNames = [];
|
||||
_hitPointsAddedStrings = [];
|
||||
_hitPointsAddedAmount = [];
|
||||
_processedHitpoints = [];
|
||||
|
||||
// add repair events to this vehicle class
|
||||
{
|
||||
if (_x in _wheelHitPoints) then {
|
||||
// add wheel repair action
|
||||
_selection = _x;
|
||||
_hitpoint = _hitPoints select _forEachIndex;
|
||||
|
||||
private ["_icon", "_selection", "_name", "_text"];
|
||||
if (_selection in _wheelHitSelections) then {
|
||||
// Wheels should always be unique
|
||||
if (_hitpoint in _processedHitpoints) exitWith {TRACE_3("Duplicate Wheel",_hitpoint,_forEachIndex,_selection);};
|
||||
|
||||
_icon = QUOTE(PATHTOF(ui\tire_ca.paa));
|
||||
_icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa";
|
||||
// textDefault = "<img image='\A3\ui_f\data\igui\cfg\actions\repair_ca.paa' size='1.8' shadow=2 />";
|
||||
_selection = _wheelHitPointSelections select (_wheelHitPoints find _x);
|
||||
|
||||
// remove wheel action
|
||||
_name = format ["Remove_%1", _x];
|
||||
_position = compile format ["_target selectionPosition ['%1', 'HitPoints'];", _selection];
|
||||
|
||||
TRACE_3("Adding Wheel Actions",_hitpoint,_forEachIndex,_selection);
|
||||
|
||||
// An action to remove the wheel is required
|
||||
_name = format ["Remove_%1_%2", _forEachIndex, _hitpoint];
|
||||
_text = localize LSTRING(RemoveWheel);
|
||||
|
||||
_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)};
|
||||
|
||||
_action = [_name, _text, _icon, _statement, _condition, {}, [_x], _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);
|
||||
|
||||
// replace wheel action
|
||||
_name = format ["Replace_%1", _x];
|
||||
// An action to replace the wheel is required
|
||||
_name = format ["Replace_%1_%2", _forEachIndex, _hitpoint];
|
||||
_text = localize LSTRING(ReplaceWheel);
|
||||
|
||||
_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)};
|
||||
|
||||
_action = [_name, _text, _icon, _statement, _condition, {}, [_x], _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);
|
||||
|
||||
} else {
|
||||
// exit if the hitpoint is in the blacklist, e.g. glasses
|
||||
if (_x in IGNORED_HITPOINTS) exitWith {};
|
||||
|
||||
private ["_hitpointGroupConfig", "_inHitpointSubGroup", "_currentHitpoint"];
|
||||
|
||||
// Get hitpoint groups if available
|
||||
_hitpointGroupConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointGroups);
|
||||
_inHitpointSubGroup = false;
|
||||
if (isArray _hitpointGroupConfig) then {
|
||||
// Set variable if current hitpoint is in a sub-group (to be excluded from adding action)
|
||||
_currentHitpoint = _x;
|
||||
{
|
||||
{
|
||||
if (_x == _currentHitpoint) exitWith {
|
||||
_inHitpointSubGroup = true;
|
||||
};
|
||||
} forEach (_x select 1);
|
||||
} forEach (getArray _hitpointGroupConfig);
|
||||
//Skip glass hitpoints
|
||||
if (((toLower _hitPoint) find "glass") != -1) exitWith {
|
||||
TRACE_3("Skipping Glass",_hitpoint,_forEachIndex,_selection);
|
||||
};
|
||||
// Empty selections don't exist
|
||||
// Empty hitpoints don't contain enough information
|
||||
if (_selection isEqualTo "") exitWith { TRACE_3("Selection Empty",_hitpoint,_forEachIndex,_selection); };
|
||||
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);
|
||||
};
|
||||
|
||||
// Exit if current hitpoint is in sub-group (only main hitpoints get actions)
|
||||
if (_inHitpointSubGroup) exitWith {};
|
||||
// Associated hitpoints can be grouped via config to produce a single repair action
|
||||
_groupsConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointGroups);
|
||||
_childHitPoint = false;
|
||||
if (isArray _groupsConfig) then {
|
||||
{
|
||||
{
|
||||
if (_hitpoint == _x) exitWith {
|
||||
_childHitPoint = true;
|
||||
};
|
||||
} forEach (_x select 1);
|
||||
} forEach (getArray _groupsConfig);
|
||||
};
|
||||
// If the current selection is associated with a child hitpoint, then skip
|
||||
if (_childHitPoint) exitWith { TRACE_3("childHitpoint",_hitpoint,_forEachIndex,_selection); };
|
||||
|
||||
// exit if the hitpoint is virtual
|
||||
if (isText (configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "depends")) exitWith {};
|
||||
// Find the action position
|
||||
_position = compile format ["_target selectionPosition ['%1', 'HitPoints'];", _selection];
|
||||
|
||||
// add misc repair action
|
||||
private ["_name", "_icon", "_selection", "_customSelectionsConfig"];
|
||||
// Custom position can be defined via config for associated hitpoint
|
||||
_positionsConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointPositions);
|
||||
if (isArray _positionsConfig) then {
|
||||
{
|
||||
_x params ["_hit", "_pos"];
|
||||
if (_hitpoint == _hit) exitWith {
|
||||
if (typeName _pos == "ARRAY") exitWith {
|
||||
_position = _pos; // Position in model space
|
||||
};
|
||||
if (typeName _pos == "STRING") exitWith {
|
||||
_position = compile format ["_target selectionPosition ['%1', 'HitPoints'];", _pos];
|
||||
};
|
||||
ACE_LOGERROR_3("Invalid custom position %1 of hitpoint %2 in vehicle %3.",_position,_hitpoint,_type);
|
||||
};
|
||||
} forEach (getArray _positionsConfig);
|
||||
};
|
||||
|
||||
_name = format ["Repair_%1", _x];
|
||||
// Prepair the repair action
|
||||
_name = format ["Repair_%1_%2", _forEachIndex, _selection];
|
||||
_icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa";
|
||||
|
||||
// Find localized string and track those added for numerization
|
||||
([_x, "%1", _x, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_text", "_trackArray"];
|
||||
([_hitpoint, "%1", _hitpoint, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_text", "_trackArray"];
|
||||
_hitPointsAddedNames = _trackArray select 0;
|
||||
_hitPointsAddedStrings = _trackArray select 1;
|
||||
_hitPointsAddedAmount = _trackArray select 2;
|
||||
|
||||
_icon = "A3\ui_f\data\igui\cfg\actions\repair_ca.paa";
|
||||
|
||||
_selection = "";
|
||||
|
||||
// Get custom position if available
|
||||
_customSelectionsConfig = configFile >> "CfgVehicles" >> _type >> QGVAR(hitpointPositions);
|
||||
if (isArray _customSelectionsConfig) then {
|
||||
// Loop through custom hitpoint positions array
|
||||
_currentHitpoint = _x;
|
||||
{
|
||||
_x params ["_hitpoint", "_position"];
|
||||
// Exit with supplied custom position when same hitpoint name found or print RPT error if it's invalid
|
||||
if (_hitpoint == _currentHitpoint) exitWith {
|
||||
if (typeName _position == "ARRAY") exitWith {
|
||||
_selection = _position; // Position in model space
|
||||
};
|
||||
if (typeName _position == "STRING") exitWith {
|
||||
_selection = _vehicle selectionPosition _position; // Selection name
|
||||
};
|
||||
ACE_LOGERROR_3("Invalid custom position %1 of hitpoint %2 in vehicle %3.",_position,_hitpoint,_vehicle);
|
||||
};
|
||||
} forEach (getArray _customSelectionsConfig);
|
||||
};
|
||||
|
||||
// If position still empty (not a position array or selection name) try extracting from model
|
||||
if (typeName _selection == "STRING" && {_selection == ""}) then {
|
||||
_selection = _vehicle selectionPosition (_hitPointsSelections select (_hitPoints find _x));
|
||||
};
|
||||
|
||||
_condition = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(canRepair)};
|
||||
_statement = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(repair)};
|
||||
|
||||
if (_x in TRACK_HITPOINTS) then {
|
||||
if (_x == "HitLTrack") then {
|
||||
_selection = [-1.75, 0, -1.75];
|
||||
if (_hitpoint in TRACK_HITPOINTS) then {
|
||||
// Tracks should always be unique
|
||||
if (_hitpoint in _processedHitpoints) exitWith {TRACE_3("Duplicate Track",_hitpoint,_forEachIndex,_selection);};
|
||||
if (_hitpoint == "HitLTrack") then {
|
||||
_position = [-1.75, 0, -1.75];
|
||||
} else {
|
||||
_selection = [1.75, 0, -1.75];
|
||||
_position = [1.75, 0, -1.75];
|
||||
};
|
||||
_action = [_name, _text, _icon, _statement, _condition, {}, [_x, "RepairTrack"], _selection, 4] call EFUNC(interact_menu,createAction);
|
||||
TRACE_4("Adding RepairTrack",_hitpoint,_forEachIndex,_selection,_text);
|
||||
_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)};
|
||||
_action = [_name, _text, _icon, _statement, _condition, {}, [_hitpoint], _position, 4] call EFUNC(interact_menu,createAction);
|
||||
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
||||
} else {
|
||||
_action = [_name, _text, _icon, _statement, _condition, {}, [_x, "MiscRepair"], _selection, 4] call EFUNC(interact_menu,createAction);
|
||||
TRACE_4("Adding MiscRepair",_hitpoint,_forEachIndex,_selection,_text);
|
||||
_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)};
|
||||
_action = [_name, _text, _icon, _statement, _condition, {}, [_forEachIndex], _position, 5] call EFUNC(interact_menu,createAction);
|
||||
// Put inside main actions if no other position was found above
|
||||
if (_selection isEqualTo [0, 0, 0]) then {
|
||||
if (_position isEqualTo [0,0,0]) then {
|
||||
[_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);
|
||||
} else {
|
||||
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach _hitPoints;
|
||||
|
||||
_condition = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(canRepair)};
|
||||
_statement = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(repair)};
|
||||
_action = [QGVAR(fullRepair), localize LSTRING(fullRepair), "A3\ui_f\data\igui\cfg\actions\repair_ca.paa", _statement, _condition, {}, ["", "fullRepair"], "", 4] call EFUNC(interact_menu,createAction);
|
||||
_processedHitPoints pushBack _hitPoint;
|
||||
};
|
||||
} forEach _hitSelections;
|
||||
|
||||
_condition = {[_this select 1, _this select 0, "", "fullRepair"] call DFUNC(canRepair)};
|
||||
_statement = {[_this select 1, _this select 0, "", "fullRepair"] call DFUNC(repair)};
|
||||
_action = [QGVAR(fullRepair), localize LSTRING(fullRepair), "A3\ui_f\data\igui\cfg\actions\repair_ca.paa", _statement, _condition, {}, [], "", 4] call EFUNC(interact_menu,createAction);
|
||||
[_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);
|
||||
|
||||
// set class as initialized
|
||||
_initializedClasses pushBack _type;
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_part"];
|
||||
params ["_vehicle", ["_amount", 1], ["_part", ""], ["_force", false]];
|
||||
TRACE_2("params",_vehicle,_amount);
|
||||
|
||||
|
@ -5,38 +5,51 @@
|
||||
* Arguments:
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT>
|
||||
* 2: Selected hitpoint <STRING>
|
||||
* 2: Selected hitpoint INDEX <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Can Misc Repair <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_canMiscRepair
|
||||
* [unit, vehicle, 5] call ace_repair_fnc_canMiscRepair
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_hitpointGroupConfig", "_hitpointGroup", "_postRepairDamage", "_return"];
|
||||
params ["_caller", "_target", "_hitPoint"];
|
||||
private ["_hitpointGroupConfig", "_hitpointGroup", "_postRepairDamage", "_return", "_hitPointClassname", "_subHitIndex"];
|
||||
params ["_caller", "_target", "_hitPointIndex"];
|
||||
|
||||
if !([_unit, _target, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
(getAllHitPointsDamage _target) params ["_allHitPoints", "", "_allHitPointDamages"];
|
||||
|
||||
if !([_caller, _target, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
// Get hitpoint groups if available
|
||||
_hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(hitpointGroups);
|
||||
_hitpointGroup = [];
|
||||
if (isArray _hitpointGroupConfig) then {
|
||||
_hitPointClassname = _allHitPoints select _hitPointIndex;
|
||||
|
||||
// Retrieve hitpoint subgroup if current hitpoint is main hitpoint of a group
|
||||
{
|
||||
_x params ["_masterHitpoint", "_subHitArray"];
|
||||
// Exit using found hitpoint group if this hitpoint is leader of any
|
||||
if (_x select 0 == _hitPoint) exitWith {
|
||||
_hitpointGroup = _x select 1;
|
||||
if (_masterHitpoint == _hitPointClassname) exitWith {
|
||||
{
|
||||
_subHitIndex = _allHitPoints find _x;
|
||||
if (_subHitIndex == -1) then {
|
||||
ERROR("Hitpoint Not Found");
|
||||
} else {
|
||||
_hitpointGroup pushBack _subHitIndex;
|
||||
};
|
||||
} forEach _subHitArray;
|
||||
};
|
||||
} forEach (getArray _hitpointGroupConfig);
|
||||
};
|
||||
|
||||
// Add current hitpoint to the group
|
||||
_hitpointGroup pushBack _hitPoint;
|
||||
_hitpointGroup pushBack _hitPointIndex;
|
||||
|
||||
// Get post repair damage
|
||||
_postRepairDamage = [_caller] call FUNC(getPostRepairDamage);
|
||||
@ -44,7 +57,7 @@ _postRepairDamage = [_caller] call FUNC(getPostRepairDamage);
|
||||
// Return true if damage can be repaired on any hitpoint in the group, else false
|
||||
_return = false;
|
||||
{
|
||||
if ((_target getHitPointDamage _x) > _postRepairDamage) exitWith {
|
||||
if ((_allHitPointDamages select _x) > _postRepairDamage) exitWith {
|
||||
_return = true;
|
||||
};
|
||||
} forEach _hitpointGroup;
|
||||
|
@ -5,14 +5,14 @@
|
||||
* Arguments:
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT>
|
||||
* 2: Selected hitpoint <STRING>
|
||||
* 2: Selected hitpoint or hitpointIndex <STRING>or<NUMBER>
|
||||
* 3: Repair Action Classname <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Can Repair <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* ["something", player] call ace_repair_fnc_canRepair
|
||||
* [player, car, "HitHull", "MiscRepair"] call ace_repair_fnc_canRepair
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
@ -21,22 +21,22 @@
|
||||
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);
|
||||
if !(isClass _config) exitwith {false}; // or go for a default?
|
||||
if(isEngineOn _target) exitwith {false};
|
||||
if !(isClass _config) exitWith {false}; // or go for a default?
|
||||
if(isEngineOn _target) exitWith {false};
|
||||
|
||||
_engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
|
||||
getNumber (_config >> "requiredEngineer");
|
||||
} else {
|
||||
// Check for required class
|
||||
if (isText (_config >> "requiredEngineer")) exitwith {
|
||||
if (isText (_config >> "requiredEngineer")) exitWith {
|
||||
missionNamespace getVariable [(getText (_config >> "requiredEngineer")), 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 = if (isArray (_config >> "items")) then {
|
||||
@ -49,12 +49,12 @@ _items = if (isArray (_config >> "items")) then {
|
||||
};
|
||||
_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;
|
||||
if (getText (_config >> "condition") != "") then {
|
||||
_condition = getText (_config >> "condition");
|
||||
if (isnil _condition) then {
|
||||
if (isNil _condition) then {
|
||||
_condition = compile _condition;
|
||||
} else {
|
||||
_condition = missionNamespace getVariable _condition;
|
||||
@ -66,39 +66,47 @@ if (getText (_config >> "condition") != "") then {
|
||||
};
|
||||
};
|
||||
|
||||
if (!_return) exitwith {false};
|
||||
if (!_return) exitWith {false};
|
||||
|
||||
_vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
|
||||
missionNamespace getVariable [getText(_config >> "vehicleStateCondition"), 0]
|
||||
} else {
|
||||
getNumber(_config >> "vehicleStateCondition")
|
||||
};
|
||||
// if (_vehicleStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitwith {false};
|
||||
// _vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
|
||||
// missionNamespace getVariable [getText(_config >> "vehicleStateCondition"), 0]
|
||||
// } else {
|
||||
// getNumber(_config >> "vehicleStateCondition")
|
||||
// };
|
||||
// if (_vehicleStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitWith {false};
|
||||
|
||||
_locations = getArray (_config >> "repairLocations");
|
||||
if ("All" in _locations) exitwith {true};
|
||||
|
||||
private ["_repairFacility", "_repairVeh"];
|
||||
_repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
|
||||
_repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
|
||||
|
||||
{
|
||||
if (_x == "field") exitwith {_return = true;};
|
||||
if (_x == "RepairFacility" && _repairFacility) exitwith {_return = true;};
|
||||
if (_x == "RepairVehicle" && _repairVeh) exitwith {_return = true;};
|
||||
if !(isnil _x) exitwith {
|
||||
private "_val";
|
||||
_val = missionNamespace getVariable _x;
|
||||
if (typeName _val == "SCALAR") then {
|
||||
_return = switch (_val) do {
|
||||
case 0: {true}; //useAnywhere
|
||||
case 1: {call _repairVeh}; //repairVehicleOnly
|
||||
case 2: {call _repairFacility}; //repairFacilityOnly
|
||||
case 3: {(call _repairFacility) || {call _repairVeh}}; //vehicleAndFacility
|
||||
default {false}; //Disabled
|
||||
private _repairLocations = getArray (_config >> "repairLocations");
|
||||
if (!("All" in _repairLocations)) then {
|
||||
private _repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
|
||||
private _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
|
||||
{
|
||||
if (_x == "field") exitWith {_return = true;};
|
||||
if (_x == "RepairFacility" && _repairFacility) exitWith {_return = true;};
|
||||
if (_x == "RepairVehicle" && _repairVeh) exitWith {_return = true;};
|
||||
if !(isNil _x) exitWith {
|
||||
private _val = missionNamespace getVariable _x;
|
||||
if (typeName _val == "SCALAR") then {
|
||||
_return = switch (_val) do {
|
||||
case 0: {true}; //useAnywhere
|
||||
case 1: {call _repairVeh}; //repairVehicleOnly
|
||||
case 2: {call _repairFacility}; //repairFacilityOnly
|
||||
case 3: {(call _repairFacility) || {call _repairVeh}}; //vehicleAndFacility
|
||||
default {false}; //Disabled
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach _locations;
|
||||
} forEach _repairLocations;
|
||||
};
|
||||
if (!_return) exitWith {false};
|
||||
|
||||
_return && alive _target;
|
||||
//Check that there are required objects nearby
|
||||
private _requiredObjects = getArray (_config >> "claimObjects");
|
||||
if (!(_requiredObjects isEqualTo [])) then {
|
||||
private _objectsAvailable = [_caller, 5, _requiredObjects] call FUNC(getClaimObjects);
|
||||
if (_objectsAvailable isEqualTo []) then {
|
||||
TRACE_2("Missing Required Objects",_requiredObjects,_objectsAvailable);
|
||||
_return = false
|
||||
};
|
||||
};
|
||||
|
||||
_return && {alive _target};
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Check if the unit can replace given wheel of the vehicle.
|
||||
* Check if the unit can replace given track of the vehicle.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
@ -17,27 +17,11 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_target", "_hitPoint", ["_wheel",false]];
|
||||
TRACE_4("params",_unit,_target,_hitPoint,_wheel);
|
||||
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
|
||||
params ["_unit", "_target", "_hitPoint"];
|
||||
TRACE_3("params",_unit,_target,_hitPoint);
|
||||
|
||||
if !([_unit, _target, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
if (typeName _wheel == "OBJECT") then {
|
||||
// not near interpret as objNull
|
||||
if !(_wheel in nearestObjects [_unit, ["ACE_Track"], 5]) then {
|
||||
_wheel = objNull;
|
||||
};
|
||||
} else {
|
||||
_wheel = objNull;
|
||||
//check for a near track is handled by claimObjects[] config
|
||||
|
||||
{
|
||||
if ([_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {
|
||||
_wheel = _x;
|
||||
};
|
||||
} forEach nearestObjects [_unit, ["ACE_Track"], 5];
|
||||
};
|
||||
|
||||
if (isNull _wheel || damage _wheel >= 1) exitWith {false};
|
||||
|
||||
alive _target && {_target getHitPointDamage _hitPoint > 0}
|
||||
(_target getHitPointDamage _hitPoint > 0)
|
||||
|
@ -1,12 +1,11 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Check if the unit can replace given wheel of the vehicle.
|
||||
* Check if the unit can replace given track of the vehicle.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT>
|
||||
* 2: Selected hitpoint <STRING>
|
||||
* 3: Track <OBJECT>/<BOOL> (default: false)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -18,27 +17,11 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_target", "_hitPoint", ["_track", false]];
|
||||
TRACE_4("params",_unit,_target,_hitPoint,_track);
|
||||
// TODO [_unit, _track] call EFUNC(common,claim); on start of action
|
||||
params ["_unit", "_target", "_hitPoint"];
|
||||
TRACE_3("params",_unit,_target,_hitPoint);
|
||||
|
||||
if !([_unit, _target, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
if (typeName _track == "OBJECT") then {
|
||||
// not near interpret as objNull
|
||||
if !(_track in nearestObjects [_unit, ["ACE_Track"], 5]) then {
|
||||
_track = objNull;
|
||||
};
|
||||
} else {
|
||||
_track = objNull;
|
||||
//check for a near track object is handled by claimObjects[] config
|
||||
|
||||
{
|
||||
if ([_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {
|
||||
_track = _x;
|
||||
};
|
||||
} forEach nearestObjects [_unit, ["ACE_Track"], 5];
|
||||
};
|
||||
|
||||
if (isNull _track) exitWith {false};
|
||||
|
||||
alive _target && {_target getHitPointDamage _hitPoint >= 1}
|
||||
(_target getHitPointDamage _hitPoint >= 1)
|
||||
|
@ -6,7 +6,6 @@
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT>
|
||||
* 2: Selected hitpoint <STRING>
|
||||
* 3: Wheel <OBJECT>/<BOOL> (default: false)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -18,31 +17,12 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_target", "_hitPoint", ["_wheel", false]];
|
||||
TRACE_4("params",_unit,_target,_hitPoint,_wheel);
|
||||
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
|
||||
//if !([_unit, _target, _hitpoint, "ReplaceWheel"] call FUNC(canRepair)) exitwith {false};
|
||||
params ["_unit", "_target", "_hitPoint"];
|
||||
TRACE_3("params",_unit,_target,_hitPoint);
|
||||
|
||||
if !([_unit, _target, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
//if !([_unit, GVAR(engineerSetting_Wheel)] call FUNC(isEngineer)) exitWith {false};
|
||||
//check for GVAR(engineerSetting_Wheel) is handeled by requiredEngineer config
|
||||
//check for a near wheel object is handled by claimObjects[] config
|
||||
|
||||
// check for a near wheel
|
||||
if (typeName _wheel == "OBJECT") then {
|
||||
// not near interpret as objNull
|
||||
if !(_wheel in nearestObjects [_unit, ["ACE_Wheel"], 5]) then {
|
||||
_wheel = objNull;
|
||||
};
|
||||
} else {
|
||||
_wheel = objNull;
|
||||
|
||||
{
|
||||
if ([_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {
|
||||
_wheel = _x;
|
||||
};
|
||||
} forEach nearestObjects [_unit, ["ACE_Wheel"], 5];
|
||||
};
|
||||
|
||||
if (isNull _wheel) exitWith {false};
|
||||
|
||||
alive _target && {_target getHitPointDamage _hitPoint >= 1}
|
||||
(_target getHitPointDamage _hitPoint >= 1)
|
||||
|
@ -1,23 +1,22 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
|
||||
* Fully repairs vehicle
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 0: Unit that does the repairing (not used) <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT>
|
||||
* 2: Selected hitpoint <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_doFullRepair
|
||||
* [unit, vehicle] call ace_repair_fnc_doFullRepair
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_vehicle", "_hitPoint"];
|
||||
TRACE_3("params",_unit,_vehicle,_hitPoint);
|
||||
params ["", "_vehicle"];
|
||||
TRACE_1("params",_vehicle);
|
||||
|
||||
_vehicle setDamage 0;
|
||||
|
@ -19,10 +19,9 @@
|
||||
|
||||
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
|
||||
private "_hitPointDamage";
|
||||
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
private _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
|
||||
// can't remove destroyed or already removed wheel
|
||||
if (_hitPointDamage >= 1) exitWith {};
|
||||
@ -30,10 +29,9 @@ if (_hitPointDamage >= 1) exitWith {};
|
||||
// don't die by spawning / moving the wheel
|
||||
["fixCollision", _unit] call EFUNC(common,localEvent);
|
||||
|
||||
// spawn wheel
|
||||
private "_wheel";
|
||||
_wheel = ["ACE_Track", getPosASL _unit] call FUNC(spawnObject);
|
||||
_wheel setdamage _hitPointDamage;
|
||||
// spawn track
|
||||
private _newTrack = ["ACE_Track", getPosASL _unit, _hitPointDamage] call FUNC(spawnObject);
|
||||
TRACE_2("new track created",_newTrack,damage _newTrack);
|
||||
|
||||
// raise event to set the new hitpoint damage
|
||||
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, 1]] call EFUNC(common,targetEvent);
|
||||
|
@ -19,10 +19,9 @@
|
||||
|
||||
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
|
||||
private "_hitPointDamage";
|
||||
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
private _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
|
||||
// can't remove destroyed or already removed wheel
|
||||
if (_hitPointDamage >= 1) exitWith {};
|
||||
@ -31,9 +30,8 @@ if (_hitPointDamage >= 1) exitWith {};
|
||||
["fixCollision", _unit] call EFUNC(common,localEvent);
|
||||
|
||||
// spawn wheel
|
||||
private "_wheel";
|
||||
_wheel = ["ACE_Wheel", getPosASL _unit] call FUNC(spawnObject);
|
||||
_wheel setdamage _hitPointDamage;
|
||||
private _newWheel = ["ACE_Wheel", getPosASL _unit, _hitPointDamage] call FUNC(spawnObject);
|
||||
TRACE_2("new wheel created",_newWheel,damage _newWheel);
|
||||
|
||||
// raise event to set the new hitpoint damage
|
||||
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, 1]] call EFUNC(common,targetEvent);
|
||||
|
@ -5,61 +5,70 @@
|
||||
* Arguments:
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT>
|
||||
* 2: Selected hitpoint <STRING>
|
||||
* 2: Selected hitpointIndex <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_doRepair
|
||||
* [unit, vehicle, 6, "MiscRepair"] call ace_repair_fnc_doRepair
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_hitPointDamage", "_text", "_hitpointGroup"];
|
||||
params ["_unit", "_vehicle", "_hitPoint"];
|
||||
TRACE_3("params",_unit,_vehicle,_hitPoint);
|
||||
params ["_unit", "_vehicle", "_hitPointIndex"];
|
||||
TRACE_3("params",_unit,_vehicle,_hitPointIndex);
|
||||
|
||||
private _postRepairDamageMin = [_unit] call FUNC(getPostRepairDamage);
|
||||
|
||||
(getAllHitPointsDamage _vehicle) params ["_allHitPoints"];
|
||||
private _hitPointClassname = _allHitPoints select _hitPointIndex;
|
||||
|
||||
// get current hitpoint damage
|
||||
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
private _hitPointCurDamage = _vehicle getHitIndex _hitPointIndex;
|
||||
|
||||
_hitPointDamage = _hitPointDamage - 0.5;
|
||||
// don't use negative values for damage
|
||||
_hitPointDamage = _hitPointDamage max ([_unit] call FUNC(getPostRepairDamage));
|
||||
// repair a max of 0.5, don't use negative values for damage
|
||||
private _hitPointNewDamage = (_hitPointCurDamage - 0.5) max _postRepairDamageMin;
|
||||
|
||||
// raise event to set the new hitpoint damage
|
||||
["setVehicleHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent);
|
||||
if (_hitPointNewDamage < _hitPointCurDamage) then {
|
||||
// raise event to set the new hitpoint damage
|
||||
TRACE_3("repairing main point", _vehicle, _hitPointIndex, _hitPointNewDamage);
|
||||
["setVehicleHitPointDamage", _vehicle, [_vehicle, _hitPointIndex, _hitPointNewDamage]] call EFUNC(common,targetEvent);
|
||||
_hitPointCurDamage = _hitPointNewDamage;
|
||||
};
|
||||
|
||||
// Get hitpoint groups if available
|
||||
_hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(hitpointGroups);
|
||||
_hitpointGroup = [];
|
||||
private _hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(hitpointGroups);
|
||||
if (isArray _hitpointGroupConfig) then {
|
||||
// Retrieve group if current hitpoint is leader of any
|
||||
// Retrieve hitpoint subgroup if current hitpoint is main hitpoint of a group
|
||||
{
|
||||
if (_x select 0 == _hitPoint) exitWith {
|
||||
([_vehicle] call EFUNC(common,getHitPointsWithSelections)) params ["_hitpoints"];
|
||||
// Set all sub-group hitpoints' damage to 0, if a hitpoint is invalid print RPT error
|
||||
_x params ["_masterHitpoint", "_subHitArray"];
|
||||
// Exit using found hitpoint group if this hitpoint is leader of any
|
||||
if (_masterHitpoint == _hitPointClassname) exitWith {
|
||||
{
|
||||
if (_x in _hitpoints) then {
|
||||
["setVehicleHitPointDamage", _vehicle, [_vehicle, _x, 0]] call EFUNC(common,targetEvent);
|
||||
private _subHitIndex = _allHitPoints find _x; //convert hitpoint classname to index
|
||||
if (_subHitIndex == -1) then {
|
||||
ACE_LOGERROR_2("Invalid hitpoint %1 in hitpointGroups of %2",_x,_vehicle);
|
||||
} else {
|
||||
diag_log text format ["[ACE] ERROR: Invalid hitpoint %1 in hitpointGroups of %2", _x, _vehicle];
|
||||
private _subPointCurDamage = _vehicle getHitIndex _hitPointIndex;
|
||||
private _subPointNewDamage = (_subPointCurDamage - 0.5) max _postRepairDamageMin;
|
||||
if (_subPointNewDamage < _subPointCurDamage) then {
|
||||
TRACE_3("repairing sub point", _vehicle, _subHitIndex, _subPointNewDamage);
|
||||
["setVehicleHitPointDamage", _vehicle, [_vehicle, _subHitIndex, _subPointNewDamage]] call EFUNC(common,targetEvent);
|
||||
};
|
||||
};
|
||||
|
||||
} forEach (_x select 1);
|
||||
} forEach _subHitArray;
|
||||
};
|
||||
} forEach (getArray _hitpointGroupConfig);
|
||||
};
|
||||
|
||||
// display text message if enabled
|
||||
if (GVAR(DisplayTextOnRepair)) then {
|
||||
private ["_textLocalized", "_textDefault"];
|
||||
|
||||
// Find localized string
|
||||
_textLocalized = localize ([LSTRING(RepairedHitPointFully), LSTRING(RepairedHitPointPartially)] select (_hitPointDamage > 0));
|
||||
_textDefault = localize ([LSTRING(RepairedFully), LSTRING(RepairedPartially)] select (_hitPointDamage > 0));
|
||||
([_hitPoint, _textLocalized, _textDefault] call FUNC(getHitPointString)) params ["_text"];
|
||||
private _textLocalized = localize ([LSTRING(RepairedHitPointFully), LSTRING(RepairedHitPointPartially)] select (_hitPointCurDamage > 0));
|
||||
private _textDefault = localize ([LSTRING(RepairedFully), LSTRING(RepairedPartially)] select (_hitPointCurDamage > 0));
|
||||
([_hitPointClassname, _textLocalized, _textDefault] call FUNC(getHitPointString)) params ["_text"];
|
||||
|
||||
// Display text
|
||||
[_text] call EFUNC(common,displayTextStructured);
|
||||
|
@ -6,43 +6,39 @@
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT>
|
||||
* 2: Selected hitpoint <STRING>
|
||||
* 3: Repair Action Classname <STRING>
|
||||
* 3: Repair Action Classname (Not used) <STRING>
|
||||
* 4: (Not used) <ARRAY>
|
||||
* 5: (Not used) <ARRAY>
|
||||
* 6: Required Repair Objects <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_doRepairTrack
|
||||
* [unit, vehicle, "hitpoint", "RepairTrack", [], [], [aTrack]] call ace_repair_fnc_doRepairTrack
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_vehicle", "_hitPoint", "_classname"];
|
||||
TRACE_4("params",_unit,_vehicle,_hitPoint,_classname);
|
||||
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
|
||||
params ["_unit", "_vehicle", "_hitPoint", "", "", "", "_claimedObjects"];
|
||||
TRACE_4("params",_unit,_vehicle,_hitPoint,_claimedObjects);
|
||||
|
||||
private ["_hitPointDamage", "_newDamage", "_wheel"];
|
||||
_claimedObjects params [["_track", objNull]];
|
||||
if ((isNull _track) || {!([_unit, _track, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith))}) exitWith {
|
||||
ACE_LOGERROR_1("Bad Track", _claimedObjects);
|
||||
};
|
||||
|
||||
_wheel = objNull;
|
||||
|
||||
{
|
||||
if ([_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {
|
||||
_wheel = _x;
|
||||
};
|
||||
} forEach nearestObjects [_unit, ["ACE_Track"], 5];
|
||||
if (isNull _wheel) exitwith {};
|
||||
// can't use a destroyed track
|
||||
if ((damage _track) >= 1) exitWith {};
|
||||
|
||||
// get current hitpoint damage
|
||||
private _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
private _damageRepaired = (1 - (damage _track)) / 4; // require 4 tracks to fully replace one side
|
||||
|
||||
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
_newDamage = (1 - (damage _wheel)) / 4; // require 4 tracks to fully replace one side
|
||||
|
||||
// can't replace a destroyed wheel
|
||||
if ((damage _wheel) >= 1) exitWith {};
|
||||
// don't die by spawning / moving the wheel
|
||||
_hitPointDamage = (_hitPointDamage - _newDamage) min 0;
|
||||
deleteVehicle _wheel;
|
||||
_hitPointDamage = (_hitPointDamage - _damageRepaired) min 0;
|
||||
deleteVehicle _track;
|
||||
|
||||
// raise event to set the new hitpoint damage
|
||||
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent);
|
||||
|
@ -1,54 +1,50 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
|
||||
* Replaces a track.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT>
|
||||
* 2: Selected hitpoint <STRING>
|
||||
* 3: Repair Action Classname <STRING>
|
||||
* 3: Repair Action Classname (Not used) <STRING>
|
||||
* 4: (Not used) <ARRAY>
|
||||
* 5: (Not used) <ARRAY>
|
||||
* 6: Required Repair Objects <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_doReplaceTrack
|
||||
* [unit, vehicle, "hitpoint", "ReplaceTrack", [], [], [aTrack]] call ace_repair_fnc_doReplaceTrack
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_vehicle", "_hitPoint", "_classname"];
|
||||
TRACE_4("params",_unit,_vehicle,_hitPoint,_classname);
|
||||
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
|
||||
params ["_unit", "_vehicle", "_hitPoint", "", "", "", "_claimedObjects"];
|
||||
TRACE_4("params",_unit,_vehicle,_hitPoint,_claimedObjects);
|
||||
|
||||
private["_hitPointDamage", "_wheel"];
|
||||
|
||||
_wheel = objNull;
|
||||
|
||||
{
|
||||
if ([_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {
|
||||
_wheel = _x;
|
||||
};
|
||||
} forEach nearestObjects [_unit, ["ACE_Track"], 5];
|
||||
if (isNull _wheel) exitwith {};
|
||||
_claimedObjects params [["_track", objNull]];
|
||||
if ((isNull _track) || {!([_unit, _track, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith))}) exitWith {
|
||||
ACE_LOGERROR_1("Bad Track", _claimedObjects);
|
||||
};
|
||||
|
||||
// get current hitpoint damage
|
||||
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
private _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
|
||||
// can't replace not destroyed wheel
|
||||
if (_hitPointDamage < 1) exitWith {};
|
||||
|
||||
// don't die by spawning / moving the wheel
|
||||
_hitPointDamage = damage _wheel;
|
||||
// get track's damage
|
||||
private _newHitPointDamage = damage _track;
|
||||
|
||||
// can't replace a destroyed wheel
|
||||
if (_hitPointDamage >= 1) exitWith {};
|
||||
// can't replace with a destroyed wheel
|
||||
if (_newHitPointDamage >= 1) exitWith {};
|
||||
|
||||
deleteVehicle _wheel;
|
||||
deleteVehicle _track;
|
||||
|
||||
// raise event to set the new hitpoint damage
|
||||
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent);
|
||||
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, _newHitPointDamage]] call EFUNC(common,targetEvent);
|
||||
|
||||
// display text message if enabled
|
||||
if (GVAR(DisplayTextOnRepair)) then {
|
||||
|
@ -1,54 +1,50 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
|
||||
* Repairs a vehicle's wheel with a ACE_wheel spare part object.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT>
|
||||
* 2: Selected hitpoint <STRING>
|
||||
* 3: Repair Action Classname <STRING>
|
||||
* 3: Repair Action Classname (Not used) <STRING>
|
||||
* 4: (Not used) <ARRAY>
|
||||
* 5: (Not used) <ARRAY>
|
||||
* 6: Required Repair Objects <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_doReplaceWheel
|
||||
* [unit, vehicle, "hitpoint", "ReplaceWheel", [], [], [aWheel]] call ace_repair_fnc_doReplaceWheel
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_vehicle", "_hitPoint", "_classname"];
|
||||
TRACE_4("params",_unit,_vehicle,_hitPoint,_classname);
|
||||
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
|
||||
params ["_unit", "_vehicle", "_hitPoint", "", "", "", "_claimedObjects"];
|
||||
TRACE_4("params",_unit,_vehicle,_hitPoint,_claimedObjects);
|
||||
|
||||
private ["_hitPointDamage", "_wheel"];
|
||||
|
||||
_wheel = objNull;
|
||||
|
||||
{
|
||||
if ([_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {
|
||||
_wheel = _x;
|
||||
};
|
||||
} forEach nearestObjects [_unit, ["ACE_Wheel"], 5];
|
||||
if (isNull _wheel) exitwith {};
|
||||
_claimedObjects params [["_wheel", objNull]];
|
||||
if ((isNull _wheel) || {!([_unit, _wheel, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith))}) exitWith {
|
||||
ACE_LOGWARNING_1("Bad Claimed Wheel", _claimedObjects);
|
||||
};
|
||||
|
||||
// get current hitpoint damage
|
||||
_hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
private _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
|
||||
|
||||
// can't replace not destroyed wheel
|
||||
if (_hitPointDamage < 1) exitWith {};
|
||||
|
||||
// don't die by spawning / moving the wheel
|
||||
_hitPointDamage = damage _wheel;
|
||||
// get replacement wheel's damage
|
||||
private _newHitPointDamage = damage _wheel;
|
||||
|
||||
// can't replace a destroyed wheel
|
||||
if (_hitPointDamage >= 1) exitWith {};
|
||||
if (_newHitPointDamage >= 1) exitWith {};
|
||||
|
||||
deleteVehicle _wheel;
|
||||
|
||||
// raise event to set the new hitpoint damage
|
||||
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent);
|
||||
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, _newHitPointDamage]] call EFUNC(common,targetEvent);
|
||||
|
||||
// display text message if enabled
|
||||
if (GVAR(DisplayTextOnRepair)) then {
|
||||
|
45
addons/repair/functions/fnc_getClaimObjects.sqf
Normal file
45
addons/repair/functions/fnc_getClaimObjects.sqf
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Returns array of required nearby repair objects (wheels/tracks)
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Max range to seach from unit (meters) <SCALAR>
|
||||
* 2: Array of arrays of classnames <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Array of objects, or [] if not all available <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [player, 5, [["Ace_Track"]]] call ace_repair_fnc_getClaimObjects
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_maxRange", "_objectsToClaim"];
|
||||
TRACE_3("params",_unit,_maxRange,_objectsToClaim);
|
||||
|
||||
private _return = [];
|
||||
|
||||
{
|
||||
private _requiredList = _x; //eg ["ace_track", "ace_track"]
|
||||
private _ableToAquire = []; //will be array of ojbects
|
||||
{
|
||||
private _nearObjects = nearestObjects [_unit, [_x], _maxRange];
|
||||
private _canClaimObject = objNull;
|
||||
{
|
||||
if ((!(_x in _ableToAquire))
|
||||
&& {[_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)}
|
||||
&&{(damage _x) < 1}
|
||||
) exitWith { _canClaimObject = _x; };
|
||||
} forEach _nearObjects;
|
||||
if (isNull _canClaimObject) exitWith {};
|
||||
_ableToAquire pushBack _canClaimObject;
|
||||
} forEach _x;
|
||||
TRACE_2("Check required equals available",_requiredList,_ableToAquire);
|
||||
if ((count _ableToAquire) == (count _requiredList)) exitWith {_return = _ableToAquire};
|
||||
false
|
||||
} count _objectsToClaim;
|
||||
|
||||
_return
|
@ -13,15 +13,16 @@
|
||||
* 1: Added Hitpoint (default: [])
|
||||
*
|
||||
* Example:
|
||||
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_getHitPointString
|
||||
* ["HitFuel", "Repairing %1 ...", "Repairing HitFuel"] call ace_repair_fnc_getHitPointString
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_track", "_trackNames", "_trackStrings", "_trackAmount", "_text", "_toFind", "_trackIndex", "_combinedString"];
|
||||
params ["_hitPoint", "_textLocalized", "_textDefault", ["_trackArray", []]];
|
||||
|
||||
private ["_track", "_trackNames", "_trackStrings", "_trackAmount", "_text", "_toFind", "_trackIndex", "_combinedString"];
|
||||
|
||||
_track = if (count _trackArray > 0) then {true} else {false};
|
||||
_trackNames = [];
|
||||
_trackStrings = [];
|
||||
@ -37,7 +38,7 @@ if (_track) then {
|
||||
_text = LSTRING(Hit);
|
||||
|
||||
// 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
|
||||
} else {
|
||||
_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
|
||||
if (_text == LSTRING(Hit)) then {
|
||||
if (_hitPoint != "") then { ACE_LOGWARNING_1("Hitpoint [%1] - could not be localized", _hitPoint); };
|
||||
_text = _textDefault;
|
||||
};
|
||||
|
||||
|
@ -19,7 +19,7 @@ params ["_unit"];
|
||||
TRACE_1("params",_unit);
|
||||
// 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)] call FUNC(isEngineer)) exitWith {GVAR(repairDamageThreshold)};
|
||||
|
@ -10,7 +10,7 @@
|
||||
* 1: Wheel hitpoint selections in model coordinates <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_getWheelHitPointsWithSelections
|
||||
* [car1] call ace_repair_fnc_getWheelHitPointsWithSelections
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
@ -19,64 +19,80 @@
|
||||
params ["_vehicle"];
|
||||
TRACE_1("params",_vehicle);
|
||||
|
||||
private["_bestDist", "_bestIndex", "_wheelBone", "_wheelBoneNameResized", "_wheelCenter", "_wheelCenterPos", "_wheelHitPoint", "_wheelHitPointSelection", "_wheelHitPointSelections", "_wheelHitPoints", "_wheelName", "_xDist", "_xPos"];
|
||||
|
||||
// get the vehicles wheel config
|
||||
private "_wheels";
|
||||
_wheels = configfile >> "CfgVehicles" >> typeOf _vehicle >> "Wheels";
|
||||
|
||||
// exit with nothing if the vehicle has no wheels class
|
||||
if !(isClass _wheels) exitWith {[[],[]]};
|
||||
if !(isClass _wheels) exitWith {TRACE_1("No Wheels",_wheels); [[],[]]};
|
||||
|
||||
// get all hitpoints and selections
|
||||
(getAllHitPointsDamage _vehicle) params ["_hitPoints", "_hitPointSelections"];
|
||||
|
||||
// get all wheels and read selections from config
|
||||
private ["_selections", "_bones"];
|
||||
|
||||
_wheels = "true" configClasses _wheels;
|
||||
|
||||
_selections = [];
|
||||
_bones = [];
|
||||
{
|
||||
_selections pushBack getText (_x >> "center");
|
||||
|
||||
private "_bone";
|
||||
_bone = getText (_x >> "boneName");
|
||||
|
||||
_bone = toArray _bone;
|
||||
_bone resize count "wheel_X_Y"; // this is a requirement for physx. Should work for all addon vehicles.
|
||||
_bone = toString _bone;
|
||||
|
||||
_bones pushBack _bone;
|
||||
} forEach _wheels;
|
||||
|
||||
// get hitpoints with their fire geometry selections
|
||||
private ["_hitPointsWithSelections", "_hitPoints", "_hitPointSelections"];
|
||||
|
||||
_hitPointsWithSelections = [_vehicle] call EFUNC(common,getHitPointsWithSelections);
|
||||
|
||||
_hitPoints = _hitPointsWithSelections select 0;
|
||||
_hitPointSelections = _hitPointsWithSelections select 1;
|
||||
|
||||
// assign hitpoints to correct wheel selection by comparing bone name and fire geometry selection
|
||||
private ["_wheelHitPoints", "_wheelHitPointSelections"];
|
||||
|
||||
_wheelHitPoints = [];
|
||||
_wheelHitPointSelections = [];
|
||||
|
||||
{
|
||||
private "_bone";
|
||||
_bone = _x;
|
||||
_wheelName = configName _x;
|
||||
_wheelCenter = getText (_x >> "center");
|
||||
_wheelBone = getText (_x >> "boneName");
|
||||
_wheelBoneNameResized = _wheelBone select [0, 9]; //ount "wheel_X_Y"; // this is a requirement for physx. Should work for all addon vehicles.
|
||||
|
||||
private "_index";
|
||||
TRACE_4("",_wheelName,_wheelCenter,_wheelBone,_wheelBoneNameResized);
|
||||
|
||||
_index = -1;
|
||||
_wheelHitPoint = "";
|
||||
_wheelHitPointSelection = "";
|
||||
|
||||
//Commy's orginal method
|
||||
{
|
||||
if (_bone != "" && {_x find _bone == 0}) exitWith { // same as above. Requirement for physx.
|
||||
_index = _forEachIndex;
|
||||
if ((_wheelBoneNameResized != "") && {_x find _wheelBoneNameResized == 0}) exitWith { // same as above. Requirement for physx.
|
||||
_wheelHitPoint = _hitPoints select _forEachIndex;
|
||||
_wheelHitPointSelection = _hitPointSelections select _forEachIndex;
|
||||
TRACE_2("wheel found [Orginal]", _wheelName, _wheelHitPoint);
|
||||
};
|
||||
} forEach _hitPointSelections;
|
||||
|
||||
if (_index != -1) then {
|
||||
_wheelHitPoints pushBack (_hitPoints select _index);
|
||||
_wheelHitPointSelections pushBack (_selections select _forEachIndex);
|
||||
|
||||
if (_vehicle isKindOf "Car") then {
|
||||
//Backup method, search for the closest hitpoint to the wheel's center selection pos.
|
||||
//Ref #2742 - RHS's HMMWV
|
||||
if (_wheelHitPoint == "") then {
|
||||
_wheelCenterPos = _vehicle selectionPosition _wheelCenter;
|
||||
if (_wheelCenterPos isEqualTo [0,0,0]) exitWith {TRACE_1("no center?",_wheelCenter);};
|
||||
|
||||
|
||||
_bestDist = 99;
|
||||
_bestIndex = -1;
|
||||
{
|
||||
if (_x != "") then {
|
||||
_xPos = _vehicle selectionPosition _x;
|
||||
if (_xPos isEqualTo [0,0,0]) exitWith {};
|
||||
_xDist = _wheelCenterPos distance _xPos;
|
||||
if (_xDist < _bestDist) then {
|
||||
_bestIndex = _forEachIndex;
|
||||
_bestDist = _xDist;
|
||||
};
|
||||
};
|
||||
} forEach _hitPointSelections;
|
||||
|
||||
TRACE_2("closestPoint",_bestDist,_bestIndex);
|
||||
if (_bestIndex != -1) then {
|
||||
_wheelHitPoint = _hitPoints select _bestIndex;
|
||||
_wheelHitPointSelection = _hitPointSelections select _bestIndex;
|
||||
TRACE_2("wheel found [Backup]", _wheelName, _wheelHitPoint);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
} forEach _bones;
|
||||
if ((_wheelHitPoint != "") && {_wheelHitPointSelection != ""}) then {
|
||||
_wheelHitPoints pushBack _wheelHitPoint;
|
||||
_wheelHitPointSelections pushBack _wheelHitPointSelection;
|
||||
};
|
||||
} forEach _wheels;
|
||||
|
||||
[_wheelHitPoints, _wheelHitPointSelections]
|
||||
|
@ -23,10 +23,10 @@ private ["_return"];
|
||||
|
||||
_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;
|
||||
};
|
||||
if (typeName _x == "STRING" && {!([_unit, _x] call EFUNC(common,hasItem))}) exitwith {
|
||||
if (typeName _x == "STRING" && {!([_unit, _x] call EFUNC(common,hasItem))}) exitWith {
|
||||
_return = false;
|
||||
};
|
||||
} forEach _items;
|
||||
|
@ -24,6 +24,6 @@ _class = _unit getVariable ["ACE_IsEngineer", getNumber (configFile >> "CfgVehic
|
||||
|
||||
// This if statement is here for copmatability with the common variant of isEngineer, which requires a bool.
|
||||
// We cannot move this function to common because we require the GVAR(engineerSetting_Repair), which only makes sense to include in the repair module.
|
||||
if (typeName _class == "BOOL") then {_class = 1};
|
||||
if (typeName _class == "BOOL") then {_class = [0, 1] select _class};
|
||||
|
||||
_class >= (_engineerN min GVAR(engineerSetting_Repair));
|
||||
|
@ -26,7 +26,7 @@ _repairFacility = [];
|
||||
|
||||
_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;
|
||||
};
|
||||
} forEach _objects;
|
||||
@ -34,7 +34,7 @@ _objects = (lineIntersectsWith [_object modelToWorldVisual [0, 0, (_position sel
|
||||
if (!_isInBuilding) then {
|
||||
_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;
|
||||
};
|
||||
} forEach _objects;
|
||||
|
@ -24,7 +24,7 @@ _nearObjects = nearestObjects [_unit, ["Air","LandVehicle"], 20];
|
||||
|
||||
_return = false;
|
||||
{
|
||||
if ([_x] call FUNC(isRepairVehicle)) exitwith {_return = true;};
|
||||
if ([_x] call FUNC(isRepairVehicle)) exitWith {_return = true;};
|
||||
} forEach _nearObjects;
|
||||
|
||||
_return;
|
||||
|
@ -18,6 +18,6 @@
|
||||
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);
|
||||
|
@ -11,7 +11,7 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* function = "ace_repair_fnc_moduleAddSpareParts"
|
||||
* [logic] call ace_repair_fnc_moduleAddSpareParts
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
@ -41,5 +41,6 @@ if (!isNull _logic) then {
|
||||
// Add spare parts
|
||||
{
|
||||
[_x, _amount, _part, true] call FUNC(addSpareParts);
|
||||
false
|
||||
} count _list;
|
||||
};
|
||||
|
@ -11,7 +11,7 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* function = "ace_repair_fnc_moduleAssignEngineer"
|
||||
* [logic] call ace_repair_fnc_moduleAssignEngineer
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -11,7 +11,7 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* function = "ace_repair_fnc_moduleAssignRepairFacility"
|
||||
* [logic] call ace_repair_fnc_moduleAssignRepairFacility
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -11,7 +11,7 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* function = "ace_repair_fnc_moduleAssignRepairVehicle"
|
||||
* [logic] call ace_repair_fnc_moduleAssignRepairVehicle
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -4,14 +4,12 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The module logic <OBJECT>
|
||||
* 1: Synchronized units <ARRAY>
|
||||
* 2: Activated <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* function = "ace_repair_fnc_moduleRepairSettings"
|
||||
* [logic] call ace_repair_fnc_moduleRepairSettings
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -16,33 +16,45 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
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
|
||||
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);
|
||||
_config = configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints";
|
||||
private _config = configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints";
|
||||
|
||||
// define global variables. Needed to parse the depends config entries. Also find dependent hitpoints.
|
||||
private _realHitPoints = [];
|
||||
private _dependentHitPoints = [];
|
||||
private _dependentHitPointScripts = [];
|
||||
|
||||
_dependentHitPoints = [];
|
||||
_dependentHitPointScripts = [];
|
||||
// Find dependent hitpoints
|
||||
{
|
||||
if ((_x != "") && {isClass (_config >> _x)} && {!(_x in _realHitPoints)}) then {
|
||||
_realHitPoints pushBack _x;
|
||||
if (isText (_config >> _x >> "depends")) then {
|
||||
_dependentHitPoints pushBack _x;
|
||||
_dependentHitPointScripts pushBack compile getText (_config >> _x >> "depends");
|
||||
};
|
||||
};
|
||||
} 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];
|
||||
if (isText (_config >> _x >> "depends")) then {
|
||||
_dependentHitPoints pushBack _x;
|
||||
_dependentHitPointScripts pushBack compile getText (_config >> _x >> "depends");
|
||||
};
|
||||
} forEach _hitPoints;
|
||||
} forEach _realHitPoints;
|
||||
|
||||
// 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];
|
||||
} forEach _dependentHitPoints;
|
||||
|
@ -4,8 +4,8 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT
|
||||
* 2: Selected hitpoint <STRING>
|
||||
* 1: Vehicle to repair <OBJECT>
|
||||
* 2: Selected hitpoint or hitpointIndex <STRING>or<NUMBER>
|
||||
* 3: Repair Action Classname <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
@ -21,22 +21,22 @@
|
||||
params ["_caller", "_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"];
|
||||
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);
|
||||
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 {
|
||||
getNumber (_config >> "requiredEngineer");
|
||||
} else {
|
||||
// Check for required class
|
||||
if (isText (_config >> "requiredEngineer")) exitwith {
|
||||
if (isText (_config >> "requiredEngineer")) exitWith {
|
||||
missionNamespace getVariable [(getText (_config >> "requiredEngineer")), 0];
|
||||
};
|
||||
0;
|
||||
};
|
||||
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitwith {false};
|
||||
if (isEngineOn _target) exitwith {false};
|
||||
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitWith {false};
|
||||
if (isEngineOn _target) exitWith {false};
|
||||
|
||||
//Items can be an array of required items or a string to a ACE_Setting array
|
||||
_items = if (isArray (_config >> "items")) then {
|
||||
@ -49,12 +49,12 @@ _items = if (isArray (_config >> "items")) then {
|
||||
};
|
||||
_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;
|
||||
if (getText (_config >> "condition") != "") then {
|
||||
_condition = getText (_config >> "condition");
|
||||
if (isnil _condition) then {
|
||||
if (isNil _condition) then {
|
||||
_condition = compile _condition;
|
||||
} else {
|
||||
_condition = missionNamespace getVariable _condition;
|
||||
@ -65,48 +65,62 @@ if (getText (_config >> "condition") != "") then {
|
||||
_return = [_caller, _target, _hitPoint, _className] call _condition;
|
||||
};
|
||||
};
|
||||
if (!_return) exitwith {false};
|
||||
if (!_return) exitWith {false};
|
||||
|
||||
_vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
|
||||
missionNamespace getVariable [getText(_config >> "vehicleStateCondition"), 0]
|
||||
} else {
|
||||
getNumber(_config >> "vehicleStateCondition")
|
||||
};
|
||||
// if (_vehicleStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitwith {false};
|
||||
// _vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
|
||||
// missionNamespace getVariable [getText(_config >> "vehicleStateCondition"), 0]
|
||||
// } else {
|
||||
// getNumber(_config >> "vehicleStateCondition")
|
||||
// };
|
||||
// if (_vehicleStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitWith {false};
|
||||
|
||||
_locations = getArray (_config >> "repairLocations");
|
||||
if ("All" in _locations) exitwith {true};
|
||||
|
||||
private ["_repairFacility", "_repairVeh"];
|
||||
_repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
|
||||
_repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
|
||||
|
||||
{
|
||||
if (_x == "field") exitwith {_return = true;};
|
||||
if (_x == "RepairFacility" && _repairFacility) exitwith {_return = true;};
|
||||
if (_x == "RepairVehicle" && _repairVeh) exitwith {_return = true;};
|
||||
if !(isnil _x) exitwith {
|
||||
private "_val";
|
||||
_val = missionNamespace getVariable _x;
|
||||
if (typeName _val == "SCALAR") then {
|
||||
_return = switch (_val) do {
|
||||
case 0: {true}; //useAnywhere
|
||||
case 1: {call _repairVeh}; //repairVehicleOnly
|
||||
case 2: {call _repairFacility}; //repairFacilityOnly
|
||||
case 3: {(call _repairFacility) || {call _repairVeh}}; //vehicleAndFacility
|
||||
default {false}; //Disabled
|
||||
private _repairLocations = getArray (_config >> "repairLocations");
|
||||
if (!("All" in _repairLocations)) then {
|
||||
private _repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
|
||||
private _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
|
||||
{
|
||||
if (_x == "field") exitWith {_return = true;};
|
||||
if (_x == "RepairFacility" && _repairFacility) exitWith {_return = true;};
|
||||
if (_x == "RepairVehicle" && _repairVeh) exitWith {_return = true;};
|
||||
if !(isNil _x) exitWith {
|
||||
private _val = missionNamespace getVariable _x;
|
||||
if (typeName _val == "SCALAR") then {
|
||||
_return = switch (_val) do {
|
||||
case 0: {true}; //useAnywhere
|
||||
case 1: {call _repairVeh}; //repairVehicleOnly
|
||||
case 2: {call _repairFacility}; //repairFacilityOnly
|
||||
case 3: {(call _repairFacility) || {call _repairVeh}}; //vehicleAndFacility
|
||||
default {false}; //Disabled
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach _locations;
|
||||
} forEach _repairLocations;
|
||||
};
|
||||
|
||||
if !(_return && alive _target) exitwith {false};
|
||||
private _requiredObjects = getArray (_config >> "claimObjects");
|
||||
private _claimObjectsAvailable = [];
|
||||
if (!(_requiredObjects isEqualTo [])) then {
|
||||
_claimObjectsAvailable = [_caller, 5, _requiredObjects] call FUNC(getClaimObjects);
|
||||
if (_claimObjectsAvailable isEqualTo []) then {
|
||||
TRACE_2("Missing Required Objects",_requiredObjects,_claimObjectsAvailable);
|
||||
_return = false
|
||||
};
|
||||
};
|
||||
|
||||
if !(_return && alive _target) exitWith {false};
|
||||
//Last exitWith: repair_success or repair_failure will be run
|
||||
|
||||
//Claim required objects
|
||||
{
|
||||
TRACE_2("Claiming", _x, (typeOf _x));
|
||||
[_caller, _x, false] call EFUNC(common,claim);
|
||||
} forEach _claimObjectsAvailable;
|
||||
|
||||
_consumeItems = if (isNumber (_config >> "itemConsumed")) then {
|
||||
getNumber (_config >> "itemConsumed");
|
||||
} else {
|
||||
// Check for required class
|
||||
if (isText (_config >> "itemConsumed")) exitwith {
|
||||
if (isText (_config >> "itemConsumed")) exitWith {
|
||||
missionNamespace getVariable [(getText (_config >> "itemConsumed")), 0];
|
||||
};
|
||||
0;
|
||||
@ -160,14 +174,14 @@ if (vehicle _caller == _caller && {_callerAnim != ""}) then {
|
||||
_repairTime = if (isNumber (_config >> "repairingTime")) then {
|
||||
getNumber (_config >> "repairingTime");
|
||||
} else {
|
||||
if (isText (_config >> "repairingTime")) exitwith {
|
||||
if (isText (_config >> "repairingTime")) exitWith {
|
||||
_repairTimeConfig = getText(_config >> "repairingTime");
|
||||
if (isnil _repairTimeConfig) then {
|
||||
if (isNil _repairTimeConfig) then {
|
||||
_repairTimeConfig = compile _repairTimeConfig;
|
||||
} else {
|
||||
_repairTimeConfig = missionNamespace getVariable _repairTimeConfig;
|
||||
};
|
||||
if (typeName _repairTimeConfig == "SCALAR") exitwith {
|
||||
if (typeName _repairTimeConfig == "SCALAR") exitWith {
|
||||
_repairTimeConfig;
|
||||
};
|
||||
[_caller, _target, _hitPoint, _className] call _repairTimeConfig;
|
||||
@ -177,13 +191,21 @@ _repairTime = if (isNumber (_config >> "repairingTime")) then {
|
||||
|
||||
private ["_processText"];
|
||||
// Find localized string
|
||||
_hitPointClassname = if ((typeName _hitPoint) == "STRING") then {
|
||||
_hitPoint
|
||||
} else {
|
||||
((getAllHitPointsDamage _target) select 0) select _hitPoint
|
||||
};
|
||||
_processText = getText (_config >> "displayNameProgress");
|
||||
([_hitPoint, _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);
|
||||
|
||||
// Start repair
|
||||
[
|
||||
_repairTime,
|
||||
[_caller, _target, _hitPoint, _className, _items, _usersOfItems],
|
||||
[_caller, _target, _hitPoint, _className, _items, _usersOfItems, _claimObjectsAvailable],
|
||||
DFUNC(repair_success),
|
||||
DFUNC(repair_failure),
|
||||
_text,
|
||||
|
@ -6,23 +6,24 @@
|
||||
* 0: Arguments <ARRAY>
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT
|
||||
* 2: Selected hitpoint <STRING>
|
||||
* 2: Selected hitpoint or hitpointIndex <STRING>or<NUMBER>
|
||||
* 3: Repair Action Classname <STRING>
|
||||
* 4: None
|
||||
* 5: Items available <ARRAY>
|
||||
* 6: Claimed Repair Objects <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [[unit, vehicle, "hitpoint", "classname", nil, [items]]] call ace_repair_fnc_repair_failure
|
||||
* [[unit, vehicle, "hitpoint", "classname", nil, [items], [aWheel]]] call ace_repair_fnc_repair_failure
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_args"];
|
||||
_args params ["_caller", "_target","_selectionName","_className","","_usersOfItems"];
|
||||
_args params ["_caller", "_target","_selectionName","_className","","_usersOfItems", "_claimedObjects"];
|
||||
TRACE_5("params",_caller,_target,_selectionName,_className,_usersOfItems);
|
||||
|
||||
private ["_config","_callback", "_usersOfItems", "_weaponSelect"];
|
||||
@ -46,6 +47,13 @@ if (_weaponSelect != "") then {
|
||||
(_x select 0) addItem (_x select 1);
|
||||
} forEach _usersOfItems;
|
||||
|
||||
//Unclaim repair objects:
|
||||
{
|
||||
TRACE_2("Releasing", _x, (typeOf _x));
|
||||
[objNull, _x, false] call EFUNC(common,claim);
|
||||
} forEach _claimedObjects;
|
||||
|
||||
|
||||
// Record specific callback
|
||||
_config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className);
|
||||
|
||||
@ -58,4 +66,4 @@ if (isNil _callback) then {
|
||||
|
||||
_args call _callback;
|
||||
|
||||
// _args call FUNC(createLitter);
|
||||
//todo: repair litter?
|
||||
|
@ -6,21 +6,24 @@
|
||||
* 0: Arguments <ARRAY>
|
||||
* 0: Unit that does the repairing <OBJECT>
|
||||
* 1: Vehicle to repair <OBJECT
|
||||
* 2: Selected hitpoint <STRING>
|
||||
* 2: Selected hitpoint or hitpointIndex <STRING>or<NUMBER>
|
||||
* 3: Repair Action Classname <STRING>
|
||||
* 4: Items <ARRAY>
|
||||
* 5: User of Items <ARRAY>
|
||||
* 6: Claimed Repair Objects <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [[unit, vehicle, "hitpoint", "classname"]] call ace_repair_fnc_repair_success
|
||||
* [[unit, vehicle, "hitpoint", "classname", [], [], [aWheel]]] call ace_repair_fnc_repair_success
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_args"];
|
||||
_args params ["_caller", "_target","_selectionName","_className"];
|
||||
_args params ["_caller", "_target","_selectionName","_className","","","_claimedObjects"];
|
||||
TRACE_4("params",_caller,_target,_selectionName,_className);
|
||||
|
||||
private ["_config","_callback", "_weaponSelect"];
|
||||
@ -40,6 +43,12 @@ if (_weaponSelect != "") then {
|
||||
_caller action ["SwitchWeapon", _caller, _caller, 99];
|
||||
};
|
||||
|
||||
//Unclaim repair objects:
|
||||
{
|
||||
TRACE_2("Releasing", _x, (typeOf _x));
|
||||
[objNull, _x, false] call EFUNC(common,claim);
|
||||
} forEach _claimedObjects;
|
||||
|
||||
// Record specific callback
|
||||
_config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className);
|
||||
|
||||
@ -51,4 +60,4 @@ if (isNil _callback) then {
|
||||
};
|
||||
_args call _callback;
|
||||
|
||||
// _args call FUNC(createLitter);
|
||||
//todo: repair litter?
|
||||
|
@ -1,86 +1,83 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Set the hitpoint damage and change the structural damage acordingly, requires local vehicle.
|
||||
* Handles the "setVehicleHitPointDamage" event
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Local Vehicle to Damage <OBJECT>
|
||||
* 1: Selected hitpoint <STRING>
|
||||
* 1: Selected hitpoint INDEX <NUMBER>
|
||||
* 2: Total Damage <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [vehicle, "hitpoint", 0.5] call ace_repair_fnc_setHitPointDamage
|
||||
* [vehicle, 1, 0.5] call ace_repair_fnc_setHitPointDamage
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_vehicle", "_hitPoint", "_hitPointDamage"];
|
||||
TRACE_3("params",_vehicle,_hitPoint,_hitPointDamage);
|
||||
params ["_vehicle", "_hitPointIndex", "_hitPointDamage"];
|
||||
TRACE_4("params",_vehicle,typeOf _vehicle,_hitPointIndex,_hitPointDamage);
|
||||
|
||||
private["_damageNew", "_damageOld", "_hitPointDamageRepaired", "_hitPointDamageSumOld", "_realHitpointCount", "_selectionName"];
|
||||
|
||||
// can't execute all commands if the vehicle isn't local. exit here.
|
||||
if !(local _vehicle) exitWith {};
|
||||
if !(local _vehicle) exitWith {ACE_LOGERROR_1("Vehicle Not Local %1", _vehicle);};
|
||||
|
||||
// get all valid hitpoints
|
||||
private ["_hitPoints", "_hitPointsWithSelections"];
|
||||
//Check for bad typeName (changed from orignal v3.3 that took string)
|
||||
if ((typeName _hitPointIndex) == "STRING") then {
|
||||
ACE_DEPRECATED("repair-setHitPointDamage (hit point name <string>","3.5.0","hit index <number>");
|
||||
_hitPointIndex = _allHitPoints find _hitPointIndex;
|
||||
};
|
||||
|
||||
_hitPoints = [_vehicle] call EFUNC(common,getHitpoints);
|
||||
_hitPointsWithSelections = [_vehicle] call EFUNC(common,getHitpointsWithSelections) select 0;
|
||||
// get all hitpoints and selections and damages
|
||||
(getAllHitPointsDamage _vehicle) params [["_allHitPoints", []], ["_allHitPointsSelections", []], ["_allHitPointDamages", []]];
|
||||
|
||||
// exit if the hitpoint is not valid
|
||||
if !(_hitPoint in _hitPoints) exitWith {systemChat format["NOT A VALID HITPOINT: %1",_hitpoint]};
|
||||
|
||||
// save array with damage values of all hitpoints
|
||||
private "_hitPointDamages";
|
||||
_hitPointDamages = [];
|
||||
|
||||
{
|
||||
_hitPointDamages set [_forEachIndex, (_vehicle getHitPointDamage _x)];
|
||||
} forEach _hitPoints;
|
||||
if ((_hitPointIndex < 0) || {_hitPointIndex >= (count _allHitPoints)}) exitWith {ACE_LOGERROR_2("NOT A VALID HITPOINT: %1-%2", _hitPointIndex,_vehicle);};
|
||||
|
||||
// save structural damage and sum of hitpoint damages
|
||||
private ["_damageOld", "_hitPointDamageSumOld"];
|
||||
|
||||
_damageOld = damage _vehicle;
|
||||
|
||||
_realHitpointCount = 0;
|
||||
_hitPointDamageSumOld = 0;
|
||||
_hitPointDamageRepaired = 0; //positive for repairs : newSum = (oldSum - repaired)
|
||||
{
|
||||
if (!(_x in IGNORED_HITPOINTS) && {!isText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints" >> _x >> "depends")}) then {
|
||||
_hitPointDamageSumOld = _hitPointDamageSumOld + (_hitPointDamages select (_hitPoints find _x));
|
||||
_selectionName = _allHitPointsSelections select _forEachIndex;
|
||||
//Filter out all the bad hitpoints (HitPoint="" or no selection)
|
||||
if ((!isNil {_vehicle getHit _selectionName}) && {_x != ""}) then {
|
||||
_realHitpointCount = _realHitpointCount + 1;
|
||||
|
||||
if ((((toLower _x) find "glass") == -1) && {!isText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints" >> _x >> "depends")}) then {
|
||||
_hitPointDamageSumOld = _hitPointDamageSumOld + (_allHitPointDamages select _forEachIndex);
|
||||
if (_forEachIndex == _hitPointIndex) then {
|
||||
_hitPointDamageRepaired = (_allHitPointDamages select _forEachIndex) - _hitPointDamage;
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach _hitPointsWithSelections;
|
||||
} forEach _allHitPoints;
|
||||
|
||||
// set new damage in array
|
||||
_hitPointDamages set [_hitPoints find _hitPoint, _hitPointDamage];
|
||||
|
||||
// save sum of new hitpoint damages
|
||||
private "_hitPointDamageSumNew";
|
||||
|
||||
_hitPointDamageSumNew = 0;
|
||||
{
|
||||
if (!(_x in IGNORED_HITPOINTS) && {!isText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints" >> _x >> "depends")}) then {
|
||||
_hitPointDamageSumNew = _hitPointDamageSumNew + (_hitPointDamages select (_hitPoints find _x));
|
||||
};
|
||||
} forEach _hitPointsWithSelections;
|
||||
|
||||
// calculate new strctural damage
|
||||
private "_damageNew";
|
||||
_damageNew = _hitPointDamageSumNew / count _hitPoints;
|
||||
// calculate new structural damage
|
||||
_damageNew = (_hitPointDamageSumOld - _hitPointDamageRepaired) / _realHitpointCount;
|
||||
|
||||
if (_hitPointDamageSumOld > 0) then {
|
||||
_damageNew = _damageOld * (_hitPointDamageSumNew / _hitPointDamageSumOld);
|
||||
_damageNew = _damageOld * ((_hitPointDamageSumOld - _hitPointDamageRepaired) / _hitPointDamageSumOld);
|
||||
};
|
||||
TRACE_5("structuralDamage",_damageOld,_damageNew,_hitPointDamageRepaired,_hitPointDamageSumOld,_realHitpointCount);
|
||||
|
||||
// set new structural damage value
|
||||
_vehicle setDamage _damageNew;
|
||||
|
||||
// set the new damage for that hit point
|
||||
//Repair the hitpoint in the damages array:
|
||||
_allHitPointDamages set [_hitPointIndex, _hitPointDamage];
|
||||
|
||||
//Set the new damage for all hitpoints
|
||||
{
|
||||
_vehicle setHitPointDamage [_x, _hitPointDamages select _forEachIndex];
|
||||
} forEach _hitPoints;
|
||||
_vehicle setHitIndex [_forEachIndex, _x];
|
||||
} forEach _allHitPointDamages;
|
||||
|
||||
// normalize hitpoints
|
||||
// [_vehicle] call FUNC(normalizeHitPoints);
|
||||
[_vehicle] call FUNC(normalizeHitPoints);
|
||||
|
@ -4,11 +4,11 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Item classname <STRING>
|
||||
* 1: Position <ARRAY>
|
||||
* 1: Position ASL <ARRAY>
|
||||
* 2: Damage <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
* The new object <OBJECT>
|
||||
*
|
||||
* Example:
|
||||
* ["classname", [0, 0, 0], 1] call ace_repair_fnc_spawnObject
|
||||
@ -23,10 +23,12 @@ TRACE_3("params",_item,_position,_damage);
|
||||
// randomized end position
|
||||
_position = _position vectorAdd [1 - random 2, 1 - random 2, 0];
|
||||
|
||||
_item = createVehicle [_item, _position, [], 0, "NONE"];
|
||||
_item setPosASL _position;
|
||||
private _newObject = createVehicle [_item, _position, [], 0, "NONE"];
|
||||
_newObject setPosASL _position;
|
||||
|
||||
["fixCollision", _item] call EFUNC(common,localEvent);
|
||||
["fixPosition", _item] call EFUNC(common,localEvent);
|
||||
_newObject setDamage _damage;
|
||||
|
||||
_item setDamage _damage;
|
||||
["fixCollision", _newObject] call EFUNC(common,localEvent);
|
||||
["fixPosition", _newObject] call EFUNC(common,localEvent);
|
||||
|
||||
_newObject
|
||||
|
@ -4,10 +4,10 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 2: Item classname <STRING>
|
||||
* 1: Item classname <STRING>
|
||||
*
|
||||
* ReturnValue:
|
||||
* None
|
||||
* [Had Item to Use <BOOL>, Unit <OBJECT>] <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [unit, "classname"] call ace_repair_fnc_useItem
|
||||
@ -19,8 +19,9 @@
|
||||
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 */
|
||||
[true, _unit];
|
||||
};
|
||||
|
||||
[false, objNull];
|
||||
|
@ -7,7 +7,7 @@
|
||||
* 1: Item classnames <ARRAY>
|
||||
*
|
||||
* ReturnValue:
|
||||
* None
|
||||
* [Had Item to Use <BOOL>, Array of units that used the items <ARRAY>] <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [unit, ["classname1", "classname2"]] call ace_repair_fnc_useItems
|
||||
@ -27,14 +27,14 @@ _itemsUsedBy = [];
|
||||
if (typeName _x == "ARRAY") then {
|
||||
{
|
||||
_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;
|
||||
};
|
||||
|
||||
// handle required item
|
||||
if (typeName _x == "STRING") then {
|
||||
_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;
|
||||
|
||||
|
@ -13,6 +13,4 @@
|
||||
|
||||
#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"]
|
||||
|
Loading…
Reference in New Issue
Block a user