This repository has been archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Vehicle quick mount #29
Closed
Closed
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
ba80da5
Add initial files for quick mount
86a5f27
Add debug code
6615ac4
Add distance variable (needs to be changed via ACE settings)
6a0e966
Add vehicle code - still needs moveInX code to be fixed
001263e
Fix direction command
633faea
Add ACE settings
250e632
Add texts to stringtable
01406c0
Exit if not enabled, fix object selection, fix positions
ee15bd7
Rename function
b5f0a23
Exit if no interface, fix strings
dc4cbdf
Change to lower-case
9a87450
Remove param
6fe488d
Remove param, use ACE isPlayer func, check target is alive, add morta…
bbb2141
Remove forced
cd6e123
Improve description
34819ed
Fix docs
4f148ee
Add module
9fcb2be
Add default distance macro, disable debug mode
ea74c99
PREP moduleInit
e9870d9
Remove unnecessary isPlayer check
4b25d7c
Update value, remove values property
da714be
Fix _start position
d2b4fde
Re-add values
5650fae
Clean fnc_getInNearest by adding a loop
654wak654 7987d47
Explicitly return false
f582a5e
Exit if unit is unconscious
1a477b3
Optimize object selection
68a420d
Merge pull request #1 from 654wak654/patch-1
1c82ff7
Format condition, explicitly check for locked
ea10dfb
Shorten loop, check for empty turret when picking cargo
b0039d0
Fix for when seat is occupied by corpse
9c644ce
Update docs
857d036
Default to disabled
8f12c08
Shorten function
ee641fa
Fix condition, remove whitespace, return true
c63c455
Update readme
25cc304
Prevent mount if dialog is open (medical)
a975194
Fix ACEX tag string
001c315
Add beautified component name
0f7da45
Make client settable for singleplayer use
6369cc2
Add "locked" message
40ce16d
Fix texts
f5f8008
Add speed option
cab1f64
Add priority setting
b2caa06
Change to <=
ff9ff03
Change to not client settable
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
z\acex\addons\quickmount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class ACE_Settings { | ||
class GVAR(enabled) { | ||
value = 0; | ||
typeName = "BOOL"; | ||
category = CSTRING(Category); | ||
displayName = ACECSTRING(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"}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
init = QUOTE(call COMPILE_FILE(XEH_postInit)); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class CfgVehicles { | ||
class ACE_Module; | ||
|
||
class GVAR(module): ACE_Module { | ||
author = ACECSTRING(common,ACETeam); | ||
category = "ACEX"; | ||
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 = ACECSTRING(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); | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
acex_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) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PREP(getInNearest); | ||
PREP(moduleInit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "script_component.hpp" | ||
|
||
if (!hasInterface) exitWith {}; | ||
|
||
["ACEX", QGVAR(actionID), [localize LSTRING(KeybindName), localize LSTRING(KeybindDescription)], "", { | ||
if (!dialog) then { | ||
[] call FUNC(getInNearest); | ||
}; | ||
|
||
false | ||
}] call CBA_fnc_addKeybind; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "script_component.hpp" | ||
|
||
ADDON = false; | ||
|
||
#include "XEH_PREP.hpp" | ||
|
||
ADDON = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "script_component.hpp" | ||
|
||
#include "XEH_PREP.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "script_component.hpp" | ||
|
||
class CfgPatches { | ||
class ADDON { | ||
units[] = {}; | ||
weapons[] = {}; | ||
requiredVersion = REQUIRED_VERSION; | ||
requiredAddons[] = {"acex_main"}; | ||
author = ACECSTRING(common,ACETeam); | ||
authors[] = {"Kingsley"}; | ||
url = ACECSTRING(main,URL); | ||
VERSION_CONFIG; | ||
}; | ||
}; | ||
|
||
#include "CfgEventHandlers.hpp" | ||
#include "ACE_Settings.hpp" | ||
#include "CfgVehicles.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Author: Kingsley | ||
* Mount the player in the vehicle they are directly looking at based on their distance. | ||
* | ||
* Arguments: | ||
* None | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [] call acex_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 positionCameraToWorld [0, 0, 0]; | ||
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 ACEFUNC(common,displayTextStructured); | ||
true | ||
}; | ||
|
||
if ( | ||
!isNull _target && | ||
{alive _target} && | ||
{{_target isKindOf _x} count ["Air","LandVehicle","Ship","StaticMortar"] > 0} && | ||
{([ACE_player, _target] call ACEFUNC(common,canInteractWith))} && | ||
{speed _target <= GVAR(speed)} | ||
) then { | ||
private _hasAction = false; | ||
|
||
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 _unit = _target call compile format ["assigned%1 _this", _x]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems slightly strange. Might there be a better way to do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure there is, unless it was just hard-coded and repeated. |
||
|
||
if (_unit isEqualType objNull && {!isNull _unit} && {!alive _unit}) exitWith { | ||
if (!_hasAction) then { | ||
ACE_player action ["GetIn" + _x, _target]; | ||
_hasAction = true; | ||
}; | ||
}; | ||
|
||
if (_target emptyPositions _x > 0) exitWith { | ||
if (!_hasAction) then { | ||
if (_x == "Cargo") then { | ||
private _crew = fullCrew [_target, "turret", true]; | ||
private _turretSeat = (_crew select {isNull (_x select 0)}) param [0, []]; | ||
|
||
if (_turretSeat isEqualTo []) then { | ||
ACE_player action ["GetIn" + _x, _target]; | ||
} else { | ||
ACE_player action ["GetInTurret", _target, _turretSeat select 3]; | ||
}; | ||
|
||
_hasAction = true; | ||
} else { | ||
ACE_player action ["GetIn" + _x, _target]; | ||
}; | ||
|
||
_hasAction = true; | ||
}; | ||
}; | ||
|
||
if (_forEachIndex == 3) then { | ||
[localize LSTRING(VehicleFull)] call ACEFUNC(common,displayTextStructured); | ||
}; | ||
} forEach _sortedSeats; | ||
}; | ||
|
||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 ACEFUNC(common,readSettingFromModule); | ||
[_logic, QGVAR(distance), "Distance"] call ACEFUNC(common,readSettingFromModule); | ||
[_logic, QGVAR(speed), "Speed"] call ACEFUNC(common,readSettingFromModule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "\z\acex\addons\quickmount\script_component.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#define COMPONENT quickmount | ||
#define COMPONENT_BEAUTIFIED QuickMount | ||
#include "\z\acex\addons\main\script_mod.hpp" | ||
|
||
// #define DEBUG_MODE_FULL | ||
// #define DISABLE_COMPILE_CACHE | ||
// #define CBA_DEBUG_SYNCHRONOUS | ||
// #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\acex\addons\main\script_macros.hpp" | ||
|
||
#define DEFAULT_DISTANCE 3 | ||
#define DEFAULT_SPEED 18 | ||
#define DEFAULT_PRIORITY 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project name="ACEX"> | ||
<Package name="QuickMount"> | ||
<Key ID="STR_ACEX_QuickMount_Category"> | ||
<English>Quick Mount</English> | ||
</Key> | ||
<Key ID="STR_ACEX_QuickMount_KeybindName"> | ||
<English>Vehicle quick mount</English> | ||
<German>Fahrzeug schnell montieren</German> | ||
<Polish>Pojazd szybkie mocowanie</Polish> | ||
</Key> | ||
<Key ID="STR_ACEX_QuickMount_KeybindDescription"> | ||
<English>Quickly enter the vehicle you are directly looking at.</English> | ||
</Key> | ||
<Key ID="STR_ACEX_QuickMount_VehicleFull"> | ||
<English>Vehicle Full</English> | ||
</Key> | ||
<Key ID="STR_ACEX_QuickMount_Distance"> | ||
<English>Distance</English> | ||
</Key> | ||
<Key ID="STR_ACEX_QuickMount_DistanceDescription"> | ||
<English>Maximum distance to check for vehicles.</English> | ||
</Key> | ||
<Key ID="STR_ACEX_QuickMount_VehicleLocked"> | ||
<English>Vehicle Locked</English> | ||
</Key> | ||
<Key ID="STR_ACEX_QuickMount_Speed"> | ||
<English>Maximum Speed (km/h)</English> | ||
</Key> | ||
<Key ID="STR_ACEX_QuickMount_SpeedDescription"> | ||
<English>Maximum vehicle speed (km/h) allowed for player entry</English> | ||
</Key> | ||
<Key ID="STR_ACEX_QuickMount_Priority"> | ||
<English>Prioritize Seat</English> | ||
</Key> | ||
<Key ID="STR_ACEX_QuickMount_PriorityDescription"> | ||
<English>Seat priority on entry</English> | ||
</Key> | ||
</Package> | ||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be removed.