Merge pull request #2003 from jokoho48/codeCleanupWeaponselect

Code cleanup Weaponselect module
This commit is contained in:
Glowbal 2015-08-08 13:32:45 +02:00
commit 13f7d0f632
16 changed files with 119 additions and 47 deletions

View File

@ -12,10 +12,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_unit,_muzzle);
private ["_uniformMags", "_vestMags", "_backpackMags", "_numberOfMagazines", "_magazineClasses", "_firstMagazine"]; private ["_uniformMags", "_vestMags", "_backpackMags", "_numberOfMagazines", "_magazineClasses", "_firstMagazine"];
params ["_unit", "_muzzle"];
_uniformMags = getMagazineCargo uniformContainer _unit; _uniformMags = getMagazineCargo uniformContainer _unit;
_vestMags = getMagazineCargo vestContainer _unit; _vestMags = getMagazineCargo vestContainer _unit;
_backpackMags = getMagazineCargo backpackContainer _unit; _backpackMags = getMagazineCargo backpackContainer _unit;

View File

@ -14,10 +14,10 @@
if !(GVAR(DisplayText)) exitwith {}; if !(GVAR(DisplayText)) exitwith {};
PARAMS_2(_magazine,_numberofMagazines);
private ["_color", "_name", "_text", "_picture"]; private ["_color", "_name", "_text", "_picture"];
params ["_magazine", "_numberofMagazines"];
_color = [[1,0,0], [1,1,1]] select (_numberofMagazines > 0); _color = [[1,0,0], [1,1,1]] select (_numberofMagazines > 0);
_name = getText (configFile >> "CfgMagazines" >> _magazine >> "displayNameShort"); _name = getText (configFile >> "CfgMagazines" >> _magazine >> "displayNameShort");

View File

@ -1,17 +1,25 @@
// by commy2 /*
* Author: commy2
*
* Find the next Grenade Magazine.
*
* Argument:
* 0: Grenade Type ("All", "Frag", "NonFrag") <STRING>
*
* Return value:
* Magazine classname <STRING>
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_allMags", "_allMuzzles", "_magazines"]; private ["_allMags", "_allMuzzles", "_magazines", "_start", "_index", "_nextMagazine"];
PARAMS_1(_type); //"All", "Frag" or "NonFrag" params ["_type"];
_allMags = missionNamespace getVariable [format [QGVAR(%1Magazines), _type], []]; _allMags = missionNamespace getVariable [format [QGVAR(%1Magazines), _type], []];
_allMuzzles = missionNamespace getVariable [format [QGVAR(%1Muzzles), _type], []]; _allMuzzles = missionNamespace getVariable [format [QGVAR(%1Muzzles), _type], []];
_magazines = magazines ACE_player; _magazines = magazines ACE_player;
private ["_start", "_index", "_nextMagazine"];
_start = [GVAR(CurrentGrenadeMuzzleOther), GVAR(CurrentGrenadeMuzzleFrag)] select GVAR(CurrentGrenadeMuzzleIsFrag); _start = [GVAR(CurrentGrenadeMuzzleOther), GVAR(CurrentGrenadeMuzzleFrag)] select GVAR(CurrentGrenadeMuzzleIsFrag);
_index = _allMuzzles find _start; _index = _allMuzzles find _start;

View File

@ -1,17 +1,25 @@
// by commy2 /*
* Author: commy2
*
* Find the next Grenade Muzzle.
*
* Argument:
* 0: Grenade Type ("All", "Frag", "NonFrag") <STRING>
*
* Return value:
* Class name of next throw muzzle <STRING>
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_allMags", "_allMuzzles", "_magazines"]; private ["_allMags", "_allMuzzles", "_magazines", "_start", "_index", "_nextMuzzle"];
PARAMS_1(_type); //"All", "Frag" or "NonFrag" params ["_type"];
_allMags = missionNamespace getVariable [format [QGVAR(%1Magazines), _type], []]; _allMags = missionNamespace getVariable [format [QGVAR(%1Magazines), _type], []];
_allMuzzles = missionNamespace getVariable [format [QGVAR(%1Muzzles), _type], []]; _allMuzzles = missionNamespace getVariable [format [QGVAR(%1Muzzles), _type], []];
_magazines = magazines ACE_player; _magazines = magazines ACE_player;
private ["_start", "_index", "_nextMuzzle"];
_start = [GVAR(CurrentGrenadeMuzzleOther), GVAR(CurrentGrenadeMuzzleFrag)] select GVAR(CurrentGrenadeMuzzleIsFrag); _start = [GVAR(CurrentGrenadeMuzzleOther), GVAR(CurrentGrenadeMuzzleFrag)] select GVAR(CurrentGrenadeMuzzleIsFrag);
_index = _allMuzzles find _start; _index = _allMuzzles find _start;

