Created
February 27, 2023 15:32
-
-
Save Oscar-Geare/51c0ffa1c014db547b0480caf81deb81 to your computer and use it in GitHub Desktop.
Put the top codeblock in the "On Activation" for a "Radio" repeatable radio trigger. It should create an LZ and a task for it. Haven't worked out how to cancel the current task yet, so oh well, don't create a billion tasks. To fix later (pronounced /ˈnɛvə/))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_currTask = player call bis_fnc_tasksCurrent; | |
if (not isNil (_currTask select 0)) then { [(_currTask select 0),"CANCELED"] call bis_fnc_taskSetState; }; | |
searchRadiusMin = 5000; | |
searchRadiusMax = 8000; | |
landingZoneSize = 10; | |
landingZoneSlope = 0.25; | |
smokeDistance = 2000; | |
playerPos = getPos player; | |
randomPos = [playerPos, searchRadius, searchRadiusMax, landingZoneSize, 0, landingZoneSlope] call BIS_fnc_findSafePos; | |
markerName = format ["LandingZone_%1", str(random 1000)]; | |
_marker = createMarker [markerName, randomPos]; | |
gridRef = mapGridPosition randomPos; | |
_marker setMarkerType "hd_dot"; | |
_marker setMarkerText gridRef; | |
ingressDir = ["N", "NW", "W", "SW", "S", "SE", "E", "NE"] call BIS_fnc_selectRandom; | |
egressDir = ["N", "NW", "W", "SW", "S", "SE", "E", "NE"] call BIS_fnc_selectRandom; | |
hint format ["%1\nSmoke\nNo Obstacles\nNo Friendlies\nNo Factor\n2Kms Smoke will be popped\nIngress %2 Egress %3", gridRef, ingressDir, egressDir]; | |
_taskName = "Move to Landing Zone"; | |
_taskDescription = format ["%1<br/>Smoke<br/>No Obstacles<br/>No Friendlies<br/>No Factor<br/>2Kms Smoke will be popped<br/>Ingress %2 Egress %3", gridRef, ingressDir, egressDir]; | |
chars = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"]; | |
randomString = ""; | |
for "_i" from 1 to 10 do { randomChar = selectRandom chars; randomString = randomString + randomChar; }; | |
[player, randomString, [_taskDescription, _taskName, _marker], randomPos, true] call BIS_fnc_taskCreate; | |
[] spawn { waitUntil {(player distance randomPos) < smokeDistance}; | |
_smoke = "SmokeShellGreen" createVehicle randomPos; | |
hint "Smoke Deployed"; | |
}; | |
[] spawn { waitUntil {(player distance randomPos) < 50 }; | |
[randomString,"SUCCEEDED"] call bis_fnc_taskSetState; | |
hint "Task Complete"; | |
}; | |
deleteMarker _marker; | |
// COPY EVERYTHING ABOVE // | |
// COMMENTS DON'T WORK IN RADIO TRIGGERS // | |
// Trying to remove any current task. The task selection doesn't appear to be working so this doesn't do anything atm | |
_currTask = player call bis_fnc_tasksCurrent; | |
if (not isNil (_currTask select 0)) then { [(_currTask select 0),"CANCELED"] call bis_fnc_taskSetState; }; | |
// vars to change if you want | |
searchRadiusMin = 5000; | |
searchRadiusMax = 8000; | |
landingZoneSize = 10; | |
landingZoneSlope = 0.25; | |
smokeDistance = 2000; | |
// get player pos and finds somewhere thats within the search radius, not on a stupid slope, on land, and with no obstacles within 10m | |
playerPos = getPos player; | |
randomPos = [playerPos, searchRadiusMin, searchRadiusMax, landingZoneSize, 0, landingZoneSlope] call BIS_fnc_findSafePos; | |
// Create marker. Theres some redundancy here. Sue me | |
markerName = format ["LandingZone_%1", str(random 1000)]; | |
_marker = createMarker [markerName, randomPos]; | |
gridRef = mapGridPosition randomPos; | |
_marker setMarkerType "hd_dot"; | |
_marker setMarkerText gridRef; | |
// Create randomised ingress and egress directions | |
ingressDir = ["N", "NW", "W", "SW", "S", "SE", "E", "NE"] call BIS_fnc_selectRandom; | |
egressDir = ["N", "NW", "W", "SW", "S", "SE", "E", "NE"] call BIS_fnc_selectRandom; | |
// Pop a LZ Brief Hint | |
hint format ["%1\nSmoke\nNo Obstacles\nNo Friendlies\nNo Factor\n2Kms Smoke will be popped\nIngress %2 Egress %3", gridRef, ingressDir, egressDir]; | |
// Create a task | |
_taskName = "Move to Landing Zone"; | |
// Task description uses HTML | |
_taskDescription = format ["%1<br/>Smoke<br/>No Obstacles<br/>No Friendlies<br/>No Factor<br/>2Kms Smoke will be popped<br/>Ingress %2 Egress %3", gridRef, ingressDir, egressDir]; | |
// Creating a random ID for the task, so the task can be repeatable | |
chars = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"]; | |
randomString = ""; | |
for "_i" from 1 to 10 do { randomChar = selectRandom chars; randomString = randomString + randomChar; }; | |
[player, randomString, [_taskDescription, _taskName, _marker], randomPos, true] call BIS_fnc_taskCreate; | |
// Wait until the player is close and deploy a smoke grenade. I think this will cause a memory leak if not triggered. Need to do something about that. spawn [] essentially spins itself off into it's own thread so it needs to be closed by something | |
[] spawn { waitUntil {(player distance randomPos) < smokeDistance}; | |
_smoke = "SmokeShellGreen" createVehicle randomPos; | |
hint "Smoke Deployed"; | |
}; | |
// Another memory leak maybe if the task isn't succeeded | |
[] spawn { waitUntil {(player distance randomPos) < 50 }; | |
[randomString,"SUCCEEDED"] call bis_fnc_taskSetState; | |
hint "Task Complete"; | |
}; | |
// clean up the map | |
deleteMarker _marker; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment