Some things

Made params nicer, replaced some forEach and used params in XEH_respawn
This commit is contained in:
GitHawk 2016-05-12 14:55:40 +02:00
parent 29cd940fd0
commit d0509830e3
38 changed files with 172 additions and 54 deletions

View File

@ -1,14 +1,12 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit"]; params ["_unit"];
_unit = _this select 0;
if !(local _unit) exitWith {}; if !(local _unit) exitWith {};
_unit setVariable [QGVAR(selectedWeaponOnRearm), nil]; _unit setVariable [QGVAR(selectedWeaponOnRearm), nil];
_unit setVariable [QGVAR(carriedMagazine), nil]; _unit setVariable [QGVAR(carriedMagazine), nil];
_dummy = _unit getVariable [QGVAR(dummy), objNull]; private _dummy = _unit getVariable [QGVAR(dummy), objNull];
if !(isNull _dummy) then { if !(isNull _dummy) then {
detach _dummy; detach _dummy;
deleteVehicle _dummy; deleteVehicle _dummy;

View File

@ -17,7 +17,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_magazineClass", "", [""]], ["_partial", false, [false]]]; params [
["_truck", objNull, [objNull]],
["_magazineClass", "", [""]],
["_partial", false, [false]]
];
if (isNull _truck || if (isNull _truck ||
{_magazineClass isEqualTo ""} || {_magazineClass isEqualTo ""} ||

View File

@ -15,7 +15,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]]]; params [
["_truck", objNull, [objNull]]
];
private _vehicles = nearestObjects [_truck, ["AllVehicles"], 20]; private _vehicles = nearestObjects [_truck, ["AllVehicles"], 20];
if (count _vehicles < 2) exitWith {false}; // Rearming needs at least 2 vehicles if (count _vehicles < 2) exitWith {false}; // Rearming needs at least 2 vehicles
@ -63,8 +65,10 @@ private _vehicleActions = [];
}; };
}; };
}; };
} forEach _magazines; false
} forEach REARM_TURRET_PATHS; } count _magazines;
false
} count REARM_TURRET_PATHS;
}; };
if (_needToAdd && !(_vehicle getVariable [QGVAR(disabled), false])) then { if (_needToAdd && !(_vehicle getVariable [QGVAR(disabled), false])) then {
private _icon = getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "Icon"); private _icon = getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "Icon");
@ -91,6 +95,7 @@ private _vehicleActions = [];
_vehicleActions pushBack [_action, _actions, _truck]; _vehicleActions pushBack [_action, _actions, _truck];
}; };
}; };
} forEach _vehicles; false
} count _vehicles;
_vehicleActions _vehicleActions

View File

@ -20,7 +20,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_vehicle", objNull, [objNull, ""]]]; params [
["_truck", objNull, [objNull]],
["_vehicle", objNull, [objNull, ""]]
];
if (isNull _truck || if (isNull _truck ||
{typeName _vehicle == "OBJECT" && {isNull _vehicle}}) exitWith {}; {typeName _vehicle == "OBJECT" && {isNull _vehicle}}) exitWith {};
@ -32,11 +35,13 @@ if (typeName _vehicle == "OBJECT") then {
if (typeName _vehicle == "STRING") then { if (typeName _vehicle == "STRING") then {
_string = _vehicle; _string = _vehicle;
}; };
if (_string == "") exitWith {[]}; if (_string == "") exitWith {};
{ {
private _turretPath = _x; private _turretPath = _x;
private _magazines = [_string, _turretPath] call FUNC(getConfigMagazines); private _magazines = [_string, _turretPath] call FUNC(getConfigMagazines);
{ {
[_truck, _x] call FUNC(addMagazineToSupply); [_truck, _x] call FUNC(addMagazineToSupply);
} forEach _magazines; false
} forEach REARM_TURRET_PATHS; } count _magazines;
false
} count REARM_TURRET_PATHS;

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]]]; params [
["_truck", objNull, [objNull]],
["_unit", objNull, [objNull]]
];
!(isNull _unit || !(isNull _unit ||
{!(_unit isKindOf "CAManBase")} || {!(_unit isKindOf "CAManBase")} ||

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_vehicle", objNull, [objNull]], ["_unit", objNull, [objNull]]]; params [
["_vehicle", objNull, [objNull]],
["_unit", objNull, [objNull]]
];
if (GVAR(level) == 0 || {isNull _unit} || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {_vehicle distance _unit > REARM_ACTION_DISTANCE} || {_vehicle getVariable [QGVAR(disabled), false]}) exitWith {false}; if (GVAR(level) == 0 || {isNull _unit} || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {_vehicle distance _unit > REARM_ACTION_DISTANCE} || {_vehicle getVariable [QGVAR(disabled), false]}) exitWith {false};

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_vehicle", objNull, [objNull]], ["_unit", objNull, [objNull]]]; params [
["_vehicle", objNull, [objNull]],
["_unit", objNull, [objNull]]
];
!(isNull _unit || !(isNull _unit ||
{!(_unit isKindOf "CAManBase")} || {!(_unit isKindOf "CAManBase")} ||

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]]]; params [
["_truck", objNull, [objNull]],
["_unit", objNull, [objNull]]
];
!(isNull _unit || !(isNull _unit ||
{!(_unit isKindOf "CAManBase")} || {!(_unit isKindOf "CAManBase")} ||

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]]]; params [
["_truck", objNull, [objNull]],
["_unit", objNull, [objNull]]
];
!(isNull _unit || !(isNull _unit ||
{!(_unit isKindOf "CAManBase")} || {!(_unit isKindOf "CAManBase")} ||

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_magazineClass", "", [""]]]; params [
["_unit", objNull, [objNull]],
["_magazineClass", "", [""]]
];
private _ammo = getText (configFile >> "CfgMagazines" >> _magazineClass >> "ammo"); private _ammo = getText (configFile >> "CfgMagazines" >> _magazineClass >> "ammo");
private _dummyName = getText (configFile >> "CfgAmmo" >> _ammo >> QGVAR(dummy)); private _dummyName = getText (configFile >> "CfgAmmo" >> _ammo >> QGVAR(dummy));

View File

@ -17,5 +17,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_vehicle", objNull, [objNull]], ["_disable", true, [true]]]; params [
["_vehicle", objNull, [objNull]],
["_disable", true, [true]]
];
_vehicle setVariable [QGVAR(disabled), _disable, true]; _vehicle setVariable [QGVAR(disabled), _disable, true];

