2307 - Repair sub-turrets

Privates

Cleanup debug

Add repair actions for sub turrets

Cleanup

Fix Header

Error Handling

Cleanup setHitpointDamage

Fix common ACE_isEngineer to handle scalar or bool

Claim and release repair objects (wheel/track)

Repair sub-turrets
This commit is contained in:
PabstMirror 2015-09-25 23:36:35 -05:00
parent d0cb09196d
commit 4e93b9c72d
32 changed files with 457 additions and 366 deletions

View File

@ -8,10 +8,17 @@
* Return Value: * Return Value:
* is the unit an engineer <BOOL> * is the unit an engineer <BOOL>
* *
* Example:
* [player] call ace_common_fnc_isEngineer
*
* Public: Yes * Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit"]; params ["_unit"];
_unit getVariable ["ACE_isEngineer", getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "engineer") == 1] // return local _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

View File

@ -4,13 +4,14 @@ class ACE_Repair {
displayName = CSTRING(ReplaceWheel); displayName = CSTRING(ReplaceWheel);
displayNameProgress = CSTRING(ReplacingWheel); displayNameProgress = CSTRING(ReplacingWheel);
locations[] = {"All"}; repairLocations[] = {"All"};
requiredEngineer = QGVAR(engineerSetting_Wheel); requiredEngineer = QGVAR(engineerSetting_Wheel);
repairingTime = 10; repairingTime = 10;
repairingTimeSelfCoef = 1; repairingTimeSelfCoef = 1;
items = QGVAR(wheelRepairRequiredItems); items = QGVAR(wheelRepairRequiredItems);
condition = QUOTE(call FUNC(canReplaceWheel)); condition = QUOTE(call FUNC(canReplaceWheel));
itemConsumed = 0; itemConsumed = 0;
claimObjects[] = {{"ACE_Wheel"}};
callbackSuccess = QUOTE(call FUNC(doReplaceWheel)); callbackSuccess = QUOTE(call FUNC(doReplaceWheel));
callbackFailure = ""; callbackFailure = "";
@ -27,6 +28,7 @@ class ACE_Repair {
displayNameProgress = CSTRING(RemovingWheel); displayNameProgress = CSTRING(RemovingWheel);
condition = QUOTE(call FUNC(canRemove)); condition = QUOTE(call FUNC(canRemove));
callbackSuccess = QUOTE(call FUNC(doRemoveWheel)); callbackSuccess = QUOTE(call FUNC(doRemoveWheel));
claimObjects[] = {};
}; };
class MiscRepair: ReplaceWheel { class MiscRepair: ReplaceWheel {
displayName = CSTRING(Repairing); // let's make empty string an auto generated string displayName = CSTRING(Repairing); // let's make empty string an auto generated string
@ -36,6 +38,7 @@ class ACE_Repair {
repairingTime = 15; repairingTime = 15;
callbackSuccess = QUOTE(call FUNC(doRepair)); callbackSuccess = QUOTE(call FUNC(doRepair));
items[] = {"ToolKit"}; items[] = {"ToolKit"};
claimObjects[] = {};
}; };
class RepairTrack: MiscRepair { class RepairTrack: MiscRepair {
displayName = CSTRING(Repairing); displayName = CSTRING(Repairing);
@ -43,6 +46,7 @@ class ACE_Repair {
condition = QUOTE(call FUNC(canRepairTrack)); condition = QUOTE(call FUNC(canRepairTrack));
callbackSuccess = QUOTE(call FUNC(doRepairTrack)); callbackSuccess = QUOTE(call FUNC(doRepairTrack));
requiredEngineer = QGVAR(engineerSetting_Wheel); requiredEngineer = QGVAR(engineerSetting_Wheel);
claimObjects[] = {{"ACE_Track"}};
}; };
class RemoveTrack: MiscRepair { class RemoveTrack: MiscRepair {
displayName = CSTRING(RemoveTrack); displayName = CSTRING(RemoveTrack);
@ -57,6 +61,7 @@ class ACE_Repair {
condition = QUOTE(call FUNC(canReplaceTrack)); condition = QUOTE(call FUNC(canReplaceTrack));
callbackSuccess = QUOTE(call FUNC(doReplaceTrack)); callbackSuccess = QUOTE(call FUNC(doReplaceTrack));
requiredEngineer = QGVAR(engineerSetting_Wheel); requiredEngineer = QGVAR(engineerSetting_Wheel);
claimObjects[] = {{"ACE_Track"}};
}; };
class FullRepair: MiscRepair { class FullRepair: MiscRepair {
displayName = CSTRING(fullRepair); displayName = CSTRING(fullRepair);

View File

@ -404,4 +404,7 @@ class CfgVehicles {
class B_Quadbike_01_F: Quadbike_01_base_F { class B_Quadbike_01_F: Quadbike_01_base_F {
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 {
GVAR(hitpointPositions[]) = {{"HitBody", {0, 0.7, -0.5}}};
};
}; };

View File

@ -17,6 +17,7 @@ PREP(doRepair);
PREP(doRepairTrack); PREP(doRepairTrack);
PREP(doReplaceTrack); PREP(doReplaceTrack);
PREP(doReplaceWheel); PREP(doReplaceWheel);
PREP(getClaimObjects);
PREP(getHitPointString); PREP(getHitPointString);
PREP(getPostRepairDamage); PREP(getPostRepairDamage);
PREP(getWheelHitPointsWithSelections); PREP(getWheelHitPointsWithSelections);

View File

@ -13,12 +13,13 @@
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_vehicle"]; params ["_vehicle"];
TRACE_1("params", _vehicle); TRACE_1("params", _vehicle);
private ["_type", "_initializedClasses", "_condition", "_statement", "_action"]; private ["_type", "_initializedClasses", "_condition", "_statement", "_action", "_duplicateHitpointName", "_processedHitPoints", "_selectionName", "_hitPointsAddedNames", "_hitPointsAddedStrings", "_hitPointsAddedAmount"];
_type = typeOf _vehicle; _type = typeOf _vehicle;
@ -28,33 +29,43 @@ _initializedClasses = GETMVAR(GVAR(initializedClasses),[]);
if (_type in _initializedClasses) exitWith {}; if (_type in _initializedClasses) exitWith {};
// get all hitpoints and selections // get all hitpoints and selections
([_vehicle] call EFUNC(common,getHitPointsWithSelections)) params ["_hitPoints", "_hitPointsSelections"]; (getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitPointsSelections", []]];
if (_hitPoints isEqualTo []) exitWith {ACE_LOGERROR_1("No Hitpoints on %1", _type);};
// get hitpoints of wheels with their selections // get hitpoints of wheels with their selections
([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitPointSelections"]; ([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitPointSelections"];
private ["_hitPointsAddedNames", "_hitPointsAddedStrings", "_hitPointsAddedAmount"];
_hitPointsAddedNames = []; _hitPointsAddedNames = [];
_hitPointsAddedStrings = []; _hitPointsAddedStrings = [];
_hitPointsAddedAmount = []; _hitPointsAddedAmount = [];
_processedHitPoints = [];
// add repair events to this vehicle class // add repair events to this vehicle class
{ {
_duplicateHitpointName = (_x in _processedHitPoints);
_processedHitPoints pushBack _x;
_selectionName = _hitPointsSelections select _forEachIndex;
if (_x in _wheelHitPoints) then { if (_x in _wheelHitPoints) then {
// add wheel repair action // add wheel repair action
if (_duplicateHitpointName) exitWith {TRACE_3("Duplicate Wheel",_x,_forEachIndex,_selectionName);}; //Wheels should always be unique
if (isNil {_vehicle getHit _selectionName}) exitWith {TRACE_3("No Selection",_x,_forEachIndex,_selectionName);}; //Not a real hitpoint
private ["_icon", "_selection", "_name", "_text"]; private ["_icon", "_selection", "_name", "_text"];
_icon = QUOTE(PATHTOF(ui\tire_ca.paa)); // _icon = QUOTE(PATHTOF(ui\tire_ca.paa));
_icon = "A3\ui_f\data\igui\cfg\actions\repair_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); _selection = _wheelHitPointSelections select (_wheelHitPoints find _x);
// remove wheel action // remove wheel action
_name = format ["Remove_%1", _x]; _name = format ["Remove_%1_%2", _forEachIndex, _x];
_text = localize LSTRING(RemoveWheel); _text = localize LSTRING(RemoveWheel);
TRACE_5("Adding Wheel Actions",_name,_forEachIndex,_selectionName,_text,_selection);
_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)};
@ -62,7 +73,7 @@ _hitPointsAddedAmount = [];
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass); [_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
// replace wheel action // replace wheel action
_name = format ["Replace_%1", _x]; _name = format ["Replace_%1_%2", _forEachIndex, _x];
_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)};
@ -73,7 +84,9 @@ _hitPointsAddedAmount = [];
} else { } else {
// exit if the hitpoint is in the blacklist, e.g. glasses // exit if the hitpoint is in the blacklist, e.g. glasses
if (_x in IGNORED_HITPOINTS) exitWith {}; if (_x in IGNORED_HITPOINTS) exitWith {TRACE_3("Ignored Hitpoint",_x,_forEachIndex,_selectionName);};
if (_x == "") exitWith {TRACE_3("Hitpoint Empty",_x,_forEachIndex,_selectionName);};
if (isNil {_vehicle getHit _selectionName}) exitWith {TRACE_3("No Selection",_x,_forEachIndex,_selectionName);}; //Not a real hitpoint
private ["_hitpointGroupConfig", "_inHitpointSubGroup", "_currentHitpoint"]; private ["_hitpointGroupConfig", "_inHitpointSubGroup", "_currentHitpoint"];
@ -93,15 +106,15 @@ _hitPointsAddedAmount = [];
}; };
// Exit if current hitpoint is in sub-group (only main hitpoints get actions) // Exit if current hitpoint is in sub-group (only main hitpoints get actions)
if (_inHitpointSubGroup) exitWith {}; if (_inHitpointSubGroup) exitWith {TRACE_3("inHitpointSubGroup",_x,_forEachIndex,_selectionName);};
// exit if the hitpoint is virtual // exit if the hitpoint is virtual
if (isText (configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "depends")) exitWith {}; if (isText (configFile >> "CfgVehicles" >> _type >> "HitPoints" >> _x >> "depends")) exitWith {TRACE_3("Depends",_x,_forEachIndex,_selectionName);};
// add misc repair action // add misc repair action
private ["_name", "_icon", "_selection", "_customSelectionsConfig"]; private ["_name", "_icon", "_selection", "_customSelectionsConfig"];
_name = format ["Repair_%1", _x]; _name = format ["Repair_%1_%2", _forEachIndex, _x];
// Find localized string and track those added for numerization // Find localized string and track those added for numerization
([_x, "%1", _x, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_text", "_trackArray"]; ([_x, "%1", _x, [_hitPointsAddedNames, _hitPointsAddedStrings, _hitPointsAddedAmount]] call FUNC(getHitPointString)) params ["_text", "_trackArray"];
@ -135,22 +148,26 @@ _hitPointsAddedAmount = [];
// If position still empty (not a position array or selection name) try extracting from model // If position still empty (not a position array or selection name) try extracting from model
if (typeName _selection == "STRING" && {_selection == ""}) then { if (typeName _selection == "STRING" && {_selection == ""}) then {
_selection = _vehicle selectionPosition (_hitPointsSelections select (_hitPoints find _x)); _selection = _vehicle selectionPosition _selectionName;
}; };
_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 in TRACK_HITPOINTS) then {
if (_duplicateHitpointName) exitWith {TRACE_3("Duplicate Track",_x,_forEachIndex,_selectionName);}; //Tracks should always be unique
if (_x == "HitLTrack") then { if (_x == "HitLTrack") then {
_selection = [-1.75, 0, -1.75]; _selection = [-1.75, 0, -1.75];
} else { } else {
_selection = [1.75, 0, -1.75]; _selection = [1.75, 0, -1.75];
}; };
_action = [_name, _text, _icon, _statement, _condition, {}, [_x, "RepairTrack"], _selection, 4] call EFUNC(interact_menu,createAction); TRACE_5("Adding RepairTrack",_name,_forEachIndex,_selectionName,_text,_selection);
_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, {}, [_x], _selection, 4] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass); [_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
} else { } else {
_action = [_name, _text, _icon, _statement, _condition, {}, [_x, "MiscRepair"], _selection, 4] call EFUNC(interact_menu,createAction); TRACE_5("Adding MiscRepair",_name,_forEachIndex,_selectionName,_text,_selection);
_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], _selection, 5] call EFUNC(interact_menu,createAction);
// Put inside main actions if no other position was found above // Put inside main actions if no other position was found above
if (_selection isEqualTo [0, 0, 0]) then { if (_selection isEqualTo [0, 0, 0]) then {
[_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass); [_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);
@ -161,10 +178,11 @@ _hitPointsAddedAmount = [];
}; };
} forEach _hitPoints; } forEach _hitPoints;
_condition = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(canRepair)}; _condition = {[_this select 1, _this select 0, "", "fullRepair"] call DFUNC(canRepair)};
_statement = {[_this select 1, _this select 0, _this select 2 select 0, _this select 2 select 1] call DFUNC(repair)}; _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, {}, ["", "fullRepair"], "", 4] call EFUNC(interact_menu,createAction); _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); [_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);
// set class as initialized // set class as initialized
_initializedClasses pushBack _type; _initializedClasses pushBack _type;

