Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Advanced Throwing #3477

Merged
merged 61 commits into from
Aug 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
fef7441
Add Advanced Throwing
jonpas Jun 5, 2016
504118a
Move canUseWeapon check to canPrepare, Remove redundand other checks
jonpas Jun 5, 2016
ff3d392
Improve and consolidate rendering maths
jonpas Jun 5, 2016
f0e9f74
Minor cleanup and optimizations
jonpas Jun 5, 2016
c7a0d26
Cleanup 2 more defines
jonpas Jun 5, 2016
c8b7492
Use getPosASLVisual, Reset throwType when switching to drop mode
jonpas Jun 5, 2016
b3a21ee
Fix rendering in moving vehicle
jonpas Jun 6, 2016
6ab8f46
Fix throw orientation being different than holding orientation
jonpas Jun 6, 2016
8c8d148
Prime before throw animation and delay, Remove therefore redundant pi…
jonpas Jun 6, 2016
c1cce58
Add ability to pick up primed throwables
jonpas Jun 6, 2016
02c43ce
Remove unused config entry - not necessary as all throwables are rath…
jonpas Jun 6, 2016
3a3a388
Improve mouse controls hint for different states
jonpas Jun 6, 2016
390d377
Improve primed hint
jonpas Jun 6, 2016
6af7b99
Fix missing semicolon in CfgPatches
jonpas Jun 6, 2016
e506d4a
Change pick up distance to 1.5m to allow picking up while standing wi…
jonpas Jun 6, 2016
edffec9
Fix inventory check on prepare
jonpas Jun 6, 2016
df2e42c
Fix Cook control hint, Remove 2xRMB control - same can be achieved wi…
jonpas Jun 6, 2016
00865b6
Possibly fix locality issue with picking up
jonpas Jun 6, 2016
88fca3f
Allow throwing with weapon lowered/on back/no weapon when not in vehicle
jonpas Jun 6, 2016
432d770
Make drop mode bindable (hold and toggle), Cleanup dropMode variables
jonpas Jun 6, 2016
1c95c88
Fix animation changing position in some stances, Stop drawing arc and…
jonpas Jun 7, 2016
f1a4533
Fix support for picking up attached throwables, Fix IR Grenades not b…
jonpas Jun 7, 2016
f8a1804
Improve arc precision, Change high throw velocity to use throwSpeed
jonpas Jun 7, 2016
a14ad25
Add thrown and picked up listenable events, Change throwFiredXEH to C…
jonpas Jun 7, 2016
d719414
Improve pick up interaction rendering, Fix pickup helper positioning
jonpas Jun 7, 2016
2e440db
Merge branch 'master' into grenadeThrowing
jonpas Jun 12, 2016
87fe2aa
Convert GVARs to setVariable (respawn and player change compatibility)
jonpas Jun 12, 2016
95d39c2
Fix throwing
jonpas Jun 12, 2016
ff9cc39
Convert the rest of events to CBA events
jonpas Jun 12, 2016
3748d1a
Add module icon and rest of settings to module
jonpas Jun 12, 2016
1629915
Fix priming
jonpas Jun 12, 2016
40aee04
Merge branch 'master' into grenadeThrowing
jonpas Jun 30, 2016
98aa9c6
Fix #3939
jonpas Jun 30, 2016
faf2387
Merge branch 'master' into grenadeThrowing
jonpas Jul 15, 2016
415fd75
CRLF snuck in
jonpas Jul 15, 2016
4962f99
Use common,doGesture
jonpas Jul 15, 2016
e739f05
Merge branch 'master' into grenadeThrowing
jonpas Jul 23, 2016
6e0cb23
Add beautified component name
jonpas Jul 23, 2016
1554724
Prevent leaning with lowered weapon, Disable debug
jonpas Jul 23, 2016
dd52f61
Reduce throwing speed when throwing over shoulder and to sides
jonpas Jul 23, 2016
e083652
Prevent throwing in quick succession (2 second cool-down like vanilla…
jonpas Jul 24, 2016
84aba3a
Disallow preparing throwable if reloading
jonpas Jul 24, 2016
0f6d54e
Possibly fix pick-up interaction stutter
jonpas Jul 24, 2016
d468a51
Use createVehicleLocal with [0,0,0] in drawThrowable
jonpas Aug 6, 2016
3165374
Make pick-up settings not be client settable
jonpas Aug 8, 2016
7f5ecfa
Convert to CBA Player Events
jonpas Aug 8, 2016
d159556
Merge branch 'master' into grenadeThrowing
jonpas Aug 8, 2016
86dd06a
Fix locality (again), Move prepared grenade closer to the edge to not…
jonpas Aug 9, 2016
4a604d5
Improvments for advanced throwing branch (#4248)
PabstMirror Aug 16, 2016
f040497
Slightly improve arc accuracy
jonpas Aug 16, 2016
9384d86
Add comment for ammoMagLookup namespace
jonpas Aug 16, 2016
57e8df3
Made draw/throw consistant and add 3d tracing debug
PabstMirror Aug 16, 2016
76283a4
Add Advanced Throwing Docudentation (new location)
jonpas Aug 18, 2016
d6e98a8
Merge branch 'master' into grenadeThrowing
jonpas Aug 18, 2016
67d9ee8
Merge branch 'advancedThrowingWikiMaster' into grenadeThrowing
jonpas Aug 18, 2016
d4d9bb5
Remove wiki closing points
jonpas Aug 19, 2016
2ca4859
Fix positioning when over land (non-VR)
jonpas Aug 19, 2016
2402740
Allow quick throwing in debug mode
jonpas Aug 19, 2016
847dc89
Fix comment
jonpas Aug 19, 2016
21c7360
Fix throwable stuck in hand after previous died primed in hand, Move …
jonpas Aug 22, 2016
1648daf
Remove redundant empty condition
jonpas Aug 22, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/advancedthrowing/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\ace\addons\advancedthrowing
40 changes: 40 additions & 0 deletions addons/advancedthrowing/ACE_Settings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class ACE_Settings {
class GVAR(enabled) {
category = CSTRING(Category);
displayName = CSTRING(Enable_DisplayName);
description = CSTRING(Enable_Description);
typeName = "BOOL";
value = 1;
isClientSettable = 1;
};
class GVAR(showThrowArc) {
category = CSTRING(Category);
displayName = CSTRING(ShowThrowArc_DisplayName);
description = CSTRING(ShowThrowArc_Description);
typeName = "BOOL";
value = 1;
isClientSettable = 1;
};
class GVAR(showMouseControls) {
category = CSTRING(Category);
displayName = CSTRING(ShowMouseControls_DisplayName);
description = CSTRING(ShowMouseControls_Description);
typeName = "BOOL";
value = 1;
isClientSettable = 1;
};
class GVAR(enablePickUp) {
category = CSTRING(Category);
displayName = CSTRING(EnablePickUp_DisplayName);
description = CSTRING(EnablePickUp_Description);
typeName = "BOOL";
value = 1;
};
class GVAR(enablePickUpAttached) {
category = CSTRING(Category);
displayName = CSTRING(EnablePickUpAttached_DisplayName);
description = CSTRING(EnablePickUpAttached_Description);
typeName = "BOOL";
value = 1;
};
};
17 changes: 17 additions & 0 deletions addons/advancedthrowing/CfgEventHandlers.hpp
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 {
clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient));
};
};
72 changes: 72 additions & 0 deletions addons/advancedthrowing/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
class CBA_Extended_EventHandlers;

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;
icon = QPATHTOF(UI\Icon_Module_AdvancedThrowing_ca.paa);
class Arguments {
class enabled {
displayName = CSTRING(Enable_DisplayName);
description = CSTRING(Enable_Description);
typeName = "BOOL";
defaultValue = 1;
};
class showThrowArc {
displayName = CSTRING(ShowThrowArc_DisplayName);
description = CSTRING(ShowThrowArc_Description);
typeName = "BOOL";
defaultValue = 1;
};
class showMouseControls {
displayName = CSTRING(ShowMouseControls_DisplayName);
description = CSTRING(ShowMouseControls_Description);
typeName = "BOOL";
defaultValue = 1;
};
class enablePickUp {
displayName = CSTRING(EnablePickUp_DisplayName);
description = CSTRING(EnablePickUp_Description);
typeName = "BOOL";
defaultValue = 1;
};
class enablePickUpAttached {
displayName = CSTRING(EnablePickUpAttached_DisplayName);
description = CSTRING(EnablePickUpAttached_Description);
typeName = "BOOL";
defaultValue = 1;
};
};
class ModuleDescription {
description = CSTRING(Module_Description);
};
};


