WeaponSelect cleanup

This commit is contained in:
commy2 2015-09-27 14:55:36 +02:00
parent e3b926296f
commit f8819d3ee4
4 changed files with 49 additions and 71 deletions

View File

@ -4,8 +4,7 @@
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};
// add keybinds // add keybinds
["ACE3 Weapons", QGVAR(SelectPistolNew), localize LSTRING(SelectPistol), ["ACE3 Weapons", QGVAR(SelectPistolNew), localize LSTRING(SelectPistol), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -16,10 +15,9 @@ if (!hasInterface) exitWith {};
false false
}, },
{false}, {false},
[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 1 Key) [0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 1 Key)
["ACE3 Weapons", QGVAR(SelectRifleNew), localize LSTRING(SelectRifle), ["ACE3 Weapons", QGVAR(SelectRifleNew), localize LSTRING(SelectRifle), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -30,10 +28,9 @@ if (!hasInterface) exitWith {};
false false
}, },
{false}, {false},
[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 2 Key) [0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 2 Key)
["ACE3 Weapons", QGVAR(SelectRifleMuzzleNew), localize LSTRING(SelectRifleMuzzle), ["ACE3 Weapons", QGVAR(SelectRifleMuzzleNew), localize LSTRING(SelectRifleMuzzle), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -44,10 +41,9 @@ if (!hasInterface) exitWith {};
false false
}, },
{false}, {false},
[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 3 Key) [0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 3 Key)
["ACE3 Weapons", QGVAR(SelectLauncherNew), localize LSTRING(SelectLauncher), ["ACE3 Weapons", QGVAR(SelectLauncherNew), localize LSTRING(SelectLauncher), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -58,10 +54,9 @@ if (!hasInterface) exitWith {};
false false
}, },
{false}, {false},
[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 4 Key) [0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 4 Key)
["ACE3 Weapons", QGVAR(SelectBinocularNew), localize LSTRING(SelectBinocular), ["ACE3 Weapons", QGVAR(SelectBinocularNew), localize LSTRING(SelectBinocular), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -72,10 +67,9 @@ if (!hasInterface) exitWith {};
false false
}, },
{false}, {false},
[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 5 Key) [0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 5 Key)
["ACE3 Weapons", QGVAR(SelectGrenadeFrag), localize LSTRING(SelectGrenadeFrag), ["ACE3 Weapons", QGVAR(SelectGrenadeFrag), localize LSTRING(SelectGrenadeFrag), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -86,10 +80,9 @@ if (!hasInterface) exitWith {};
true true
}, },
{false}, {false},
[7, [false, false, false]], false] call cba_fnc_addKeybind; //6 Key [7, [false, false, false]], false] call CBA_fnc_addKeybind; //6 Key
["ACE3 Weapons", QGVAR(SelectGrenadeOther), localize LSTRING(SelectGrenadeOther), ["ACE3 Weapons", QGVAR(SelectGrenadeOther), localize LSTRING(SelectGrenadeOther), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -100,10 +93,9 @@ if (!hasInterface) exitWith {};
true true
}, },
{false}, {false},
[8, [false, false, false]], false] call cba_fnc_addKeybind; //7 Key [8, [false, false, false]], false] call CBA_fnc_addKeybind; //7 Key
["ACE3 Weapons", QGVAR(HolsterWeapon), localize LSTRING(HolsterWeapon), ["ACE3 Weapons", QGVAR(HolsterWeapon), localize LSTRING(HolsterWeapon), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -125,10 +117,9 @@ if (!hasInterface) exitWith {};
true true
}, },
{false}, {false},
[11, [false, false, false]], false] call cba_fnc_addKeybind; //0 Key [11, [false, false, false]], false] call CBA_fnc_addKeybind; //0 Key
["ACE3 Vehicles", QGVAR(EngineOn), localize LSTRING(EngineOn), ["ACE3 Vehicles", QGVAR(EngineOn), localize LSTRING(EngineOn), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -139,10 +130,9 @@ if (!hasInterface) exitWith {};
true true
}, },
{false}, {false},
[3, [false, false, false]], false] call cba_fnc_addKeybind; //2 Key [3, [false, false, false]], false] call CBA_fnc_addKeybind; //2 Key
["ACE3 Vehicles", QGVAR(EngineOff), localize LSTRING(EngineOff), ["ACE3 Vehicles", QGVAR(EngineOff), localize LSTRING(EngineOff), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -153,10 +143,9 @@ if (!hasInterface) exitWith {};
true true
}, },
{false}, {false},
[2, [false, false, false]], false] call cba_fnc_addKeybind; //1 Key [2, [false, false, false]], false] call CBA_fnc_addKeybind; //1 Key
["ACE3 Vehicles", QGVAR(SelectMainGunNew), localize LSTRING(SelectMainGun), ["ACE3 Vehicles", QGVAR(SelectMainGunNew), localize LSTRING(SelectMainGun), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -167,10 +156,9 @@ if (!hasInterface) exitWith {};
true true
}, },
{false}, {false},
[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 3 Key) [0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 3 Key)
["ACE3 Vehicles", QGVAR(SelectMachineGunNew), localize LSTRING(SelectMachineGun), ["ACE3 Vehicles", QGVAR(SelectMachineGunNew), localize LSTRING(SelectMachineGun), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -181,10 +169,9 @@ if (!hasInterface) exitWith {};
true true
}, },
{false}, {false},
[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 4 Key) [0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 4 Key)
["ACE3 Vehicles", QGVAR(SelectMissilesNew), localize LSTRING(SelectMissiles), ["ACE3 Vehicles", QGVAR(SelectMissilesNew), localize LSTRING(SelectMissiles), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -195,10 +182,9 @@ if (!hasInterface) exitWith {};
true true
}, },
{false}, {false},
[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 5 Key) [0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 5 Key)
["ACE3 Vehicles", QGVAR(FireSmokeLauncher), localize LSTRING(FireSmokeLauncher), ["ACE3 Vehicles", QGVAR(FireSmokeLauncher), localize LSTRING(FireSmokeLauncher), {
{
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
@ -209,4 +195,4 @@ if (!hasInterface) exitWith {};
true true
}, },
{false}, {false},
[10, [false, false, false]], false] call cba_fnc_addKeybind; //9 Key [10, [false, false, false]], false] call CBA_fnc_addKeybind; //9 Key

View File

@ -15,10 +15,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_turret", "_weapons"];
params ["_vehicle"]; params ["_vehicle"];
private ["_turret", "_weapons"];
_turret = [_vehicle] call EFUNC(common,getTurretCommander); _turret = [_vehicle] call EFUNC(common,getTurretCommander);
_weapons = _vehicle weaponsTurret _turret; _weapons = _vehicle weaponsTurret _turret;
@ -29,11 +29,10 @@ if (
) then { ) then {
//This doesn't work reliably for vehilces with additional weapons for the commander. Select smoke launcher instead. //This doesn't work reliably for vehilces with additional weapons for the commander. Select smoke launcher instead.
private "_index";
// avoid infinite loop // avoid infinite loop
if !("SmokeLauncher" in _weapons) exitWith {}; if !("SmokeLauncher" in _weapons) exitWith {};
private "_index";
_index = 0; _index = 0;
while { while {
_vehicle currentWeaponTurret _turret != "SmokeLauncher" _vehicle currentWeaponTurret _turret != "SmokeLauncher"
@ -46,8 +45,9 @@ if (
// fire away! // fire away!
private "_logic"; private "_logic";
_logic = createGroup sideLogic createUnit ["Logic", [0,0,0], [], 0, "NONE"]; _logic = createGroup sideLogic createUnit ["Logic", [0,0,0], [], 0, "NONE"];
_logic action ["useWeapon", _vehicle, commander _vehicle, 0]; _logic action ["useWeapon", _vehicle, commander _vehicle, 0];
deleteVehicle _logic; deleteVehicle _logic;
}; };

View File

@ -1,6 +1,6 @@
/* /*
* Author: commy2 * Author: commy2
* Play the change firemode sound for specified weapon at units position. * Play weapon firemode change sound.
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
@ -16,32 +16,24 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_sound"];
params ["_unit", "_weapon"]; params ["_unit", "_weapon"];
private ["_sound", "_position"];
_sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound"); _sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound");
if (count _sound == 0) exitWith {}; if (_sound isEqualTo []) exitWith {};
// add file extension // get position where to play the sound (position of the weapon)
if call { _position = AGLToASL (_unit modelToWorldVisual (_unit selectionPosition "RightHand"));
{
if (toLower (_sound select 0) find _x == count toArray (_sound select 0) - count toArray _x - 1) exitWith {false}; _sound params ["_filename", ["_volume", 1], ["_soundPitch", 1], ["_distance", 0]];
true
} forEach [".wav", ".ogg", ".wss"]; if (_filename == "") exitWith {};
} then {
_sound set [0, (_sound select 0) + ".wss"]; // add file extension .wss as default
if !(toLower (_filename select [count _filename - 4]) in [".wav", ".ogg", ".wss"]) then {
_filename = format ["%1.wss", _filename];
}; };
// add default volume, pitch and distance playSound3D [_filename, objNull, false, _position, _volume, _soundPitch, _distance];
if (count _sound < 2) then {_sound pushBack 1};
if (count _sound < 3) then {_sound pushBack 1};
if (count _sound < 4) then {_sound pushBack 0};
private "_position";
_position = _unit modelToWorldVisual (_unit selectionPosition "RightHand");
_position set [2, (_position select 2) + ((getPosASLW _unit select 2) - (getPosATL _unit select 2) max 0)];
playSound3D [_sound select 0, objNull, false, _position, _sound select 1, _sound select 2, _sound select 3];

View File

@ -11,7 +11,7 @@
* Example: * Example:
* [player] call ace_weaponselect_fnc_putWeaponAway * [player] call ace_weaponselect_fnc_putWeaponAway
* *
* Public: NO * Public: Yes
*/ */
#include "script_component.hpp" #include "script_component.hpp"