Jump to content
Sign in to follow this  
hridaysabz

How to spawn units in sea

Recommended Posts

Hey everyone. I was wondering if it would be possible to filter the sea on a marker that spans the entire map? I'm writing a script where I need the ammobox to spawn in a place anywhere in the sea. I wasn't wanting to place several markers and selecting one randomly, but if that's how it has to be done, so be it.

Plus, can you correct me on this script?

Doesn't seem to be working right.

/*
Welcome to the Sea Ammobox script. This script places a random ammobox in the sea at defined markers.
Variables defined can be changed to suit your needs. 
Code by : Hridaysabz
*/

//Ammobox types listed for your discretion.
//Classnames      |      Type
//Box_NATO_Ammo_F | Ammo
//Box_NATO_Wps_F  | Weapons
//Box_NATO_AmmoOrd_F | Explosives
//Box_NATO_Grenades_F| Grenades
//Box_NATO_WpsLaunch_F| Launchers
//Box_NATO_WpsSpecial_F| Special Weapons
//B_supplyCrate_F | Supply Box
//Box_NATO_Support_F | Support Box
//Box_NATO_AmmoVeh_F | Vehicle Ammo Box

//Variables
_ammobox = [box_NATO_Ammo_F, Box_NATO_Wps_F, Box_NATO_AmmoOrd_F, Box_NATO_Grenades_F, Box_NATO_WpsLaunch_F, Box_NATO_WpsSpecial_F, B_supplyCrate_F, Box_NATO_Support_F, Box_NATO_AmmoVeh_F] call bis_fnc_selectRandom
_spawnpoints = [diverbox, diverbox2, diverbox3, diverbox4, diverbox5, diverbox6] //Markers to be spawned on.

//Do not edit below this.
if (!isServer) exitWith {};

while {alive player} do {
_spawncrate = "_ammobox" createVehicle (getMarkerPos "_spawnpoints");
};

_pos = getpos "_ammobox"

//hint with ammobox details and marker - Editable
hint "We have located an ammobox at _pos, it has been marked on the map. It is an underwater stash so you will need to get diver equipment."
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
_marker = createMarker ["DiverMarker", _pos]
"DiverMarker" setMarkerType "Flag"
"DiverMarker" setMarkerText "Underwater Stash"

Edited by Hridaysabz

Share this post


Link to post
Share on other sites

I use the following code to place the Nimitz on the sea randomly. The center pos is the player and a 30km circle around it is searched:

private ["_pos"];
_pos = [];
while {count _pos == 0} do {
       _pos = [[[getPos player, 30000]], ["out", "ground"], {true}] call BIS_fnc_randomPos;

       // refine it, not too close to shore?
       _pos = _pos isflatempty [1000, 0, 0, 1000, 2, true, ObjNull];
};

TeTeT

Share this post


Link to post
Share on other sites

use the standard game function : BIS_fnc_findSafePos

you can find them in the editor, Fx, this function can find a land, sea and coast position.

Share this post


Link to post
Share on other sites

Thanks guys, the position find seems fine but the code as a whole doesn't work. ideas?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×