no more compiling

This commit is contained in:
commy2 2015-03-28 11:08:17 +01:00
parent 464d078511
commit 74a6d5875f
8 changed files with 100 additions and 60 deletions

View File

@ -3,6 +3,9 @@
ADDON = false;
PREP(addRepairActions);
PREP(canRemoveWheel);
PREP(canRepair);
PREP(canReplaceWheel);
PREP(doRepair);
PREP(getWheelHitPointsWithSelections);
PREP(normalizeHitPoints);

View File

@ -41,54 +41,35 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1;
if (_x in _wheelHitPoints) then {
// add wheel repair action
private ["_nameRemove", "_nameReplace", "_icon", "_selection"];
private ["_icon", "_selection"];
_nameRemove = format ["Remove_%1", _x];
_nameReplace = format ["Replace_%1", _x];
_icon = QUOTE(PATHTOF(ui\tire_ca.paa));
_selection = _wheelHitPointSelections select (_wheelHitPoints find _x);
private ["_statement_remove", "_condition_remove", "_statement_replace", "_condition_replace"];
private ["_name", "_text", "_condition", "_statement"];
_statement_remove = format [QFUNC(removeWheel_%1), _x];
_condition_remove = format [QFUNC(canRemoveWheel_%1), _x];
_statement_replace = format [QFUNC(replaceWheel_%1), _x];
_condition_replace = format [QFUNC(canReplaceWheel_%1), _x];
// remove wheel action
_name = format ["Remove_%1", _x];
_text = "Remove Wheel"; //@todo localize
// compile functions for that hitpoint if no such functions currently exist
if (isNil _statement_remove) then {
// remove wheel
private "_function";
_function = compile format [QUOTE([ARR_2(_target,'%1')] call DFUNC(removeWheel)), _x];
missionNamespace setVariable [_statement_remove, _function];
_function = compile format ["alive _target && {_target getHitPointDamage '%1' < 1}", _x];
missionNamespace setVariable [_condition_remove, _function];
// replace wheel
_function = compile format [QUOTE([ARR_2(_target,'%1')] call DFUNC(replaceWheel)), _x];
missionNamespace setVariable [_statement_replace, _function];
_function = compile format ["alive _target && {_target getHitPointDamage '%1' >= 1}", _x];
missionNamespace setVariable [_condition_replace, _function];
};
_statement_remove = missionNamespace getVariable [_statement_remove, {}];
_condition_remove = missionNamespace getVariable [_condition_remove, {}];
_statement_replace = missionNamespace getVariable [_statement_replace, {}];
_condition_replace = missionNamespace getVariable [_condition_replace, {}];
_condition = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(canRemoveWheel)};
_statement = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(removeWheel)};
private "_action";
_action = [_nameRemove, _nameRemove, _icon, _statement_remove, _condition_remove, {}, [], _selection, 2] call EFUNC(interact_menu,createAction);
_action = [_name, _text, _icon, _statement, _condition, {}, [_x], _selection, 2] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
_action = [_nameReplace, _nameReplace, _icon, _statement_replace, _condition_replace, {}, [], _selection, 2] call EFUNC(interact_menu,createAction);
// replace wheel action
_name = format ["Replace_%1", _x];
_text = "Replace Wheel"; //@todo localize
_condition = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(canReplaceWheel)};
_statement = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(replaceWheel)};
_action = [_name, _text, _icon, _statement, _condition, {}, [_x], _selection, 2] call EFUNC(interact_menu,createAction);
[_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass);
} else {
@ -100,36 +81,18 @@ _wheelHitPointSelections = _wheelHitPointsWithSelections select 1;
// add misc repair action
private ["_name", "_icon", "_selection"];
private ["_name", "_text", "_icon", "_selection", "_condition", "_statement"];
_name = format ["Repair_%1", _x];
_text = format ["Repair %1", _x]; //@todo localize
_icon = "";
_selection = "";
private ["_statement", "_condition"];
_statement = format [QFUNC(repair_%1), _x];
_condition = format [QFUNC(canRepair_%1), _x];
// compile functions for that hitpoint if no such functions currently exist
if (isNil _statement) then {
private "_function";
_function = compile format [QUOTE([ARR_3(_player,_target,'%1')] call DFUNC(repairVehicle)), _x];
missionNamespace setVariable [_statement, _function];
_function = compile format ["alive _target && {_target getHitPointDamage '%1' > 0}", _x];
missionNamespace setVariable [_condition, _function];
};
_statement = missionNamespace getVariable [_statement, {}];
_condition = missionNamespace getVariable [_condition, {}];
_condition = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(canRepair)};
_statement = {[_this select 1, _this select 0, _this select 2 select 0] call DFUNC(repairVehicle)};
private "_action";
_action = [_name, _name, _icon, _statement, _condition, {}, [], _selection, 4] call EFUNC(interact_menu,createAction);
_action = [_name, _text, _icon, _statement, _condition, {}, [_x], _selection, 4] call EFUNC(interact_menu,createAction);
[_type, 0, ["ACE_MainActions", QGVAR(Repair)], _action] call EFUNC(interact_menu,addActionToClass);
};

View File

@ -0,0 +1,24 @@
/*
* 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"
private ["_unit", "_target", "_hitPoint"];
_unit = _this select 0;
_target = _this select 1;
_hitPoint = _this select 2;
if !([_unit, _target, []] call ace_common_fnc_canInteractWith) exitWith {false};
alive _target && {_target getHitPointDamage _hitPoint < 1}

View File

@ -0,0 +1,24 @@
/*
* Author: commy2
*
* Check if the unit can repair given hitpoint 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"
private ["_unit", "_target", "_hitPoint"];
_unit = _this select 0;
_target = _this select 1;
_hitPoint = _this select 2;
if !([_unit, _target, []] call ace_common_fnc_canInteractWith) exitWith {false};
alive _target && {_target getHitPointDamage _hitPoint > 0}

View File

@ -0,0 +1,24 @@
/*
* Author: commy2
*
* 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)
*
* Return Value:
* NONE
*/
#include "script_component.hpp"
private ["_unit", "_target", "_hitPoint"];
_unit = _this select 0;
_target = _this select 1;
_hitPoint = _this select 2;
if !([_unit, _target, []] call ace_common_fnc_canInteractWith) exitWith {false};
alive _target && {_target getHitPointDamage _hitPoint >= 1}

View File

@ -1 +1 @@
(_this select 0) setHitPointDamage [_this select 1, 1]; systemChat str _this;
(_this select 1) setHitPointDamage [_this select 2, 1]; systemChat str _this;

View File

@ -44,3 +44,5 @@ if (isLocalized _text) then {
// do animation
[_unit] call EFUNC(common,goKneeling);
// @todo play sound

View File

@ -1 +1 @@
(_this select 0) setHitPointDamage [_this select 1, 0]; systemChat str _this;
(_this select 1) setHitPointDamage [_this select 2, 0]; systemChat str _this;