-
Notifications
You must be signed in to change notification settings - Fork 749
Casings - Add support for dropped magazines (40mm shell casings) #9839
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
Open
PabstMirror
wants to merge
17
commits into
master
Choose a base branch
from
40mmBrass
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f776c1b
Casings - Add support for dropped magazines (40mm shells)
PabstMirror 4b30e09
Merge branch 'master' into 40mmBrass
PabstMirror 3f9da5f
Add `ace_common_fnc_addPlayerEH`
PabstMirror a735ec5
Merge branch 'master' into 40mmBrass
PabstMirror 6c98b98
fix merge
PabstMirror 1159637
Merge branch 'master' into 40mmBrass
PabstMirror 4f9eb50
Merge branch 'master' into 40mmBrass
PabstMirror 1ba4b9c
update to use `CBA_fnc_addBISPlayerEventHandler`
PabstMirror b678150
Merge remote-tracking branch 'origin/master' into 40mmBrass
LinkIsGrim bd91f5f
feat: add support for magazine proxies/dropped model
LinkIsGrim a729b37
Update addons/casings/functions/fnc_createCasing.sqf
LinkIsGrim 5661fd8
Merge remote-tracking branch 'origin' into 40mmBrass
LinkIsGrim fa967e7
fix: regex & undefined vars
LinkIsGrim 4f12946
fix: trace
LinkIsGrim f8f9f1c
fix: include/function header
LinkIsGrim 83c361c
Merge branch 'master' into 40mmBrass
PabstMirror f903812
Fix _unitPos
PabstMirror 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 hidden or 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 +1,3 @@ | ||
| PREP(createCasing); | ||
| PREP(createLitter); | ||
| PREP(createMagazine); |
This file contains hidden or 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 hidden or 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 hidden or 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,51 @@ | ||
| #include "..\script_component.hpp" | ||
| /* | ||
| * Author: esteldunedain / Cyruz / diwako | ||
| * Handles casing/dropped mag creation. | ||
| * | ||
| * Arguments: | ||
| * 0: Unit - Unit to create litter for <OBJECT> | ||
| * 1: Model - Path to litter model <STRING> | ||
| * 2: Force creation - Skip the distance + RNG check <BOOL> (default: false) | ||
| * | ||
| * Return Value: | ||
| * None | ||
| * | ||
| * Example: | ||
| * [player, "\a3\weapons_f\mag_univ.p3d"] call ace_casings_fnc_createLitter | ||
| * | ||
| * Public: No | ||
| */ | ||
|
|
||
| params ["_unit", "_modelPath", ["_force", false]]; | ||
|
|
||
| if (_modelPath == "") exitWith {}; | ||
|
|
||
| private _unitPos = getPosASL _unit; | ||
| // Distant shooters don't produce as many cases | ||
| if (!_force && {(AGLToASL positionCameraToWorld [0,0,0]) vectorDistance _unitPos > 100 && {random 1 < 0.9}}) exitWith {}; | ||
|
|
||
| private _weapDir = _unit weaponDirection currentWeapon _unit; | ||
| private _ejectDir = _weapDir vectorCrossProduct [0, 0, 1]; | ||
| private _pos = _unitPos | ||
| vectorAdd (_weapDir vectorMultiply (-0.5 + random 2)) | ||
| vectorAdd (_ejectDir vectorMultiply (0.2 + random 2)); | ||
|
|
||
| [ | ||
| { | ||
| params ["_modelPath", "_pos"]; | ||
| TRACE_2("creating litter",_modelPath,_pos); | ||
|
|
||
| private _lisPos = (lineIntersectsSurfaces [_pos, _pos vectorAdd [0,0,-1e11], objNull, objNull, true, 1, "ROADWAY", "FIRE"]) #0; | ||
| private _casing = createSimpleObject [_modelPath, (_lisPos #0 vectorAdd [0,0,0.010]), false]; // global | ||
| _casing setDir (random 360); | ||
| _casing setVectorUp _lisPos #1; | ||
| private _idx = GVAR(casings) pushBack _casing; | ||
|
|
||
| for "_" from 0 to (_idx - GVAR(maxCasings)) do { | ||
| deleteVehicle (GVAR(casings) deleteAt 0); | ||
| }; | ||
| }, | ||
| [_modelPath,_pos], | ||
| 0.4 | ||
| ] call CBA_fnc_waitAndExecute; |
This file contains hidden or 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,51 @@ | ||
| #include "..\script_component.hpp" | ||
| /* | ||
| * Author: GabrielPearce / esteldunedain / Cyruz / diwako / PabstMirror | ||
| * Produces a casing matching the reloaded and dropped magazine | ||
| * | ||
| * Arguments: | ||
| * 0: unit - Object the reloaded event handler is assigned to <OBJECT> | ||
| * 4: Old magazine (can be nil) - <ARRAY> | ||
| * | ||
| * Return Value: | ||
| * None | ||
| * | ||
| * Example: | ||
| * [player, "", "","", ["1Rnd_HE_Grenade_shell", 0]] call ace_casings_fnc_createMagazine | ||
| * | ||
| * Public: No | ||
| */ | ||
|
|
||
| params ["_unit", "", "", "", "_oldMagazine"]; | ||
| TRACE_2("createMagazine",_unit,_oldMagazine); | ||
|
|
||
| if (isNil "_oldMagazine") exitWith {}; | ||
| _oldMagazine params ["_mag", "_ammo"]; | ||
| if (_ammo != 0) exitWith {}; | ||
|
|
||
| private _modelPath = GVAR(cachedMagazines) getOrDefaultCall [_mag, { | ||
| private _magConfig = configNull; // private var in switch condition scope isn't available in the result block. | ||
| private _modelOverride = ""; // very annoying. | ||
|
|
||
| private _model = switch true do { | ||
| // Should cover most 40x36 | ||
| case (_mag in compatibleMagazines ["arifle_Mk20_GL_F", "EGLM"]): { "A3\Weapons_F\MagazineProxies\mag_40x36_HE_1rnd.p3d" }; | ||
|
|
||
| _magConfig = configFile >> "CfgMagazines" >> _mag; | ||
| _modelOverride = getText (_magConfig >> QGVAR(model)); | ||
|
|
||
| case (_modelOverride != ""): { _modelOverride }; // Use the override if non-empty | ||
| case (getNumber (_magConfig >> "modelSpecialIsProxy") == 1): {getText (_magConfig >> "modelSpecial")}; // Use the magazine's proxy | ||
|
|
||
| default { getText (_magConfig >> "model") }; // Use the magazine's dropped model | ||
| }; | ||
|
|
||
| // Add file extension if missing (fileExists needs file extension) | ||
| if ((_model select [count _model - 4]) != ".p3d") then { | ||
| _model = _model + ".p3d"; | ||
| }; | ||
|
|
||
| ["", _model] select (!(_model regexMatch "(?:\\)?a3\\weapons_f\\(?:empty|ammo\\mag_univ).p3d") && {fileExists _model}) | ||
| }, true]; | ||
|
|
||
| [_unit, _modelPath, true] call FUNC(createLitter); |
This file contains hidden or 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 hidden or 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,42 @@ | ||
| --- | ||
| layout: wiki | ||
| title: Casings Framework | ||
| description: Explains how to set-up dropped magazine models with ACE3 casings system. | ||
| group: framework | ||
| order: 5 | ||
| parent: wiki | ||
| mod: ace | ||
| version: | ||
| major: 3 | ||
| minor: 0 | ||
| patch: 0 | ||
| --- | ||
|
|
||
| ## 1. Config Values | ||
|
|
||
| ```cpp | ||
| class CfgAmmo { // In order of priority | ||
| class MyAmmo { | ||
| cartridge = "CartridgeClassnameInCfgVehicles"; // if empty (""), no casing will be created | ||
| ace_casings_model = "path\to\casing\model.p3d"; // Dropped casing will have this model if not an empty string | ||
| }; | ||
| }; | ||
|
|
||
| class CfgVehicles { | ||
| class MyCartridge { | ||
| model = "path\to\cartridge\model.p3d"; // If empty string or model, no casing will be created | ||
| }; | ||
| }; | ||
|
|
||
| class CfgMagazines { | ||
| class MyMagazine { // In order of priority | ||
| // If magazine is compatible with vanilla Mk20's EGLM, model will always be "A3\Weapons_F\MagazineProxies\mag_40x36_HE_1rnd.p3d" | ||
| ace_casings_model = "path\to\magazine\model.p3d"; //Dropped magazine will have this model if not an empty string | ||
| modelSpecialIsProxy = 1; | ||
| modelSpecial = "path\to\magazine\proxy\model.p3d"; // Proxy model | ||
| model = "path\to\magazine\dropped\model.p3d"; // Dropped model | ||
|
|
||
| // If model doesn't exist, is the default dropped magazine model (pouch), or is empty, no dropped magazine will be created. | ||
| }; | ||
| }; | ||
| ``` |
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.
Uh oh!
There was an error while loading. Please reload this page.