diff --git a/scripts/spot-randomizer/funcs.hpp b/scripts/spot-randomizer/funcs.hpp index b45ffa5..3c4d692 100644 --- a/scripts/spot-randomizer/funcs.hpp +++ b/scripts/spot-randomizer/funcs.hpp @@ -2,6 +2,7 @@ class spot_randomizer { tag = "spot_randomizer"; class functions { file = "scripts\spot-randomizer\functions"; + class initStationClient{}; class randomizeSpots{postInit = 1;}; class placeTask{}; class placeSupplyStation{}; diff --git a/scripts/spot-randomizer/functions/fn_initStationClient.sqf b/scripts/spot-randomizer/functions/fn_initStationClient.sqf new file mode 100644 index 0000000..ceeadde --- /dev/null +++ b/scripts/spot-randomizer/functions/fn_initStationClient.sqf @@ -0,0 +1,56 @@ +if !(hasInterface) exitWith {}; +// _this === station container + +/* + * ACE Progress Bar + * Finish/Failure/Conditional are all passed [_args, _elapsedTime, _totalTime, _errorCode] + * 0: Total Time (in game "time" seconds) + * 1: Arguments, passed to condition, fail and finish + * 2: On Finish: Code called or STRING raised as event. + * 3: On Failure: Code called or STRING raised as event. + * 4: (Optional) Localized Title + * 5: Code to check each frame (Optional) + * 6: Exceptions for checking EFUNC(common,canInteractWith) (Optional) +*/ +private _pbar = {[ + 10, + _this#0, + { + (_this#0 getVariable "shootnscoot_stationNet") setDamage 0.8; + }, + { + }, + "Repairing...", + { + alive player and (player distance _this#0) < 12 && + isNull objectParent player && + speed(_this#0) < 3 + } +] call ace_common_fnc_progressBar; +}; + +/* + * Argument: + * 0: Object the action should be assigned to + * 1: Type of action, 0 for actions, 1 for self-actions + * 2: Parent path of the new action (Example: `["ACE_SelfActions", "ACE_Equipment"]`) + * 3: Action + */ +[_this, 0, ["ACE_MainActions"], _action] call ace_interact_menu_fnc_addActionToObject; + +// Vanilla menu, but with progress bar +_this addAction [ + "Fix broken camouflage net", + _pbar, + nil, + 6, // high up in priority + true, + true, + "", + "player distance _target < 12 && damage (_target getVariable 'shootnscoot_stationNet') > 0.9" + , + 20, + false, + "", + "" +]; diff --git a/scripts/spot-randomizer/functions/fn_placeSupplyStation.sqf b/scripts/spot-randomizer/functions/fn_placeSupplyStation.sqf index 2191486..691d9ad 100644 --- a/scripts/spot-randomizer/functions/fn_placeSupplyStation.sqf +++ b/scripts/spot-randomizer/functions/fn_placeSupplyStation.sqf @@ -31,6 +31,7 @@ switch (_side) do private _net = (_netType createVehicle _fuzzyPosition); // net first because it requires most space private _container = (_containerType createVehicle (getPosATL _net)); _container setVariable [ "shootnscoot_stationid", _stationid, true]; +_container setVariable [ "shootnscoot_stationNet", _net, true]; _container lockInventory true; // prevent inventory from being used (necessary for opfor container) // apply a random rotation for variety @@ -44,76 +45,21 @@ if (not isNull _nearbyRoad) then { [_net, [_rotation, 0, 0]] call BIS_fnc_setObjectRotation; [_container, [(_rotation+90) % 360, 0, 0]] call BIS_fnc_setObjectRotation; +//clear area for supply stations from obstacles +private _nearObjects = nearestTerrainObjects [_fuzzyPosition, [], 11]; +{ hideObjectGlobal _x } forEach _nearObjects; + sleep 3; // wait for jerky physics to finish // restore health after jerky Arma physics _container setDamage 0.0; // start with a bit over 50% hit points (requested by players) -_net setDamage 0.0; // fix broken nets +_net setDamage 0.8; // start with low health to fix https://github.com/gruppe-adler/Shoot_and_Scoot.Tanoa/issues/29 - -//clear area for supply stations from obstacles -private _nearObjects = nearestTerrainObjects [_fuzzyPosition, [], 11]; -{ hideObjectGlobal _x } forEach _nearObjects; +_container remoteExec ["spot_randomizer_fnc_initStationClient", 0, true]; // Init any local container stuff for all players (incl. JIP!) // add a trigger area to restock ammo trucks (incl. Stompers) [_fuzzyPosition, _rotation] call spot_randomizer_fnc_placeRestockArea; -// add menu entry that allows putting a damaged camo net back up -private _spot_randomizer_fnc_CamoNetBroken = { - private _return = false; - private _nets = nearestObjects [player, ["CamoNet_BLUFOR_big_F", "CamoNet_ghex_big_F"], 10]; - { - if (damage _x > 0.9) then { - _return = true; - break; - }; - } forEach _nets; - _return; -}; -private _spot_randomizer_fnc_RepairCamoNet = { - private _nets = nearestObjects [player, ["CamoNet_BLUFOR_big_F", "CamoNet_ghex_big_F"], 10]; - { - if (call spot_randomizer_fnc_CamoNetBroken) then { - _x setDamage 0.9; // once damaged it shall remain damaged (but standing) - }; - } forEach _nets; -}; -_container addAction [ - "Erect broken camouflage net", - _spot_randomizer_fnc_RepairCamoNet, - nil, - 6, // high up in priority - true, - true, - "", - toString _spot_randomizer_fnc_CamoNetBroken, - 20, - false, - "", - "" -]; -/* TODO: I would prefer a Hold action but it does not work yet :-( -[ - _container, // Object the action is attached to - "Erect broken camouflage net", // Title of the action - "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen - "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen - toString spot_randomizer_fnc_CamoNetBroken, // Condition for the action to be shown - "_caller distance _target < 15", // Condition for the action to progress - {}, // Code executed when action starts - {}, // Code executed on every progress tick - { - call spot_randomizer_fnc_RepairCamoNet; - }, // Code executed on completion - {}, // Code executed on interrupted - [], // Arguments passed to the scripts as _this select 3 - 10, // action duration in seconds - 0, // priority - false, // Remove on completion - false// Show in unconscious state -] remoteExec ["BIS_fnc_holdActionAdd", 0, _container];// MP compatible implementation -*/ - private _idx = _container addEventHandler [ "HandleDamage", { params ["_container", "_selection", "_damage", "_source", "_ammo", "_hitIndex", "_instigator", "_hitPoint", "_directHit"]; private _damagePrv = damage _container;