-
Notifications
You must be signed in to change notification settings - Fork 749
Towing - Fix some issues #9007
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
Towing - Fix some issues #9007
Changes from 18 commits
0394bcf
436ed12
784355c
d5e3198
4310dfa
4381198
3e9b821
9dc8ded
c118b01
54d842f
0565947
ddf8b56
9f5ed64
42c0cd4
81eb091
9feaa72
7423ce0
ec35e15
323dd43
ae0616f
f993822
597b772
ec04b3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,39 @@ | ||
| #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(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; | ||
|
|
||
| if (!isServer) exitWith {}; | ||
|
|
||
| [QGVAR(setTowParent), { | ||
| params ["_parent", "_child"]; | ||
| _child setTowParent _parent; | ||
| [QGVAR(cleanupParent), { | ||
| params ["_parent"]; | ||
| TRACE_1("cleanupParent",_parent); | ||
| _parent removeEventHandler ["RopeBreak", _parent getVariable QGVAR(RopeBreakEHID)]; | ||
| _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)]; | ||
| _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; | ||
| }]; | ||
|
johnb432 marked this conversation as resolved.
|
||
| 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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be much better if the fnc did the 'Run globally' parts for themselves automatically.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't get you. Do you mean I should replace one global event and one function with 3 events and its own functions (1 for parent owner, 1 global
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean the script is changed to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still can't understand how it could be better to move script executing to server and split 1 global event to 3 events (1 of those is global anyway) and functions. In any case we have to 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.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.