mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Vehicle quick mount (#4931)
* Add quickmount files from ACEX * Rename to ACE3, Streamline, Use clientInit * Rename functions to ACE3, Fix crew getting * Fix enabled text * Fix texts * Remove spaces * Rework seat search
This commit is contained in:
parent
288f956316
commit
4872e186cd
1
addons/quickmount/$PBOPREFIX$
Normal file
1
addons/quickmount/$PBOPREFIX$
Normal file
@ -0,0 +1 @@
|
||||
z\ace\addons\quickmount
|
41
addons/quickmount/ACE_Settings.hpp
Normal file
41
addons/quickmount/ACE_Settings.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
class ACE_Settings {
|
||||
class GVAR(enabled) {
|
||||
value = 0;
|
||||
typeName = "BOOL";
|
||||
category = CSTRING(Category);
|
||||
displayName = ECSTRING(common,Enabled);
|
||||
description = CSTRING(KeybindDescription);
|
||||
isClientSettable = 1;
|
||||
force = 0;
|
||||
};
|
||||
class GVAR(distance) {
|
||||
value = DEFAULT_DISTANCE;
|
||||
typeName = "SCALAR";
|
||||
category = CSTRING(Category);
|
||||
displayName = CSTRING(Distance);
|
||||
description = CSTRING(DistanceDescription);
|
||||
isClientSettable = 0;
|
||||
force = 0;
|
||||
values[] = {"0m", "1m", "2m", "3m", "4m", "5m", "6m", "7m", "8m", "9m", "10m"};
|
||||
};
|
||||
class GVAR(speed) {
|
||||
value = DEFAULT_SPEED;
|
||||
typeName = "SCALAR";
|
||||
category = CSTRING(Category);
|
||||
displayName = CSTRING(Speed);
|
||||
description = CSTRING(SpeedDescription);
|
||||
isClientSettable = 0;
|
||||
force = 0;
|
||||
values[] = {"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30"};
|
||||
};
|
||||
class GVAR(priority) {
|
||||
value = DEFAULT_PRIORITY;
|
||||
typeName = "SCALAR";
|
||||
category = CSTRING(Category);
|
||||
displayName = CSTRING(Priority);
|
||||
description = CSTRING(PriorityDescription);
|
||||
isClientSettable = 1;
|
||||
force = 0;
|
||||
values[] = {"Driver", "Gunner", "Commander", "Passenger"};
|
||||
};
|
||||
};
|
17
addons/quickmount/CfgEventHandlers.hpp
Normal file
17
addons/quickmount/CfgEventHandlers.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
class Extended_PreStart_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preStart));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_PreInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_PostInit_EventHandlers {
|
||||
class ADDON {
|
||||
clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient));
|
||||
};
|
||||
};
|
37
addons/quickmount/CfgVehicles.hpp
Normal file
37
addons/quickmount/CfgVehicles.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
class CfgVehicles {
|
||||
class ACE_Module;
|
||||
class GVAR(module): ACE_Module {
|
||||
author = ECSTRING(common,ACETeam);
|
||||
category = "ACE";
|
||||
displayName = CSTRING(Category);
|
||||
function = QFUNC(moduleInit);
|
||||
scope = 2;
|
||||
isGlobal = 1;
|
||||
isTriggerActivated = 0;
|
||||
isDisposable = 0;
|
||||
icon = QPATHTOF(UI\Icon_Module_QuickMount_ca.paa);
|
||||
class Arguments {
|
||||
class enabled {
|
||||
displayName = ECSTRING(common,Enabled);
|
||||
description = CSTRING(KeybindDescription);
|
||||
typeName = "BOOL";
|
||||
defaultValue = 1;
|
||||
};
|
||||
class distance {
|
||||
displayName = CSTRING(Distance);
|
||||
description = CSTRING(DistanceDescription);
|
||||
typeName = "NUMBER";
|
||||
defaultValue = DEFAULT_DISTANCE;
|
||||
};
|
||||
class speed {
|
||||
displayName = CSTRING(Speed);
|
||||
description = CSTRING(SpeedDescription);
|
||||
typeName = "NUMBER";
|
||||
defaultValue = DEFAULT_SPEED;
|
||||
};
|
||||
};
|
||||
class ModuleDescription {
|
||||
description = CSTRING(KeybindDescription);
|
||||
};
|
||||
};
|
||||
};
|
9
addons/quickmount/README.md
Normal file
9
addons/quickmount/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
ace_quickmount
|
||||
============
|
||||
Adds a keybind to quickly enter the vehicle you are directly looking at.
|
||||
|
||||
## Maintainers
|
||||
|
||||
The people responsible for merging changes to this component or answering potential questions.
|
||||
|
||||
- [Kingsley](https://github.com/jameslkingsley)
|
BIN
addons/quickmount/UI/Icon_Module_QuickMount_ca.paa
Normal file
BIN
addons/quickmount/UI/Icon_Module_QuickMount_ca.paa
Normal file
Binary file not shown.
2
addons/quickmount/XEH_PREP.hpp
Normal file
2
addons/quickmount/XEH_PREP.hpp
Normal file
@ -0,0 +1,2 @@
|
||||
PREP(getInNearest);
|
||||
PREP(moduleInit);
|
10
addons/quickmount/XEH_postInitClient.sqf
Normal file
10
addons/quickmount/XEH_postInitClient.sqf
Normal file
@ -0,0 +1,10 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
["ACE3 Movement", QGVAR(mount), [localize LSTRING(KeybindName), localize LSTRING(KeybindDescription)], "", {
|
||||
if (!dialog) then {
|
||||
call FUNC(getInNearest);
|
||||
};
|
||||
false
|
||||
}] call CBA_fnc_addKeybind;
|
9
addons/quickmount/XEH_preInit.sqf
Normal file
9
addons/quickmount/XEH_preInit.sqf
Normal file
@ -0,0 +1,9 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP_RECOMPILE_START;
|
||||
#include "XEH_PREP.hpp"
|
||||
PREP_RECOMPILE_END;
|
||||
|
||||
ADDON = true;
|
3
addons/quickmount/XEH_preStart.sqf
Normal file
3
addons/quickmount/XEH_preStart.sqf
Normal file
@ -0,0 +1,3 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
#include "XEH_PREP.hpp"
|
18
addons/quickmount/config.cpp
Normal file
18
addons/quickmount/config.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
class CfgPatches {
|
||||
class ADDON {
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_common"};
|
||||
author = ECSTRING(common,ACETeam);
|
||||
authors[] = {"Kingsley"};
|
||||
url = ECSTRING(main,URL);
|
||||
VERSION_CONFIG;
|
||||
};
|
||||
};
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "ACE_Settings.hpp"
|
||||
#include "CfgVehicles.hpp"
|
98
addons/quickmount/functions/fnc_getInNearest.sqf
Normal file
98
addons/quickmount/functions/fnc_getInNearest.sqf
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Author: Kingsley
|
||||
* Mount the player in the vehicle they are directly looking at based on their distance.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_quickmount_fnc_getInNearest;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!GVAR(enabled) ||
|
||||
{isNull ACE_player} ||
|
||||
{vehicle ACE_player != ACE_player} ||
|
||||
{!alive ACE_player} ||
|
||||
{ACE_player getVariable ["ace_unconscious", false]}
|
||||
) exitWith {};
|
||||
|
||||
private _start = AGLtoASL (ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot"));
|
||||
private _end = (_start vectorAdd (getCameraViewDirection ACE_player vectorMultiply GVAR(distance)));
|
||||
private _objects = lineIntersectsSurfaces [_start, _end, ACE_player];
|
||||
private _target = (_objects param [0, []]) param [2, objNull];
|
||||
|
||||
if (locked _target in [2,3]) exitWith {
|
||||
[localize LSTRING(VehicleLocked)] call EFUNC(common,displayTextStructured);
|
||||
true
|
||||
};
|
||||
|
||||
TRACE_1("",_target);
|
||||
|
||||
if (!isNull _target &&
|
||||
{alive _target} &&
|
||||
{{_target isKindOf _x} count ["Air","LandVehicle","Ship","StaticMortar"] > 0} &&
|
||||
{([ACE_player, _target] call EFUNC(common,canInteractWith))} &&
|
||||
{speed _target <= GVAR(speed)}
|
||||
) then {
|
||||
|
||||
|
||||
if (GVAR(priority) > 3 || GVAR(priority) < 0) then {
|
||||
GVAR(priority) = 0;
|
||||
};
|
||||
|
||||
private _seats = ["Driver", "Gunner", "Commander", "Cargo"];
|
||||
private _sortedSeats = [_seats select GVAR(priority)];
|
||||
_seats deleteAt GVAR(priority);
|
||||
_sortedSeats append _seats;
|
||||
|
||||
|
||||
private _hasAction = false;
|
||||
scopeName "SearchForSeat";
|
||||
{
|
||||
private _desiredRole = _x;
|
||||
{
|
||||
_x params ["_unit", "_role", "_cargoIndex", "_turretPath"];
|
||||
if ((isNull _unit) || {!alive _unit}) then {
|
||||
private _effectiveRole = toLower _role;
|
||||
|
||||
if ((_effectiveRole in ["driver", "gunner"]) && {unitIsUAV _target}) exitWith {}; // Ignoring UAV Driver/Gunner
|
||||
if ((_effectiveRole == "driver") && {(getNumber (([_target] call CBA_fnc_getObjectConfig) >> "hasDriver")) == 0}) exitWith {}; // Ignoring Non Driver (static weapons)
|
||||
if (_effectiveRole == "turret") then {
|
||||
if ((getNumber (([_target, _turretPath] call CBA_fnc_getTurret) >> "isCopilot")) == 1) exitWith {
|
||||
_effectiveRole = "driver";
|
||||
};
|
||||
if (_cargoIndex < 0) exitWith {
|
||||
_effectiveRole = "gunner"; // door gunners / 2nd turret
|
||||
};
|
||||
_effectiveRole = "cargo"; // probably a FFV
|
||||
};
|
||||
TRACE_2("",_effectiveRole,_x);
|
||||
if (_effectiveRole != _desiredRole) exitWith {};
|
||||
|
||||
if (_role == "Turret") then {
|
||||
ACE_player action ["GetIn" + _role, _target, _turretPath];
|
||||
TRACE_3("Geting In",_x,_role,_turretPath);
|
||||
} else {
|
||||
ACE_player action ["GetIn" + _role, _target];
|
||||
TRACE_3("Geting In",_x,_role);
|
||||
};
|
||||
|
||||
_hasAction = true;
|
||||
breakTo "SearchForSeat";
|
||||
};
|
||||
} forEach (fullCrew [_target, "", true]);
|
||||
} forEach _sortedSeats;
|
||||
|
||||
if (!_hasAction) then {
|
||||
TRACE_1("no empty seats",_hasAction);
|
||||
[localize LSTRING(VehicleFull)] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
};
|
||||
|
||||
true
|
25
addons/quickmount/functions/fnc_moduleInit.sqf
Normal file
25
addons/quickmount/functions/fnc_moduleInit.sqf
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Author: Kingsley
|
||||
* Initializes the quick-mount module.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The module logic <LOGIC>
|
||||
* 1: Units <ARRAY> (Unused)
|
||||
* 2: Activated <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!isServer) exitWith {};
|
||||
|
||||
params ["_logic", "", "_activated"];
|
||||
|
||||
if (!_activated) exitWith {};
|
||||
|
||||
[_logic, QGVAR(enabled), "enabled"] call EFUNC(common,readSettingFromModule);
|
||||
[_logic, QGVAR(distance), "distance"] call EFUNC(common,readSettingFromModule);
|
||||
[_logic, QGVAR(speed), "speed"] call EFUNC(common,readSettingFromModule);
|
1
addons/quickmount/functions/script_component.hpp
Normal file
1
addons/quickmount/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
||||
#include "\z\ace\addons\quickmount\script_component.hpp"
|
21
addons/quickmount/script_component.hpp
Normal file
21
addons/quickmount/script_component.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
#define COMPONENT quickmount
|
||||
#define COMPONENT_BEAUTIFIED Quick Mount
|
||||
#include "\z\ace\addons\main\script_mod.hpp"
|
||||
|
||||
// #define DEBUG_MODE_FULL
|
||||
// #define DISABLE_COMPILE_CACHE
|
||||
// #define ENABLE_PERFORMANCE_COUNTERS
|
||||
|
||||
#ifdef DEBUG_ENABLED_QUICKMOUNT
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SETTINGS_QUICKMOUNT
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_QUICKMOUNT
|
||||
#endif
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
||||
|
||||
#define DEFAULT_DISTANCE 3
|
||||
#define DEFAULT_SPEED 18
|
||||
#define DEFAULT_PRIORITY 0
|
40
addons/quickmount/stringtable.xml
Normal file
40
addons/quickmount/stringtable.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project name="ACE">
|
||||
<Package name="QuickMount">
|
||||
<Key ID="STR_ACE_QuickMount_Category">
|
||||
<English>Quick Mount</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_QuickMount_KeybindName">
|
||||
<English>Vehicle quick mount</English>
|
||||
<German>Fahrzeug schnell montieren</German>
|
||||
<Polish>Pojazd szybkie mocowanie</Polish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_QuickMount_KeybindDescription">
|
||||
<English>Quickly enter the vehicle you are directly looking at.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_QuickMount_VehicleFull">
|
||||
<English>Vehicle Full</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_QuickMount_Distance">
|
||||
<English>Distance</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_QuickMount_DistanceDescription">
|
||||
<English>Maximum distance to check for vehicles.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_QuickMount_VehicleLocked">
|
||||
<English>Vehicle Locked</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_QuickMount_Speed">
|
||||
<English>Maximum Speed (km/h)</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_QuickMount_SpeedDescription">
|
||||
<English>Maximum vehicle speed (km/h) allowed for player entry</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_QuickMount_Priority">
|
||||
<English>Prioritize Seat</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_QuickMount_PriorityDescription">
|
||||
<English>Seat priority on entry</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user