View File

@ -18,7 +18,6 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_part"];
params ["_vehicle", ["_amount", 1], ["_part", ""], ["_force", false]]; params ["_vehicle", ["_amount", 1], ["_part", ""], ["_force", false]];
TRACE_2("params",_vehicle,_amount); TRACE_2("params",_vehicle,_amount);

View File

@ -5,38 +5,51 @@
* Arguments: * Arguments:
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT> * 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING> * 2: Selected hitpoint INDEX <NUMBER>
* *
* Return Value: * Return Value:
* Can Misc Repair <BOOL> * Can Misc Repair <BOOL>
* *
* Example: * Example:
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_canMiscRepair * [unit, vehicle, 5] call ace_repair_fnc_canMiscRepair
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_hitpointGroupConfig", "_hitpointGroup", "_postRepairDamage", "_return"]; private ["_hitpointGroupConfig", "_hitpointGroup", "_postRepairDamage", "_return", "_hitPointClassname", "_subHitIndex"];
params ["_caller", "_target", "_hitPoint"]; 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 // Get hitpoint groups if available
_hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(hitpointGroups); _hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(hitpointGroups);
_hitpointGroup = []; _hitpointGroup = [];
if (isArray _hitpointGroupConfig) then { if (isArray _hitpointGroupConfig) then {
_hitPointClassname = _allHitPoints select _hitPointIndex;
// Retrieve hitpoint subgroup if current hitpoint is main hitpoint of a group // 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 // Exit using found hitpoint group if this hitpoint is leader of any
if (_x select 0 == _hitPoint) exitWith { if (_masterHitpoint == _hitPointClassname) exitWith {
_hitpointGroup = _x select 1; {
_subHitIndex = _allHitPoints find _x;
if (_subHitIndex == -1) then {
ERROR("Hitpoint Not Found");
} else {
_hitpointGroup pushBack _subHitIndex;
};
} forEach _subHitArray;
}; };
} forEach (getArray _hitpointGroupConfig); } forEach (getArray _hitpointGroupConfig);
}; };
// Add current hitpoint to the group // Add current hitpoint to the group
_hitpointGroup pushBack _hitPoint; _hitpointGroup pushBack _hitPointIndex;
// Get post repair damage // Get post repair damage
_postRepairDamage = [_caller] call FUNC(getPostRepairDamage); _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 true if damage can be repaired on any hitpoint in the group, else false
_return = false; _return = false;
{ {
if ((_target getHitPointDamage _x) > _postRepairDamage) exitWith { if ((_allHitPointDamages select _x) > _postRepairDamage) exitWith {
_return = true; _return = true;
}; };
} forEach _hitpointGroup; } forEach _hitpointGroup;

View File

@ -5,14 +5,14 @@
* Arguments: * Arguments:
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT> * 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING> * 2: Selected hitpoint or hitpointIndex <STRING>or<NUMBER>
* 3: Repair Action Classname <STRING> * 3: Repair Action Classname <STRING>
* *
* Return Value: * Return Value:
* Can Repair <BOOL> * Can Repair <BOOL>
* *
* Example: * Example:
* ["something", player] call ace_repair_fnc_canRepair * [player, car, "HitHull", "MiscRepair"] call ace_repair_fnc_canRepair
* *
* Public: Yes * Public: Yes
*/ */
@ -68,27 +68,23 @@ 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};
_locations = getArray (_config >> "repairLocations"); local _repairLocations = getArray (_config >> "repairLocations");
if ("All" in _locations) exitwith {true}; if (!("All" in _repairLocations)) then {
local _repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
private ["_repairFacility", "_repairVeh"]; local _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
_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 == "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 {
private "_val"; local _val = missionNamespace getVariable _x;
_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
@ -99,6 +95,18 @@ _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC
}; };
}; };
}; };
} forEach _locations; } forEach _repairLocations;
};
if (!_return) exitwith {false};
_return && alive _target; //Check that there are required objects nearby
local _requiredObjects = getArray (_config >> "claimObjects");
if (!(_requiredObjects isEqualTo [])) then {
local _objectsAvailable = [_caller, 5, _requiredObjects] call FUNC(getClaimObjects);
if (_objectsAvailable isEqualTo []) then {
TRACE_2("Missing Required Objects",_requiredObjects,_objectsAvailable);
_return = false
};
};
_return && {alive _target};