View File

@ -17,7 +17,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_delete", false, [false]], ["_unholster", true, [true]]]; params [
["_unit", objNull, [objNull]],
["_delete", false, [false]],
["_unholster", true, [true]]
];
private _dummy = _unit getVariable [QGVAR(dummy), objNull]; private _dummy = _unit getVariable [QGVAR(dummy), objNull];
if !(isNull _dummy) then { if !(isNull _dummy) then {

View File

@ -17,7 +17,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_magazineClass", "", [""]]]; params [
["_magazineClass", "", [""]]
];
if (_magazineClass isEqualTo "") exitWith {[8, 2]}; if (_magazineClass isEqualTo "") exitWith {[8, 2]};

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_cfgString", "", [""]], ["_turretPath", [], [[]]]]; params [
["_cfgString", "", [""]],
["_turretPath", [], [[]]]
];
if (_cfgString == "") exitWith {[]}; if (_cfgString == "") exitWith {[]};

View File

@ -17,7 +17,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_vehicle", objNull, [objNull]], ["_turretPath", [], [[]]], ["_magazineClass", "", [""]]]; params [
["_vehicle", objNull, [objNull]],
["_turretPath", [], [[]]],
["_magazineClass", "", [""]]
];
if (isNull _vehicle) exitWith {0}; if (isNull _vehicle) exitWith {0};

View File

@ -13,13 +13,16 @@
* 2: Number of current magazines in turret path <NUMBER> * 2: Number of current magazines in turret path <NUMBER>
* *
* Example: * Example:
* [tank, "mag"] call ace_rearm_fnc_getNeedRearmMagazines * [tank, "500Rnd_127x99_mag_Tracer_Red"] call ace_rearm_fnc_getNeedRearmMagazines
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_vehicle", "_magazineClass"]; params [
["_vehicle", objNull, [objNull]],
["_magazineClass", "", [""]]
];
private _return = [false, [], 0]; private _return = [false, [], 0];
{ {
@ -38,6 +41,7 @@ private _return = [false, [], 0];
}; };
if (_return select 0) exitWith {}; if (_return select 0) exitWith {};
} forEach REARM_TURRET_PATHS; false
} count REARM_TURRET_PATHS;
_return _return

View File

@ -15,7 +15,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]]]; params [
["_truck", objNull, [objNull]]
];
private _supply = _truck getVariable QGVAR(currentSupply); private _supply = _truck getVariable QGVAR(currentSupply);

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_vehicle", objNull, [objNull]], ["_turretPath", [], [[]]]]; params [
["_vehicle", objNull, [objNull]],
["_turretPath", [], [[]]]
];
if (isNull _vehicle) exitWith {[]}; if (isNull _vehicle) exitWith {[]};

View File

