Merge pull request #2182 from jonpas/repairClean

Repair Cleanup
This commit is contained in:
Glowbal 2015-08-17 11:31:57 +02:00
commit 4d10f2a72d
44 changed files with 373 additions and 290 deletions

View File

@ -25,7 +25,7 @@ class ACE_Repair {
class RemoveWheel: ReplaceWheel {
displayName = CSTRING(RemoveWheel);
displayNameProgress = CSTRING(RemovingWheel);
condition = QUOTE(call FUNC(canRemoveWheel));
condition = QUOTE(call FUNC(canRemove));
callbackSuccess = QUOTE(call FUNC(doRemoveWheel));
};
class MiscRepair: ReplaceWheel {
@ -46,7 +46,7 @@ class ACE_Repair {
class RemoveTrack: MiscRepair {
displayName = CSTRING(RemoveTrack);
displayNameProgress = CSTRING(RemovingTrack);
condition = QUOTE(call FUNC(canRemoveTrack));
condition = QUOTE(call FUNC(canRemove));
callbackSuccess = QUOTE(call FUNC(doRemoveTrack));
requiredEngineer = QGVAR(engineerSetting_Wheel);
};

View File

@ -45,7 +45,6 @@ class ACE_Settings {
values[] = {ECSTRING(common,No), ECSTRING(common,Yes)};
category = CSTRING(categoryName);
};
class GVAR(fullRepairLocation) {
displayName = CSTRING(fullRepairLocation);
description = CSTRING(fullRepairLocation_description);

View File

@ -0,0 +1,9 @@
class CfgActions {
class None;
class Repair: None {
show = 0;
};
class RepairVehicle: None {
show = 0;
};
};

View File

@ -1,4 +1,3 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));

View File

@ -1,4 +1,3 @@
class CfgVehicleClasses {
class GVAR(items) {
displayName = "ACE";

View File

@ -1,4 +1,3 @@
#define MACRO_REPAIRVEHICLE \
class ACE_Actions { \
class ACE_MainActions { \
@ -23,7 +22,7 @@ class CfgVehicles {
displayName = CSTRING(moduleName);
icon = QUOTE(PATHTOF(ui\Icon_Module_Repair_ca.paa)); //@todo
category = "ACE";
function = QUOTE(DFUNC(moduleRepairSettings));
function = QFUNC(moduleRepairSettings);
functionPriority = 1;
isGlobal = 1;
isTriggerActivated = 0;
@ -105,7 +104,7 @@ class CfgVehicles {
displayName = CSTRING(AssignEngineerRole_Module_DisplayName);
icon = QUOTE(PATHTOF(ui\Icon_Module_Repair_ca.paa));
category = "ACE";
function = QUOTE(DFUNC(moduleAssignEngineer));
function = QFUNC(moduleAssignEngineer);
functionPriority = 10;
isGlobal = 2;
isTriggerActivated = 0;
@ -149,7 +148,7 @@ class CfgVehicles {
displayName = CSTRING(AssignRepairVehicle_Module_DisplayName);
icon = QUOTE(PATHTOF(ui\Icon_Module_Repair_ca.paa));
category = "ACE";
function = QUOTE(DFUNC(moduleAssignRepairVehicle));
function = QFUNC(moduleAssignRepairVehicle);
functionPriority = 10;
isGlobal = 2;
isTriggerActivated = 0;
@ -186,7 +185,7 @@ class CfgVehicles {
};
class ACE_moduleAssignRepairFacility: ACE_moduleAssignRepairVehicle {
displayName = CSTRING(AssignRepairFacility_Module_DisplayName);
function = QUOTE(DFUNC(moduleAssignRepairFacility));
function = QFUNC(moduleAssignRepairFacility);
class Arguments {
class EnableList {
displayName = CSTRING(AssignRepairFacility_EnableList_DisplayName);
@ -221,7 +220,6 @@ class CfgVehicles {
class LandVehicle;
class Car: LandVehicle {
MACRO_REPAIRVEHICLE
class ACE_Cargo {
class Cargo {
class ACE_Wheel {
@ -261,8 +259,8 @@ class CfgVehicles {
};
class ACE_Track: ACE_RepairItem_Base {
ace_cargo_size = 2;
ace_cargo_canLoad = 1;
EGVAR(cargo,size) = 2;
EGVAR(cargo,canLoad) = 1;
author = "Hawkins";
scope = 2;
model = QUOTE(PATHTOF(data\ace_track.p3d));
@ -270,8 +268,8 @@ class CfgVehicles {
};
class ACE_Wheel: ACE_RepairItem_Base {
ace_cargo_size = 1;
ace_cargo_canLoad = 1;
EGVAR(cargo,size) = 1;
EGVAR(cargo,canLoad) = 1;
author = "Hawkins";
scope = 2;
model = QUOTE(PATHTOF(data\ace_wheel.p3d));

View File

@ -3,19 +3,18 @@
ADDON = false;
PREP(addRepairActions);
PREP(canRemoveWheel);
PREP(canRemoveTrack);
PREP(canRemove);
PREP(canRepair);
PREP(canRepairTrack);
PREP(canReplaceWheel);
PREP(canReplaceTrack);
PREP(doRemoveWheel);
PREP(doRemoveTrack);
PREP(doRepair);
PREP(canReplaceWheel);
PREP(doFullRepair);
PREP(doRemoveTrack);
PREP(doRemoveWheel);
PREP(doRepair);
PREP(doRepairTrack);
PREP(doReplaceWheel);
PREP(doReplaceTrack);
PREP(doReplaceWheel);
PREP(getPostRepairDamage);
PREP(getWheelHitPointsWithSelections);
PREP(hasItems);
@ -23,10 +22,10 @@ PREP(isEngineer);
PREP(isInRepairFacility);
PREP(isNearRepairVehicle);
PREP(isRepairVehicle);
PREP(moduleRepairSettings);
PREP(moduleAssignEngineer);
PREP(moduleAssignRepairVehicle);
PREP(moduleAssignRepairFacility);
PREP(moduleRepairSettings);
PREP(normalizeHitPoints);
PREP(repair);
PREP(repair_failure);

View File

@ -5,7 +5,7 @@ class CfgPatches {
units[] = {"ACE_Wheel", "ACE_Track"};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common","ace_interact_menu"};
requiredAddons[] = {"ace_interaction"};
author[] = {"commy2", "Glowbal"};
authorUrl = "https://ace3mod.com";
VERSION_CONFIG;
@ -14,18 +14,9 @@ class CfgPatches {
#include "CfgEventHandlers.hpp"
#include "CfgActions.hpp"
#include "CfgVehicleClasses.hpp"
#include "CfgVehicles.hpp"
#include "ACE_Settings.hpp"
#include "ACE_repair.hpp"
class CfgActions {
class None;
class Repair: None {
show = 0;
};
class RepairVehicle: None {
show = 0;
};
};
#include "ACE_Repair.hpp"

View File

@ -1,12 +1,17 @@
/*
* Author: commy2
* Called from init eventhandler. Checks if the vehicles class already has the actions initialized. Otherwise add all available repair options.
* Checks if the vehicles class already has the actions initialized, otherwise add all available repair options. Calleed from init EH.
*
* Arguments:
* 0: vehicle <OBJECT>
* 0: Vehicle <OBJECT>
*
* Return Value:
* NONE
* None
*
* Example:
* [vehicle] call ace_repair_fnc_addRepairActions
*
* Public: No
*/
#include "script_component.hpp"
#define TRACK_HITPOINTS ["HitLTrack", "HitRTrack"]

View File

@ -1,14 +1,19 @@
/*
* Author: commy2
* Check if the unit can remove given wheel of the vehicle.
* Check if the unit can remove given wheel/track of the vehicle.
*
* Arguments:
* 0: Unit that does the repairing <OBJECT>
* 1: vehicle to repair <OBJECT>
* 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
*
* Return Value:
* NONE
* Can Remove <BOOL>
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_canRemove
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -1,18 +0,0 @@
/*
* Author: commy2
* Check if the unit can remove given wheel of the vehicle.
*
* Arguments:
* 0: Unit that does the repairing <OBJECT>
* 1: vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
*
* Return Value:
* NONE
*/
#include "script_component.hpp"
params ["_unit", "_target", "_hitPoint"];
TRACE_3("params",_unit,_target,_hitPoint);
alive _target && {_target getHitPointDamage _hitPoint < 1}

View File

@ -3,17 +3,19 @@
* Check if the repair action can be performed.
*
* Arguments:
* 0: The caller <OBJECT>
* 1: The target <OBJECT>
* 2: Selection name <STRING>
* 3: ACE_Engineeral_Treatments Classname <STRING>
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
* 3: Repair Action Classname <STRING>
*
* ReturnValue:
* Can Treat <BOOL>
* Return Value:
* Can Repair <BOOL>
*
* Example:
* ["something", player] call ace_repair_fnc_canRepair
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_caller", "_target", "_hitPoint", "_className"];
@ -30,7 +32,7 @@ _engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
} else {
// Check for required class
if (isText (_config >> "requiredEngineer")) exitwith {
missionNamespace getvariable [(getText (_config >> "requiredEngineer")), 0];
missionNamespace getVariable [(getText (_config >> "requiredEngineer")), 0];
};
0;
};
@ -45,7 +47,7 @@ if (getText (_config >> "condition") != "") then {
if (isnil _condition) then {
_condition = compile _condition;
} else {
_condition = missionNamespace getvariable _condition;
_condition = missionNamespace getVariable _condition;
};
if (typeName _condition == "BOOL") then {
_return = _condition;
@ -57,7 +59,7 @@ if (getText (_config >> "condition") != "") then {
if (!_return) exitwith {false};
_vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
missionNamespace getvariable [getText(_config >> "vehicleStateCondition"), 0]
missionNamespace getVariable [getText(_config >> "vehicleStateCondition"), 0]
} else {
getNumber(_config >> "vehicleStateCondition")
};
@ -76,7 +78,7 @@ _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC
if (_x == "RepairVehicle" && _repairVeh) exitwith {_return = true;};
if !(isnil _x) exitwith {
private "_val";
_val = missionNamespace getvariable _x;
_val = missionNamespace getVariable _x;
if (typeName _val == "SCALAR") then {
_return = switch (_val) do {
case 0: {true}; //useAnywhere

View File

@ -3,12 +3,17 @@
* Check if the unit can replace given wheel of the vehicle.
*
* Arguments:
* 0: Unit that does the repairing (Object)
* 1: vehicle to repair (Object)
* 2: Selected hitpoint (String)
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
*
* Return Value:
* NONE
* None
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_canRepairTrack
*
* Public: No
*/
#include "script_component.hpp"
@ -34,4 +39,3 @@ if (typeName _wheel == "OBJECT") then {
if (isNull _wheel || damage _wheel >= 1) exitWith {false};
alive _target && {_target getHitPointDamage _hitPoint > 0}

View File

@ -3,35 +3,40 @@
* Check if the unit can replace given wheel of the vehicle.
*
* Arguments:
* 0: Unit that does the repairing (Object)
* 1: vehicle to repair (Object)
* 2: Selected hitpoint (String)
* 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
* None
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_canReplaceTrack
*
* Public: No
*/
#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", ["_track", false]];
TRACE_4("params",_unit,_target,_hitPoint,_track);
// TODO [_unit, _track] call EFUNC(common,claim); on start of action
if (typeName _wheel == "OBJECT") then {
if (typeName _track == "OBJECT") then {
// not near interpret as objNull
if !(_wheel in nearestObjects [_unit, ["ACE_Track"], 5]) then {
_wheel = objNull;
if !(_track in nearestObjects [_unit, ["ACE_Track"], 5]) then {
_track = objNull;
};
} else {
_wheel = objNull;
_track = objNull;
{
if ([_unit, _x, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {
_wheel = _x;
_track = _x;
};
} forEach nearestObjects [_unit, ["ACE_Track"], 5];
};
if (isNull _wheel) exitWith {false};
if (isNull _track) exitWith {false};
alive _target && {_target getHitPointDamage _hitPoint >= 1}

View File

@ -3,16 +3,22 @@
* Check if the unit can replace given wheel of the vehicle.
*
* Arguments:
* 0: Unit that does the repairing (Object)
* 1: vehicle to repair (Object)
* 2: Selected hitpoint (String)
* 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
* None
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_canReplaceWheel
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_target", "_hitPoint", ["_wheel",false]];
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};
@ -40,4 +46,3 @@ if (typeName _wheel == "OBJECT") then {
if (isNull _wheel) exitWith {false};
alive _target && {_target getHitPointDamage _hitPoint >= 1}

View File

@ -1,13 +1,19 @@
/*
* Author: Glowbal
*
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
*
* Arguments:
* Stuff from progress bar.
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
*
* Return Value:
* NONE
* None
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_doFullRepair
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -1,13 +1,19 @@
/*
* Author: commy2
*
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
*
* Arguments:
* Stuff from progress bar.
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
*
* Return Value:
* NONE
* None
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_doRemoveTrack
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -1,13 +1,19 @@
/*
* Author: commy2
*
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
*
* Arguments:
* Stuff from progress bar.
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
*
* Return Value:
* NONE
* None
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_doRemoveWheel
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -3,10 +3,17 @@
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
*
* Arguments:
* 0: Stuff from progress bar. <ARRAY>
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
*
* Return Value:
* NONE
* None
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_doRepair
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -3,10 +3,18 @@
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
*
* Arguments:
* 0: Stuff from progress bar. <ARRAY>
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
* 3: Repair Action Classname <STRING>
*
* Return Value:
* NONE
* None
*
* Example:
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_doRepairTrack
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -3,10 +3,18 @@
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
*
* Arguments:
* 0: Stuff from progress bar. <ARRAY>
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
* 3: Repair Action Classname <STRING>
*
* Return Value:
* NONE
* None
*
* Example:
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_doReplaceTrack
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -3,10 +3,18 @@
* Called by repair action / progress bar. Raise events to set the new hitpoint damage.
*
* Arguments:
* 0: Stuff from progress bar. <ARRAY>
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT>
* 2: Selected hitpoint <STRING>
* 3: Repair Action Classname <STRING>
*
* Return Value:
* NONE
* None
*
* Example:
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_doReplaceWheel
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -1,4 +1,18 @@
// by comm2
/*
* Author: commy2
* Returns the damage threshold based on settings and unit type.
*
* Arguments:
* 0: Unit that does the repairing <OBJECT>
*
* Return Value:
* 0: Rpair Damage Threshold <NUMBER>
*
* Example:
* [unit] call ace_repair_fnc_getPostRepairDamage
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];

View File

@ -3,10 +3,16 @@
* Returns the wheel hitpoints and their selections.
*
* Arguments:
* 0: A vehicle <Object>
* 0: Vehicle <OBJECT>
*
* Return Value:
* Wheel positions in model coordinates. <Array>
* 0: Wheel hitpoints <ARRAY>
* 1: Wheel hitpoint selections in model coordinates <ARRAY>
*
* Example:
* [unit, vehicle, "hitpoint"] call ace_repair_fnc_getWheelHitPointsWithSelections
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -3,28 +3,30 @@
* Check if the engineer has all items.
*
* Arguments:
* 0: Engineer <OBJECT>
* 1: Patient <OBJECT>
* 2: Items <ARRAY<STRING>>
* 0: Unit that does the repairing <OBJECT>
* 1: Items required <ARRAY>
*
* ReturnValue:
* Has the items <BOOL>
* Return Value:
* Has Items <BOOL>
*
* Example:
* [engineer, [items]] call ace_repair_fnc_hasItems
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_engineer", "_items"];
TRACE_2("params",_engineer,_items);
params ["_unit", "_items"];
TRACE_2("params",_unit,_items);
private ["_return"];
_return = true;
{
if (typeName _x == "ARRAY" && {({[_engineer, _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" && {!([_engineer, _x] call EFUNC(common,hasItem))}) exitwith {
if (typeName _x == "STRING" && {!([_unit, _x] call EFUNC(common,hasItem))}) exitwith {
_return = false;
};
} forEach _items;

View File

@ -1,13 +1,16 @@
/*
* Author: Glowbal, KoffeinFlummi, commy2
* Check if a unit is any engineer class
* Check if a unit is any engineer class.
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: Class <NUMBER> <OPTIONAL>
* 0: Unit <OBJECT>
* 1: Class <NUMBER> (default: 1)
*
* ReturnValue:
* Is in of engineer class <BOOL>
* Return Value:
* Is Engineer Class <BOOL>
*
* Example:
* [unit, 1] call ace_repair_fnc_isEngineer
*
* Public: Yes
*/
@ -23,4 +26,4 @@ _class = _unit getVariable ["ACE_IsEngineer", getNumber (configFile >> "CfgVehic
// 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};
_class >= (_engineerN min GVAR(engineerSetting_Repair));
_class >= (_engineerN min GVAR(engineerSetting_Repair));

View File

@ -1,16 +1,18 @@
/*
* Author: Glowbal
* Checks if a unit is in a repair facility
* Checks if a unit is in a repair facility.
*
* Arguments:
* 0: The Unit <OBJECT>
* 0: Unit <OBJECT>
*
* ReturnValue:
* Return Value:
* Is inside a repair facility <BOOL>
*
* Example:
* [unit] call ace_repair_fnc_isInRepairFacility
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_object"];

View File

@ -1,16 +1,18 @@
/*
* Author: KoffeinFlummi
* Checks if a unit is in a engineeral vehicle.
* Checks if a unit is near an engineering vehicle.
*
* Arguments:
* 0: unit to be checked <OBJECT>
* 0: Unit <OBJECT>
*
* Return Value:
* Is unit in engineeral vehicle? <BOOL>
* Is near engineering vehicle <BOOL>
*
* Example:
* [unit] call ace_repair_fnc_isNearRepairVehicle
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_unit"];

View File

@ -1,12 +1,15 @@
/*
* Author: Glowbal
* Check if vehicle is a engineeral vehicle
* Check if vehicle is a engineering vehicle.
*
* Arguments:
* 0: The Vehicle <OBJECT>
* 0: Vehicle <OBJECT>
*
* ReturnValue:
* Is in of engineer class <BOOL>
* Is engineering vehicle <BOOL>
*
* Example:
* [vehicle] call ace_repair_fnc_isRepairVehicle
*
* Public: Yes
*/

View File

@ -1,26 +1,28 @@
/*
* Author: Glowbal
* Assign an engineer role to a unit
* Assign an engineer role to a unit.
*
* Arguments:
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
* 0: The module logic <OBJECT>
* 1: Synchronized units <ARRAY>
* 2: Activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Example:
* function = "ace_repair_fnc_moduleAssignEngineer"
*
* Public: No
*/
#include "script_component.hpp"
params ["_logic"];
if (!isNull _logic) then {
private ["_list", "_setting"];
_list = _logic getvariable ["EnableList",""];
_setting = _logic getvariable ["role",0];
_list = _logic getVariable ["EnableList",""];
_setting = _logic getVariable ["role",0];
[_list, "ACE_IsEngineer", _setting, true] call EFUNC(common,assignObjectsInList);
[synchronizedObjects _logic, "ACE_IsEngineer", _setting, true] call EFUNC(common,assignObjectsInList);

View File

@ -1,26 +1,28 @@
/*
* Author: Glowbal
* Assign an repair facility
* Assign a repair facility.
*
* Arguments:
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
* 0: The module logic <OBJECT>
* 1: Synchronized units <ARRAY>
* 2: Activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Example:
* function = "ace_repair_fnc_moduleAssignRepairFacility"
*
* Public: No
*/
#include "script_component.hpp"
params ["_logic"];
if (!isNull _logic) then {
private ["_list", "_setting"];
_list = _logic getvariable ["EnableList",""];
_setting = _logic getvariable ["role",0];
_list = _logic getVariable ["EnableList",""];
_setting = _logic getVariable ["role",0];
[_list, "ACE_isRepairFacility", _setting, true] call EFUNC(common,assignObjectsInList);
[synchronizedObjects _logic, "ACE_isRepairFacility", _setting, true] call EFUNC(common,assignObjectsInList);

View File

@ -1,26 +1,28 @@
/*
* Author: Glowbal
* Assign an repair vehicle
* Assign a repair vehicle.
*
* Arguments:
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
* 0: The module logic <OBJECT>
* 1: Synchronized units <ARRAY>
* 2: Activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Example:
* function = "ace_repair_fnc_moduleAssignRepairVehicle"
*
* Public: No
*/
#include "script_component.hpp"
params ["_logic"];
if (!isNull _logic) then {
private ["_list", "_setting"];
_list = _logic getvariable ["EnableList",""];
_setting = _logic getvariable ["role",0];
_list = _logic getVariable ["EnableList",""];
_setting = _logic getVariable ["role",0];
[_list, "ACE_isRepairVehicle", _setting, true] call EFUNC(common,assignObjectsInList);
[synchronizedObjects _logic, "ACE_isRepairVehicle", _setting, true] call EFUNC(common,assignObjectsInList);

View File

@ -1,12 +1,17 @@
/*
* Author: commy2
* Module for adjusting the repair damage settings
* Adjusts repair damage settings.
*
* Arguments:
* 0: The module logic <LOGIC>
* 0: The module logic <OBJECT>
* 1: Synchronized units <ARRAY>
* 2: Activated <BOOL>
*
* Return Value:
* None <NIL>
* None
*
* Example:
* function = "ace_repair_fnc_moduleRepairSettings"
*
* Public: No
*/

View File

@ -3,29 +3,31 @@
* Used to normalize dependant hitpoints. May overwrite some global variables that are named like hitpoints or "Total" though...
*
* Arguments:
* 0: A local vehicle with hitpoints. <OBJECT>
* 0: Local Vehicle <OBJECT>
*
* Return Value:
* NONE
* None
*
* Example:
* [vehicle] call ace_repair_fnc_normalizeHitPoints
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle"];
TRACE_1("params",_vehicle);
// 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 if that's so
if !(local _vehicle) exitWith {};
private ["_hitPoints", "_config"];
private ["_hitPoints", "_config", "_dependentHitPoints", "_dependentHitPointScripts", "_damage"];
_hitPoints = [_vehicle] call EFUNC(common,getHitPoints);
_config = configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints";
// define global variables. Needed to parse the depends config entries. Also find dependent hitpoints.
private ["_dependentHitPoints", "_dependentHitPointScripts"];
_dependentHitPoints = [];
_dependentHitPointScripts = [];
@ -33,21 +35,14 @@ Total = damage _vehicle;
{
missionNamespace setVariable [_x, _vehicle getHitPointDamage _x];
if (isText (_config >> _x >> "depends")) then {
_dependentHitPoints pushBack _x;
_dependentHitPointScripts pushBack compile getText (_config >> _x >> "depends");
};
} forEach _hitPoints;
// apply normalized damage to all dependand hitpoints
{
private "_damage";
_damage = call (_dependentHitPointScripts select _forEachIndex);
_vehicle setHitPointDamage [_x, _damage];
} forEach _dependentHitPoints;

View File

@ -1,19 +1,21 @@
/*
* Author: Glowbal, KoffeinFlummi
* Starts the repair process
* Starts the repair process.
*
* Arguments:
* 0: The engineer <OBJECT>
* 1: The patient <OBJECT>
* 2: SelectionName <STRING>
* 3: repair classname <STRING>
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT
* 2: Selected hitpoint <STRING>
* 3: Repair Action Classname <STRING>
*
* Return Value:
* Succesful repair started <BOOL>
* Succesful Repair Started <BOOL>
*
* Example:
* [unit, vehicle, "hitpoint", "classname"] call ace_repair_fnc_repair
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_caller", "_target", "_hitPoint", "_className"];
@ -29,7 +31,7 @@ _engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
} else {
// Check for required class
if (isText (_config >> "requiredEngineer")) exitwith {
missionNamespace getvariable [(getText (_config >> "requiredEngineer")), 0];
missionNamespace getVariable [(getText (_config >> "requiredEngineer")), 0];
};
0;
};
@ -44,7 +46,7 @@ if (getText (_config >> "condition") != "") then {
if (isnil _condition) then {
_condition = compile _condition;
} else {
_condition = missionNamespace getvariable _condition;
_condition = missionNamespace getVariable _condition;
};
if (typeName _condition == "BOOL") then {
_return = _condition;
@ -55,7 +57,7 @@ if (getText (_config >> "condition") != "") then {
if (!_return) exitwith {false};
_vehicleStateCondition = if (isText(_config >> "vehicleStateCondition")) then {
missionNamespace getvariable [getText(_config >> "vehicleStateCondition"), 0]
missionNamespace getVariable [getText(_config >> "vehicleStateCondition"), 0]
} else {
getNumber(_config >> "vehicleStateCondition")
};
@ -74,7 +76,7 @@ _repairVeh = {([_caller] call FUNC(isNearRepairVehicle)) || ([_target] call FUNC
if (_x == "RepairVehicle" && _repairVeh) exitwith {_return = true;};
if !(isnil _x) exitwith {
private "_val";
_val = missionNamespace getvariable _x;
_val = missionNamespace getVariable _x;
if (typeName _val == "SCALAR") then {
_return = switch (_val) do {
case 0: {true}; //useAnywhere
@ -94,7 +96,7 @@ _consumeItems = if (isNumber (_config >> "itemConsumed")) then {
} else {
// Check for required class
if (isText (_config >> "itemConsumed")) exitwith {
missionNamespace getvariable [(getText (_config >> "itemConsumed")), 0];
missionNamespace getVariable [(getText (_config >> "itemConsumed")), 0];
};
0;
};
@ -112,7 +114,7 @@ if (_callbackProgress == "") then {
if (isNil _callbackProgress) then {
_callbackProgress = compile _callbackProgress;
} else {
_callbackProgress = missionNamespace getvariable _callbackProgress;
_callbackProgress = missionNamespace getVariable _callbackProgress;
};
@ -152,7 +154,7 @@ _repairTime = if (isNumber (_config >> "repairingTime")) then {
if (isnil _repairTimeConfig) then {
_repairTimeConfig = compile _repairTimeConfig;
} else {
_repairTimeConfig = missionNamespace getvariable _repairTimeConfig;
_repairTimeConfig = missionNamespace getVariable _repairTimeConfig;
};
if (typeName _repairTimeConfig == "SCALAR") exitwith {
_repairTimeConfig;

View File

@ -1,45 +0,0 @@
/*
* Author: commy2
*
* Start a repair action and open progress bar.
*
* Arguments:
* 0: Unit that does the repairing (Object)
* 1: vehicle to repair (Object)
* 2: Selected hitpoint (String)
*
* Return Value:
* NONE
*/
#include "script_component.hpp"
params ["_unit", "_vehicle", "_hitPoint"];
TRACE_3("params",_unit,_vehicle,_hitPoint);
// exit if not a valid hitpoint
if !(_hitPoint in ([_vehicle] call EFUNC(common,getHitPoints))) exitWith {};
// calculate time to fully repair the hitpoint
private ["_damage", "_time"];
_damage = _vehicle getHitPointDamage _hitPoint;
_time = (5 + 10 * _damage) * ([1.5, 1] select ([_unit, GVAR(engineerSetting_Repair) + 1] call FUNC(isEngineer)));
// get string of the hitpoint
private "_text";
_text = format ["STR_ACE_Repair_%1", _hitPoint];
if (isLocalized _text) then {
_text = format [localize LSTRING(RepairingHitPoint), localize _text];
} else {
_text = localize LSTRING(Repairing);
};
// open the loading bar
[_time, [_unit, _vehicle, _hitPoint], {_this call DFUNC(doRepair)}, {_this call DFUNC(doRepair)}, _text, {(_this select 0) call DFUNC(canRepair)}, []] call EFUNC(common,progressBar);
// do animation
[_unit] call EFUNC(common,goKneeling);
// @todo play sound

View File

@ -1,16 +1,21 @@
/*
* Author: KoffeinFlummi, Glowbal
* Callback when the repair fails
* Callback when repair fails.
*
* Arguments:
* 0: The engineer <OBJECT>
* 1: The patient <OBJECT>
* 2: SelectionName <STRING>
* 3: Treatment classname <STRING>
* 4: Items available <ARRAY<STRING>>
* 0: Arguments <ARRAY>
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT
* 2: Selected hitpoint <STRING>
* 3: Repair Action Classname <STRING>
* 4: None
* 5: Items available <ARRAY>
*
* Return Value:
* nil
* None
*
* Example:
* [[unit, vehicle, "hitpoint", "classname", nil, [items]]] call ace_repair_fnc_repair_failure
*
* Public: No
*/
@ -26,11 +31,11 @@ if (primaryWeapon _caller == "ACE_FakePrimaryWeapon") then {
_caller removeWeapon "ACE_FakePrimaryWeapon";
};
if (vehicle _caller == _caller) then {
[_caller, _caller getvariable [QGVAR(repairPrevAnimCaller), ""], 2] call EFUNC(common,doAnimation);
[_caller, _caller getVariable [QGVAR(repairPrevAnimCaller), ""], 2] call EFUNC(common,doAnimation);
};
_caller setvariable [QGVAR(repairPrevAnimCaller), nil];
_weaponSelect = (_caller getvariable [QGVAR(selectedWeaponOnrepair), ""]);
_weaponSelect = (_caller getVariable [QGVAR(selectedWeaponOnrepair), ""]);
if (_weaponSelect != "") then {
_caller selectWeapon _weaponSelect;
} else {
@ -48,7 +53,7 @@ _callback = getText (_config >> "callbackFailure");
if (isNil _callback) then {
_callback = compile _callback;
} else {
_callback = missionNamespace getvariable _callback;
_callback = missionNamespace getVariable _callback;
};
_args call _callback;

View File

@ -1,20 +1,22 @@
/*
* Author: KoffeinFlummi, Glowbal
* Callback when the repair is completed
* Callback when repair completes.
*
* Arguments:
* 0: The engineer <OBJECT>
* 1: The patient <OBJECT>
* 2: SelectionName <STRING>
* 3: Treatment classname <STRING>
* 4: Items available <ARRAY<STRING>>
* 0: Arguments <ARRAY>
* 0: Unit that does the repairing <OBJECT>
* 1: Vehicle to repair <OBJECT
* 2: Selected hitpoint <STRING>
* 3: Repair Action Classname <STRING>
*
* Return Value:
* nil
* None
*
* Example:
* [[unit, vehicle, "hitpoint", "classname"]] call ace_repair_fnc_repair_success
*
* Public: No
*/
#include "script_component.hpp"
params ["_args"];
@ -27,11 +29,11 @@ if (primaryWeapon _caller == "ACE_FakePrimaryWeapon") then {
_caller removeWeapon "ACE_FakePrimaryWeapon";
};
if (vehicle _caller == _caller) then {
[_caller, _caller getvariable [QGVAR(repairPrevAnimCaller), ""], 2] call EFUNC(common,doAnimation);
[_caller, _caller getVariable [QGVAR(repairPrevAnimCaller), ""], 2] call EFUNC(common,doAnimation);
};
_caller setvariable [QGVAR(repairPrevAnimCaller), nil];
_weaponSelect = (_caller getvariable [QGVAR(selectedWeaponOnrepair), ""]);
_weaponSelect = (_caller getVariable [QGVAR(selectedWeaponOnrepair), ""]);
if (_weaponSelect != "") then {
_caller selectWeapon _weaponSelect;
} else {
@ -45,7 +47,7 @@ _callback = getText (_config >> "callbackSuccess");
if (isNil _callback) then {
_callback = compile _callback;
} else {
_callback = missionNamespace getvariable _callback;
_callback = missionNamespace getVariable _callback;
};
_args call _callback;

View File

@ -1,13 +1,18 @@
/*
* Author: commy2
* Sets the structural damage of a vehicle without altering the hitPoints. Requires local vehicle.
* Sets the structural damage of a vehicle without altering the hitPoints, requires local vehicle.
*
* Arguments:
* 0: vehicle to damage <OBJECT>
* 1: Total damage <NUMBER>
* 0: Local Vehicle to Damage <OBJECT>
* 1: Total Damage <NUMBER>
*
* Return Value:
* NONE
* None
*
* Example:
* [vehicle, 0.5] call ace_repair_fnc_setDamage
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -1,14 +1,19 @@
/*
* 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.
*
* Arguments:
* 0: vehicle
* 1: hitpoint
* 2: damage
* 0: Local Vehicle to Damage <OBJECT>
* 1: Selected hitpoint <STRING>
* 2: Total Damage <NUMBER>
*
* Return Value:
* NONE
* None
*
* Example:
* [vehicle, "hitpoint", 0.5] call ace_repair_fnc_setHitPointDamage
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -1,4 +1,20 @@
// by commy2
/*
* Author: commy2
* Spawns an object of specified string, at specified position with specified damage taken.
*
* Arguments:
* 0: Item classname <STRING>
* 1: Position <ARRAY>
* 2: Damage <NUMBER>
*
* Return Value:
* None
*
* Example:
* ["classname", [0, 0, 0], 1] call ace_repair_fnc_spawnObject
*
* Public: No
*/
#include "script_component.hpp"
params ["_item", "_position", ["_damage", 0]];

View File

@ -3,22 +3,24 @@
* Use Equipment if any is available.
*
* Arguments:
* 0: Engineer <OBJECT>
* 2: Item <STRING>
* 0: Unit <OBJECT>
* 2: Item classname <STRING>
*
* ReturnValue:
* <NIL>
* None
*
* Example:
* [unit, "classname"] call ace_repair_fnc_useItem
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_engineer", "_item"];
TRACE_2("params",_engineer,_item);
params ["_unit", "_item"];
TRACE_2("params",_unit,_item);
if ([_engineer, _item] call EFUNC(common,hasItem)) exitwith {
[[_engineer, _item], QUOTE(EFUNC(common,useItem)), _engineer] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
[true, _engineer];
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];

View File

@ -3,19 +3,21 @@
* Use Equipment items if any is available.
*
* Arguments:
* 0: Engineer <OBJECT>
* 1: Items <ARRAY<STRING>>
* 0: Unit <OBJECT>
* 1: Item classnames <ARRAY>
*
* ReturnValue:
* <NIL>
* None
*
* Example:
* [unit, ["classname1", "classname2"]] call ace_repair_fnc_useItems
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_engineer", "_items"];
TRACE_2("params",_engineer,_items);
params ["_unit", "_items"];
TRACE_2("params",_unit,_items);
private ["_itemUsedInfo", "_itemsUsedBy"];
@ -24,14 +26,14 @@ _itemsUsedBy = [];
// handle a one of type use item
if (typeName _x == "ARRAY") then {
{
_itemUsedInfo = [_engineer, _x] call FUNC(useItem);
_itemUsedInfo = [_unit, _x] call FUNC(useItem);
if (_itemUsedInfo select 0) exitwith { _itemsUsedBy pushback [(_itemUsedInfo select 1), _x]};
} forEach _x;
};
// handle required item
if (typeName _x == "STRING") then {
_itemUsedInfo = [_engineer, _x] call FUNC(useItem);
_itemUsedInfo = [_unit, _x] call FUNC(useItem);
if (_itemUsedInfo select 0) exitwith { _itemsUsedBy pushback [(_itemUsedInfo select 1), _x]};
};
} forEach _items;

View File

@ -1 +1 @@
#include "\z\ace\addons\repair\script_component.hpp"
#include "\z\ace\addons\repair\script_component.hpp"