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 {};
// add keybinds
["ACE3 Weapons", QGVAR(SelectPistolNew), localize LSTRING(SelectPistol),
{
["ACE3 Weapons", QGVAR(SelectPistolNew), localize LSTRING(SelectPistol), {
// Conditions: canInteract
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -16,10 +15,9 @@ if (!hasInterface) exitWith {};
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
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -30,10 +28,9 @@ if (!hasInterface) exitWith {};
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
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -44,10 +41,9 @@ if (!hasInterface) exitWith {};
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
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -58,10 +54,9 @@ if (!hasInterface) exitWith {};
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
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -72,10 +67,9 @@ if (!hasInterface) exitWith {};
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
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -86,10 +80,9 @@ if (!hasInterface) exitWith {};
true
},
{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
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -100,10 +93,9 @@ if (!hasInterface) exitWith {};
true
},
{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
if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -125,10 +117,9 @@ if (!hasInterface) exitWith {};
true
},
{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
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -139,10 +130,9 @@ if (!hasInterface) exitWith {};
true
},
{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
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -153,10 +143,9 @@ if (!hasInterface) exitWith {};
true
},
{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
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -167,10 +156,9 @@ if (!hasInterface) exitWith {};
true
},
{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
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -181,10 +169,9 @@ if (!hasInterface) exitWith {};
true
},
{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
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -195,10 +182,9 @@ if (!hasInterface) exitWith {};
true
},
{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
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
@ -209,4 +195,4 @@ if (!hasInterface) exitWith {};
true
},
{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"
private ["_turret", "_weapons"];
params ["_vehicle"];
private ["_turret", "_weapons"];
_turret = [_vehicle] call EFUNC(common,getTurretCommander);
_weapons = _vehicle weaponsTurret _turret;
@ -29,11 +29,10 @@ if (
) then {
//This doesn't work reliably for vehilces with additional weapons for the commander. Select smoke launcher instead.
private "_index";
// avoid infinite loop
if !("SmokeLauncher" in _weapons) exitWith {};
private "_index";
_index = 0;
while {
_vehicle currentWeaponTurret _turret != "SmokeLauncher"
@ -46,8 +45,9 @@ if (
// fire away!
private "_logic";
_logic = createGroup sideLogic createUnit ["Logic", [0,0,0], [], 0, "NONE"];
_logic action ["useWeapon", _vehicle, commander _vehicle, 0];
deleteVehicle _logic;
};

View File

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

View File

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