View File

@ -1,9 +1,19 @@
// by commy2 /*
* Author: commy2
*
* Fire Vehicle Smoke Launcher.
*
* Argument:
* 0: Vehicle <OBJECT>
*
* Return value:
* None
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_turret", "_weapons"]; private ["_turret", "_weapons"];
PARAMS_1(_vehicle); params ["_vehicle"];
_turret = [_vehicle] call EFUNC(common,getTurretCommander); _turret = [_vehicle] call EFUNC(common,getTurretCommander);

View File

@ -1,4 +1,14 @@
// by commy2 /*
* Author: commy2
*
* Returns the selected Grenade Muzzle.
*
* Argument:
* None
*
* Return value:
* Class name of selected throw muzzle. <STRING>
*/
#include "script_component.hpp" #include "script_component.hpp"
[GVAR(CurrentGrenadeMuzzleOther), GVAR(CurrentGrenadeMuzzleFrag)] select GVAR(CurrentGrenadeMuzzleIsFrag) [GVAR(CurrentGrenadeMuzzleOther), GVAR(CurrentGrenadeMuzzleFrag)] select GVAR(CurrentGrenadeMuzzleIsFrag)

View File

@ -1,9 +1,20 @@
// by commy2 /*
* Author: commy2
*
* Play the change firemode sound for specified weapon at units position.
*
* Argument:
* 0: Unit <OBJECT>
* 1: Weapon <STRING>
*
* Return value:
* None
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_sound"]; private ["_sound"];
PARAMS_2(_unit,_weapon); params ["_unit", "_weapon"];
_sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound"); _sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound");

View File

@ -4,14 +4,14 @@
* The unit will put its current weapon away. * The unit will put its current weapon away.
* *
* Argument: * Argument:
* 0: What unit should put the current weapon on back? (Object) * 0: Unit <OBJECT>
* *
* Return value: * Return value:
* None. * None
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_unit); params ["_unit"];
[_unit] call EFUNC(common,fixLoweredRifleAnimation); [_unit] call EFUNC(common,fixLoweredRifleAnimation);

View File

@ -4,7 +4,7 @@
* Cycle through all grenades. * Cycle through all grenades.
* *
* Argument: * Argument:
* None * 0: Unit <OBJECT>
* *
* Return value: * Return value:
* None * None
@ -13,13 +13,12 @@
private ["_text", "_nextMuzzle"]; private ["_text", "_nextMuzzle"];
PARAMS_1(_unit); params ["_unit"];
_nextMuzzle = ["All"] call FUNC(findNextGrenadeMuzzle); _nextMuzzle = ["All"] call FUNC(findNextGrenadeMuzzle);
if (_nextMuzzle != "") then { if (_nextMuzzle != "") then {
private ["_magazines", "_magazine", "_count", "_return"]; private ["_magazines", "_magazine", "_count", "_return"];
_magazines = GVAR(AllMagazines) select (GVAR(AllMuzzles) find _nextMuzzle); _magazines = GVAR(AllMagazines) select (GVAR(AllMuzzles) find _nextMuzzle);
reverse _magazines; reverse _magazines;

View File

@ -4,7 +4,7 @@
* Cycle through frags. * Cycle through frags.
* *
* Argument: * Argument:
* None * 0: Unit <OBJECT>
* *
* Return value: * Return value:
* None * None
@ -13,7 +13,7 @@
private ["_text", "_nextMuzzle"]; private ["_text", "_nextMuzzle"];
PARAMS_1(_unit); params ["_unit"];
_nextMuzzle = ["Frag"] call FUNC(findNextGrenadeMuzzle); _nextMuzzle = ["Frag"] call FUNC(findNextGrenadeMuzzle);

View File

@ -4,7 +4,7 @@
* Cycle through non explosive grenades. * Cycle through non explosive grenades.
* *
* Argument: * Argument:
* None * 0: Unit <OBJECT>
* *
* Return value: * Return value:
* None * None
@ -13,7 +13,7 @@
private ["_nextMuzzle", "_text"]; private ["_nextMuzzle", "_text"];
PARAMS_1(_unit); params ["_unit"];
_nextMuzzle = ["NonFrag"] call FUNC(findNextGrenadeMuzzle); _nextMuzzle = ["NonFrag"] call FUNC(findNextGrenadeMuzzle);

View File

@ -4,14 +4,15 @@
* The player will select the specified weapon or will change to the next firing mode if the weapon was already selected. * The player will select the specified weapon or will change to the next firing mode if the weapon was already selected.
* *
* Argument: * Argument:
* 0: A weapon (String) * 0: Unit <OBJECT>
* 1: Weapon <STRING>
* *
* Return value: * Return value:
* None. * None
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_unit,_weapon); params ["_unit", "_weapon"];
if (_weapon == "") exitWith {}; if (_weapon == "") exitWith {};

View File

@ -4,14 +4,15 @@
* The player will select the specified weapon and change to the first additional muzzle. E.g. the grenade launcher of a assault rifle. * The player will select the specified weapon and change to the first additional muzzle. E.g. the grenade launcher of a assault rifle.
* *
* Argument: * Argument:
* 0: A weapon (String) * 0: Unit <OBJECT>
* 1: Weapon <STRING>
* *
* Return value: * Return value:
* None. * None
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_unit,_weapon); params ["_unit", "_weapon"];
if (_weapon == "") exitWith {}; if (_weapon == "") exitWith {};

