mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
parent
80d18c468e
commit
007859d42e
@ -8,3 +8,24 @@ class Extended_PostInit_EventHandlers {
|
|||||||
clientInit = QUOTE( call COMPILE_FILE(XEH_clientInit) );
|
clientInit = QUOTE( call COMPILE_FILE(XEH_clientInit) );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
class Extended_GetIn_EventHandlers {
|
||||||
|
class All {
|
||||||
|
class ADDON {
|
||||||
|
getIn = QUOTE(_this call FUNC(handleGetIn));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Extended_GetOut_EventHandlers {
|
||||||
|
class All {
|
||||||
|
class ADDON {
|
||||||
|
getOut = QUOTE(_this call FUNC(handleGetOut));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Extended_Killed_EventHandlers {
|
||||||
|
class All {
|
||||||
|
class ADDON {
|
||||||
|
killed = QUOTE(_this call FUNC(handleKilled));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
@ -7,6 +7,9 @@ PREP(canAttach);
|
|||||||
PREP(canDetach);
|
PREP(canDetach);
|
||||||
PREP(detach);
|
PREP(detach);
|
||||||
PREP(getChildrenAttachActions);
|
PREP(getChildrenAttachActions);
|
||||||
|
PREP(handleGetIn);
|
||||||
|
PREP(handleGetOut);
|
||||||
|
PREP(handleKilled);
|
||||||
PREP(placeApprove);
|
PREP(placeApprove);
|
||||||
|
|
||||||
ADDON = true;
|
ADDON = true;
|
||||||
|
@ -17,15 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_itemVehClass", "_onAtachText", "_selfAttachPosition", "_attachedItem", "_tempObject", "_actionID", "_model"];
|
params ["_attachToVehicle","_unit","_args", ["_silentScripted", false]];
|
||||||
params ["_attachToVehicle","_unit","_args"];
|
|
||||||
_args params [["_itemClassname","", [""]]];
|
_args params [["_itemClassname","", [""]]];
|
||||||
TRACE_3("params",_attachToVehicle,_unit,_itemClassname);
|
TRACE_4("params",_attachToVehicle,_unit,_itemClassname,_silentScripted);
|
||||||
|
|
||||||
|
private ["_itemVehClass", "_onAtachText", "_selfAttachPosition", "_attachedItem", "_tempObject", "_actionID", "_model"];
|
||||||
|
|
||||||
//Sanity Check (_unit has item in inventory, not over attach limit)
|
//Sanity Check (_unit has item in inventory, not over attach limit)
|
||||||
if ((_itemClassname == "") || {!(_this call FUNC(canAttach))}) exitWith {ERROR("Tried to attach, but check failed");};
|
if ((_itemClassname == "") || {(!_silentScripted) && {!(_this call FUNC(canAttach))}}) exitWith {ERROR("Tried to attach, but check failed");};
|
||||||
|
|
||||||
_selfAttachPosition = [_unit, [-0.05, 0, 0.12], "rightshoulder"];
|
|
||||||
|
|
||||||
_itemVehClass = getText (configFile >> "CfgWeapons" >> _itemClassname >> "ACE_Attachable");
|
_itemVehClass = getText (configFile >> "CfgWeapons" >> _itemClassname >> "ACE_Attachable");
|
||||||
_onAtachText = getText (configFile >> "CfgWeapons" >> _itemClassname >> "displayName");
|
_onAtachText = getText (configFile >> "CfgWeapons" >> _itemClassname >> "displayName");
|
||||||
@ -40,12 +39,13 @@ if (_itemVehClass == "") exitWith {ERROR("no ACE_Attachable for Item");};
|
|||||||
_onAtachText = format [localize LSTRING(Item_Attached), _onAtachText];
|
_onAtachText = format [localize LSTRING(Item_Attached), _onAtachText];
|
||||||
|
|
||||||
if (_unit == _attachToVehicle) then { //Self Attachment
|
if (_unit == _attachToVehicle) then { //Self Attachment
|
||||||
_unit removeItem _itemClassname; // Remove item
|
|
||||||
_attachedItem = _itemVehClass createVehicle [0,0,0];
|
_attachedItem = _itemVehClass createVehicle [0,0,0];
|
||||||
_attachedItem attachTo _selfAttachPosition;
|
_attachedItem attachTo [_unit, [-0.05, 0, 0.12], "rightshoulder"];
|
||||||
|
if (!_silentScripted) then {
|
||||||
|
_unit removeItem _itemClassname; // Remove item
|
||||||
[_onAtachText] call EFUNC(common,displayTextStructured);
|
[_onAtachText] call EFUNC(common,displayTextStructured);
|
||||||
_attachToVehicle setVariable [QGVAR(Objects), [_attachedItem], true];
|
};
|
||||||
_attachToVehicle setVariable [QGVAR(ItemNames), [_itemClassname], true];
|
_unit setVariable [QGVAR(attached), [[_attachedItem, _itemClassname]], true];
|
||||||
} else {
|
} else {
|
||||||
GVAR(placeAction) = PLACE_WAITING;
|
GVAR(placeAction) = PLACE_WAITING;
|
||||||
|
|
||||||
|
@ -17,14 +17,17 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_attachLimit", "_attachedObjects","_playerPos"];
|
|
||||||
params ["_attachToVehicle","_player","_args"];
|
params ["_attachToVehicle","_player","_args"];
|
||||||
_args params [["_itemClassname","", [""]]];
|
_args params [["_itemClassname","", [""]]];
|
||||||
TRACE_3("params",_attachToVehicle,_unit,_itemClassname);
|
TRACE_3("params",_attachToVehicle,_player,_itemClassname);
|
||||||
|
|
||||||
|
private ["_attachLimit", "_attachedObjects"];
|
||||||
|
|
||||||
_attachLimit = [6, 1] select (_player == _attachToVehicle);
|
_attachLimit = [6, 1] select (_player == _attachToVehicle);
|
||||||
_attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []];
|
_attachedObjects = _attachToVehicle getVariable [QGVAR(attached), []];
|
||||||
|
|
||||||
_playerPos = (ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot"));
|
((_player == _attachToVehicle) || {canStand _player}) &&
|
||||||
|
{(_attachToVehicle distance _player) < 7} &&
|
||||||
(canStand _player) && {(_attachToVehicle distance _player) < 7} && {alive _attachToVehicle} && {(count _attachedObjects) < _attachLimit} && {_itemClassname in ((itemsWithMagazines _player) + [""])};
|
{alive _attachToVehicle} &&
|
||||||
|
{(count _attachedObjects) < _attachLimit} &&
|
||||||
|
{_itemClassname in ((itemsWithMagazines _player) + [""])};
|
||||||
|
@ -16,25 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_attachedObjects", "_inRange"];
|
|
||||||
params ["_attachToVehicle", "_unit"];
|
params ["_attachToVehicle", "_unit"];
|
||||||
TRACE_2("params",_attachToVehicle,_unit);
|
TRACE_2("params",_attachToVehicle,_unit);
|
||||||
|
|
||||||
_attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []];
|
private ["_inRange"];
|
||||||
|
|
||||||
_inRange = false;
|
_inRange = false;
|
||||||
if (_unit == _attachToVehicle) then {
|
{
|
||||||
_inRange = count _attachedObjects > 0;
|
_x params ["_xObject"];
|
||||||
} else {
|
if (((getPos _unit) distance2d (getPos _xObject)) < 4) exitWith {_inRange = true};
|
||||||
//Scan if unit is within range (using 2d distance)
|
} forEach (_attachToVehicle getVariable [QGVAR(attached), []]);
|
||||||
private ["_unitPos", "_objectPos"];
|
|
||||||
_unitPos = getPos _unit;
|
|
||||||
_unitPos set [2,0];
|
|
||||||
{
|
|
||||||
_objectPos = getPos _x;
|
|
||||||
_objectPos set [2, 0];
|
|
||||||
if (_objectPos distance _unitPos < 4) exitWith {_inRange = true};
|
|
||||||
} forEach _attachedObjects;
|
|
||||||
};
|
|
||||||
|
|
||||||
canStand _unit && {_inRange} && {alive _attachToVehicle}
|
_inRange &&
|
||||||
|
{(_unit == _attachToVehicle) || {canStand _unit}} &&
|
||||||
|
{alive _attachToVehicle}
|
||||||
|
@ -16,15 +16,12 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_attachedObjects", "_attachedItems", "_itemDisplayName",
|
|
||||||
"_attachedObject", "_attachedIndex", "_itemName", "_minDistance",
|
|
||||||
"_unitPos", "_objectPos"
|
|
||||||
];
|
|
||||||
params ["_attachToVehicle","_unit"],
|
params ["_attachToVehicle","_unit"],
|
||||||
TRACE_2("params",_attachToVehicle,_unit);
|
TRACE_2("params",_attachToVehicle,_unit);
|
||||||
|
|
||||||
_attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []];
|
private ["_attachedList", "_itemDisplayName", "_attachedObject", "_attachedIndex", "_itemName", "_minDistance", "_unitPos", "_objectPos"];
|
||||||
_attachedItems = _attachToVehicle getVariable [QGVAR(ItemNames), []];
|
|
||||||
|
_attachedList = _attachToVehicle getVariable [QGVAR(attached), []];
|
||||||
|
|
||||||
_attachedObject = objNull;
|
_attachedObject = objNull;
|
||||||
_attachedIndex = -1;
|
_attachedIndex = -1;
|
||||||
@ -32,18 +29,17 @@ _itemName = "";
|
|||||||
|
|
||||||
//Find closest attached object
|
//Find closest attached object
|
||||||
_minDistance = 1000;
|
_minDistance = 1000;
|
||||||
_unitPos = getPos _unit;
|
|
||||||
_unitPos set [2,0];
|
|
||||||
{
|
{
|
||||||
_objectPos = getPos _x;
|
_x params ["_xObject", "_xItemName"];
|
||||||
_objectPos set [2, 0];
|
|
||||||
if (_objectPos distance _unitPos < _minDistance) then {
|
if (((getPos _unit) distance2d (getPos _xObject)) < _minDistance) then {
|
||||||
_minDistance = _objectPos distance _unitPos;
|
_minDistance = ((getPos _unit) distance2d (getPos _xObject));
|
||||||
_attachedObject = _x;
|
_attachedObject = _xObject;
|
||||||
_itemName = _attachedItems select _forEachIndex;
|
_itemName = _xItemName;
|
||||||
_attachedIndex = _forEachIndex;
|
_attachedIndex = _forEachIndex;
|
||||||
};
|
};
|
||||||
} forEach _attachedObjects;
|
} forEach _attachedList;
|
||||||
|
|
||||||
// Check if unit has an attached item
|
// Check if unit has an attached item
|
||||||
if (isNull _attachedObject || {_itemName == ""}) exitWith {ERROR("Could not find attached object")};
|
if (isNull _attachedObject || {_itemName == ""}) exitWith {ERROR("Could not find attached object")};
|
||||||
@ -68,10 +64,8 @@ if (toLower _itemName in ["b_ir_grenade", "o_ir_grenade", "i_ir_grenade"]) then
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Reset unit variables
|
// Reset unit variables
|
||||||
_attachedObjects deleteAt _attachedIndex;
|
_attachedList deleteAt _attachedIndex;
|
||||||
_attachedItems deleteAt _attachedIndex;
|
_attachToVehicle setVariable [QGVAR(attached), _attachedList, true];
|
||||||
_attachToVehicle setVariable [QGVAR(Objects), _attachedObjects, true];
|
|
||||||
_attachToVehicle setVariable [QGVAR(ItemNames), _attachedItems, true];
|
|
||||||
|
|
||||||
// Display message
|
// Display message
|
||||||
_itemDisplayName = getText (configFile >> "CfgWeapons" >> _itemName >> "displayName");
|
_itemDisplayName = getText (configFile >> "CfgWeapons" >> _itemName >> "displayName");
|
||||||
|
38
addons/attach/functions/fnc_handleGetIn.sqf
Normal file
38
addons/attach/functions/fnc_handleGetIn.sqf
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Author: PabstMirror
|
||||||
|
* Handles when a unit gets in to a vehicle.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: vehicle <OBJECT>
|
||||||
|
* 1: dunno <OBJECT>
|
||||||
|
* 2: unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [car2, x, player] call ACE_attach_fnc_handleGetIn
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
if (!isServer) exitWith {};
|
||||||
|
|
||||||
|
params ["", "", "_unit"];
|
||||||
|
TRACE_1("params",_unit);
|
||||||
|
|
||||||
|
private ["_attachedList"];
|
||||||
|
|
||||||
|
_attachedList = _unit getVariable [QGVAR(attached), []];
|
||||||
|
if ((count _attachedList) == 0) exitWith {};
|
||||||
|
|
||||||
|
(_attachedList select 0) params ["_xObject", "_xItemName"];
|
||||||
|
if (!isNull _xObject) then {
|
||||||
|
detach _xObject;
|
||||||
|
_xObject setPos ((getPos _unit) vectorAdd [0, 0, -1000]);
|
||||||
|
[{deleteVehicle (_this select 0)}, [_xObject], 2] call EFUNC(common,waitAndExecute);
|
||||||
|
(_attachedList select 0) set [0, objNull];
|
||||||
|
};
|
||||||
|
|
||||||
|
_unit setVariable [QGVAR(attached), _attachedList, true];
|
35
addons/attach/functions/fnc_handleGetOut.sqf
Normal file
35
addons/attach/functions/fnc_handleGetOut.sqf
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Author: PabstMirror
|
||||||
|
* Handles when a unit gets in to a vehicle.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: vehicle <OBJECT>
|
||||||
|
* 1: dunno <OBJECT>
|
||||||
|
* 2: unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [car2, x, player] call ACE_attach_fnc_handleGetOut
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
if (!isServer) exitWith {};
|
||||||
|
|
||||||
|
params ["", "", "_unit"];
|
||||||
|
TRACE_1("params",_unit);
|
||||||
|
|
||||||
|
private ["_attachedList"];
|
||||||
|
|
||||||
|
_attachedList = _unit getVariable [QGVAR(attached), []];
|
||||||
|
if ((count _attachedList) == 0) exitWith {};
|
||||||
|
|
||||||
|
(_attachedList select 0) params ["_xObject", "_xItemName"];
|
||||||
|
if (isNull _xObject) then {
|
||||||
|
TRACE_1("null attached when exiting vehicle, scripted reattach",_xItemName);
|
||||||
|
_unit setVariable [QGVAR(attached), [], true];
|
||||||
|
[_unit, _unit, _xItemName, true] call FUNC(attach);
|
||||||
|
};
|
33
addons/attach/functions/fnc_handleKilled.sqf
Normal file
33
addons/attach/functions/fnc_handleKilled.sqf
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Author: PabstMirror
|
||||||
|
* Handles when vehicle or man is killed.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: DeadVehicle <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [bob1] call ACE_attach_fnc_handleKilled
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
if (!isServer) exitWith {};
|
||||||
|
|
||||||
|
params ["_deadUnit"];
|
||||||
|
|
||||||
|
private ["_attachedList"];
|
||||||
|
|
||||||
|
_attachedList = _deadUnit getVariable [QGVAR(attached), []];
|
||||||
|
|
||||||
|
if ((count _attachedList) == 0) exitWith {};
|
||||||
|
|
||||||
|
{
|
||||||
|
_x params ["_xObject", "_xItemName"];
|
||||||
|
detach _xObject;
|
||||||
|
} forEach _attachedList;
|
||||||
|
|
||||||
|
_deadUnit setVariable [QGVAR(attached), nil, true];
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_startingOffset", "_startDistanceFromCenter", "_closeInUnitVector", "_closeInMax", "_closeInMin", "_closeInDistance", "_endPosTestOffset", "_endPosTest", "_doesIntersect", "_startingPosShifted", "_startASL", "_endPosShifted", "_endASL", "_attachedObject", "_currentObjects", "_currentItemNames"];
|
private ["_startingOffset", "_startDistanceFromCenter", "_closeInUnitVector", "_closeInMax", "_closeInMin", "_closeInDistance", "_endPosTestOffset", "_endPosTest", "_doesIntersect", "_startingPosShifted", "_startASL", "_endPosShifted", "_endASL", "_attachedObject", "_attachList"];
|
||||||
|
|
||||||
params ["_unit", "_attachToVehicle", "_itemClassname", "_itemVehClass", "_onAtachText", "_startingPosition"];
|
params ["_unit", "_attachToVehicle", "_itemClassname", "_itemVehClass", "_onAtachText", "_startingPosition"];
|
||||||
TRACE_6("params",_unit,_attachToVehicle,_itemClassname,_itemVehClass,_onAtachText,_startingPosition);
|
TRACE_6("params",_unit,_attachToVehicle,_itemClassname,_itemVehClass,_onAtachText,_startingPosition);
|
||||||
@ -87,12 +87,9 @@ _attachedObject attachTo [_attachToVehicle, _endPosTestOffset];
|
|||||||
//Remove Item from inventory
|
//Remove Item from inventory
|
||||||
_unit removeItem _itemClassname;
|
_unit removeItem _itemClassname;
|
||||||
|
|
||||||
//Add Object to ACE_AttachedObjects and ACE_AttachedItemNames
|
//Add Object to attached array
|
||||||
_currentObjects = _attachToVehicle getVariable [QGVAR(Objects), []];
|
_attachList = _attachToVehicle getVariable [QGVAR(attached), []];
|
||||||
_currentObjects pushBack _attachedObject;
|
_attachList pushBack [_attachedObject, _itemClassname];
|
||||||
_attachToVehicle setVariable [QGVAR(Objects), _currentObjects, true];
|
_attachToVehicle setVariable [QGVAR(attached), _attachList, true];
|
||||||
_currentItemNames = _attachToVehicle getVariable [QGVAR(ItemNames), []];
|
|
||||||
_currentItemNames pushBack _itemClassname;
|
|
||||||
_attachToVehicle setVariable [QGVAR(ItemNames), _currentItemNames, true];
|
|
||||||
|
|
||||||
[_onAtachText] call EFUNC(common,displayTextStructured);
|
[_onAtachText] call EFUNC(common,displayTextStructured);
|
||||||
|
Loading…
Reference in New Issue
Block a user