-
Notifications
You must be signed in to change notification settings - Fork 149
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 disposable launcher framework #1116
Merged
Merged
Changes from 23 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
b665fb3
add disposable launcher framework
commy2 e32c51e
fix and simplify launcher dummy magazine
commy2 126be1a
rename 2doptics to optics
commy2 f162b2c
rename 2doptics to optics
commy2 215f1d4
Merge branch 'rename-optics' into disposable
commy2 eec0682
add disposable component
commy2 f2b89fb
manual merge
commy2 ad59ccb
Merge branch 'master' of https://github.com/CBATeam/CBA_A3 into dispo…
commy2 f6ba624
disposable arsenal handling
commy2 09fee91
fix a bug
commy2 a0144e2
replace with used launcher script
commy2 1971152
auto drop launcher
commy2 38c4958
disable secondary weapon magazine slot for disposable launchers
commy2 3746349
disable secondary weapon magazine slot for disposable launchers
commy2 6651dbc
fix a thing, delete unused
commy2 eeaf031
fix addWeapon leeching magazines
commy2 6cd1016
simplify setUnitLoadout
commy2 c41f1a2
cba_optics_fnc_addWeapon
commy2 a5fabe4
cba_optics_fnc_addWeapon
commy2 32d6488
optimize and keep weapon mode when toggling to pip / normal weapon wi…
commy2 eec31df
Merge branch 'master' of https://github.com/CBATeam/CBA_A3 into dispo…
commy2 3931762
report mags of all muzzles
commy2 b83a61d
replace loaded launcher mags with loaded launchers
commy2 0db4829
add shared function CBA_fnc_addWeaponWithoutMagazines
commy2 0496b48
add shared function CBA_fnc_addWeaponWithoutItems
commy2 e4cdd72
add launcher mags and attachments to dropped container
commy2 c8e45f1
handle prequipped backpacks
commy2 ca99085
handle prequipped backpacks stored themselves in cargo
commy2 72d6838
handle prequipped backpacks stored themselves in cargo
commy2 6074858
drop used launcher setting
commy2 e5a51e5
handle Arsenal
commy2 2d012f7
fix a problem with backpacks
commy2 2b9454f
manual merge
commy2 e5bc3ce
support for vehicle optics
commy2 98c1a12
global to disable mag replacement
commy2 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 @@ | ||
x\cba\addons\disposable |
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 @@ | ||
class CBA_DisposableLaunchers {}; |
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_DisplayLoad_EventHandlers { | ||
class RscDisplayInventory { | ||
ADDON = QUOTE(_this call (uiNamespace getVariable 'FUNC(initDisplayInventory)')); | ||
}; | ||
}; |
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 @@ | ||
class CfgFunctions { | ||
class CBA { | ||
class Weapons { | ||
PATHTO_FNC(firedDisposable); | ||
}; | ||
}; | ||
}; |
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 @@ | ||
class CfgMagazines { | ||
class CA_LauncherMagazine; | ||
class CBA_FakeLauncherMagazine: CA_LauncherMagazine { | ||
scope = 1; | ||
ammo = "RocketBase"; | ||
count = 0; | ||
allowedSlots[] = {}; | ||
}; | ||
}; |
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 @@ | ||
PREP(replaceMagazineCargo); |
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,58 @@ | ||
#include "script_component.hpp" | ||
|
||
ADDON = false; | ||
|
||
if (configProperties [configFile >> "CBA_DisposableLaunchers"] isEqualTo []) exitWith {}; | ||
|
||
#include "XEH_PREP.sqf" | ||
|
||
private _fnc_update = { | ||
params ["_unit"]; | ||
if (!local _unit) exitWith {}; | ||
(GVAR(NormalLaunchers) getVariable secondaryWeapon _unit) params ["_launcher", "_magazine"]; | ||
|
||
if (!isNil "_launcher") then { | ||
private _launcherItems = secondaryWeaponItems _unit; | ||
|
||
_unit addWeapon _launcher; | ||
{ | ||
_unit addSecondaryWeaponItem _x; | ||
} forEach _launcherItems; | ||
|
||
_unit addWeaponItem [_launcher, _magazine]; | ||
}; | ||
}; | ||
|
||
["loadout", _fnc_update] call CBA_fnc_addPlayerEventHandler; | ||
["CAManBase", "InitPost", _fnc_update] call CBA_fnc_addClassEventHandler; | ||
["CAManBase", "Take", _fnc_update] call CBA_fnc_addClassEventHandler; | ||
|
||
GVAR(NormalLaunchers) = [] call CBA_fnc_createNamespace; | ||
GVAR(LoadedLaunchers) = [] call CBA_fnc_createNamespace; | ||
GVAR(UsedLaunchers) = [] call CBA_fnc_createNamespace; | ||
GVAR(magazines) = []; | ||
GVAR(MagazineLaunchers) = [] call CBA_fnc_createNamespace; | ||
|
||
private _cfgWeapons = configFile >> "CfgWeapons"; | ||
private _cfgMagazines = configFile >> "CfgMagazines"; | ||
|
||
{ | ||
private _launcher = configName _x; | ||
private _magazine = configName (_cfgMagazines >> (getArray (_cfgWeapons >> _launcher >> "magazines") select 0)); | ||
getArray _x params ["_loadedLauncher", "_usedLauncher"]; | ||
|
||
GVAR(LoadedLaunchers) setVariable [_launcher, _loadedLauncher]; | ||
GVAR(UsedLaunchers) setVariable [_launcher, _usedLauncher]; | ||
|
||
if (isNil {GVAR(NormalLaunchers) getVariable _loadedLauncher}) then { | ||
GVAR(NormalLaunchers) setVariable [_loadedLauncher, [_launcher, _magazine]]; | ||
}; | ||
|
||
if (GVAR(magazines) pushBackUnique _magazine != -1) then { | ||
GVAR(MagazineLaunchers) setVariable [_magazine, _loadedLauncher]; | ||
}; | ||
} forEach configProperties [configFile >> "CBA_DisposableLaunchers", "isArray _x"]; | ||
|
||
["All", "InitPost", FUNC(replaceMagazineCargo)] call CBA_fnc_addClassEventHandler; | ||
|
||
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,9 @@ | ||
#include "script_component.hpp" | ||
|
||
if (configProperties [configFile >> "CBA_DisposableLaunchers"] isEqualTo []) exitWith {}; | ||
|
||
#include "XEH_PREP.sqf" | ||
|
||
if (!hasInterface) exitWith {}; | ||
|
||
PREP(initDisplayInventory); |
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,20 @@ | ||
#include "script_component.hpp" | ||
|
||
class CfgPatches { | ||
class ADDON { | ||
author = "$STR_CBA_Author"; | ||
name = CSTRING(component); | ||
url = "$STR_CBA_URL"; | ||
units[] = {}; | ||
weapons[] = {}; | ||
requiredVersion = REQUIRED_VERSION; | ||
requiredAddons[] = {"cba_common","cba_events"}; | ||
version = VERSION; | ||
authors[] = {"commy2"}; | ||
}; | ||
}; | ||
|
||
#include "CfgEventHandlers.hpp" | ||
#include "CfgFunctions.hpp" | ||
#include "CfgDisposableLaunchers.hpp" | ||
#include "CfgMagazines.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,101 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_firedDisposable | ||
|
||
Description: | ||
Handles firing a disposable weapon. | ||
|
||
Parameters: | ||
_unit - Unit that fired the disposable weapon <OBEJCT> | ||
_launcher - Disposable weapon <STRING> | ||
_muzzle - Muzzle fired by the disposable weapon <STRING> | ||
_mode - Current weapon mode of the disposable weapon <STRING> | ||
_ammo - Ammo fired by the disposable weapon <STRING> | ||
_magazine - Current magazine of the disposable weapon <STRING> | ||
_projectile - Fired projectile <OBEJCT> | ||
_unit - Always same as element 0 <OBEJCT> | ||
|
||
Returns: | ||
Nothing. | ||
|
||
Examples: | ||
(begin example) | ||
class EventHandlers { | ||
fired = "_this call CBA_fnc_firedDisposable"; | ||
}; | ||
(end) | ||
|
||
Author: | ||
commy2 | ||
---------------------------------------------------------------------------- */ | ||
|
||
params ["_unit", "_launcher", "_muzzle", "", "", "", "_projectile"]; | ||
|
||
private _usedLauncher = GVAR(UsedLaunchers) getVariable _launcher; | ||
if (isNil "_usedLauncher") exitWith {}; | ||
|
||
[{ | ||
params ["_unit", "_launcher", "_usedLauncher", "_projectile"]; | ||
|
||
// switch to used tube | ||
if (local _unit) then { | ||
private _isSelected = currentWeapon _unit == _launcher; | ||
|
||
private _launcherItems = secondaryWeaponItems _unit; | ||
private _launcherMagazines = WEAPON_MAGAZINES(_unit,secondaryWeapon _unit); | ||
|
||
_unit addWeapon _usedLauncher; | ||
{ | ||
_unit addSecondaryWeaponItem _x; | ||
} forEach _launcherItems; | ||
|
||
{ | ||
_unit addWeaponItem [_usedLauncher, _x]; | ||
} forEach _launcherMagazines; | ||
|
||
if (_isSelected) then { | ||
_unit selectWeapon _usedLauncher; | ||
}; | ||
}; | ||
|
||
// automatically drop | ||
[{ | ||
params ["_unit", "_usedLauncher", "_projectile"]; | ||
|
||
// quit if dead or weapon is gone | ||
if (!alive _unit || secondaryWeapon _unit != _usedLauncher) exitWith {true}; | ||
|
||
if (local _unit && { | ||
if (_unit == call CBA_fnc_currentUnit) then { | ||
cameraView != "GUNNER" | ||
} else { | ||
isNull _projectile | ||
}; | ||
}) exitWith { | ||
_unit removeWeapon _usedLauncher; | ||
|
||
private _dir = getDir _unit - 180; | ||
|
||
private _container = createVehicle ["WeaponHolderSimulated", [0,0,0], [], 0, "CAN_COLLIDE"]; | ||
_container addWeaponCargoGlobal [_usedLauncher, 1]; | ||
|
||
_container setDir (_dir + 90); | ||
_container setPosASL AGLToASL (_unit modelToWorld (_unit selectionPosition "rightshoulder" vectorAdd [0, 0.2, 0.1])); | ||
_container setVelocity (velocity _unit vectorAdd ([sin _dir, cos _dir, 0] vectorMultiply 1.5)); | ||
|
||
/* | ||
addWeaponWithAttachmentsCargoGlobal [ | ||
_usedLauncher, | ||
_silencer, _pointer, _optic, _bipod, [ | ||
_magazine1, _ammo1, | ||
_magazine2, _ammo2 | ||
], | ||
1]; | ||
*/ | ||
|
||
true // quit | ||
}; | ||
|
||
false // continue | ||
}, {}, [_unit, _usedLauncher, _projectile]] call CBA_fnc_waitUntilAndExecute; | ||
}, [_unit, _launcher, _usedLauncher, _projectile], 1] call CBA_fnc_waitAndExecute; |
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,14 @@ | ||
#include "script_component.hpp" | ||
|
||
params ["_display"]; | ||
|
||
private _fnc_update = { | ||
params ["_display"]; | ||
private _control = _display displayCtrl IDC_FG_SW_MAGAZINE; | ||
|
||
private _unit = call CBA_fnc_currentUnit; | ||
_control ctrlEnable isNil {GVAR(LoadedLaunchers) getVariable secondaryWeapon _unit}; | ||
}; | ||
|
||
_display displayAddEventHandler ["MouseMoving", _fnc_update]; | ||
_display displayAddEventHandler ["MouseHolding", _fnc_update]; |
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,39 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Internal Function: cba_disposable_fnc_replaceMagazineCargo | ||
|
||
Description: | ||
Replaces disposable launcher magazines with loaded disposable launchers. | ||
|
||
Parameters: | ||
_box - Any object with cargo <OBJECT> | ||
|
||
Returns: | ||
Nothing. | ||
|
||
Examples: | ||
(begin example) | ||
_box call cba_disposable_fnc_replaceMagazineCargo | ||
(end) | ||
|
||
Author: | ||
commy2 | ||
---------------------------------------------------------------------------- */ | ||
|
||
params ["_box"]; | ||
if (!local _box) exitWith {}; | ||
|
||
if (magazineCargo _box arrayIntersect GVAR(magazines) isEqualTo []) exitWith {}; | ||
|
||
private _magazines = magazinesAmmoCargo _box; | ||
clearMagazineCargoGlobal _box; | ||
|
||
{ | ||
_x params ["_magazine", "_ammo"]; | ||
|
||
if (_magazine in GVAR(magazines)) then { | ||
_box addWeaponCargoGlobal [GVAR(MagazineLaunchers) getVariable _magazine, 1]; | ||
} else { | ||
_box addMagazineAmmoCargo [_magazine, 1, _ammo]; | ||
}; | ||
} forEach _magazines; |
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 disposable | ||
#include "\x\cba\addons\main\script_mod.hpp" | ||
|
||
//#define DEBUG_MODE_FULL | ||
//#define DISABLE_COMPILE_CACHE | ||
//#define DEBUG_ENABLED_DISPOSABLE | ||
|
||
#ifdef DEBUG_ENABLED_DISPOSABLE | ||
#define DEBUG_MODE_FULL | ||
#endif | ||
|
||
#ifdef DEBUG_SETTINGS_DISPOSABLE | ||
#define DEBUG_SETTINGS DEBUG_SETTINGS_DISPOSABLE | ||
#endif | ||
|
||
#define DEBUG_MODE_NORMAL | ||
#define DEBUG_SYNCHRONOUS | ||
#include "\x\cba\addons\main\script_macros.hpp" | ||
|
||
#include "\a3\ui_f\hpp\defineResincl.inc" | ||
|
||
#define WEAPON_MAGAZINES(unit,weapon) (weaponsItems (unit) select {_x select 0 == (weapon)} param [0, []] select {_x isEqualType []}) |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project name="CBA_A3"> | ||
<Package name="Disposable"> | ||
<Key ID="STR_CBA_Disposable_Component"> | ||
<English>Community Base Addons - Disposable Weapons</English> | ||
<German>Community Base Addons - Einwegwaffen</German> | ||
</Key> | ||
</Package> | ||
</Project> |
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
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
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
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
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
#include "script_component.hpp" | ||
|
||
if (configProperties [configFile >> "CBA_PIPItems"] isEqualTo [] && { | ||
configProperties [configFile >> "CBA_CarryHandleTypes"] isEqualTo [] | ||
}) exitWith {}; | ||
|
||
#include "XEH_PREP.sqf" | ||
|
||
if (!hasInterface) exitWith {}; | ||
|
||
// Do not move this below these checks, or this missing function can be exploited. | ||
commy2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
PREP(initDisplayInterrupt); | ||
|
||
if (configProperties [configFile >> "CBA_PIPItems"] isEqualTo []) exitWith {}; | ||
if (configProperties [configFile >> "CBA_CarryHandleTypes"] isEqualTo []) exitWith {}; | ||
|
||
#include "XEH_PREP.sqf" |
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
Oops, something went wrong.
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.
can be done in a later release, but we should add some way of handling spotting rounds (LAW 80)
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.
Yeah, this is why I don't like dropping the launcher. It needs
addWeaponWithAttachmentsCargoGlobal
to work.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.
maybe
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.
DropWeapon is broken. Always has been always will be.
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.
addWeaponWithAttachmentsCargo
will be fully implemented in 1.96 (contact DLC is 1.94)