View File

@ -1,7 +1,19 @@
// by commy2 /*
* Author: commy2
*
* Select weapon for unit in vehicle.
*
* Argument:
* 0: Unit <OBJECT>
* 1: Vehicle <OBJECT>
* 2: Weapon index <NUMBER>
*
* Return value:
* None
*/
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_3(_unit,_vehicle,_index); params ["_unit", "_vehicle", "_index"];
private "_turret"; private "_turret";
_turret = [_unit] call EFUNC(common,getTurretIndex); _turret = [_unit] call EFUNC(common,getTurretIndex);

View File

@ -4,18 +4,18 @@
* Select the next grenade muzzle to throw. * Select the next grenade muzzle to throw.
* *
* Argument: * Argument:
* muzzle name * 0: Unit <OBJECT>
* 1: Muzzlename <STRING>
* *
* Return value: * Return value:
* None * None
*
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_unit,_muzzle);
private ["_uniformMags", "_vestMags", "_backpackMags", "_i", "_uniformMagsToRemove", "_vestMagsToRemove", "_backpackMagsToRemove", "_firstMagazine", "_throwMuzzleNames"]; private ["_uniformMags", "_vestMags", "_backpackMags", "_i", "_uniformMagsToRemove", "_vestMagsToRemove", "_backpackMagsToRemove", "_firstMagazine", "_throwMuzzleNames"];
params ["_unit", "_muzzle"];
_uniformMags = getMagazineCargo uniformContainer _unit; _uniformMags = getMagazineCargo uniformContainer _unit;
_vestMags = getMagazineCargo vestContainer _unit; _vestMags = getMagazineCargo vestContainer _unit;
_backpackMags = getMagazineCargo backpackContainer _unit; _backpackMags = getMagazineCargo backpackContainer _unit;

View File

@ -1,11 +1,23 @@
// by commy2 /*
* Author: commy2
*
* Display Grenade information on grenade throw.
*
* Argument:
* 0: unit - Object the event handler is assigned to <OBJECT>
* 1: weapon - Fired weapon <STRING>
* 2: muzzle - Muzzle that was used <STRING>
* 3: mode - Current mode of the fired weapon <STRING>
* 4: ammo - Ammo used <STRING>
* 5: magazine - magazine name which was used <STRING>
* 6: projectile - Object of the projectile that was shot <OBJECT>
*
* Return value:
* None
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit","_weapon","_magazine"]; params ["_unit", "_weapon", "", "", "", "_magazine"];
_unit = _this select 0;
_weapon = _this select 1;
_magazine = _this select 5;
if (_weapon != "Throw") exitWith {}; if (_weapon != "Throw") exitWith {};