From 32846014a1b72a115805c488ebe7fb9e2effde1a Mon Sep 17 00:00:00 2001 From: SzwedzikPL Date: Mon, 14 Mar 2016 14:21:02 +0100 Subject: [PATCH 1/3] fix ammo handling init on dedicated --- addons/mk6mortar/XEH_postInit.sqf | 2 ++ .../fnc_handlePlayerVehicleChanged.sqf | 29 +++++++++---------- addons/mk6mortar/functions/fnc_mortarInit.sqf | 13 +++++---- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/addons/mk6mortar/XEH_postInit.sqf b/addons/mk6mortar/XEH_postInit.sqf index 5c82d55f50..9c098b8cdd 100644 --- a/addons/mk6mortar/XEH_postInit.sqf +++ b/addons/mk6mortar/XEH_postInit.sqf @@ -15,6 +15,8 @@ _static setMagazineTurretAmmo [_magazine, _ammoCount, [0]]; }] call EFUNC(common,addEventHandler); +["initMortar", {_this call FUNC(mortarInit);}] call EFUNC(common,addEventHandler); + if (!hasInterface) exitWith {}; ["playerVehicleChanged", {_this call FUNC(handlePlayerVehicleChanged);}] call EFUNC(common,addEventHandler); diff --git a/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf b/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf index 02049289aa..2d921973d4 100644 --- a/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf +++ b/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf @@ -16,31 +16,30 @@ */ #include "script_component.hpp" -PARAMS_2(_player,_newVehicle); - -private["_tubeWeaponName" ,"_fireModes", "_lastFireMode"]; +params ["_player", "_newVehicle"]; if (isNull _newVehicle) exitWith {}; if (!(_newVehicle isKindOf "Mortar_01_base_F")) exitWith {}; // Run magazine handling initialization if enabled -if (!EGVAR(common,settingsInitFinished)) then { - EGVAR(common,runAtSettingsInitialized) pushBack [{ - if (GVAR(useAmmoHandling) && {!(_this getVariable [QGVAR(initialized),false]) && !(_this getVariable [QGVAR(exclude),false])}) then { - _this call FUNC(mortarInit); +if (!(_newVehicle getVariable [QGVAR(initialized),false]) && !(_newVehicle getVariable [QGVAR(exclude),false])) then { + // Make sure that mortar init is executed after settings init + [{ + params ["_mortar"]; + if (GVAR(useAmmoHandling) && {!(_mortar getVariable [QGVAR(initialized),false]) && !(_mortar getVariable [QGVAR(exclude),false])}) then { + //wait for proper turret locality change + [{ + ["initMortar", [_this], [_this]] call EFUNC(common,globalEvent); + }, _mortar, 0.05] call EFUNC(common,waitAndExecute); }; - }, _newVehicle]; -} else { - if (GVAR(useAmmoHandling) && {!(_newVehicle getVariable [QGVAR(initialized),false]) && !(_newVehicle getVariable [QGVAR(exclude),false])}) then { - _newVehicle call FUNC(mortarInit); - }; + }, _newVehicle] call EFUNC(common,runAfterSettingsInit); }; -_tubeWeaponName = (weapons _newVehicle) select 0; -_fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes"); +private _tubeWeaponName = (weapons _newVehicle) select 0; +private _fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes"); //Restore last firemode: -_lastFireMode = _newVehicle getVariable [QGVAR(lastFireMode), -1]; +private _lastFireMode = _newVehicle getVariable [QGVAR(lastFireMode), -1]; if (_lastFireMode != -1) then { _player action ["SwitchWeapon", _newVehicle, _player, _lastFireMode]; }; diff --git a/addons/mk6mortar/functions/fnc_mortarInit.sqf b/addons/mk6mortar/functions/fnc_mortarInit.sqf index 7c74cb8249..68c9eab91e 100644 --- a/addons/mk6mortar/functions/fnc_mortarInit.sqf +++ b/addons/mk6mortar/functions/fnc_mortarInit.sqf @@ -18,27 +18,28 @@ params ["_mortar"]; if (_mortar getVariable [QGVAR(initialized),false] || _mortar getVariable [QGVAR(exclude),false]) exitWith {TRACE_1("Exit",_mortar)}; +if (!(_mortar turretLocal [0])) exitWith {TRACE_1("Exit - turret not local",_mortar)}; -// Remove all magazines +// Remove all magazines from turret if (count magazines _mortar > 0) then { { - [QGVAR(removeMagazine), [_mortar, _x]] call EFUNC(common,globalEvent); + _mortar removeMagazineTurret [_x,[0]]; } forEach magazines _mortar; }; -// Replace current weapon with ammo handling weapon +// Replace current turret weapon with ammo handling weapon private _currentWeapon = _mortar weaponsTurret [0] select 0; private _newWeapon = ""; -if (_currentWeapon == "mortar_82mm") then { +if (tolower _currentWeapon == "mortar_82mm") then { _newWeapon = "ace_mortar_82mm"; } else { _newWeapon = getText (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(replaceWith)); }; if (_newWeapon != "") then { - _mortar removeWeaponGlobal _currentWeapon; - _mortar addWeaponGlobal _newWeapon; + _mortar removeWeaponTurret [_currentWeapon,[0]]; + _mortar addWeaponTurret [_newWeapon,[0]]; }; _mortar setVariable [QGVAR(initialized),true,true]; From 14183470bc65251a4ddf2461c1e80b7ff2c89010 Mon Sep 17 00:00:00 2001 From: esteldunedain Date: Mon, 14 Mar 2016 12:16:23 -0300 Subject: [PATCH 2/3] Revert "Improved rope glitchyness" This reverts commit c65656a016fc377eb03583dcc04d144ff1aa3141. --- addons/fastroping/XEH_postInit.sqf | 5 +++++ addons/fastroping/functions/fnc_cutRopes.sqf | 6 ++---- addons/fastroping/functions/fnc_deployRopes.sqf | 5 ++--- addons/fastroping/functions/fnc_fastRopeLocalPFH.sqf | 1 - addons/fastroping/functions/fnc_fastRopeServerPFH.sqf | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/addons/fastroping/XEH_postInit.sqf b/addons/fastroping/XEH_postInit.sqf index ae88feaa76..873d1091e5 100644 --- a/addons/fastroping/XEH_postInit.sqf +++ b/addons/fastroping/XEH_postInit.sqf @@ -7,3 +7,8 @@ [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); diff --git a/addons/fastroping/functions/fnc_cutRopes.sqf b/addons/fastroping/functions/fnc_cutRopes.sqf index 71fe682f7e..88b02a70af 100644 --- a/addons/fastroping/functions/fnc_cutRopes.sqf +++ b/addons/fastroping/functions/fnc_cutRopes.sqf @@ -32,10 +32,8 @@ _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []]; }; }; - detach _dummy; - deleteVehicle _ropeTop; - deleteVehicle _hook; - [{{deleteVehicle _x} count _this}, [_ropeBottom, _dummy], 60] call EFUNC(common,waitAndExecute); + [QGVAR(ropeDetach), [_hook, _ropeTop]] call EFUNC(common,serverEvent); + [{{deleteVehicle _x} count _this}, [_ropeTop, _ropeBottom, _dummy, _hook], 60] call EFUNC(common,waitAndExecute); } count _deployedRopes; _vehicle setVariable [QGVAR(deployedRopes), [], true]; diff --git a/addons/fastroping/functions/fnc_deployRopes.sqf b/addons/fastroping/functions/fnc_deployRopes.sqf index af79dd2cfe..c944b2c3cb 100644 --- a/addons/fastroping/functions/fnc_deployRopes.sqf +++ b/addons/fastroping/functions/fnc_deployRopes.sqf @@ -35,14 +35,13 @@ _hookAttachment = _vehicle getVariable [QGVAR(FRIES), _vehicle]; _origin = getPosATL _hook; - _dummy = createVehicle [QGVAR(helper), _origin, [], 0, "CAN_COLLIDE"]; + _dummy = createVehicle [QGVAR(helper), _origin vectorAdd [0, 0, -1], [], 0, "CAN_COLLIDE"]; _dummy allowDamage false; _dummy disableCollisionWith _vehicle; - _dummy attachTo [_hook, [0, 0, 0]]; _ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 0.5]; _ropeBottom = ropeCreate [_dummy, [0, 0, 0], 1]; - ropeUnwind [_ropeBottom, 30, 35, false]; + ropeUnwind [_ropeBottom, 30, 34.5, false]; _ropeTop addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}]; _ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}]; diff --git a/addons/fastroping/functions/fnc_fastRopeLocalPFH.sqf b/addons/fastroping/functions/fnc_fastRopeLocalPFH.sqf index 6a4e810ff5..d05c8bfdbc 100644 --- a/addons/fastroping/functions/fnc_fastRopeLocalPFH.sqf +++ b/addons/fastroping/functions/fnc_fastRopeLocalPFH.sqf @@ -26,7 +26,6 @@ if (vehicle _unit != _unit) exitWith {}; //Start fast roping if (animationState _unit != "ACE_FastRoping") exitWith { - detach _dummy; _unit disableCollisionWith _dummy; _unit attachTo [_dummy, [0, 0, -1.45]]; [_unit, "ACE_FastRoping", 2] call EFUNC(common,doAnimation); diff --git a/addons/fastroping/functions/fnc_fastRopeServerPFH.sqf b/addons/fastroping/functions/fnc_fastRopeServerPFH.sqf index 627ed959bc..44f9fedd1a 100644 --- a/addons/fastroping/functions/fnc_fastRopeServerPFH.sqf +++ b/addons/fastroping/functions/fnc_fastRopeServerPFH.sqf @@ -54,14 +54,14 @@ if (((getPos _unit select 2) < 0.2) || {ropeLength _ropeTop == 34.5} || {vectorM deleteVehicle _ropeBottom; _origin = getPosASL _hook; - _dummy attachTo [_hook, [0, 0, 0]]; + _dummy setPosASL (_origin vectorAdd [0, 0, -1]); //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], 0.5]; - _ropeBottom = ropeCreate [_dummy, [0, 0, 0], 35]; + _ropeBottom = ropeCreate [_dummy, [0, 0, 0], 34.5]; _ropeTop addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}]; _ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}]; From 72c9e9da39dd2bbb3e96070eae482e5f3468159c Mon Sep 17 00:00:00 2001 From: jonpas Date: Wed, 16 Mar 2016 20:17:23 +0100 Subject: [PATCH 3/3] Replace usage of filter to select in tagging --- addons/tagging/functions/fnc_tagTestingThread.sqf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/tagging/functions/fnc_tagTestingThread.sqf b/addons/tagging/functions/fnc_tagTestingThread.sqf index 18d14e2e4f..a904587f8a 100644 --- a/addons/tagging/functions/fnc_tagTestingThread.sqf +++ b/addons/tagging/functions/fnc_tagTestingThread.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" -_fnc_isLeaning = { +GVAR(tagsToTest) = GVAR(tagsToTest) select { params ["_tag", "_tagPosASL", "_vectorDirAndUp"]; _vectorDirAndUp params ["_v1", "_v2"]; @@ -34,7 +34,6 @@ _fnc_isLeaning = { }; true }; -GVAR(tagsToTest) = [GVAR(tagsToTest), _fnc_isLeaning] call EFUNC(common,filter); // If there's no more tag if (GVAR(tagsToTest) isEqualTo []) exitWith {