mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #209 from KoffeinFlummi/disposableCleanup
Disposable cleanup
This commit is contained in:
commit
08eb40a606
@ -1,7 +1,7 @@
|
||||
ace_disposable
|
||||
==============
|
||||
|
||||
Makes the NLAW a disposable one-way weapon.
|
||||
Makes the NLAW a disposable one-shot weapon.
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
@ -4,10 +4,8 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (isNil QGVAR(UpdateInventoryDisplay_EHID)) then {
|
||||
GVAR(UpdateInventoryDisplay_EHID) = ["inventoryDisplayLoaded",{
|
||||
["inventoryDisplayLoaded",{
|
||||
_player = ACE_player;
|
||||
[_player, secondaryWeapon _player] call FUNC(takeLoadedATWeapon);
|
||||
[_player] call FUNC(takeLoadedATWeapon);
|
||||
[_player, (_this select 0)] call FUNC(updateInventoryDisplay);
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
};
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(aiDropWeaponCallback);
|
||||
PREP(replaceATWeapon);
|
||||
PREP(takeLoadedATWeapon);
|
||||
PREP(updateInventoryDisplay);
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Author: bux, commy2
|
||||
*
|
||||
* Remove the ai's missle launcher tube
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_tube", "_projectile", "_logic"];
|
||||
|
||||
_unit = (_this select 0) select 0;
|
||||
_tube = (_this select 0) select 1;
|
||||
_projectile = (_this select 0) select 2;
|
||||
|
||||
if (!isNull _projectile) exitWith {};
|
||||
|
||||
//remove frameEH
|
||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
||||
|
||||
if ([_unit] call EFUNC(common,isPlayer)) exitWith {}; //Just in case a player took control
|
||||
if (!alive _unit) exitWith {}; //No point doing this for dead
|
||||
|
||||
//If AI still has tube, throw it on ground
|
||||
if (secondaryWeapon _unit == _tube) then {
|
||||
_logic = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"];
|
||||
_logic addWeaponCargoGlobal [_tube, 1]; // @todo secondary weapon items
|
||||
|
||||
_unit removeWeaponGlobal _tube;
|
||||
};
|
@ -1,38 +1,79 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Author: bux, commy2
|
||||
* Replace the disposable launcher with the used dummy.
|
||||
*
|
||||
* Argument:
|
||||
* Input from "Fired" eventhandler
|
||||
* Arguments:
|
||||
* 0: unit - Object the event handler is assigned to <OBJECT>
|
||||
* 1: weapon - Fired weapon <STRING>
|
||||
* 2: muzzle - Muzzle that was used <STRING>
|
||||
* 3: mode - Current mode of the fired weapon <STRING>
|
||||
* 4: ammo - Ammo used <STRING>
|
||||
* 5: magazine - magazine name which was used <STRING>
|
||||
* 6: projectile - Object of the projectile that was shot <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [fromBisFiredEH] call ace_disposable_fnc_replaceATWeapon;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_tube", "_projectile"];
|
||||
private ["_unit", "_weapon", "_projectile", "_replacementTube", "_items"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_tube = getText (configFile >> "CfgWeapons" >> (_this select 1) >> "ACE_UsedTube");
|
||||
_weapon = _this select 1;
|
||||
_projectile = _this select 6;
|
||||
|
||||
if (!local _unit) exitWith {};
|
||||
if (_tube == "") exitWith {};
|
||||
|
||||
private "_items";
|
||||
_replacementTube = getText (configFile >> "CfgWeapons" >> _weapon >> "ACE_UsedTube");
|
||||
if (_replacementTube == "") exitWith {}; //If no replacement defined just exit
|
||||
if (_weapon != (secondaryWeapon _unit)) exitWith {}; //just to be sure
|
||||
|
||||
|
||||
//Save array of items attached to launcher
|
||||
_items = secondaryWeaponItems _unit;
|
||||
|
||||
_unit addWeapon _tube;
|
||||
_unit selectWeapon _tube;
|
||||
//Replace the orginal weapon with the 'usedTube' weapon
|
||||
_unit addWeapon _replacementTube;
|
||||
//Makes sure the used tube is still equiped
|
||||
_unit selectWeapon _replacementTube;
|
||||
//Re-add all attachments to the used tube
|
||||
{
|
||||
if (_x != "") then {_unit addSecondaryWeaponItem _x};
|
||||
} forEach _items;
|
||||
|
||||
// AI
|
||||
|
||||
// AI - Remove the ai's missle launcher tube after the missle has exploded
|
||||
if !([_unit] call EFUNC(common,isPlayer)) then {
|
||||
//waits until _projectile is null, so random 0-2 tickTime seconds after that
|
||||
[FUNC(aiDropWeaponCallback), 2, [_unit, _tube, _projectile]] call CBA_fnc_addPerFrameHandler;
|
||||
[{
|
||||
EXPLODE_2_PVT(_this,_params,_pfhId);
|
||||
EXPLODE_3_PVT(_params,_unit,_tube,_projectile);
|
||||
|
||||
//don't do anything until projectile is null (exploded/max range)
|
||||
if (isNull _projectile) then {
|
||||
//Remove PFEH:
|
||||
[_pfhId] call cba_fnc_removePerFrameHandler;
|
||||
|
||||
//If (tube is dropped) OR (is dead) OR (is player) just exit
|
||||
if (((secondaryWeapon _unit) != _tube) || {!alive _unit} || {([_unit] call EFUNC(common,isPlayer))}) exitWith {};
|
||||
|
||||
private ["_items", "_container"];
|
||||
|
||||
// _items = secondaryWeaponItems _unit;
|
||||
_container = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"];
|
||||
_container setPosAsl (getPosAsl _unit);
|
||||
_container addWeaponCargoGlobal [_tube, 1];
|
||||
|
||||
//This will duplicate attachements, because we will be adding a weapon that may already have attachments on it
|
||||
//We either need a way to add a clean weapon, or a way to add a fully configured weapon to a container:
|
||||
// {
|
||||
// if (_x != "") then {_container addItemCargoGlobal [_x, 1];};
|
||||
// } forEach _items;
|
||||
|
||||
_unit removeWeaponGlobal _tube;
|
||||
};
|
||||
}, 1, [_unit, _replacementTube, _projectile]] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
@ -1,24 +1,26 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Handle the take event. Add a dummy magazine if a disposable rocket launcher is taken.
|
||||
*
|
||||
* Argument:
|
||||
* Input from "Take" eventhandler
|
||||
* Arguments:
|
||||
* 0: unit - Object the event handler is assigned to <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [fromTakeEH] call ace_disposable_fnc_takeLoadedATWeapon;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_launcher", "_config"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_launcher = secondaryWeapon _unit;
|
||||
|
||||
PARAMS_1(_unit);
|
||||
if (!local _unit) exitWith {};
|
||||
|
||||
_launcher = secondaryWeapon _unit;
|
||||
_config = configFile >> "CfgWeapons" >> _launcher;
|
||||
|
||||
if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber (_config >> "ACE_isUsedLauncher") != 1} && {count secondaryWeaponMagazine _unit == 0}) then {
|
||||
|
@ -1,26 +1,28 @@
|
||||
/*
|
||||
* Author: bux, commy2
|
||||
*
|
||||
* Hide or show the secondary weapon magazine inventory slot to prevent unloading of dummy magazines.
|
||||
*
|
||||
* Argument:
|
||||
* 0: The player. (Object)
|
||||
* Arguments:
|
||||
* 0: unit - Object the event handler is assigned to <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_disposable_fnc_updateInventoryDisplay;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_player", "_display"];
|
||||
disableSerialization;
|
||||
|
||||
_player = _this select 0;
|
||||
PARAMS_1(_player);
|
||||
DEFAULT_PARAM(1,_display,(findDisplay 602));
|
||||
|
||||
_player removeMagazines "ACE_PreloadedMissileDummy";
|
||||
_player removeMagazines "ACE_FiredMissileDummy";
|
||||
|
||||
disableSerialization;
|
||||
_display = [_this, 1, (findDisplay 602)] call BIS_fnc_param;
|
||||
if (isNull _display) exitWith {};
|
||||
|
||||
private ["_launcher", "_control", "_config"];
|
||||
|
Loading…
Reference in New Issue
Block a user