Skip to content

Instantly share code, notes, and snippets.

@veteran29
Last active October 3, 2023 21:19
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veteran29/4735d4d96add5cdf0134a834cd2f12d3 to your computer and use it in GitHub Desktop.
Save veteran29/4735d4d96add5cdf0134a834cd2f12d3 to your computer and use it in GitHub Desktop.
Arma Editor/Missions stuff

Arma Stuff

Various editor/arma sqf stuff.

This gist

knowledge

useful scripts

  • 3DEN Scripting (very useful stuff here) - Article
  • Customize loadingscreen - Code, Cfg
  • Custom respawn system - Code
  • Save static ammo count on packed bag - Code
  • Global/3d sound - Code
  • cursorPosition - Code
  • Compress unitcapture Code
  • Get pos 1m left from object no matter direction getPosASL _object vectorAdd (_object vectorModelToWorld [-1,0,0])
  • No gravity for object Code
  • Flies around object: Code
  • Respawn all, zeus button: Code
  • ACRE jammer Code
  • BFT/Friendly Tracker Code
  • S.O.G. Prairie Fire - Run custom code on Tracker Area group spawn Code
  • Detect floating bushes on terrain
  • Global Mobilization T-55 Searchlight Code
  • Draw country borders on Cam Lao Nam Repo

Finding my stuff interesting, useful or just helpful, you can buy me a coffee ( ͡° ͜ʖ ͡°):

// Heal Unit
[player] call ace_medical_treatment_fnc_fullHealLocal;
// Disable damage, this is enough since rewrite ;-)
this allowDamage false;

// Prevnt from dying, allow damage
this setVariable ["ace_medical_deathBlocked", true];

Unconcious

https://github.com/acemod/ACE3/blob/master/addons/medical/functions/fnc_setUnconscious.sqf

[player, true] call ace_medical_fnc_setUnconscious;

Damage stuff

https://github.com/acemod/ACE3/blob/master/addons/medical_status/functions/fnc_handleKilledMission.sqf#L40

cursorObject getVariable "ace_medical_lastDamageSource";
cursorObject getVariable "ace_medical_lastInstigator";

