From f97ec9051321825c3a6ff82cb8b5a223c96cee20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20E=C4=9Fitmen?= Date: Fri, 26 May 2017 23:02:46 +0300 Subject: [PATCH 1/5] Add ability to change repair time based on vehicle --- addons/repair/functions/fnc_repair.sqf | 40 ++++++++++++++++---------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/addons/repair/functions/fnc_repair.sqf b/addons/repair/functions/fnc_repair.sqf index d4f5412e6fc..0569c85c671 100644 --- a/addons/repair/functions/fnc_repair.sqf +++ b/addons/repair/functions/fnc_repair.sqf @@ -177,23 +177,33 @@ if (vehicle _caller == _caller && {_callerAnim != ""}) then { [_caller, _callerAnim] call EFUNC(common,doAnimation); }; -//Get repair time -_repairTime = if (isNumber (_config >> "repairingTime")) then { - getNumber (_config >> "repairingTime"); -} else { - if (isText (_config >> "repairingTime")) exitWith { - _repairTimeConfig = getText(_config >> "repairingTime"); - if (isNil _repairTimeConfig) then { - _repairTimeConfig = compile _repairTimeConfig; - } else { - _repairTimeConfig = missionNamespace getVariable _repairTimeConfig; - }; - if (_repairTimeConfig isEqualType 0) exitWith { - _repairTimeConfig; +// Get repair time +_repairTime = _target getVariable [QGVAR(repairTime), + [ + configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(repairTime), + "number", + -1 + ] call CBA_fnc_getConfigEntry; +]; + +if (_repairTime == -1) then { + _repairTime = if (isNumber (_config >> "repairingTime")) then { + getNumber (_config >> "repairingTime"); + } else { + if (isText (_config >> "repairingTime")) exitWith { + _repairTimeConfig = getText(_config >> "repairingTime"); + if (isNil _repairTimeConfig) then { + _repairTimeConfig = compile _repairTimeConfig; + } else { + _repairTimeConfig = missionNamespace getVariable _repairTimeConfig; + }; + if (_repairTimeConfig isEqualType 0) exitWith { + _repairTimeConfig; + }; + [_caller, _target, _hitPoint, _className] call _repairTimeConfig; }; - [_caller, _target, _hitPoint, _className] call _repairTimeConfig; + 0; }; - 0; }; // Find localized string From 5db1899a3747422c27a946514304783119b994cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20E=C4=9Fitmen?= Date: Fri, 26 May 2017 23:24:10 +0300 Subject: [PATCH 2/5] Much better --- addons/repair/functions/fnc_repair.sqf | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/addons/repair/functions/fnc_repair.sqf b/addons/repair/functions/fnc_repair.sqf index 0569c85c671..c3bcebf6577 100644 --- a/addons/repair/functions/fnc_repair.sqf +++ b/addons/repair/functions/fnc_repair.sqf @@ -178,15 +178,13 @@ if (vehicle _caller == _caller && {_callerAnim != ""}) then { }; // Get repair time -_repairTime = _target getVariable [QGVAR(repairTime), - [ - configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(repairTime), - "number", - -1 - ] call CBA_fnc_getConfigEntry; -]; - -if (_repairTime == -1) then { +_repairTime = [ + configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(repairTimes) >> configName _config, + "number", + -1 +] call CBA_fnc_getConfigEntry; + +if (_repairTime < 0) then { _repairTime = if (isNumber (_config >> "repairingTime")) then { getNumber (_config >> "repairingTime"); } else { From b4245deab065c483f0b59819ede758d23479daac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20E=C4=9Fitmen?= Date: Sat, 27 May 2017 05:05:53 +0300 Subject: [PATCH 3/5] Unary command not function --- addons/repair/functions/fnc_repair.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/repair/functions/fnc_repair.sqf b/addons/repair/functions/fnc_repair.sqf index c3bcebf6577..3ee6d4097f4 100644 --- a/addons/repair/functions/fnc_repair.sqf +++ b/addons/repair/functions/fnc_repair.sqf @@ -189,7 +189,7 @@ if (_repairTime < 0) then { getNumber (_config >> "repairingTime"); } else { if (isText (_config >> "repairingTime")) exitWith { - _repairTimeConfig = getText(_config >> "repairingTime"); + _repairTimeConfig = getText (_config >> "repairingTime"); if (isNil _repairTimeConfig) then { _repairTimeConfig = compile _repairTimeConfig; } else { From 8c0856400b4c8eee633a0e1aefd2490dc72f69f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20E=C4=9Fitmen?= Date: Sun, 28 May 2017 10:38:05 +0300 Subject: [PATCH 4/5] Allow changing of track or wheel object per vehicle --- addons/repair/functions/fnc_doRemoveTrack.sqf | 8 +++++++- addons/repair/functions/fnc_doRemoveWheel.sqf | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/addons/repair/functions/fnc_doRemoveTrack.sqf b/addons/repair/functions/fnc_doRemoveTrack.sqf index ca6ac58ffd0..64baa623d57 100644 --- a/addons/repair/functions/fnc_doRemoveTrack.sqf +++ b/addons/repair/functions/fnc_doRemoveTrack.sqf @@ -30,7 +30,13 @@ if (_hitPointDamage >= 1) exitWith {}; [QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent; // spawn track -private _newTrack = ["ACE_Track", getPosASL _unit, _hitPointDamage] call FUNC(spawnObject); +private _track = [ + configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(track) + "text", + "ACE_Track" +] call CBA_fnc_getConfigEntry; + +private _newTrack = [_track, getPosASL _unit, _hitPointDamage] call FUNC(spawnObject); TRACE_2("new track created",_newTrack,damage _newTrack); // raise event to set the new hitpoint damage diff --git a/addons/repair/functions/fnc_doRemoveWheel.sqf b/addons/repair/functions/fnc_doRemoveWheel.sqf index dafe603a188..a426d8c02bd 100644 --- a/addons/repair/functions/fnc_doRemoveWheel.sqf +++ b/addons/repair/functions/fnc_doRemoveWheel.sqf @@ -30,7 +30,13 @@ if (_hitPointDamage >= 1) exitWith {}; [QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent; // spawn wheel -private _newWheel = ["ACE_Wheel", getPosASL _unit, _hitPointDamage] call FUNC(spawnObject); +private _wheel = [ + configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(wheel) + "text", + "ACE_Wheel" +] call CBA_fnc_getConfigEntry; + +private _newWheel = [_wheel, getPosASL _unit, _hitPointDamage] call FUNC(spawnObject); TRACE_2("new wheel created",_newWheel,damage _newWheel); // raise event to set the new hitpoint damage From 4a41403dea83a18ebf954b346249cd842a1f0feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20E=C4=9Fitmen?= Date: Sun, 28 May 2017 11:05:31 +0300 Subject: [PATCH 5/5] Lot more complicated than I thought --- addons/repair/functions/fnc_doRemoveTrack.sqf | 8 +------- addons/repair/functions/fnc_doRemoveWheel.sqf | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/addons/repair/functions/fnc_doRemoveTrack.sqf b/addons/repair/functions/fnc_doRemoveTrack.sqf index 64baa623d57..ca6ac58ffd0 100644 --- a/addons/repair/functions/fnc_doRemoveTrack.sqf +++ b/addons/repair/functions/fnc_doRemoveTrack.sqf @@ -30,13 +30,7 @@ if (_hitPointDamage >= 1) exitWith {}; [QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent; // spawn track -private _track = [ - configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(track) - "text", - "ACE_Track" -] call CBA_fnc_getConfigEntry; - -private _newTrack = [_track, getPosASL _unit, _hitPointDamage] call FUNC(spawnObject); +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 diff --git a/addons/repair/functions/fnc_doRemoveWheel.sqf b/addons/repair/functions/fnc_doRemoveWheel.sqf index a426d8c02bd..dafe603a188 100644 --- a/addons/repair/functions/fnc_doRemoveWheel.sqf +++ b/addons/repair/functions/fnc_doRemoveWheel.sqf @@ -30,13 +30,7 @@ if (_hitPointDamage >= 1) exitWith {}; [QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent; // spawn wheel -private _wheel = [ - configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(wheel) - "text", - "ACE_Wheel" -] call CBA_fnc_getConfigEntry; - -private _newWheel = [_wheel, getPosASL _unit, _hitPointDamage] call FUNC(spawnObject); +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