Better twitching fix, failsaves and EHs

This commit is contained in:
BaerMitUmlaut 2015-11-30 00:14:46 +01:00
parent 3ec9369a9e
commit 2695fc6beb
8 changed files with 107 additions and 22 deletions

View File

@ -12,12 +12,13 @@ class CfgVehicles {
class NonStrategic: Building {
class AnimationSources;
};
class ACE_friesBar: NonStrategic {
class ACE_friesBase: NonStrategic {
destrType = "DestructNo";
};
class ACE_friesAnchorBar: ACE_friesBase {
author = "BaerMitUmlaut";
scope = 1;
model = PATHTOF(data\friesBar.p3d);
destrType = "DestructNo";
displayName = "";
scope = 2;
model = PATHTOF(data\friesAnchorBar.p3d);
animated = 1;
class AnimationSources: AnimationSources {
class extendHookRight {
@ -105,7 +106,7 @@ class CfgVehicles {
class Heli_Transport_01_base_F: Helicopter_Base_H {
GVAR(enabled) = 2;
GVAR(ropeOrigins[]) = {"hookRight", "hookLeft"};
GVAR(friesType) = "ace_friesBar";
GVAR(friesType) = "ACE_friesAnchorBar";
GVAR(friesAttachmentPoint[]) = {0, 2.2, -0.15};
GVAR(onDeploy) = QFUNC(onDeployRopesCommon);

View File

@ -12,5 +12,6 @@ PREP(fastRopePFH);
PREP(moduleEquipFRIES);
PREP(onCutRopesCommon);
PREP(onDeployRopesCommon);
PREP(onRopeBreak);
ADDON = true;

View File

@ -4,7 +4,7 @@ class CfgSkeletons {
skeletonInherit = "";
skeletonBones[] = {};
};
class ace_friesBar_skeleton: Default {
class ace_friesAnchorBar_skeleton: Default {
isDiscrete = 1;
skeletonInherit = "Default";
skeletonBones[] = {
@ -20,8 +20,8 @@ class CfgModels {
sections[] = {""};
skeletonName = "";
};
class friesBar: Default {
skeletonName = "ace_friesBar_skeleton";
class friesAnchorBar: Default {
skeletonName = "ace_friesAnchorBar_skeleton";
sectionsInherit = "";
sections[] = {"hookRight", "hookLeft"};
class animations {

View File

@ -51,8 +51,11 @@ if (isText (_config >> QGVAR(onDeploy))) then {
_anchor allowDamage false;
_anchor setPosASL (_origin vectorAdd [0, 0, -2.5]);
_ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 2];
_ropeBottom = ropeCreate [_dummy, [0, 0, 0], _anchor, [0, 0, 0], 33];
_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 [_x, _ropeTop, _ropeBottom, _dummy, _anchor, _hook, false];

View File

@ -26,20 +26,34 @@ 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];
_origin = getPosASL _hook;
_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];
_dummy setMass (_vehicle getVariable ["mass", 50]);
_dummy setCenterOfMass (_vehicle getVariable ["cofmass", [0,0,-2]]);
};
drawLine3D [getPos _dummy, (getPos _dummy) vectorAdd (vectorDir _dummy), [0,0,1,1]];
drawLine3D [getPos _dummy, (getPos _dummy) vectorAdd (vectorUp _dummy), [1,0,0,1]];
drawIcon3D ["", [0,1,0,1], getPos _dummy, 0, 0, 0, (str (getMass _dummy)) + " | " + (str (getCenterOfMass _dummy)), 1, 0.05, "PuristaMedium"];
//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;
};
//Setting the velocity manually to reduce twitching
_dummy setVelocity [0,0,-6];
//Check if fast rope is finished
if (((getPos _unit select 2) < 0.2) || {ropeUnwound _ropeTop} || {vectorMagnitude (velocity _vehicle) > 5}) exitWith {
if (((getPos _unit select 2) < 0.2) || {ropeUnwound _ropeTop} || {vectorMagnitude (velocity _vehicle) > 5} || {!(alive _unit)} || {captive _unit}) exitWith {
detach _unit;
[_unit, "", 2] call EFUNC(common,doAnimation);
_unit setVectorUp [0, 0, 1];
@ -49,17 +63,22 @@ if (((getPos _unit select 2) < 0.2) || {ropeUnwound _ropeTop} || {vectorMagnitud
deleteVehicle _ropeBottom;
_origin = getPosASL _hook;
_dummy setPosASL (_origin vectorAdd [0, 0, -2]);
_dummy setPosASL (_origin vectorAdd [0, 0, -1]);
_ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 2];
_ropeBottom = ropeCreate [_dummy, [0, 0, 0], _anchor, [0, 0, 0], 33];
//Restore original mass and center of mass
_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 addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}];
_ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}];
//Update deployedRopes array
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
_deployedRopes set [_ropeIndex, [_attachmentPoint, _ropeTop, _ropeBottom, _dummy, _anchor, _hook, false]];
_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true];
[FUNC(fastRope), [_unit, _vehicle], 1] call EFUNC(common,waitAndExecute);
[_pfhHandle] call CBA_fnc_removePerFrameHandler;
};

View File

@ -33,6 +33,15 @@ _synchedUnits = synchronizedObjects _module;
_fries = (getText (_config >> QGVAR(friesType))) createVehicle [0, 0, 0];
_fries attachTo [_x, (getArray (_config >> QGVAR(friesAttachmentPoint)))];
_x setVariable [QGVAR(FRIES), _fries, true];
_x addEventHandler ["Killed", {
params ["_vehicle"];
deleteVehicle (_vehicle getVariable [QGVAR(FRIES), objNull]);
_vehicle setVariable [QGVAR(FRIES), nil, true];
if !((_vehicle getVariable [QGVAR(deployedRopes), []] isEqualTo [])) then {
[_vehicle] call FUNC(cutRopes);
};
}];
};
};
false

View File

@ -0,0 +1,52 @@
/*
* Author: BaerMitUmlaut
* Handles ropes breaking when deployed.
*
* Arguments:
* 0: RopeBreak EH arguments <ARRAY>
* 1: Part of rope ("top" or "bottom") <STRING>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_ehArgs", "_part"];
_ehArgs params ["_rope", "_helper1", "_helper2"];
private ["_vehicle", "_deployedRopes", "_unit"];
if (_part == "bottom") then {
_helper2 = (ropeAttachedObjects _helper1) select 0;
};
_vehicle = attachedTo _helper2;
if (isNil "_vehicle") exitWith {}; //Exit when vehicle got destroyed
if (_vehicle isKindOf "ACE_friesBase") then {
_vehicle = attachedTo _vehicle;
};
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
_brokenRope = [];
{
if (_x select 1 == _rope) exitWith {
_brokenRope = _x;
};
} forEach _deployedRopes;
_brokenRope set [6, false];
_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true];
_unit = {
if (_x isKindOf "CAManBase") exitWith {_x};
} forEach (attachedObjects (_brokenRope select 3));
if !(isNil "_unit") then {
if (_part == "top") then {
detach _unit;
} else {
//TODO: ???
//Rope might break at the very bottom
//-> letting the unit fall is not always ideal
};
};