mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fixed locality issues, moved rope creation and simulation to server
Fix rope cut while fastroping Locality fix pt2 - serverside ropes
This commit is contained in:
parent
8f49715ae6
commit
c1ea6fd327
@ -3,3 +3,9 @@ class Extended_PreInit_EventHandlers {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_PostInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_postInit));
|
||||
};
|
||||
};
|
||||
|
@ -68,7 +68,7 @@ class CfgVehicles {
|
||||
class ACE_deployRopes {
|
||||
displayName = CSTRING(Interaction_deployRopes);
|
||||
condition = [_player, vehicle _player] call FUNC(canDeployRopes);
|
||||
statement = [vehicle _player] call FUNC(deployRopes);
|
||||
statement = [QGVAR(deployRopes), [vehicle _player]] call EFUNC(common,serverEvent);
|
||||
showDisabled = 0;
|
||||
priority = 1;
|
||||
};
|
||||
|
14
addons/fastroping/XEH_postInit.sqf
Normal file
14
addons/fastroping/XEH_postInit.sqf
Normal file
@ -0,0 +1,14 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
[QGVAR(deployRopes), {
|
||||
_this call FUNC(deployRopes);
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
||||
[QGVAR(startFastRope), {
|
||||
[FUNC(fastRopeServerPFH), 0, _this] call CBA_fnc_addPerFrameHandler;
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
||||
[QGVAR(ropeDetach), {
|
||||
params ["_object", "_rope"];
|
||||
_object ropeDetach _rope;
|
||||
}] call EFUNC(common,addEventHandler);
|
@ -9,7 +9,8 @@ PREP(canPrepareFRIES);
|
||||
PREP(cutRopes);
|
||||
PREP(deployRopes);
|
||||
PREP(fastRope);
|
||||
PREP(fastRopePFH);
|
||||
PREP(fastRopeLocalPFH);
|
||||
PREP(fastRopeServerPFH);
|
||||
PREP(moduleEquipFRIES);
|
||||
PREP(onCutCommon);
|
||||
PREP(onPrepareCommon);
|
||||
|
@ -20,10 +20,20 @@ private ["_deployedRopes", "_config", "_waitTime"];
|
||||
|
||||
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
|
||||
{
|
||||
_x params ["", "_ropeTop", "_ropeBottom", "_dummy", "_anchor", "_hook"];
|
||||
_x params ["", "_ropeTop", "_ropeBottom", "_dummy", "_anchor", "_hook", "_occupied"];
|
||||
|
||||
deleteVehicle _ropeTop;
|
||||
[{{deleteVehicle _x} count _this}, [_dummy, _anchor, _ropeBottom, _hook], 60] call EFUNC(common,waitAndExecute);
|
||||
//Make player fall if rope is occupied
|
||||
if (_occupied) then {
|
||||
private _attachedObjects = attachedObjects _dummy;
|
||||
//Rope is considered occupied when it's broken as well, so check if array is empty
|
||||
//Note: ropes are not considered attached objects by Arma
|
||||
if !(_attachedObjects isEqualTo []) then {
|
||||
detach ((attachedObjects _dummy) select 0);
|
||||
};
|
||||
};
|
||||
|
||||
[QGVAR(ropeDetach), [_hook, _ropeTop]] call EFUNC(common,serverEvent);
|
||||
[{{deleteVehicle _x} count _this}, [_ropeTop, _ropeBottom, _dummy, _anchor, _hook], 60] call EFUNC(common,waitAndExecute);
|
||||
} count _deployedRopes;
|
||||
|
||||
_vehicle setVariable [QGVAR(deployedRopes), [], true];
|
||||
|
@ -25,35 +25,33 @@ _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
|
||||
_hookAttachment = _vehicle getVariable [QGVAR(FRIES), _vehicle];
|
||||
{
|
||||
_ropeOrigin = _x;
|
||||
if ({(_x select 0) isEqualTo _ropeOrigin} count _deployedRopes == 0) then {
|
||||
_hook = QGVAR(helper) createVehicle [0, 0, 0];
|
||||
_hook allowDamage false;
|
||||
if (typeName _ropeOrigin == "ARRAY") then {
|
||||
_hook attachTo [_hookAttachment, _ropeOrigin];
|
||||
} else {
|
||||
_hook attachTo [_hookAttachment, [0, 0, 0], _ropeOrigin];
|
||||
};
|
||||
|
||||
_origin = getPosASL _hook;
|
||||
|
||||
_dummy = QGVAR(helper) createVehicle [0, 0, 0];
|
||||
_dummy allowDamage false;
|
||||
_dummy setPosASL (_origin vectorAdd [0, 0, -1]);
|
||||
|
||||
_anchor = QGVAR(helper) createVehicle [0, 0, 0];
|
||||
_anchor allowDamage false;
|
||||
_anchor setPosASL (_origin vectorAdd [0, 0, -2.5]);
|
||||
|
||||
_ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 1];
|
||||
_ropeBottom = ropeCreate [_dummy, [0, 0, 0], _anchor, [0, 0, 0], 34];
|
||||
|
||||
_ropeTop addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}];
|
||||
_ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}];
|
||||
|
||||
//deployedRopes format: attachment point, top part of the rope, bottom part of the rope, attachTo helper object, anchor helper object, occupied
|
||||
_deployedRopes pushBack [_ropeOrigin, _ropeTop, _ropeBottom, _dummy, _anchor, _hook, false];
|
||||
_hook = QGVAR(helper) createVehicle [0, 0, 0];
|
||||
_hook allowDamage false;
|
||||
if (typeName _ropeOrigin == "ARRAY") then {
|
||||
_hook attachTo [_hookAttachment, _ropeOrigin];
|
||||
} else {
|
||||
_hook attachTo [_hookAttachment, [0, 0, 0], _ropeOrigin];
|
||||
};
|
||||
|
||||
_origin = getPosATL _hook;
|
||||
|
||||
_dummy = createVehicle [QGVAR(helper), _origin vectorAdd [0, 0, -1], [], 0, "CAN_COLLIDE"];
|
||||
_dummy allowDamage false;
|
||||
_dummy disableCollisionWith _vehicle;
|
||||
|
||||
_anchor = createVehicle [QGVAR(helper), _origin vectorAdd [0, 0, -2], [], 0, "CAN_COLLIDE"];
|
||||
_anchor allowDamage false;
|
||||
_anchor disableCollisionWith _vehicle;
|
||||
|
||||
_ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 0.5];
|
||||
_ropeBottom = ropeCreate [_dummy, [0, 0, 0], _anchor, [0, 0, 0], 34.5];
|
||||
|
||||
_ropeTop addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}];
|
||||
_ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}];
|
||||
|
||||
//deployedRopes format: attachment point, top part of the rope, bottom part of the rope, attachTo helper object, anchor helper object, occupied
|
||||
_deployedRopes pushBack [_ropeOrigin, _ropeTop, _ropeBottom, _dummy, _anchor, _hook, false];
|
||||
|
||||
false
|
||||
} count _ropeOrigins;
|
||||
|
||||
|
@ -34,5 +34,7 @@ _usableRope set [6, true];
|
||||
_deployedRopes set [_usableRopeIndex, _usableRope];
|
||||
_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true];
|
||||
|
||||
//Start server PFH asap
|
||||
[QGVAR(startFastRope), [_unit, _vehicle, _usableRope, _usableRopeIndex]] call EFUNC(common,serverEvent);
|
||||
moveOut _unit;
|
||||
[FUNC(fastRopePFH), 0, [_unit, _vehicle, _usableRope, _usableRopeIndex]] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(fastRopeLocalPFH), 0, [_unit, _vehicle, _usableRope, _usableRopeIndex]] call CBA_fnc_addPerFrameHandler;
|
||||
|
40
addons/fastroping/functions/fnc_fastRopeLocalPFH.sqf
Normal file
40
addons/fastroping/functions/fnc_fastRopeLocalPFH.sqf
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Author: BaerMitUmlaut
|
||||
* Local PerFrameHandler during fast roping.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: PFH arguments <ARRAY>
|
||||
* 1: PFH handle <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [[_unit, _vehicle, _rope, _ropeIndex], 0] call ace_fastroping_fnc_fastRopeLocalPFH
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
params ["_arguments", "_pfhHandle"];
|
||||
_arguments params ["_unit", "_vehicle", "_rope", "_ropeIndex"];
|
||||
_rope params ["_attachmentPoint", "_ropeTop", "_ropeBottom", "_dummy", "_anchor", "_hook", "_occupied"];
|
||||
private ["_vectorUp", "_vectorDir", "_origin"];
|
||||
|
||||
//Wait until the unit is actually outside of the helicopter
|
||||
if (vehicle _unit != _unit) exitWith {};
|
||||
|
||||
//Start fast roping
|
||||
if (animationState _unit != "ACE_FastRoping") exitWith {
|
||||
_unit disableCollisionWith _dummy;
|
||||
_unit attachTo [_dummy, [0, 0, -1.2]];
|
||||
[_unit, "ACE_FastRoping", 2] call EFUNC(common,doAnimation);
|
||||
};
|
||||
|
||||
//End of fast rope
|
||||
if (isNull attachedTo _unit) exitWith {
|
||||
[_unit, "", 2] call EFUNC(common,doAnimation);
|
||||
_unit setVectorUp [0, 0, 1];
|
||||
|
||||
[_pfhHandle] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: BaerMitUmlaut
|
||||
* PerFrameHandler during fast roping.
|
||||
* Server PerFrameHandler during fast roping.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: PFH arguments <ARRAY>
|
||||
@ -10,7 +10,7 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [[_unit, _vehicle, _rope, _ropeIndex], 0] call ace_fastroping_fnc_fastRopePFH
|
||||
* [[_unit, _vehicle, _rope, _ropeIndex], 0] call ace_fastroping_fnc_fastRopeServerPFH
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
@ -26,8 +26,6 @@ if (vehicle _unit != _unit) exitWith {};
|
||||
|
||||
//Start fast roping
|
||||
if (animationState _unit != "ACE_FastRoping") exitWith {
|
||||
_unit disableCollisionWith _dummy;
|
||||
|
||||
//Fix for twitchyness
|
||||
_dummy setMass 80;
|
||||
_dummy setCenterOfMass [0, 0, -1];
|
||||
@ -35,17 +33,12 @@ if (animationState _unit != "ACE_FastRoping") exitWith {
|
||||
_dummy setPosASL (_origin vectorAdd [0, 0, -2]);
|
||||
_dummy setVectorUp [0, 0, 1];
|
||||
|
||||
_unit attachTo [_dummy, [0, 0, -1.2]];
|
||||
[_unit, "ACE_FastRoping", 2] call EFUNC(common,doAnimation);
|
||||
ropeUnwind [_ropeTop, 6, 35];
|
||||
ropeUnwind [_ropeBottom, 6, 0];
|
||||
ropeUnwind [_ropeTop, 6, 34.5];
|
||||
ropeUnwind [_ropeBottom, 6, 0.5];
|
||||
};
|
||||
|
||||
//Check if rope broke and unit is falling
|
||||
if (isNull attachedTo _unit) exitWith {
|
||||
[_unit, "", 2] call EFUNC(common,doAnimation);
|
||||
_unit setVectorUp [0, 0, 1];
|
||||
|
||||
[_pfhHandle] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
@ -53,10 +46,8 @@ if (isNull attachedTo _unit) exitWith {
|
||||
_dummy setVelocity [0,0,-6];
|
||||
|
||||
//Check if fast rope is finished
|
||||
if (((getPos _unit select 2) < 0.2) || {ropeUnwound _ropeTop} || {vectorMagnitude (velocity _vehicle) > 5} || {!(alive _unit)} || {captive _unit}) exitWith {
|
||||
if (((getPos _unit select 2) < 0.2) || {ropeLength _ropeTop == 34.5} || {vectorMagnitude (velocity _vehicle) > 5} || {!(alive _unit)} || {captive _unit}) exitWith {
|
||||
detach _unit;
|
||||
[_unit, "", 2] call EFUNC(common,doAnimation);
|
||||
_unit setVectorUp [0, 0, 1];
|
||||
|
||||
//Reset rope
|
||||
deleteVehicle _ropeTop;
|
||||
@ -69,8 +60,8 @@ if (((getPos _unit select 2) < 0.2) || {ropeUnwound _ropeTop} || {vectorMagnitud
|
||||
_dummy setMass 40;
|
||||
_dummy setCenterOfMass [0.000143227,0.00105986,-0.246147];
|
||||
|
||||
_ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 1];
|
||||
_ropeBottom = ropeCreate [_dummy, [0, 0, 0], _anchor, [0, 0, 0], 34];
|
||||
_ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 0.5];
|
||||
_ropeBottom = ropeCreate [_dummy, [0, 0, 0], _anchor, [0, 0, 0], 34.5];
|
||||
|
||||
_ropeTop addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}];
|
||||
_ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}];
|
Loading…
Reference in New Issue
Block a user