class Items_base_F;
class GVAR(pickUpHelper): Items_base_F {
author = ECSTRING(common,ACETeam);
displayName = "ACE Throwable Pick Up Helper";
model = "\a3\weapons_f\dummyweapon.p3d";
scope = 1;

class ACE_Actions {
class GVAR(pickUp) {
displayName = CSTRING(PickUp);
condition = QUOTE(_player call FUNC(canPrepare));
statement = QUOTE(_this call FUNC(pickUp));
distance = 1.8; // Requires >1.7 to work when standing with weapon on back
icon = "\a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_takemine_ca.paa";
};
};

class EventHandlers {
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
};
};
};
11 changes: 11 additions & 0 deletions addons/advancedthrowing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ace_advancedthrowing
===================

Integrates advanced throwing by [Dslyecxi](https://github.com/dslyecxi).


## Maintainers

The people responsible for merging changes to this component or answering potential questions.

- [Jonpas](https://github.com/jonpas)
Binary file not shown.
17 changes: 17 additions & 0 deletions addons/advancedthrowing/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PREP(canPrepare);
PREP(canThrow);
PREP(drawArc);
PREP(drawThrowable);
PREP(exitThrowMode);
PREP(getMuzzle);
PREP(moduleInit);
PREP(onKeyDown);
PREP(onMouseButtonDown);
PREP(onMouseScroll);
PREP(pickUp);
PREP(prepare);
PREP(prime);
PREP(renderPickUpInteraction);
PREP(throw);
PREP(throwFiredXEH);
PREP(updateControlsHint);
107 changes: 107 additions & 0 deletions addons/advancedthrowing/XEH_postInitClient.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#include "script_component.hpp"

// Exit on HC
if (!hasInterface) exitWith {};

// Ammo/Magazines look-up hash for correctness of initSpeed
GVAR(ammoMagLookup) = call CBA_fnc_createNamespace;
{
{
private _ammo = getText (configFile >> "CfgMagazines" >> _x >> "ammo");
GVAR(ammoMagLookup) setVariable [_ammo, _x];
} count (getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines"));
nil
} count getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles");


// Add keybinds
["ACE3 Weapons", QGVAR(prepare), localize LSTRING(Prepare), {
// Condition
if (!([ACE_player] call FUNC(canPrepare))) exitWith {false};

// Statement
[ACE_player] call FUNC(prepare);

true
}, {false}, [34, [true, false, false]], false] call CBA_fnc_addKeybind; // Shift + G

["ACE3 Weapons", QGVAR(dropModeToggle), localize LSTRING(DropModeToggle), {
// Condition
if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {false};

// Statement
private _currentDropMode = ACE_player getVariable [QGVAR(dropMode), false];
ACE_player setVariable [QGVAR(dropMode), !_currentDropMode];

ACE_player setVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; // Reset for consistency when opening
call FUNC(updateControlsHint); // Change controls hint for MMB
true
}, {false}, [34, [false, true, false]], false] call CBA_fnc_addKeybind; // Ctrl + G

["ACE3 Weapons", QGVAR(dropModeHold), localize LSTRING(DropModeHold), {
// Condition
if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {false};

// Statement
ACE_player setVariable [QGVAR(dropMode), true];
ACE_player setVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; // Reset for consistency when opening
call FUNC(updateControlsHint); // Change controls hint for MMB
true
}, {
// Condition
if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {false};

// Statement
ACE_player setVariable [QGVAR(dropMode), false];
call FUNC(updateControlsHint); // Change controls hint for MMB
true
}, [0, [false, false, false]], false] call CBA_fnc_addKeybind; // Empty


// Event handlers
["unit", {
[_this select 1, "Player changed"] call FUNC(exitThrowMode);
}] call CBA_fnc_addPlayerEventhandler;

["ace_interactMenuOpened", {
// Exit if advanced throwing is disabled (pick up only supports advanced throwing)
if (!GVAR(enabled)) exitWith {};

if (ACE_player getVariable [QGVAR(inHand), false]) then {
[ACE_player, "Interact menu opened"] call FUNC(exitThrowMode);
} else {
params ["_interactionType"];
// Ignore self-interaction menu, when in vehicle and when pick up is disabled
if (GVAR(enablePickUp) && {_interactionType == 0} && {vehicle ACE_player == ACE_player}) then {
// Show pick up actions on CfgAmmo's
call FUNC(renderPickUpInteraction);
};
};
}] call CBA_fnc_addEventHandler;


// Fired XEH
[QGVAR(throwFiredXEH), FUNC(throwFiredXEH)] call CBA_fnc_addEventHandler;


// Display handlers
["KeyDown", {_this call FUNC(onKeyDown)}] call CBA_fnc_addDisplayHandler;
["MouseButtonDown", {_this call FUNC(onMouseButtonDown)}] call CBA_fnc_addDisplayHandler;
["MouseZChanged", {_this call FUNC(onMouseScroll)}] call CBA_fnc_addDisplayHandler;


#ifdef DRAW_THROW_PATH
GVAR(predictedPath) = [];
GVAR(flightPath) = [];

addMissionEventHandler ["Draw3D", { // Blue is predicted before throw, red is real
{
_x params ["", "_newTrajAGL"];
drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [0,0,1,1], _newTrajAGL, 1, 1, 0, "", 2];
} forEach GVAR(predictedPath);
{
_newTrajAGL = _x;
drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [1,0,0,1], _newTrajAGL, 1, 1, 0, "", 2];
} forEach GVAR(flightPath)
}];
#endif
7 changes: 7 additions & 0 deletions addons/advancedthrowing/XEH_preInit.sqf
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;
3 changes: 3 additions & 0 deletions addons/advancedthrowing/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"
19 changes: 19 additions & 0 deletions addons/advancedthrowing/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "script_component.hpp"

class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common", "ace_weaponselect"};
author = ECSTRING(common,ACETeam);
authors[] = {"Jonpas", "Dslyecxi", "Zapat"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};

#include "ACE_Settings.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
31 changes: 31 additions & 0 deletions addons/advancedthrowing/functions/fnc_canPrepare.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Author: Jonpas
* Checks if a throwable can be prepared.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Can Prepare <BOOL>
*
* Example:
* [unit] call ace_advancedthrowing_fnc_canPrepare
*
* Public: No
*/
#include "script_component.hpp"

params ["_unit"];

GVAR(enabled) &&

#ifndef DEBUG_MODE_FULL
{_unit getVariable [QGVAR(lastThrownTime), CBA_missionTime - 3] < CBA_missionTime - 2} && // Prevent throwing in quick succession
#else
{true} &&
#endif

{!(call EFUNC(common,isFeatureCameraActive))} &&
{!EGVAR(common,isReloading)} &&
{[_unit, objNull, ["isNotInside", "isNotSitting"/*, "isNotOnLadder"*/]] call EFUNC(common,canInteractWith)} && // Ladder needs positioning fixes on throw
{_unit call CBA_fnc_canUseWeapon} // Disable in non-FFV seats due to surface detection issues
31 changes: 31 additions & 0 deletions addons/advancedthrowing/functions/fnc_canThrow.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Author: Jonpas
* Checks if a throwable can be thrown.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Can Throw <BOOL>
*
* Example:
* [unit] call ace_advancedthrowing_fnc_canThrow
*
* Public: No
*/
#include "script_component.hpp"

params ["_unit"];

if !(_unit getVariable [QGVAR(inHand), false]) exitWith {false};

if (vehicle _unit != _unit) exitWith {
private _startPos = eyePos _unit;
private _aimLinePos = AGLToASL (positionCameraToWorld [0, 0, 1]);
private _intersections = lineIntersectsSurfaces [_startPos, _aimLinePos, _unit, objNull, false];
//TRACE_1("Intersections",_intersections);

(_intersections select {(vehicle _unit) in (_x select 3)}) isEqualTo []
};

true
Loading