cursorObject getVariable "ace_medical_bodyPartDamage";
vet_fnc_replaceAcreRack = {
if (!isServer) exitWith {};
params [
["_vehicle", objNull, [objNull]],
["_rackToAdd", "", [""]],
["_racksToRemove", [], [[], ""]],
["_intercoms", ["intercom_1"], [[]]]
],
if (_racksToRemove isEqualType "") then {
_racksToRemove = [_racksToRemove];
};
// Add specified rack to vehicle
[
_vehicle,
[
_rackToAdd, // Rack class
localize "STR_ACRE_sys_rack_dash",
localize "STR_ACRE_sys_rack_dashShort",
false,
// Who has access:
// "inside" - anyone inside
// "external" - provides access upto 10m away,
// "driver", "gunner", "copilot", "commander"
["inside"],
[],
createHashMapFromArray [
["ACRE_VRC103", "ACRE_PRC117F"],
["ACRE_VRC110", "ACRE_PRC152"],
["ACRE_VRC111", "ACRE_PRC148"],
["ACRE_VRC64", "ACRE_PRC77"],
["ACRE_SEM90", "ACRE_SEM70"]
] get _rackToAdd,
[],
// All units in intercom will be able to hear/send transmittions (ACE3 interaction menu) but they cannot manipulate the radio (GUI interface)
_intercoms
],
true, // force init, needs to be true to work on vehicles that were not entered by players yet
{}
] call acre_api_fnc_addRackToVehicle;
[{(_this select 0) call acre_api_fnc_areVehicleRacksInitialized}, {
params ["_vehicle", "_racksToRemove"];
// remove specified racks
{
private _rackToRemove = toLower _x;
{
if (_rackToRemove in toLower _x) then {
[_vehicle, _x] call acre_api_fnc_removeRackFromVehicle;
};
} forEach (_vehicle call acre_api_fnc_getVehicleRacks);
} forEach _racksToRemove;
}, [_vehicle, _racksToRemove], 5] call CBA_fnc_waitUntilAndExecute;
};
// Rack - Supported radio
// ACRE_VRC103 - ACRE_PRC117F
// ACRE_VRC110 - ACRE_PRC152
// ACRE_VRC111 - ACRE_PRC148
// ACRE_VRC64 - ACRE_PRC77
// ACRE_SEM90 - ACRE_SEM70
// Change rack of CUP_B_M60A3_USMC from ACRE_VRC64 to ACRE_VRC103
["CUP_B_M60A3_USMC", "initPost", {
params ["_vehicle"];
[
_vehicle,
"ACRE_VRC103", // Rack to add
"ACRE_VRC64" // Rack to remove
] call vet_fnc_replaceAcreRack;
}, false, [], true] call CBA_fnc_addClassEventHandler;
fnc_adjustMainInteractionPosition = {
params [
["_class", "", [""]],
["_posCode", {call ace_interaction_fnc_getVehiclePos}, [{}]]
];
private _actions = ace_interact_menu_ActNamespace getVariable [_class, []];
private _mainAction = [_actions, ["ACE_MainActions"]] call ace_interact_menu_fnc_findActionNode;
if (isNil "_mainAction") exitWith {
// ACE_MainActions not added yet, add it and try again.
[_class, 0] call ace_interact_menu_fnc_addMainAction;
_this call fnc_adjustMainInteractionPosition;
};
// overwrite the position of the main action
_mainAction = _mainAction # 0;
_mainAction set [7, _posCode];
};
["CUP_C_Datsun", {[0,0,-1]}] call fnc_adjustMainInteractionPosition;
/*
AAS_fnc_unitInAo
File: fn_playerInAO.sqf
Date: 2019-03-04
Last Update: 2019-03-04
Description:
Checks if unit is in area of operations.
Parameter(s):
_unit - Unit to check [OBJECT, defaults to player]
Returns:
Is unit in AO [BOOL]
*/
params [
["_unit", player, [objNull]]
];
// Return true if unit is in area or area is not limited
_unit inArea "bis_fnc_moduleCoverMap_border" || {getMarkerColor "bis_fnc_moduleCoverMap_border" == ""}
// pabstmirror 6:20 PM
// I've used these for ace and cba
["recompile", "recompile", "recompile", {
private _start = diag_tickTime;
[] call ACE_PREP_RECOMPILE;
[] call ace_common_fnc_dumpPerformanceCounters;
private _end = diag_tickTime;
systemChat format ["recompile took [%1 ms]", (1000 * (_end - _start)) toFixed 1];
false
}, {false}, [0x21, [false, false, false]], false] call CBA_fnc_addKeybind; // F Key
player addAction ["CBArecompile", {
{
_cat = configProperties [configFile >> "CfgFunctions" >> "CBA"];
{
_subFnc = configProperties [_x];
{
_fncName = format ["CBA_fnc_%1", configName _x];
_fncName call BIS_fnc_recompile;
} forEach _subFnc;
} forEach _cat;
diag_log "CBA Recomp";
} call CBA_fnc_directCall;
}, [], 55];
VET_fnc_changePfehTime = {
params [["_handle", -1, [0], ["_rate", 0, [0]];
private _index = CBA_common_PFHhandles param [_handle];
(CBA_common_perFrameHandlerArray select _index) set [1, _rate];
nil
};
[player, {
params ["_unit"];
private _curator = (createGroup sideLogic) createUnit ["ModuleCurator_F", [0, 0, 0], [], 0, "CAN_COLLIDE"];
// Since 1.86 modules don't activate automatically when created via scripts
// We need to activate it manually
_curator setVariable ["BIS_fnc_initModules_activate", true, true];
_curator setVariable ["Addons", 3, true];
_curator addCuratorEditableObjects [entities "", true];
_unit assignCurator _curator;
}] remoteExec ["call", 2];
["custom_high_jog_coef", {
private _isHighJog = (animationState _this) select [9, 3] == "tac";
if (_isHighJog) exitWith {0.95};
1
}] call ace_advanced_fatigue_fnc_addDutyFactor;
/*
Simple script to set damaged materials on simple object.
*/
vet_fnc_arraySlice = {
params ["_array", "_size"];
private _out = [];
for "_i" from 0 to (count _array-1) step _size do {
_out pushBack (_array select [_i, _size]);
};
_out // return
};
_vehicle = cursorObject;
private _damageMaterials = getArray (configOf _vehicle >> "Damage" >> "mat");
/*
Array of arrays in format of:
[
[
"mat default",
"mat damaged",
"mat destroyed"
]
]
*/
_damageMaterials = [_damageMaterials, 3] call vet_fnc_arraySlice;
{
private _selectionIndex = _forEachIndex;
// private _index = 0; // mat default
// private _index = 1; // mat damaged
private _index = 2; // mat destroyed
_vehicle setObjectMaterial [_selectionIndex, _x#_index];
} forEach _damageMaterials
// disable radio drop
player addEventHandler ["InventoryOpened", {
[] spawn {
private _timeout = time + 5;
private _displayInventory = displayNull;
waitUntil {
_displayInventory = findDisplay 602;
!isNull _displayInventory || {time > _timeout}
};
(_displayInventory displayCtrl 6214) ctrlEnable false;
};
}];
/*
Prevents any damage from FOG anomalies so they can be used for local harmless fog.
*/
// https://github.com/diwako/stalker_anomalies/blob/594ae04ae42bd855d4a69a749b62f6b4148b6d52/mod/diwako_anomalies/functions/anomalies/fn_createFog.sqf#L52
[] spawn {
if (!isServer) exitWith {};
sleep 5;
private _fogTriggers = allMissionObjects "EmptyDetector" select {_x getVariable ["anomaly_type", ""] == "fog"};
{
// trigger activation is what does the damage to player, disable damage by making the trigger do nothing
// fog particles are handled by effects loop so it will still be there.
[_x, ["false", "", ""]] remoteExec ["setTriggerStatements", 0, _x];
} forEach _fogTriggers;
};
_fnc_drawCOM = {
private _camPos = (positionCameraToWorld [0,0,0]);
private _nearest = nearestObjects [_camPos, [], 25, false];
private "_com";
{
_centerOfMassWorld = _x modelToWorldVisual getCenterOfMass _x;
drawIcon3D ["", [1,0,0,1], _centerOfMassWorld, 0, 0, 0, "X", 1, 0.05, "PuristaMedium"];
} forEach _nearest;
};
onEachFrame _fnc_drawCOM;
fnc_drawBB = {
params ["_object", "_bb"];
_bb params ["_c1", "_c2"];
systemChat str _c1;
systemChat str _c2;
// Draw the bounding box
{
_x params ["_from", "_to"];
// Draw the line
drawLine3D [
_object modelToWorldVisual _from,
_object modelToWorldVisual _to,
[1,0,0,1]
];
} forEach [
[_c1, [_c1 select 0, _c1 select 1, _c2 select 2]],
[_c1, [_c1 select 0, _c2 select 1, _c1 select 2]],
[_c1, [_c2 select 0, _c1 select 1, _c1 select 2]],
[_c2, [_c2 select 0, _c2 select 1, _c1 select 2]],
[_c2, [_c2 select 0, _c1 select 1, _c2 select 2]],
[_c2, [_c1 select 0, _c2 select 1, _c2 select 2]],
[[_c1 select 0, _c2 select 1, _c1 select 2], [_c2 select 0, _c2 select 1, _c1 select 2]],
[[_c2 select 0, _c1 select 1, _c1 select 2], [_c2 select 0, _c1 select 1, _c2 select 2]],
[[_c1 select 0, _c1 select 1, _c2 select 2], [_c2 select 0, _c1 select 1, _c2 select 2]],
[[_c1 select 0, _c1 select 1, _c2 select 2], [_c1 select 0, _c2 select 1, _c2 select 2]],
[[_c2 select 0, _c1 select 1, _c1 select 2], [_c2 select 0, _c2 select 1, _c1 select 2]],
// front bottom left > front top left (vertical)
[[_c1 select 0, _c2 select 1, _c1 select 2], [_c1 select 0, _c2 select 1, _c2 select 2]]
];
true
};
_fnc_drawViVBB = {
private _camPos = (positionCameraToWorld [0,0,0]);
private _nearest = nearestObjects [_camPos, [], 25, false];
{
private _object = _x;
private _dimensions = getArray (configFile >> "CfgVehicles" >> typeOf _object >> "VehicleTransport" >> "Cargo" >> "dimensions");
if !(_dimensions isEqualTo []) then {
_dimensions = _dimensions apply {_object selectionPosition _x};
{
private _d = _object modelToWorldVisual _x;
drawIcon3D ["", [1,0,0,1], _d, 0, 0, 0, "X", 1, 0.05, "PuristaMedium"];
} forEach _dimensions;
[_object, _dimensions] call fnc_drawBB;
};
} forEach _nearest;
};
onEachFrame _fnc_drawViVBB;
if (isNil "whiteboard") then {
whiteboard = "Land_MapBoard_F" createVehicle getPos player;
};
[] spawn {
_cam = "camera" camCreate (whiteboard modelToWorld [0, -1.4, 0.6]);
_cam cameraEffect ["internal", "back"];
_cam camSetTarget (whiteboard modelToWorld [0, 0, 0.35]);
showCinemaBorder false;
_cam camCommit 1;
sleep 0.1;
// AGL
leftUpperCorner = whiteboard modelToWorld [-0.705566,-0.144257,0.950002];
rightBottomCorner = whiteboard modelToWorld [0.733643,-0.329407,-0.0551631];
_topLeft = worldToScreen leftUpperCorner;
_bottomRight = worldToScreen rightBottomCorner;
(_bottomRight vectorAdd (_topLeft vectorMultiply -1)) params ["_w", "_h"];
_display = findDisplay 46 createDisplay "RscDisplayEmpty";
_ctrlDraw = _display ctrlCreate ["RscControlsGroupNoScrollbars", -1];
_ctrlDraw ctrlSetPosition (_topLeft + [_w, _h]);
_ctrlDraw ctrlSetBackgroundColor [0,0,0,0.2];
_ctrlDraw ctrlCommit 0;
with uiNamespace do {
draw_xMin = _topLeft select 0;
draw_xMax = _bottomRight select 0;
draw_yMin = _topLeft select 1;
draw_yMax = _bottomRight select 1;
draw_ctrlLine = controlNull;
draw_startPos = [];
draw_endPos = [];
draw_lines = [];
draw_currentLine = [];
draw_polyline = true;
draw_polylineThreshold = 0.01;
drawing = false;
};
_ctrlDraw ctrlAddEventHandler ["MouseButtonDown", {
params ["_ctrl", "_button", "_x", "_y", "_shift"];
if (_button != 0) exitWith {};
private _display = ctrlParent _ctrl;
with uiNamespace do {
draw_ctrlLine = _display ctrlCreate ["RscLine", -1];
draw_ctrlLine ctrlSetPosition [_x, _y, 0, 0];
draw_ctrlLine ctrlSetTextColor [1,0,0,1];
draw_ctrlLine ctrlCommit 0;
draw_startPos = [_x, _y];
draw_endPos = draw_startPos;
draw_polyline = !_shift;
drawing = true;
};
}];
_ctrlDraw ctrlAddEventHandler ["MouseButtonUp", {
params ["", "_button"];
if (_button != 0) exitWith {};
with uiNamespace do {
if ((draw_startPos vectorDistance draw_endPos) < 0.001) then {
ctrlDelete draw_ctrlLine;
} else {
draw_lines pushBack [draw_polyline, draw_currentLine];
};
drawing = false;
};
}];
_ctrlDraw ctrlAddEventHandler ["MouseMoving", {
params ["_ctrl", "_x", "_y"];
private _display = ctrlParent _ctrl;
with uiNamespace do {
if (!drawing) exitWith {};
_x = draw_xMin max _x min draw_xMax;
_y = draw_yMin max _y min draw_yMax;
draw_endPos = [_x, _y];
(draw_endPos vectorAdd (draw_startPos vectorMultiply -1)) params ["_w", "_h"];
draw_ctrlLine ctrlSetPositionW _w;
draw_ctrlLine ctrlSetPositionH _h;
draw_ctrlLine ctrlCommit 0;
if (draw_polyline) then {
if ((draw_startPos vectorDistance draw_endPos) < draw_polylineThreshold) exitWith {};
draw_currentLine pushBack [draw_startPos, draw_endPos];
draw_ctrlLine = _display ctrlCreate ["RscLine", -1];
draw_ctrlLine ctrlSetPosition [_x, _y, 0, 0];
draw_ctrlLine ctrlSetTextColor [1,0,0,1];
draw_ctrlLine ctrlCommit 0;
draw_startPos = draw_endPos;
} else {
draw_currentLine = [draw_startPos, draw_endPos];
};
};
}];
waitUntil {isNull _display};
_cam cameraEffect ["terminate","back"];
camDestroy _cam;
};
// unfinished
_positions = waypoints driver apc;
_positions = _positions apply {waypointPosition _x};
private _pairs = [];
for "_i" from 0 to (count _positions-1) do {
if (_i >= count _positions-1) exitWith {};
_pairs pushBack (_positions select [_i, 2]);
};
vet_fnc_calculatePath = {
params ["_class", "_path", "_fnc_callback", ["_args", []]];
_path params ["_start", "_end"];
private _agent = nil;
isNil {
_agent = calculatePath [_class, "aware", _start, _end];
_agent forceFollowRoad true;
_agent setVariable ["vet_pathEnd", _end];
_agent setVariable ["vet_callback", _fnc_callback];
_agent setVariable ["vet_args", _args];
_agent addEventHandler ["PathCalculated", {
params ["_agent", "_path"];
_agent removeEventHandler ["PathCalculated", _thisEventHandler];
private _pathEnd = _agent getVariable "vet_pathEnd";
// handle buggy eh behaviour, see wiki
if ([_pathEnd, _pathEnd] isEqualTo _path) exitWith {};
private _lastPos = [-100, -100, 0];
// remove bad positions from path
_path = _path select {
private _result = _x distance _lastPos > 10;
_lastPos = _x;
_result // return
};
private _args = _agent getVariable "vet_args";
[_path, _args] call (_agent getVariable "vet_callback");
}];
};
_agent // return
};
vet_fnc_createPath = {
params ["_path", "_pathId"];
private _items = vet_pathMap getOrDefault [_pathId, [], true];
{
private _sphere = createVehicle ["Sign_Sphere25cm_F", [0,0,0], [], 0, "CAN_COLLIDE"];
_sphere setPosASL _x;
_items pushBack _sphere;
} forEach _path;
};
flatten values vet_pathMap apply {deleteVehicle _x};
vet_pathMap = createHashMap;
vet_pathMapDraw = []; // for ADT debugger
_pairs spawn {
{
private _agent = [typeof apc, _x, vet_fnc_createPath, _forEachIndex] call vet_fnc_calculatePath;
waitUntil {isNull _agent};
} forEach _this;
{
vet_pathMapDraw append (vet_pathMap get _forEachIndex);
} forEach vet_pathMap;
apc limitSpeed 30;
apc setDriveOnPath (vet_pathMapDraw apply {getPosATL _x});
};
// Reset height and width of elements that were set to 0 by a editor bug
private _settings = [];
{
_tag = _x;
_tagName = configname _tag;
_presetName = uinamespace getvariable [_tagName + "preset",""];
_varPreset = if (_presetName == "") then {""} else {"preset_"};
{
private _varName = configname _x;
private _varBase = _tagName + "_" + _varName + "_";
{
private _var = _varBase+_x;
private _val = profileNamespace getVariable _var;
// if width or height is 0 then it's most likely a bug, reset to default
if (!isNil "_val" && {_val == 0}) then {
_settings pushBack [_var, _val];
profileNamespace setVariable [_var, nil];
};
} forEach ["X", "Y", "W", "H"];
} foreach ((_tag >> "variables") call bis_fnc_subClasses);
} foreach ((configfile >> "CfgUIGrids") call bis_fnc_subclasses);
_settings
// init.sqf
// Disable LOW terrain quality in CH View Distance
CHVD_allowNoGrass = false;
// Force grass
setTerrainGrid (48.99 min getTerrainGrid);
_cfgFaces = "isClass _x" configClasses (configfile >> "cfgfaces");
_facesCfg = [];
{
_facesCfg append ("isClass _x" configClasses _x);
} forEach _cfgFaces;
_faces = _facesCfg select {getText (_x >> "head") != ""} select {configName _x != "Default"};
_faces = _faces select {getNumber (_x >> "disabled") != 1};
_faces apply {configName _x}
// https://feedback.bistudio.com/T171135
params [
["_layer", "", [""]],
["_side", sideUnknown, [sideUnknown]]
];
private _units = getMissionLayerEntities _layer param [0, []] select {_x isKindOf "CAManBase"};
private _groups = _units apply {group _x};
if (_side != sideUnknown) then {
_groups arrayIntersect groups _side // return
} else {
_groups arrayIntersect _groups // return
};
/*
Description:
Iterates over an array with processing single element per frame/set delay.
Parameter(s):
_code - Code to execute on each array element [CODE, defaults to {}]
_array - Array to iterate on [ARRAY, defaults to []]
_initFnc - Code to execute when array is empty, must return array. [CODE]
Returned value will be iterated on. By default PFH is removed when array is empty.
_delay - Delay between every element [NUMBER, defaults to 0]
(example begin)
// delete single body every 10s
[
{
systemChat str 'deleting body!';
deleteVehicle _this
},
allDeadMen,
{allDeadMen},
10
] call armaforces_framework_util_fnc_handleArrayOverFrames
(example end)
Returns:
CBA PFH Handle index [NUMBER]
*/
#define DEFAULT_INIT_FNC {call CBA_fnc_removePerFrameHandler}
params [
["_code", nil, [{}]],
["_array", [],[[]]],
["_initFnc", DEFAULT_INIT_FNC, [{}]],
["_delay", 0, [0]]
];
[{
params ["_args", "_pfhId"];
_args params ["_code", "_array", "_initFnc"];
if (_array isEqualTo []) exitWith {
_array = _pfhId call _initFnc;
_args set [1, _array];
};
(_array deleteAt 0) call _code;
}, _delay, [_code, _array, _initFnc]] call CBA_fnc_addPerFrameHandler
// Position in EDEN your objects how you want to have them attached, then add this to objects init:
private _near = nearestObject [this, "LandVehicle"];
[this, _near] call BIS_fnc_attachToRelative;
//
// Execute this to get their relative offsets
(entities "All") apply {
private _attached = attachedObjects _x;
private _vehicle = _x;
if (_attached isEqualTo []) then {nil} else {
private _ret = [
typeOf _x,
-5 // Hardcoded unload offset, might need tweaking
];
{
private _offset = _vehicle worldToModel (_x modelToWorld [0,0,0]);
_ret pushBack _offset;
} forEach _attached;
_ret // return
};
} select {!isNil "_x"};
// KP LIBERATION 0.96 Box transport config tester
//
player setPos [worldSize,worldSize,0];
test_result = [];
test_pos = [worldSize,worldSize + 25,0];
fnc_unload_box = compile preprocessFileLineNumbers "scripts\client\ammoboxes\do_unload_truck.sqf";
test_handle = (+box_transport_config) spawn {
reverse _this; // start from end
// Test every vehicle
test_result = _this apply {
_x params ["_class", "_unloadDist"];
private _offsets = _x select [2, count _x];
if (isClass (configFile >> "CfgVehicles" >> _class)) then {
systemChat ("Testing " + _class);
private _veh = _class createVehicle test_pos;
_veh enableSimulationGlobal false;
_veh allowDamage false;
// Load vehicle with crates
private _crates = _offsets apply {
private _crate = [nil, nil, [0,0,0]] call F_createCrate;
_crate attachTo [_veh, _x];
_crate
};
// Save crates amount for liberation unload func
_veh setVariable ["GRLIB_ammo_truck_load", count _crates];
_veh enableSimulationGlobal true;
_veh allowDamage true;
// Let vehicle "settle" after enabling simulation and damage
sleep 1;
// Save position before unloading crates
private _initialPos = getPos _veh;
_veh call fnc_unload_box;
// There is 1s delay between crates unload
sleep (1 * count _crates);
private _result = [_class, true];
private _currentPos = getPos _veh;
// Compare X, Y only
_initialPos deleteAt 2;
_currentPos deleteAt 2;
// It seems that there is always some small floating point difference not visible in diag_log or str.
// Sooo... stringified arrays ¯\_(ツ)_/¯
if (str _initialPos != str _currentPos) then {
systemchat str _initialPos;
systemchat str _currentPos;
// If vehicle is not standing exactly where it was before unloading something if wrong with offsets
_result = [_class, false];
};
{deleteVehicle _x} forEach _crates + [_veh];
_result
} else {
systemChat ("Missing class: " + _class);
[_class, "missing"]
}
};
systemChat "Test done";
if ((test_result findIf {_x#1 isEqualTo false}) != -1) then {
systemChat "Bad configs found";
} else {
systemChat "All configs are ok";
};
// copyToClipboard str test_result;
diag_log test_result;
};
_building = cursorObject;
_unit = player;
_ladderPoints = _building selectionNames "Memory" select {"ladder_" in _x};
_ladderPositionsAGL = _ladderPoints apply {[_building modelToWorld (_building selectionPosition _x), _x]};
_ladderDists = _ladderPositionsAGL apply {[_unit distance _x#0, _x#1]};
_ladderDists sort true;
_closestLadder = _ladderDists param [0, []] param [1, ""];
if (_closestLadder == "") exitWith {
diag_log format ["No ladder found - %1, %2", typeOf _building, _ladderPoints];
false
};
_closestLadderIdx = parseNumber (_closestLadder splitString "_" select 1) - 1;
_posOnLadder = [0, 1] select ("end" in _closestLadder);
_unit action ["LadderOnUp", _building, _closestLadderIdx, _posOnLadder];
true
// open vehicle doors
this animateDoor ["door_back_R",1];
this animateDoor ["door_back_L",1];
this animateDoor ['door_R',1];
this animateDoor ['door_L',1];
this animateDoor ['Door_L_source',1];
this animateDoor ['Door_rear',1];
this animateDoor ['Door_rear_source',1];
this animateDoor ['Door_1_source',1];
this animateDoor ['Door_2_source',1];
this animateDoor ['Door_3_source',1];
this animateDoor ['Door_LM',1];
this animateDoor ['Door_RM',1];
this animateDoor ['Door_LF',1];
this animateDoor ['Door_RF',1];
this animateDoor ['Door_LB',1];
this animateDoor ['Door_RB',1];
this animateDoor ['DoorL_Front_Open',1];
this animateDoor ['DoorR_Front_Open',1];
this animateDoor ['DoorL_Back_Open',1];
this animateDoor ['DoorR_Back_Open ',1];
// Classes or models of objects to remove
_rm = [
"Land_ToiletBox_F",
"Land_FieldToilet_F",
"Land_Kiosk_blueking_F",
"Land_Kiosk_redburger_F",
"Land_Kiosk_gyros_F",
"Land_Kiosk_papers_F",
"vergepost_f.p3d"
];
_pos = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
_toHide = nearestObjects [_pos, [], worldSize, false];
_toHideFiltered = _toHide select {typeOf _x in _rm || {((getModelInfo _x)#0) in _rm}};
{
_x hideObjectGlobal true;
} forEach _toHideFiltered;
draw_dist = 75;
show_simple_objects = true;
if (show_simple_objects) then {
fnc_getName = {[typeOf _this, (getModelInfo _this)#0] select (typeOf _this == "")};
} else {
fnc_getName = {typeOf _this};
};
_fnc_draw = {
private _camPos = (positionCameraToWorld [0,0,0]);
private _nearest = nearestTerrainObjects [_camPos, [], draw_dist, false];
{
drawIcon3D ["", [1,0,0,1], ASLToAGL getPosASL _x, 0, 0, 0, _x call fnc_getName, 1, 0.05, "PuristaMedium"];
} forEach _nearest;
};
onEachFrame _fnc_draw;
removeMissionEventHandler ["Draw3D", missionNamespace getVariable ["AF_friendlyDrawEH", -1]];
AF_friendlyDrawEH = addMissionEventHandler ["Draw3D", {
private _playerGrp = (units group player);
{
drawIcon3D [
"",
[
[.5,0,0,.5],
[0,.5,0,.5]
] select alive _x,
_x modelToWorldVisual ((_x selectionPosition "pilot") vectorAdd [0,0,.1]),
0,
-2,
0,
name _x,
2,
0.03,
"TahomaB",
"center",
true
];
} forEach _playerGrp - [player]
}];
// respawn group if more than X in group dead
if (!isServer) exitWith {};
#define RESPAWN_TIME 30
#define RESPAWN_THRESHOLD 0.5
private _stateMachine = [{allGroups select {isPlayer leader _x}}, true] call CBA_statemachine_fnc_create;
[_stateMachine, {}, {}, {}, "operational"] call CBA_statemachine_fnc_addState;
[_stateMachine, {}, {}, {}, "respawning"] call CBA_statemachine_fnc_addState;
[_stateMachine, {}, {}, {}, "respawned"] call CBA_statemachine_fnc_addState;
[_stateMachine, "operational", "respawning",
{
({alive _x} count units _this) < (RESPAWN_THRESHOLD * count units _this)
},
{
systemChat "group respawning";
[RESPAWN_TIME] remoteExec ["setPlayerRespawnTime", _this];
_this setVariable ["AF_respawnTime", diag_tickTime + RESPAWN_TIME];
},
"start_respawning"
] call CBA_statemachine_fnc_addTransition;
[_stateMachine, "respawning", "respawned",
{
diag_tickTime > (_this getVariable "AF_respawnTime")
},
{
_this setVariable ["AF_respawnCooldown", diag_tickTime + RESPAWN_TIME];
//[1e10] remoteExec ["setPlayerRespawnTime", _this];
["Terminate"] remoteExecCall ["BIS_fnc_EGSpectator", _this];
},
"end_respawning"
] call CBA_statemachine_fnc_addTransition;
[_stateMachine, "respawned", "operational",
{
diag_tickTime > (_this getVariable "AF_respawnCooldown")
},
{
systemChat "group respawned";
},
"respawn_done"
] call CBA_statemachine_fnc_addTransition;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment