mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Condense AI func, and drop attachements
This commit is contained in:
parent
6e03bb6144
commit
0c88b92eba
@ -4,10 +4,8 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (isNil QGVAR(UpdateInventoryDisplay_EHID)) then {
|
||||
GVAR(UpdateInventoryDisplay_EHID) = ["inventoryDisplayLoaded",{
|
||||
_player = ACE_player;
|
||||
[_player] call FUNC(takeLoadedATWeapon);
|
||||
[_player, (_this select 0)] call FUNC(updateInventoryDisplay);
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
};
|
||||
["inventoryDisplayLoaded",{
|
||||
_player = ACE_player;
|
||||
[_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,36 +0,0 @@
|
||||
/*
|
||||
* Author: bux, commy2
|
||||
* Remove the ai's missle launcher tube after the missle has exploded
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Params [unit<OBJECT>, Tube<STRING>, Projectile<OBJECT>] <ARRAY>
|
||||
* 1: CBA PFH ID <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [[someAI, "emptyTube", theRocket], 55] call ace_disposable_fnc_aiDropWeaponCallback;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_params,_pfhId);
|
||||
EXPLODE_3_PVT(_params,_unit,_tube,_projectile);
|
||||
|
||||
if (!isNull _projectile) exitWith {};
|
||||
|
||||
//remove frameEH
|
||||
[_pfhId] 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 {
|
||||
private ["_logic"];
|
||||
_logic = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"];
|
||||
_logic addWeaponCargoGlobal [_tube, 1]; // @todo secondary weapon items
|
||||
_unit removeWeaponGlobal _tube;
|
||||
};
|
@ -21,28 +21,55 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_tube", "_projectile"];
|
||||
private ["_unit", "_weapon", "_projectile", "_replacementTube", "_items"];
|
||||
|
||||
_unit = _this select 0;
|
||||
if (!local _unit) exitWith {};
|
||||
|
||||
_tube = getText (configFile >> "CfgWeapons" >> (_this select 1) >> "ACE_UsedTube");
|
||||
if (_tube == "") exitWith {};
|
||||
|
||||
_weapon = _this select 1;
|
||||
_projectile = _this select 6;
|
||||
|
||||
private "_items";
|
||||
if (!local _unit) exitWith {};
|
||||
|
||||
_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];
|
||||
{
|
||||
if (_x != "") then {_container addItemCargoGlobal [_x, 1];};
|
||||
} forEach _items;
|
||||
_unit removeWeaponGlobal _tube;
|
||||
};
|
||||
}, 1, [_unit, _replacementTube, _projectile]] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
* 0: unit - Object the event handler is assigned to <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [fromTakeEH] call ace_disposable_fnc_takeLoadedATWeapon;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* 0: unit - Object the event handler is assigned to <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_disposable_fnc_updateInventoryDisplay;
|
||||
|
Loading…
Reference in New Issue
Block a user