forked from acemod/ACE3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Towing - Fix some issues (acemod#9007)
Co-authored-by: johnb432 <[email protected]> Co-authored-by: LinkIsGrim <[email protected]>
- Loading branch information
1 parent
a3aef6a
commit b54992b
Showing
16 changed files
with
350 additions
and
197 deletions.
There are no files selected for viewing
This file contains 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 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 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,14 +1,40 @@ | ||
#include "script_component.hpp" | ||
["MouseButtonDown", LINKFUNC(onMouseButtonDown)] call CBA_fnc_addDisplayHandler; | ||
|
||
["MouseButtonUp", LINKFUNC(onMouseButtonUp)] call CBA_fnc_addDisplayHandler; | ||
GVAR(mouseLeft) = false; | ||
GVAR(mouseRight) = false; | ||
GVAR(blockFireEHID) = -1; | ||
|
||
GVAR(cancel) = false; | ||
GVAR(canAttach) = false; | ||
[QGVAR(ropeAttachTo), { | ||
params ["_child", "_relativeAttachPos", "_rope", "_helper"]; | ||
TRACE_4("ropeAttachTo",_child,_relativeAttachPos,_rope,_helper); | ||
_helper ropeDetach _rope; | ||
[_child, _relativeAttachPos] ropeAttachTo _rope; | ||
deleteVehicle _helper; | ||
}] call CBA_fnc_addEventHandler; | ||
|
||
[QGVAR(attachVehicles), LINKFUNC(attachVehicles)] call CBA_fnc_addEventHandler; | ||
[QGVAR(detachChild), LINKFUNC(detachChild)] call CBA_fnc_addEventHandler; | ||
|
||
[QGVAR(setTowParent), { | ||
params ["_parent", "_child"]; | ||
_child setTowParent _parent; | ||
if (!isServer) exitWith {}; | ||
|
||
[QGVAR(cleanupParent), { | ||
params ["_parent"]; | ||
TRACE_1("cleanupParent",_parent); | ||
_parent removeEventHandler ["RopeBreak", _parent getVariable [QGVAR(RopeBreakEHID), -1]]; | ||
_parent setVariable [QGVAR(RopeBreakEHID), -1]; | ||
private _parentParentHooks = _parent getVariable [QGVAR(parentHooks), []]; | ||
if (_parentParentHooks isEqualTo []) then { | ||
TRACE_1("remove Deleted EH",_parent); | ||
_parent removeEventHandler ["Deleted", _parent getVariable [QGVAR(DeletedEHID), -1]]; | ||
_parent setVariable [QGVAR(DeletedEHID), -1]; | ||
}; | ||
}] call CBA_fnc_addEventHandler; | ||
|
||
addMissionEventHandler ["PlayerConnected", { | ||
if (GVAR(allChildren) isEqualTo []) exitWith {}; | ||
params ["", "", "", "_jip", "_owner"]; | ||
if (!_jip) exitWith {}; | ||
TRACE_2("pushing children",_owner,GVAR(allChildren)); | ||
[QGVAR(setTowParentAllChildren), [GVAR(allChildren)], _owner] call CBA_fnc_ownerEvent; | ||
}]; |
This file contains 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 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 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,65 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: Dystopian | ||
* Attaches child to parent vehicle. | ||
* Run globally. | ||
* | ||
* Arguments: | ||
* 0: Vehicle to tow from <OBJECT> | ||
* 1: Vehicle to tow <OBJECT> | ||
* 2: Rope End Position <ARRAY> | ||
* 3: Rope <OBJECT> | ||
* 4: Attached Helper Object <OBJECT> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [parent, cursorObject, [0,0,0], ropes parent select 0] call ace_towing_fnc_attachVehicles | ||
* | ||
* Public: No | ||
*/ | ||
params ["_parent", "_child", "_relativeAttachPos", "_rope", "_helper"]; | ||
TRACE_5("attachVehicles",_parent,_child,_relativeAttachPos,_rope,_helper); | ||
|
||
if (local _parent) then { | ||
_helper ropeDetach _rope; | ||
[_child, _relativeAttachPos] ropeAttachTo _rope; | ||
deleteVehicle _helper; | ||
}; | ||
|
||
_child setTowParent _parent; | ||
if (!isServer) exitWith {}; | ||
|
||
_child setVariable [QGVAR(parent), _parent, true]; | ||
GVAR(allChildren) pushBack _child; | ||
|
||
{ | ||
if (-1 == _x getVariable [QGVAR(DeletedEHID), -1]) then { | ||
_x setVariable [QGVAR(DeletedEHID), _x addEventHandler ["Deleted", { | ||
params ["_entity"]; | ||
private _childHooks = _entity getVariable [QGVAR(childHooks), []]; | ||
private _parentHooks = _entity getVariable [QGVAR(parentHooks), []]; | ||
TRACE_3("Deleted EH",_entity,_childHooks,_parentHooks); | ||
{ | ||
[objNull, _x, _entity] call FUNC(detachRope); | ||
} forEach (_childHooks + _parentHooks); | ||
if (_childHooks isNotEqualTo []) then { // only for parent | ||
// because deleting lasts for several frames we have to delete RB EH to fix double cleanup | ||
_entity removeEventHandler ["RopeBreak", _entity getVariable QGVAR(RopeBreakEHID)]; | ||
}; | ||
}]]; | ||
}; | ||
} forEach [_parent, _child]; | ||
|
||
if (-1 == _parent getVariable [QGVAR(RopeBreakEHID), -1]) then { | ||
_parent setVariable [QGVAR(RopeBreakEHID), _parent addEventHandler ["RopeBreak", { | ||
params ["_parent", "_rope", "_child"]; | ||
if (isNull _rope) exitWith {}; // happens | ||
private _hook = _rope getVariable [QGVAR(hook), objNull]; | ||
private _hookChild = _hook getVariable [QGVAR(vars), []] param [1, objNull]; | ||
if (isNull _hook || {_child != _hookChild}) exitWith {}; // handle helper detach | ||
TRACE_4("RopeBreak EH",_parent,_rope,_child,_hook); | ||
[objNull, _hook] call FUNC(detachRope); | ||
}]]; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.