@ -16,10 +16,12 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_dummy", objNull, [objNull]], ["_unit", objNull, [objNull]]]; params [
["_dummy", objNull, [objNull]],
["_unit", objNull, [objNull]]
];
REARM_HOLSTER_WEAPON REARM_HOLSTER_WEAPON
[_unit, "forceWalk", QGVAR(vehRearm), true] call EFUNC(common,statusEffect_set);
[ [
5, 5,
@ -29,7 +31,7 @@ REARM_HOLSTER_WEAPON
params ["_args"]; params ["_args"];
_args params ["_dummy", "_unit"]; _args params ["_dummy", "_unit"];
[_dummy, _unit] call FUNC(pickUpAmmo); [_dummy, _unit] call FUNC(pickUpAmmo);
[_unit, "forceWalk", QGVAR(vehRearm), true] call EFUNC(common,statusEffect_set);
_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
if (_actionID != -1) then { if (_actionID != -1) then {
_unit removeAction _actionID; _unit removeAction _actionID;

View File

@ -15,7 +15,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]]]; params [
["_unit", objNull, [objNull]]
];
if (!local _unit) exitWith {}; if (!local _unit) exitWith {};

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_isUnconscious", false, [false]]]; params [
["_unit", objNull, [objNull]],
["_isUnconscious", false, [false]]
];
if (!local _unit || {!_isUnconscious}) exitWith {}; if (!local _unit || {!_isUnconscious}) exitWith {};

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_magazineClass", "", [""]]]; params [
["_truck", objNull, [objNull]],
["_magazineClass", "", [""]]
];
if (isNull _truck || if (isNull _truck ||
{_magazineClass isEqualTo ""}) exitWith {false}; {_magazineClass isEqualTo ""}) exitWith {false};

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_magazineClass", "", [""]]]; params [
["_truck", objNull, [objNull]],
["_magazineClass", "", [""]]
];
if (isNull _truck || if (isNull _truck ||
{_magazineClass isEqualTo ""}) exitWith {false}; {_magazineClass isEqualTo ""}) exitWith {false};

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_obj", objNull, [objNull]], ["_dirAndUp", [[1,0,0],[0,0,1]], [[]]]]; params [
["_obj", objNull, [objNull]],
["_dirAndUp", [[1,0,0],[0,0,1]], [[]]]
];
_obj setVectorDirAndUp _dirAndUp; _obj setVectorDirAndUp _dirAndUp;
_obj allowDamage false; _obj allowDamage false;

View File

@ -17,7 +17,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_logic", "", ["_activated", false, [false]]]; params [
"_logic",
"",
["_activated", false, [false]]
];
if (!_activated) exitWith {}; if (!_activated) exitWith {};

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_dummy", objNull, [objNull]], ["_unit", objNull, [objNull]]]; params [
["_dummy", objNull, [objNull]],
["_unit", objNull, [objNull]]
];
private _attachedDummy = _unit getVariable [QGVAR(dummy), objNull]; private _attachedDummy = _unit getVariable [QGVAR(dummy), objNull];
if !(isNull _attachedDummy) exitWith {}; if !(isNull _attachedDummy) exitWith {};

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]]]; params [
["_truck", objNull, [objNull]],
["_unit", objNull, [objNull]]
];
if (GVAR(supply) == 0) exitWith {}; if (GVAR(supply) == 0) exitWith {};
@ -57,7 +60,8 @@ if (GVAR(supply) == 1) then {
_numChars = _numChars max (count _line); _numChars = _numChars max (count _line);
_text = format ["%1<br/>%2", _text, _line]; _text = format ["%1<br/>%2", _text, _line];
_supply = _supply + 0.5; _supply = _supply + 0.5;
} forEach _magazines; false
} count _magazines;
}; };
if (_supply > 1.5) then { if (_supply > 1.5) then {
["displayTextStructured", [_unit], [[LSTRING(Hint_RemainingAmmo), _text], _supply, _unit, (_numChars/2.9)]] call EFUNC(common,targetEvent); ["displayTextStructured", [_unit], [[LSTRING(Hint_RemainingAmmo), _text], _supply, _unit, (_numChars/2.9)]] call EFUNC(common,targetEvent);

View File

@ -15,7 +15,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]]]; params [
["_unit", objNull, [objNull]]
];
private _attachedDummy = _unit getVariable [QGVAR(dummy), objNull]; private _attachedDummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _attachedDummy) exitwith {false}; if (isNull _attachedDummy) exitwith {false};

View File

