Merge pull request #2277 from jokoho48/codeCleanUpConcertina_wire

Code cleanup of Concertina_wire Module
This commit is contained in:
Glowbal 2015-10-18 12:13:44 +02:00
commit ebe2bf96cd
7 changed files with 45 additions and 54 deletions

View File

@ -1,4 +1,3 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_wire"];
PARAMS_1(_wire); _wire addEventHandler ["HandleDamage", FUNC(handleDamage)];
_wire addEventHandler ["HandleDamage", {_this call FUNC(handleDamage)}];

View File

@ -8,10 +8,9 @@
* 1: unit <OBJECT> * 1: unit <OBJECT>
* *
* Return Value: * Return Value:
* Nothing
*
* Return value:
* None * None
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
@ -22,7 +21,7 @@ private ["_wireNoGeo", "_dir", "_pos", "_wireNoGeoPos"];
_wireNoGeo = "ACE_ConcertinaWireNoGeo" createVehicle [0,0,0]; _wireNoGeo = "ACE_ConcertinaWireNoGeo" createVehicle [0,0,0];
{ {
_wireNoGeo animate [_x, 1]; _wireNoGeo animate [_x, 1];
} foreach WIRE_FAST; } count WIRE_FAST;
GVAR(placer) = _unit; GVAR(placer) = _unit;
_dir = getDir _unit; _dir = getDir _unit;
@ -37,8 +36,9 @@ deleteVehicle _wirecoil;
_unit setVariable [QGVAR(wireDeployed), false]; _unit setVariable [QGVAR(wireDeployed), false];
GVAR(deployPFH) = [{ GVAR(deployPFH) = [{
EXPLODE_3_PVT(_this select 0,_wireNoGeo,_wireNoGeoPos,_unit); params ["_args", "_idPFH"];
_args params ["_wireNoGeo", "_wireNoGeoPos", "_unit"];
private ["_range", "_posStart", "_posEnd", "_dirVect", "_dir", "_anim", "_wire"]; private ["_range", "_posStart", "_posEnd", "_dirVect", "_dir", "_anim", "_wire"];
_posStart = (_wireNoGeo modelToWorldVisual (_wireNoGeo selectionPosition "start")) call EFUNC(common,positionToASL); _posStart = (_wireNoGeo modelToWorldVisual (_wireNoGeo selectionPosition "start")) call EFUNC(common,positionToASL);
_posEnd = (getPosASL _unit) vectorAdd (vectorDir _unit); _posEnd = (getPosASL _unit) vectorAdd (vectorDir _unit);
@ -46,37 +46,38 @@ GVAR(deployPFH) = [{
_dir = _dirVect call CBA_fnc_vectDir; _dir = _dirVect call CBA_fnc_vectDir;
_range = vectorMagnitude _dirVect; _range = vectorMagnitude _dirVect;
_anim = 0 max (1 - (_range / 12)); _anim = 0 max (1 - (_range / 12));
if (!(alive _unit) || _range >= 12 || (_unit getVariable [QGVAR(wireDeployed), false])) exitWith { if (!(alive _unit) || _range >= 12 || (_unit getVariable [QGVAR(wireDeployed), false])) exitWith {
_wire = "ACE_ConcertinaWire" createvehicle [0, 0, 0]; _wire = "ACE_ConcertinaWire" createvehicle [0, 0, 0];
{ {
_wire animate [_x, _anim]; _wire animate [_x, _anim];
} foreach WIRE_FAST; } count WIRE_FAST;
[{ [{
EXPLODE_5_PVT(_this select 0,_wireNoGeo,_wire,_anim,_dir,_wireNoGeoPos); params ["_args", "_idPFH"];
_args params ["_wireNoGeo", "_wire", "_anim", "_dir", "_wireNoGeoPos"];
if (_wire animationPhase "wire_2" == _anim) then { if (_wire animationPhase "wire_2" == _anim) then {
deleteVehicle _wireNoGeo; deleteVehicle _wireNoGeo;
_wire setDir _dir; _wire setDir _dir;
_wire setPosASL _wireNoGeoPos; _wire setPosASL _wireNoGeoPos;
[_this select 1] call CBA_fnc_removePerFrameHandler; [_idPFH] call CBA_fnc_removePerFrameHandler;
}; };
}, 0, [_wireNoGeo, _wire, _anim, _dir, _wireNoGeoPos]] call CBA_fnc_addPerFrameHandler; }, 0, [_wireNoGeo, _wire, _anim, _dir, _wireNoGeoPos]] call CBA_fnc_addPerFrameHandler;
[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(Common,removeActionEventHandler); [_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(Common,removeActionEventHandler);
call EFUNC(interaction,hideMouseHint); call EFUNC(interaction,hideMouseHint);
[_this select 1] call CBA_fnc_removePerFrameHandler; [_idPFH] call CBA_fnc_removePerFrameHandler;
}; };
_wireNoGeo setDir _dir; _wireNoGeo setDir _dir;
{ {
_wireNoGeo animate [_x, _anim]; _wireNoGeo animate [_x, _anim];
} foreach WIRE_FAST; } count WIRE_FAST;
}, 0, [_wireNoGeo, _wireNoGeoPos, _unit]] call CBA_fnc_addPerFrameHandler; }, 0, [_wireNoGeo, _wireNoGeoPos, _unit]] call CBA_fnc_addPerFrameHandler;
[localize "STR_ACE_ROLLWIRE", "", ""] call EFUNC(interaction,showMouseHint); [localize "STR_ACE_ROLLWIRE", "", ""] call EFUNC(interaction,showMouseHint);
GVAR(placer) setVariable [QGVAR(Deploy), GVAR(placer) setVariable [QGVAR(Deploy),
[GVAR(placer), "DefaultAction", [GVAR(placer), "DefaultAction",
{GVAR(deployPFH) != -1}, {GVAR(deployPFH) != -1},

View File

@ -8,10 +8,9 @@
* 1: unit <OBJECT> * 1: unit <OBJECT>
* *
* Return Value: * Return Value:
* Nothing
*
* Return value:
* None * None
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
@ -21,8 +20,7 @@ if (uiNamespace getVariable [QEGVAR(interact_menu,cursorMenuOpened),false]) exit
_this call FUNC(dismount); _this call FUNC(dismount);
}, _this] call EFUNC(common,execNextFrame); }, _this] call EFUNC(common,execNextFrame);
}; };
params ["_wire", "_unit"];
PARAMS_2(_wire,_unit);
private ["_config", "_delay"]; private ["_config", "_delay"];
_config = (configFile >> "CfgVehicles" >> typeOf _unit); _config = (configFile >> "CfgVehicles" >> typeOf _unit);

View File

@ -7,10 +7,9 @@
* 0: wire <OBJECT> * 0: wire <OBJECT>
* *
* Return Value: * Return Value:
* Nothing
*
* Return value:
* None * None
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
@ -18,25 +17,26 @@ PARAMS_1(_wire);
{ {
_wire animate [_x, 1]; _wire animate [_x, 1];
} foreach WIRE_FAST; } count WIRE_FAST;
[{ [{
EXPLODE_1_PVT(_this select 0,_wire); params ["_args", "_idPFH"];
_args params ["_wire"];
if (_wire animationPhase "wire_2" == 1) then { if (_wire animationPhase "wire_2" == 1) then {
private ["_dir", "_pos", "_wirecoil"]; private ["_dir", "_pos", "_wirecoil"];
_dir = getDir _wire; _dir = getDir _wire;
_pos = getPosASL _wire; _pos = getPosASL _wire;
_wirecoil = "ACE_ConcertinaWireCoil" createvehicle [0, 0, 0]; _wirecoil = "ACE_ConcertinaWireCoil" createvehicle [0, 0, 0];
deleteVehicle _wire; deleteVehicle _wire;
_wirecoil setDir _dir; _wirecoil setDir _dir;
_wirecoil setPosASL _pos; _wirecoil setPosASL _pos;
_wirecoil setVelocity [0, 0, 0]; _wirecoil setVelocity [0, 0, 0];
[_this select 1] call CBA_fnc_removePerFrameHandler; [_idPFH] call CBA_fnc_removePerFrameHandler;
}; };
}, 0, [_wire]] call CBA_fnc_addPerFrameHandler; }, 0, [_wire]] call CBA_fnc_addPerFrameHandler;

View File

@ -11,15 +11,12 @@
* 4: projectile <STRING> * 4: projectile <STRING>
* *
* Return Value: * Return Value:
* Nothing
*
* Return value:
* None * None
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_wire", "", "_damage", "_source", ""];
PARAMS_5(_wire,_selectionName,_damage,_source,_projectile);
if (_damage < 0.5) exitWith { 0 }; if (_damage < 0.5) exitWith { 0 };
if (!(isNull _source)) then { if (!(isNull _source)) then {

View File

@ -8,14 +8,12 @@
* 1: killer (vehicle) <OBJECT> * 1: killer (vehicle) <OBJECT>
* *
* Return Value: * Return Value:
* Nothing
*
* Return value:
* None * None
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_wire", "_killer"];
PARAMS_2(_wire,_killer);
private ["_distance", "_vehicle"]; private ["_distance", "_vehicle"];

View File

@ -7,14 +7,12 @@
* 1: vehicle <OBJECT> * 1: vehicle <OBJECT>
* *
* Return Value: * Return Value:
* Nothing
*
* Return value:
* None * None
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_wire", "_vehicle"];
PARAMS_2(_wire,_vehicle);
private ["_type", "_mode", "_anim", "_parts", "_selectionPart", "_selection", "_pos_w", "_dir_w"]; private ["_type", "_mode", "_anim", "_parts", "_selectionPart", "_selection", "_pos_w", "_dir_w"];
@ -43,8 +41,8 @@ _dir_w = getDir _wire;
if (_mode == 0) then { if (_mode == 0) then {
private ["_x", "_y", "_found", "_wireCheckPosAr", "_no"]; private ["_x", "_y", "_found", "_wireCheckPosAr", "_no"];
_x = _pos_w select 0; _pos_w params ["_x","_y"];
_y = _pos_w select 1;
// Check if two Single coils are placed next to each other (i.e playes have built a big wire obstacle) // Check if two Single coils are placed next to each other (i.e playes have built a big wire obstacle)
_wireCheckPosAr = [ _wireCheckPosAr = [
[_x + (sin (_dir_w+90) * 1.5),_y + (cos (_dir_w+90) * 1.5)], [_x + (sin (_dir_w+90) * 1.5),_y + (cos (_dir_w+90) * 1.5)],