Skip to content

Commit

Permalink
Merge pull request #32 from senshi-x/camo_strength
Browse files Browse the repository at this point in the history
Example camonet actions added
  • Loading branch information
b-mayr-1984 authored Aug 6, 2023
2 parents b10642a + 8db61f2 commit 5c09a1b
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 61 deletions.
1 change: 1 addition & 0 deletions scripts/spot-randomizer/funcs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down
56 changes: 56 additions & 0 deletions scripts/spot-randomizer/functions/fn_initStationClient.sqf
Original file line number Diff line number Diff line change
@@ -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) <NUMBER>
* 1: Arguments, passed to condition, fail and finish <ARRAY>
* 2: On Finish: Code called or STRING raised as event. <CODE, STRING>
* 3: On Failure: Code called or STRING raised as event. <CODE, STRING>
* 4: (Optional) Localized Title <STRING>
* 5: Code to check each frame (Optional) <CODE>
* 6: Exceptions for checking EFUNC(common,canInteractWith) (Optional)<ARRAY>
*/
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 <OBJECT>
* 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>
* 2: Parent path of the new action <ARRAY> (Example: `["ACE_SelfActions", "ACE_Equipment"]`)
* 3: Action <ARRAY>
*/
[_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,
"",
""
];
68 changes: 7 additions & 61 deletions scripts/spot-randomizer/functions/fn_placeSupplyStation.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 5c09a1b

Please sign in to comment.