@ -17,7 +17,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], "", ["_vehicle", objNull, [objNull]]]; params [
["_truck", objNull, [objNull]],
"",
["_vehicle", objNull, [objNull]]
];
[ [
10, 10,

View File

@ -18,7 +18,10 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_args"]; params ["_args"];
_args params [["_truck", objNull, [objNull]], ["_vehicle", objNull, [objNull]]]; _args params [
["_truck", objNull, [objNull]],
["_vehicle", objNull, [objNull]]
];
if (isServer) then { if (isServer) then {
{ {
@ -28,6 +31,7 @@ if (isServer) then {
} else { } else {
[QGVAR(rearmEntireVehicleSuccessLocalEH), _turretOwnerID, [_truck, _vehicle, _x]] call EFUNC(common,targetEvent); [QGVAR(rearmEntireVehicleSuccessLocalEH), _turretOwnerID, [_truck, _vehicle, _x]] call EFUNC(common,targetEvent);
}; };
false
} count REARM_TURRET_PATHS; } count REARM_TURRET_PATHS;
} else { } else {
[QGVAR(rearmEntireVehicleSuccessLocalEH), _this] call EFUNC(common,serverEvent); [QGVAR(rearmEntireVehicleSuccessLocalEH), _this] call EFUNC(common,serverEvent);

View File

@ -17,7 +17,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_vehicle", objNull, [objNull]], ["_turretPath", [], [[]]]]; params [
["_truck", objNull, [objNull]],
["_vehicle", objNull, [objNull]],
["_turretPath", [], [[]]]
];
private _magazines = [_vehicle, _turretPath] call FUNC(getVehicleMagazines); private _magazines = [_vehicle, _turretPath] call FUNC(getVehicleMagazines);
if (isNil "_magazines") exitWith {}; if (isNil "_magazines") exitWith {};
@ -58,4 +62,5 @@ if (isNil "_magazines") exitWith {};
_vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath]; _vehicle setMagazineTurretAmmo [_magazine, _maxRounds, _turretPath];
}; };
}; };
} foreach _magazines; false
} count _magazines;

View File

@ -21,7 +21,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_args", [objNull, objNull, [], 0, "", 0], [[]], [6]]]; params [
["_args", [objNull, objNull, [], 0, "", 0], [[]], [6]]
];
_args params ["_vehicle", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"]; _args params ["_vehicle", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"];
//hint format ["Vehicle: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _vehicle, _turretPath, _numMagazines, _magazineClass, _numRounds]; //hint format ["Vehicle: %1\nTurretPath: %2\nNumMagazines: %3\nMagazine: %4\nNumRounds: %5", _vehicle, _turretPath, _numMagazines, _magazineClass, _numRounds];

View File

@ -21,7 +21,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_args", [objNull, objNull, [], 0, "", 0], [[]], [6]]]; params [
["_args", [objNull, objNull, [], 0, "", 0], [[]], [6]]
];
_args params ["_vehicle", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"]; _args params ["_vehicle", "_unit", "_turretPath", "_numMagazines", "_magazineClass", "_numRounds"];
private _rounds = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count"); private _rounds = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count");

View File

@ -17,7 +17,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_magazineClass", "", [""]], ["_numRounds", -1, [0]]]; params [
["_truck", objNull, [objNull]],
["_magazineClass", "", [""]],
["_numRounds", -1, [0]]
];
if (isNull _truck || if (isNull _truck ||
{_magazineClass isEqualTo ""}) exitWith {false}; {_magazineClass isEqualTo ""}) exitWith {false};

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_supply", 0, [0]]]; params [
["_truck", objNull, [objNull]],
["_supply", 0, [0]]
];
if (isNull _truck) exitWith {}; if (isNull _truck) exitWith {};

View File

@ -16,7 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]]]; params [
["_truck", objNull, [objNull]],
["_unit", objNull, [objNull]]
];
private _attachedDummy = _unit getVariable [QGVAR(dummy), objNull]; private _attachedDummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _attachedDummy) exitwith {}; if (isNull _attachedDummy) exitwith {};

View File

@ -19,7 +19,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_truck", objNull, [objNull]], ["_unit", objNull, [objNull]], ["_args", ["", objNull], [[]]]]; params [
["_truck", objNull, [objNull]],
["_unit", objNull, [objNull]],
["_args", ["", objNull], [[]]]
];
_args params ["_magazineClass", "_vehicle"]; _args params ["_magazineClass", "_vehicle"];
([_magazineClass] call FUNC(getCaliber)) params ["_cal", "_idx"]; ([_magazineClass] call FUNC(getCaliber)) params ["_cal", "_idx"];

View File

@ -18,7 +18,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_args", [objNull, "", objNull], [[]], 3]]; params [
["_args", [objNull, "", objNull], [[]], 3]
];
_args params ["_unit", "_magazineClass", "_truck"]; _args params ["_unit", "_magazineClass", "_truck"];
private _success = true; private _success = true;