View File

@ -1,6 +1,6 @@
/* /*
* Author: commy2 * 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: * Arguments:
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
@ -17,27 +17,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit", "_target", "_hitPoint", ["_wheel",false]]; params ["_unit", "_target", "_hitPoint"];
TRACE_4("params",_unit,_target,_hitPoint,_wheel); TRACE_3("params",_unit,_target,_hitPoint);
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
if !([_unit, _target, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([_unit, _target, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false};
if (typeName _wheel == "OBJECT") then { //check for a near track is handled by claimObjects[] config
// not near interpret as objNull
if !(_wheel in nearestObjects [_unit, ["ACE_Track"], 5]) then {
_wheel = objNull;
};
} else {
_wheel = objNull;
{ (_target getHitPointDamage _hitPoint > 0)
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}

View File

@ -1,12 +1,11 @@
/* /*
* Author: commy2 * 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: * Arguments:
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT> * 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING> * 2: Selected hitpoint <STRING>
* 3: Track <OBJECT>/<BOOL> (default: false)
* *
* Return Value: * Return Value:
* None * None
@ -18,27 +17,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit", "_target", "_hitPoint", ["_track", false]]; params ["_unit", "_target", "_hitPoint"];
TRACE_4("params",_unit,_target,_hitPoint,_track); TRACE_3("params",_unit,_target,_hitPoint);
// TODO [_unit, _track] call EFUNC(common,claim); on start of action
if !([_unit, _target, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([_unit, _target, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false};
if (typeName _track == "OBJECT") then { //check for a near track object is handled by claimObjects[] config
// not near interpret as objNull
if !(_track in nearestObjects [_unit, ["ACE_Track"], 5]) then {
_track = objNull;
};
} else {
_track = objNull;
{ (_target getHitPointDamage _hitPoint >= 1)
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}

View File

@ -6,7 +6,6 @@
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT> * 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING> * 2: Selected hitpoint <STRING>
* 3: Wheel <OBJECT>/<BOOL> (default: false)
* *
* Return Value: * Return Value:
* None * None
@ -18,31 +17,12 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit", "_target", "_hitPoint", ["_wheel", false]]; params ["_unit", "_target", "_hitPoint"];
TRACE_4("params",_unit,_target,_hitPoint,_wheel); TRACE_3("params",_unit,_target,_hitPoint);
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
//if !([_unit, _target, _hitpoint, "ReplaceWheel"] call FUNC(canRepair)) exitwith {false};
if !([_unit, _target, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {false}; 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 (_target getHitPointDamage _hitPoint >= 1)
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}

View File

@ -1,23 +1,22 @@
/* /*
* Author: Glowbal * Author: Glowbal
* Called by repair action / progress bar. Raise events to set the new hitpoint damage. * Fully repairs vehicle
* *
* Arguments: * Arguments:
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing (not used) <OBJECT>
* 1: Vehicle to repair <OBJECT> * 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_doFullRepair * [unit, vehicle] call ace_repair_fnc_doFullRepair
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit", "_vehicle", "_hitPoint"]; params ["", "_vehicle"];
TRACE_3("params",_unit,_vehicle,_hitPoint); TRACE_1("params",_vehicle);
_vehicle setDamage 0; _vehicle setDamage 0;

View File

@ -5,61 +5,70 @@
* Arguments: * Arguments:
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT> * 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING> * 2: Selected hitpointIndex <NUMBER>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_doRepair * [unit, vehicle, 6, "MiscRepair"] call ace_repair_fnc_doRepair
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_hitPointDamage", "_text", "_hitpointGroup"]; params ["_unit", "_vehicle", "_hitPointIndex"];
params ["_unit", "_vehicle", "_hitPoint"]; TRACE_3("params",_unit,_vehicle,_hitPointIndex);
TRACE_3("params",_unit,_vehicle,_hitPoint);
local _postRepairDamageMin = [_unit] call FUNC(getPostRepairDamage);
(getAllHitPointsDamage _vehicle) params ["_allHitPoints"];
local _hitPointClassname = _allHitPoints select _hitPointIndex;
// get current hitpoint damage // get current hitpoint damage
_hitPointDamage = _vehicle getHitPointDamage _hitPoint; local _hitPointCurDamage = _vehicle getHitIndex _hitPointIndex;
_hitPointDamage = _hitPointDamage - 0.5; // repair a max of 0.5, don't use negative values for damage
// don't use negative values for damage local _hitPointNewDamage = (_hitPointCurDamage - 0.5) max _postRepairDamageMin;
_hitPointDamage = _hitPointDamage max ([_unit] call FUNC(getPostRepairDamage));
// raise event to set the new hitpoint damage if (_hitPointNewDamage < _hitPointCurDamage) then {
["setVehicleHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent); // 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 // Get hitpoint groups if available
_hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(hitpointGroups); local _hitpointGroupConfig = configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(hitpointGroups);
_hitpointGroup = [];
if (isArray _hitpointGroupConfig) then { 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 { _x params ["_masterHitpoint", "_subHitArray"];
([_vehicle] call EFUNC(common,getHitPointsWithSelections)) params ["_hitpoints"]; // Exit using found hitpoint group if this hitpoint is leader of any
// Set all sub-group hitpoints' damage to 0, if a hitpoint is invalid print RPT error if (_masterHitpoint == _hitPointClassname) exitWith {
{ {
if (_x in _hitpoints) then { local _subHitIndex = _allHitPoints find _x; //convert hitpoint classname to index
["setVehicleHitPointDamage", _vehicle, [_vehicle, _x, 0]] call EFUNC(common,targetEvent); if (_subHitIndex == -1) then {
ACE_LOGERROR_2("Invalid hitpoint %1 in hitpointGroups of %2",_x,_vehicle);
} else { } else {
diag_log text format ["[ACE] ERROR: Invalid hitpoint %1 in hitpointGroups of %2", _x, _vehicle]; local _subPointCurDamage = _vehicle getHitIndex _hitPointIndex;
local _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); } forEach (getArray _hitpointGroupConfig);
}; };
// display text message if enabled // display text message if enabled
if (GVAR(DisplayTextOnRepair)) then { if (GVAR(DisplayTextOnRepair)) then {
private ["_textLocalized", "_textDefault"];
// Find localized string // Find localized string
_textLocalized = localize ([LSTRING(RepairedHitPointFully), LSTRING(RepairedHitPointPartially)] select (_hitPointDamage > 0)); local _textLocalized = localize ([LSTRING(RepairedHitPointFully), LSTRING(RepairedHitPointPartially)] select (_hitPointCurDamage > 0));
_textDefault = localize ([LSTRING(RepairedFully), LSTRING(RepairedPartially)] select (_hitPointDamage > 0)); local _textDefault = localize ([LSTRING(RepairedFully), LSTRING(RepairedPartially)] select (_hitPointCurDamage > 0));
([_hitPoint, _textLocalized, _textDefault] call FUNC(getHitPointString)) params ["_text"]; ([_hitPointClassname, _textLocalized, _textDefault] call FUNC(getHitPointString)) params ["_text"];
// Display text // Display text
[_text] call EFUNC(common,displayTextStructured); [_text] call EFUNC(common,displayTextStructured);

View File

@ -6,43 +6,39 @@
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT> * 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING> * 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: * Return Value:
* None * None
* *
* Example: * Example:
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_doRepairTrack * [unit, vehicle, "hitpoint", "RepairTrack", [], [], [aTrack]] call ace_repair_fnc_doRepairTrack
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit", "_vehicle", "_hitPoint", "_classname"]; params ["_unit", "_vehicle", "_hitPoint", "", "", "", "_claimedObjects"];
TRACE_4("params",_unit,_vehicle,_hitPoint,_classname); TRACE_4("params",_unit,_vehicle,_hitPoint,_claimedObjects);
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
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; // can't use a destroyed track
if ((damage _track) >= 1) exitWith {};
{
if ([_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {
_wheel = _x;
};
} forEach nearestObjects [_unit, ["ACE_Track"], 5];
if (isNull _wheel) exitwith {};
// get current hitpoint damage // get current hitpoint damage
local _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
local _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 // don't die by spawning / moving the wheel
_hitPointDamage = (_hitPointDamage - _newDamage) min 0; _hitPointDamage = (_hitPointDamage - _damageRepaired) min 0;
deleteVehicle _wheel; deleteVehicle _track;
// raise event to set the new hitpoint damage // raise event to set the new hitpoint damage
["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent); ["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent);

View File

@ -1,54 +1,50 @@
/* /*
* Author: commy2 * Author: commy2
* Called by repair action / progress bar. Raise events to set the new hitpoint damage. * Replaces a track.
* *
* Arguments: * Arguments:
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT> * 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING> * 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: * Return Value:
* None * None
* *
* Example: * Example:
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_doReplaceTrack * [unit, vehicle, "hitpoint", "ReplaceTrack", [], [], [aTrack]] call ace_repair_fnc_doReplaceTrack
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit", "_vehicle", "_hitPoint", "_classname"]; params ["_unit", "_vehicle", "_hitPoint", "", "", "", "_claimedObjects"];
TRACE_4("params",_unit,_vehicle,_hitPoint,_classname); TRACE_4("params",_unit,_vehicle,_hitPoint,_claimedObjects);
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
private["_hitPointDamage", "_wheel"]; _claimedObjects params [["_track", objNull]];
if ((isNull _track) || {!([_unit, _track, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith))}) exitWith {
_wheel = objNull; ACE_LOGERROR_1("Bad Track", _claimedObjects);
};
{
if ([_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {
_wheel = _x;
};
} forEach nearestObjects [_unit, ["ACE_Track"], 5];
if (isNull _wheel) exitwith {};
// get current hitpoint damage // get current hitpoint damage
_hitPointDamage = _vehicle getHitPointDamage _hitPoint; local _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
// can't replace not destroyed wheel // can't replace not destroyed wheel
if (_hitPointDamage < 1) exitWith {}; if (_hitPointDamage < 1) exitWith {};
// don't die by spawning / moving the wheel // get track's damage
_hitPointDamage = damage _wheel; local _newHitPointDamage = damage _track;
// can't replace a destroyed wheel // can't replace with a destroyed wheel
if (_hitPointDamage >= 1) exitWith {}; if (_newHitPointDamage >= 1) exitWith {};
deleteVehicle _wheel; deleteVehicle _track;
// raise event to set the new hitpoint damage // 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 // display text message if enabled
if (GVAR(DisplayTextOnRepair)) then { if (GVAR(DisplayTextOnRepair)) then {

View File

@ -1,54 +1,50 @@
/* /*
* Author: commy2 * 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: * Arguments:
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT> * 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING> * 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: * Return Value:
* None * None
* *
* Example: * Example:
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_doReplaceWheel * [unit, vehicle, "hitpoint", "ReplaceWheel", [], [], [aWheel]] call ace_repair_fnc_doReplaceWheel
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit", "_vehicle", "_hitPoint", "_classname"]; params ["_unit", "_vehicle", "_hitPoint", "", "", "", "_claimedObjects"];
TRACE_4("params",_unit,_vehicle,_hitPoint,_classname); TRACE_4("params",_unit,_vehicle,_hitPoint,_claimedObjects);
// TODO [_unit, _wheel] call EFUNC(common,claim); on start of action
private ["_hitPointDamage", "_wheel"]; _claimedObjects params [["_wheel", objNull]];
if ((isNull _wheel) || {!([_unit, _wheel, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith))}) exitWith {
_wheel = objNull; ACE_LOGWARNING_1("Bad Claimed Wheel", _claimedObjects);
};
{
if ([_unit, _x, ["isNotDragging", "isNotCarrying", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) exitWith {
_wheel = _x;
};
} forEach nearestObjects [_unit, ["ACE_Wheel"], 5];
if (isNull _wheel) exitwith {};
// get current hitpoint damage // get current hitpoint damage
_hitPointDamage = _vehicle getHitPointDamage _hitPoint; local _hitPointDamage = _vehicle getHitPointDamage _hitPoint;
// can't replace not destroyed wheel // can't replace not destroyed wheel
if (_hitPointDamage < 1) exitWith {}; if (_hitPointDamage < 1) exitWith {};
// don't die by spawning / moving the wheel // get replacement wheel's damage
_hitPointDamage = damage _wheel; local _newHitPointDamage = damage _wheel;
// can't replace a destroyed wheel // can't replace a destroyed wheel
if (_hitPointDamage >= 1) exitWith {}; if (_newHitPointDamage >= 1) exitWith {};
deleteVehicle _wheel; deleteVehicle _wheel;
// raise event to set the new hitpoint damage // 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 // display text message if enabled
if (GVAR(DisplayTextOnRepair)) then { if (GVAR(DisplayTextOnRepair)) then {

View File

@ -0,0 +1,44 @@
/*
* 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);
local _return = [];
{
local _requiredList = _x; //eg ["ace_track", "ace_track"]
local _ableToAquire = []; //will be array of ojbects
{
local _nearObjects = nearestObjects [_unit, [_x], _maxRange];
local _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};
} count _objectsToClaim;
_return

View File

@ -10,7 +10,7 @@
* 1: Wheel hitpoint selections in model coordinates <ARRAY> * 1: Wheel hitpoint selections in model coordinates <ARRAY>
* *
* Example: * Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_getWheelHitPointsWithSelections * [car1] call ace_repair_fnc_getWheelHitPointsWithSelections
* *
* Public: No * Public: No
*/ */
@ -19,64 +19,80 @@
params ["_vehicle"]; params ["_vehicle"];
TRACE_1("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 // get the vehicles wheel config
private "_wheels"; private "_wheels";
_wheels = configfile >> "CfgVehicles" >> typeOf _vehicle >> "Wheels"; _wheels = configfile >> "CfgVehicles" >> typeOf _vehicle >> "Wheels";
// exit with nothing if the vehicle has no wheels class // 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 // get all wheels and read selections from config
private ["_selections", "_bones"];
_wheels = "true" configClasses _wheels; _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 = []; _wheelHitPoints = [];
_wheelHitPointSelections = []; _wheelHitPointSelections = [];
{ {
private "_bone"; _wheelName = configName _x;
_bone = _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. if ((_wheelBoneNameResized != "") && {_x find _wheelBoneNameResized == 0}) exitWith { // same as above. Requirement for physx.
_index = _forEachIndex; _wheelHitPoint = _hitPoints select _forEachIndex;
_wheelHitPointSelection = _hitPointSelections select _forEachIndex;
TRACE_2("wheel found [Orginal]", _wheelName, _wheelHitPoint);
}; };
} forEach _hitPointSelections; } forEach _hitPointSelections;
if (_index != -1) then {
_wheelHitPoints pushBack (_hitPoints select _index); if (_vehicle isKindOf "Car") then {
_wheelHitPointSelections pushBack (_selections select _forEachIndex); //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] [_wheelHitPoints, _wheelHitPointSelections]

View File

@ -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. // 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. // 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)); _class >= (_engineerN min GVAR(engineerSetting_Repair));

View File

@ -11,7 +11,7 @@
* None * None
* *
* Example: * Example:
* function = "ace_repair_fnc_moduleAddSpareParts" * [logic] call ace_repair_fnc_moduleAddSpareParts
* *
* Public: No * Public: No
*/ */

View File

@ -11,7 +11,7 @@
* None * None
* *
* Example: * Example:
* function = "ace_repair_fnc_moduleAssignEngineer" * [logic] call ace_repair_fnc_moduleAssignEngineer
* *
* Public: No * Public: No
*/ */

View File

@ -11,7 +11,7 @@
* None * None
* *
* Example: * Example:
* function = "ace_repair_fnc_moduleAssignRepairFacility" * [logic] call ace_repair_fnc_moduleAssignRepairFacility
* *
* Public: No * Public: No
*/ */

View File

@ -11,7 +11,7 @@
* None * None
* *
* Example: * Example:
* function = "ace_repair_fnc_moduleAssignRepairVehicle" * [logic] call ace_repair_fnc_moduleAssignRepairVehicle
* *
* Public: No * Public: No
*/ */

View File

@ -4,14 +4,12 @@
* *
* Arguments: * Arguments:
* 0: The module logic <OBJECT> * 0: The module logic <OBJECT>
* 1: Synchronized units <ARRAY>
* 2: Activated <BOOL>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* function = "ace_repair_fnc_moduleRepairSettings" * [logic] call ace_repair_fnc_moduleRepairSettings
* *
* Public: No * Public: No
*/ */

View File

@ -4,8 +4,8 @@
* *
* Arguments: * Arguments:
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT * 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING> * 2: Selected hitpoint or hitpointIndex <STRING>or<NUMBER>
* 3: Repair Action Classname <STRING> * 3: Repair Action Classname <STRING>
* *
* Return Value: * Return Value:
@ -21,7 +21,7 @@
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"]; private["_callbackProgress", "_callerAnim", "_calller", "_condition", "_config", "_consumeItems", "_displayText", "_engineerRequired", "_iconDisplayed", "_items", "_locations", "_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?
@ -67,27 +67,23 @@ 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};
_locations = getArray (_config >> "repairLocations"); local _repairLocations = getArray (_config >> "repairLocations");
if ("All" in _locations) exitwith {true}; if (!("All" in _repairLocations)) then {
local _repairFacility = {([_caller] call FUNC(isInRepairFacility)) || ([_target] call FUNC(isInRepairFacility))};
private ["_repairFacility", "_repairVeh"]; local _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC(isNearRepairVehicle))};
_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 == "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 {
private "_val"; local _val = missionNamespace getVariable _x;
_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
@ -98,9 +94,27 @@ _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC
}; };
}; };
}; };
} forEach _locations; } forEach _repairLocations;
};
local _requiredObjects = getArray (_config >> "claimObjects");
local _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}; 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 { _consumeItems = if (isNumber (_config >> "itemConsumed")) then {
getNumber (_config >> "itemConsumed"); getNumber (_config >> "itemConsumed");
@ -177,13 +191,20 @@ _repairTime = if (isNumber (_config >> "repairingTime")) then {
private ["_processText"]; private ["_processText"];
// Find localized string // Find localized string
_hitPointClassname = if ((typeName _hitPoint) == "STRING") then {
_hitPoint
} else {
((getAllHitPointsDamage _target) select 0) select _hitPoint
};
_processText = getText (_config >> "displayNameProgress"); _processText = getText (_config >> "displayNameProgress");
([_hitPoint, _processText, _processText] call FUNC(getHitPointString)) params ["_text"]; ([_hitPointClassname, _processText, _processText] call FUNC(getHitPointString)) params ["_text"];
TRACE_4("display",_hitPoint,_hitPointClassname,_processText,_text);
// Start repair // Start repair
[ [
_repairTime, _repairTime,
[_caller, _target, _hitPoint, _className, _items, _usersOfItems], [_caller, _target, _hitPoint, _className, _items, _usersOfItems, _claimObjectsAvailable],
DFUNC(repair_success), DFUNC(repair_success),
DFUNC(repair_failure), DFUNC(repair_failure),
_text, _text,

View File

@ -6,23 +6,24 @@
* 0: Arguments <ARRAY> * 0: Arguments <ARRAY>
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT * 1: Vehicle to repair <OBJECT
* 2: Selected hitpoint <STRING> * 2: Selected hitpoint or hitpointIndex <STRING>or<NUMBER>
* 3: Repair Action Classname <STRING> * 3: Repair Action Classname <STRING>
* 4: None * 4: None
* 5: Items available <ARRAY> * 5: Items available <ARRAY>
* 6: Claimed Repair Objects <ARRAY>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * 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 * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_args"]; 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); TRACE_5("params",_caller,_target,_selectionName,_className,_usersOfItems);
private ["_config","_callback", "_usersOfItems", "_weaponSelect"]; private ["_config","_callback", "_usersOfItems", "_weaponSelect"];
@ -46,6 +47,13 @@ if (_weaponSelect != "") then {
(_x select 0) addItem (_x select 1); (_x select 0) addItem (_x select 1);
} forEach _usersOfItems; } forEach _usersOfItems;
//Unclaim repair objects:
{
TRACE_2("Releasing", _x, (typeOf _x));
[objNull, _x, false] call EFUNC(common,claim);
} forEach _claimedObjects;
// Record specific callback // Record specific callback
_config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className); _config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className);
@ -58,4 +66,4 @@ if (isNil _callback) then {
_args call _callback; _args call _callback;
// _args call FUNC(createLitter); //todo: repair litter?

View File

@ -6,21 +6,24 @@
* 0: Arguments <ARRAY> * 0: Arguments <ARRAY>
* 0: Unit that does the repairing <OBJECT> * 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT * 1: Vehicle to repair <OBJECT
* 2: Selected hitpoint <STRING> * 2: Selected hitpoint or hitpointIndex <STRING>or<NUMBER>
* 3: Repair Action Classname <STRING> * 3: Repair Action Classname <STRING>
* 4: Items <ARRAY>
* 5: User of Items <ARRAY>
* 6: Claimed Repair Objects <ARRAY>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [[unit, vehicle, "hitpoint", "classname"]] call ace_repair_fnc_repair_success * [[unit, vehicle, "hitpoint", "classname", [], [], [aWheel]]] call ace_repair_fnc_repair_success
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_args"]; params ["_args"];
_args params ["_caller", "_target","_selectionName","_className"]; _args params ["_caller", "_target","_selectionName","_className","","","_claimedObjects"];
TRACE_4("params",_caller,_target,_selectionName,_className); TRACE_4("params",_caller,_target,_selectionName,_className);
private ["_config","_callback", "_weaponSelect"]; private ["_config","_callback", "_weaponSelect"];
@ -40,6 +43,12 @@ if (_weaponSelect != "") then {
_caller action ["SwitchWeapon", _caller, _caller, 99]; _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 // Record specific callback
_config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className); _config = (ConfigFile >> "ACE_Repair" >> "Actions" >> _className);
@ -51,4 +60,4 @@ if (isNil _callback) then {
}; };
_args call _callback; _args call _callback;
// _args call FUNC(createLitter); //todo: repair litter?

View File

@ -1,86 +1,83 @@
/* /*
* Author: commy2 * Author: commy2
* Set the hitpoint damage and change the structural damage acordingly, requires local vehicle. * Set the hitpoint damage and change the structural damage acordingly, requires local vehicle.
* Handles the "setVehicleHitPointDamage" event
* *
* Arguments: * Arguments:
* 0: Local Vehicle to Damage <OBJECT> * 0: Local Vehicle to Damage <OBJECT>
* 1: Selected hitpoint <STRING> * 1: Selected hitpoint INDEX <NUMBER>
* 2: Total Damage <NUMBER> * 2: Total Damage <NUMBER>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [vehicle, "hitpoint", 0.5] call ace_repair_fnc_setHitPointDamage * [vehicle, 1, 0.5] call ace_repair_fnc_setHitPointDamage
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_vehicle", "_hitPoint", "_hitPointDamage"]; params ["_vehicle", "_hitPointIndex", "_hitPointDamage"];
TRACE_3("params",_vehicle,_hitPoint,_hitPointDamage); TRACE_3("params",_vehicle,_hitPointIndex,_hitPointDamage);
private["_damageNew", "_damageOld", "_hitPointDamageRepaired", "_hitPointDamageSumOld", "_realHitpointCount", "_selectionName"];
// can't execute all commands if the vehicle isn't local. exit here. // 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 //Check for bad typeName (changed from orignal v3.3 that took string)
private ["_hitPoints", "_hitPointsWithSelections"]; 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); // get all hitpoints and selections and damages
_hitPointsWithSelections = [_vehicle] call EFUNC(common,getHitpointsWithSelections) select 0; (getAllHitPointsDamage _vehicle) params [["_allHitPoints", []], ["_allHitPointsSelections", []], ["_allHitPointDamages", []]];
// exit if the hitpoint is not valid // exit if the hitpoint is not valid
if !(_hitPoint in _hitPoints) exitWith {systemChat format["NOT A VALID HITPOINT: %1",_hitpoint]}; if ((_hitPointIndex < 0) || {_hitPointIndex >= (count _allHitPoints)}) exitWith {ACE_LOGERROR_2("NOT A VALID HITPOINT: %1-%2", _hitPointIndex,_vehicle);};
// save array with damage values of all hitpoints
private "_hitPointDamages";
_hitPointDamages = [];
{
_hitPointDamages set [_forEachIndex, (_vehicle getHitPointDamage _x)];
} forEach _hitPoints;
// save structural damage and sum of hitpoint damages // save structural damage and sum of hitpoint damages
private ["_damageOld", "_hitPointDamageSumOld"];
_damageOld = damage _vehicle; _damageOld = damage _vehicle;
_realHitpointCount = 0;
_hitPointDamageSumOld = 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 { _selectionName = _allHitPointsSelections select _forEachIndex;
_hitPointDamageSumOld = _hitPointDamageSumOld + (_hitPointDamages select (_hitPoints find _x)); //Filter out all the bad hitpoints (HitPoint="" or no selection)
if ((!isNil {_vehicle getHit _selectionName}) && {_x != ""}) then {
_realHitpointCount = _realHitpointCount + 1;
if ((!(_x in IGNORED_HITPOINTS)) && {!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;
// 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; };
} forEach _allHitPoints;
// calculate new strctural damage // calculate new structural damage
private "_damageNew"; _damageNew = (_hitPointDamageSumOld - _hitPointDamageRepaired) / _realHitpointCount;
_damageNew = _hitPointDamageSumNew / count _hitPoints;
if (_hitPointDamageSumOld > 0) then { 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 // set new structural damage value
_vehicle setDamage _damageNew; _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]; _vehicle setHitIndex [_forEachIndex, _x];
} forEach _hitPoints; } forEach _allHitPointDamages;
// normalize hitpoints // normalize hitpoints
// [_vehicle] call FUNC(normalizeHitPoints); // [_vehicle] call FUNC(normalizeHitPoints);

View File

@ -4,7 +4,7 @@
* *
* Arguments: * Arguments:
* 0: Item classname <STRING> * 0: Item classname <STRING>
* 1: Position <ARRAY> * 1: Position ASL <ARRAY>
* 2: Damage <NUMBER> * 2: Damage <NUMBER>
* *
* Return Value: * Return Value:

View File

@ -4,10 +4,10 @@
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 2: Item classname <STRING> * 1: Item classname <STRING>
* *
* ReturnValue: * ReturnValue:
* None * [Had Item to Use <BOOL>, Unit <OBJECT>] <ARRAY>
* *
* Example: * Example:
* [unit, "classname"] call ace_repair_fnc_useItem * [unit, "classname"] call ace_repair_fnc_useItem
@ -23,4 +23,5 @@ 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];
}; };
[false, objNull]; [false, objNull];

View File

@ -7,7 +7,7 @@
* 1: Item classnames <ARRAY> * 1: Item classnames <ARRAY>
* *
* ReturnValue: * ReturnValue:
* None * [Had Item to Use <BOOL>, Array of units that used the items <ARRAY>] <ARRAY>
* *
* Example: * Example:
* [unit, ["classname1", "classname2"]] call ace_repair_fnc_useItems * [unit, ["classname1", "classname2"]] call ace_repair_fnc_useItems