-
Notifications
You must be signed in to change notification settings - Fork 752
Compat SPE - Fix dropped SPE CSWs not converting to ACE CSWs #11312
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
johnb432
wants to merge
3
commits into
master
Choose a base branch
from
compat-spe-handle-inventory-drop
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.
+106
−0
Open
Changes from all commits
Commits
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
50 changes: 50 additions & 0 deletions
50
addons/compat_spe/compat_spe_csw/functions/fnc_player_put_EH.sqf
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,50 @@ | ||
| #include "..\script_component.hpp" | ||
| /* | ||
| * Author: Kerc (SPE), original by www.3commandobrigade.com, edited by johnb43 to be made CSW compatible | ||
| * EH to allow a player to drop a tripod from the launcher slot, converting it into a weapon base. | ||
| * | ||
| * Arguments: | ||
| * 0: Unit <OBJECT> | ||
| * 1: Container <OBJECT> | ||
| * 2: Item <STRING> | ||
| * | ||
| * Return Value: | ||
| * None | ||
| * | ||
| * Example: | ||
| * [player, cursorObject, "SPE_MLE_27_31_Stand"] call SPE_Weapons_Static_fnc_player_put_EH | ||
| * | ||
| * Public: No | ||
| */ | ||
|
|
||
| params ["_unit", "_container", "_item"]; | ||
|
|
||
| if (!alive _unit) exitWith {}; | ||
|
|
||
| // Don't run when placing a tripod in a vehicle/box | ||
| if !(_container isKindOf "GroundWeaponHolder") exitWith {}; | ||
|
|
||
| private _weaponConfig = configFile >> "CfgWeapons" >> _item; | ||
|
|
||
| // isKindOf does not currently work for weapons | ||
| if (getNumber (_weaponConfig >> "SPE_isTripod") == 0) exitWith {}; | ||
|
|
||
| private _vectorDir = vectorDir _unit; | ||
|
|
||
| private _tripodClass = if (EGVAR(csw,defaultAssemblyMode)) then { | ||
| getText (_weaponConfig >> "ace_csw" >> "deploy") | ||
| } else { | ||
| // Note M6 is also considered a tripod as far as the next instruction is concerned | ||
| getText (_weaponConfig >> "SPE_Deployed_Tripod_Name") | ||
| }; | ||
|
|
||
| if (_tripodClass == "") exitWith {}; | ||
|
|
||
| // Remove tripod from container | ||
| _container addItemCargoGlobal [_item, -1]; | ||
|
|
||
| // Create a vehicle replacing the tripod | ||
| private _pos = (getPosATL _unit) vectorAdd (_vectorDir vectorMultiply 1.1); | ||
| private _weaponPlatform = createVehicle [_tripodClass, _pos, [], 0, "CAN_COLLIDE"]; | ||
|
|
||
| _weaponPlatform setVectorDirAndUp [_vectorDir, surfaceNormal _pos]; | ||
54 changes: 54 additions & 0 deletions
54
addons/compat_spe/compat_spe_csw/functions/fnc_player_take_EH.sqf
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,54 @@ | ||
| #include "..\script_component.hpp" | ||
| /* | ||
| * Author: Kerc (SPE), edited by johnb43 to be made CSW compatible | ||
| * EH Backup for when the Put EH does not run (Swapping items). | ||
| * | ||
| * Arguments: | ||
| * 0: Unit <OBJECT> | ||
| * 1: Container <OBJECT> | ||
| * 2: Item <STRING> | ||
| * | ||
| * Return Value: | ||
| * None | ||
| * | ||
| * Example: | ||
| * [player, cursorObject, "SPE_MLE_27_31_Stand"] call SPE_Weapons_Static_fnc_player_take_EH | ||
| * | ||
| * Public: No | ||
| */ | ||
|
|
||
| params ["_unit", "_container", "_item"]; | ||
|
|
||
| if (!alive _unit) exitWith {}; | ||
|
|
||
| // Don't run when placing a tripod in a vehicle/box | ||
| if !(_container isKindOf "GroundWeaponHolder") exitWith {}; | ||
|
|
||
| private _cfgWeapons = configFile >> "CfgWeapons"; | ||
| private _tripods = (weaponCargo _container) select {getNumber (_cfgWeapons >> _x >> "SPE_isTripod") == 1}; | ||
|
|
||
| if (_tripods isEqualTo []) exitWith {}; | ||
|
|
||
| private _vectorDir = vectorDir _unit; | ||
| private _pos = (getPosATL _unit) vectorAdd (_vectorDir vectorMultiply 1.1); | ||
|
|
||
| { | ||
| private _tripodClass = if (EGVAR(csw,defaultAssemblyMode)) then { | ||
| getText (_cfgWeapons >> _x >> "ace_csw" >> "deploy") | ||
| } else { | ||
| // Note M6 is also considered a tripod as far as the next instruction is concerned | ||
| getText (_cfgWeapons >> _x >> "SPE_Deployed_Tripod_Name") | ||
| }; | ||
|
|
||
| if (_tripodClass == "") then { | ||
| continue; | ||
| }; | ||
|
|
||
| // Remove tripod from container | ||
| _container addItemCargoGlobal [_x, -1]; | ||
|
|
||
| // Create a vehicle replacing the tripod | ||
| private _weaponPlatform = createVehicle [_tripodClass, _pos, [], 0, ["NONE", "CAN_COLLIDE"] select (_forEachIndex == 0)]; | ||
|
|
||
| _weaponPlatform setVectorDirAndUp [_vectorDir, surfaceNormal getPosWorld _weaponPlatform]; | ||
| } forEach _tripods; |
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.
I think it wants AGL (so
ASLtoAGL getPosASL _unit)?but I'm guessing this is part of the original func so it's probably best to leave it alone
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.
It is, but I've already extensively rewritten most of the function anyway, so I'll change it.