Jump to content

Recommended Posts

Hi,

 

I searching for a way to spawn units randomly in a marker.

I've tried something with radius etc but it seems that units spawn even out of the marker and even on water...

 

I'd like to spawn those units only on ground and in the definided marker.

And I have another problem,

The units I try to spawn are zombies...
And when I choose to spawn 2000 of them with a debug marker to know where each zombies are, I don't find any zombies at the markers positions... is there any units limit on Arma 3 ?

  • Like 1

Share this post


Link to post
Share on other sites

To prevent unit spawning on water you can use surfaceIsWater command to check the spawn pos.

 

post the code you have so far to here so people can help you better.

 

  • Thanks 1

Share this post


Link to post
Share on other sites

There is the code I'm using :

 

Trigger :

[200,"mkr_z"] execVM "Init_Z.sqf";


Init_Z :

 

if (isServer) then {

 

// Set probability of Zombies spawning 1-100%
_probability = 80;

 

// Show Zombies position on map (Debugging)
_showZ = true;

 

// Set Zombies classes
Zombies_Slow = ["RyanZombieC_man_1slowOpfor","RyanZombieC_man_polo_1_FslowOpfor","RyanZombieC_man_polo_2_FslowOpfor","RyanZombieC_man_polo_4_FslowOpfor","RyanZombieC_man_polo_5_FslowOpfor","RyanZombieC_man_polo_6_FslowOpfor","RyanZombieC_man_p_fugitive_FslowOpfor","RyanZombieC_man_w_worker_FslowOpfor","RyanZombieC_scientist_FslowOpfor","RyanZombieC_man_hunter_1_FslowOpfor"];
Zombies_Medium = ["RyanZombieC_man_1mediumOpfor","RyanZombieC_man_polo_1_FmediumOpfor","RyanZombieC_man_polo_2_FmediumOpfor","RyanZombieC_man_polo_4_FmediumOpfor","RyanZombieC_man_polo_5_FmediumOpfor","RyanZombieC_man_polo_6_FmediumOpfor","RyanZombieC_man_p_fugitive_FmediumOpfor","RyanZombieC_man_w_worker_FmediumOpfor","RyanZombieC_scientist_FmediumOpfor","RyanZombieC_man_hunter_1_FmediumOpfor"];
Zombies_Fast = ["RyanZombieC_man_1Opfor","RyanZombieC_man_polo_1_FOpfor","RyanZombieC_man_polo_2_FOpfor","RyanZombieC_man_polo_4_FOpfor","RyanZombieC_man_polo_5_FOpfor","RyanZombieC_man_polo_6_FOpfor","RyanZombieC_man_p_fugitive_FOpfor","RyanZombieC_man_w_worker_FOpfor","RyanZombieC_scientist_FOpfor"];

private ["_distance"];

 

_rad1 = _this select 0;
_mkr=(_this select 1);
_mkr setmarkerAlpha 0;
_pos=markerpos _mkr;
_mkrY= getmarkerSize _mkr select 0;
_mkrX= getmarkerSize _mkr select 1;

_distance=_mkrX;


if (_mkrY > _mkrX) then

{
     _distance=_mkrY;

 };


for "_n" from 0 to 40 do

{

    _Zpos=[(getMarkerPos _mkr select 0)-_rad1*sin(random 199),(getMarkerPos _mkr select 1)-_rad1*cos(random 199)];
    if (_probability > random 100) then

   {
    null=[_Zpos,_showZ] execVM "Spawn_Z.sqf";
    };
};
};


Spawn_Z.sqf : 

 

if (isServer) then {
_Zpos=    (_this select 0);
_pos0=    (_Zpos select 0);
_pos1=    (_Zpos select 1);
_showZ=    (_this select 1);

 

_BARREL = createVehicle ["Land_BarrelEmpty_F",[_pos0,_pos1,0], [], 0, "can_Collide"];

sleep 0.5;
_holder = createVehicle ["groundweaponholder",[_pos0,_pos1,0], [], 0, "can_Collide"];
deletevehicle _BARREL;
            
_type = random 2;

    if (_showZ) then 

    {            
        _id=format ["%1",_Zpos];
        _debug=createMarker [_id,GETPOS _holder];
        _debug setMarkerShape "ICON";
        _debug setMarkerType "hd_dot";
        _debug setMarkerColor "ColorBlack";
        _debug setMarkerText "Z";
    };
    

hint "marker on"; //debug
                        
// Spawn Slow Zombie
 if (_type == 0) then 
    {
    _eGrp = createGroup EAST;
    _Zunit = _eGrp createUnit [(Zombies_Slow call bis_fnc_selectRandom),position _holder, [], 0, "NONE"];
    hint "zombie spawned"; //debug
    };
                    
                    
// Spawn Medium Zombie
 if (_type == 1) then 
    {
    _eGrp = createGroup EAST;
    _Zunit = _eGrp createUnit [(Zombies_Medium call bis_fnc_selectRandom),position _holder, [], 0, "NONE"];
    hint "zombie spawned"; //debug
    };
    };
                
                // Spawn Medium Zombie
 if (_type == 2) then 
    {
    _eGrp = createGroup EAST;
    _Zunit = _eGrp createUnit [(Zombies_Fast call bis_fnc_selectRandom),position _holder, [], 0, "NONE"];
    hint "zombie spawned"; //debug
    };
    };

};

    

Share this post


Link to post
Share on other sites

@Touhou did you write that code your self?

 

in:

_Zpos=[(getMarkerPos _mkr select 0)-_rad1*sin(random 199),(getMarkerPos _mkr select 1)-_rad1*cos(random 199)];

I think 199 should be 360

 

other than that I don't see any problem...

 

the spawn area is defined in  _rad1

so you need to lower that value if the units are spawning out of the marker

 

and create some kind of loop that checks valid positions with the surfaceIsWater command

Share this post


Link to post
Share on other sites
11 hours ago, Touhou said:

spawn 2000 of them

 

Hello there Touhou!

 

I wanted to tell you that , just have in mind , every unit , thing , item anything is costing fps.

So in order to have steady and playable fps , you must have a consistency in the hole mission.

You can't just spawn at once crazy numbers of units.

 

If you don't want to bother with a unknown spawn script ,

you can use a spawn script (there are a lot if you search)

to create your mission easier and the most of them  , wil contain a tutorial on how to.

  • Like 1

Share this post


Link to post
Share on other sites

It's ok, I found myself how to make my script working properly.

I spowned 3000 Zombies on Malden (but some of them are in water so they are instantly deleted) and there is no FPS cost.

Share this post


Link to post
Share on other sites

The thing is to spawn and de-spawn , on certain distances with steady numbers.

Further more , search about headless clients , if you want theese numbers.

Share this post


Link to post
Share on other sites

There is the 288 group (per side) limitations anyway. If zombies are civilians and not grouped each others, I'm not sure you can have more than 288 of them.

  • Like 1

Share this post


Link to post
Share on other sites

I advise you to spawn zombies in distance of player that player cant see and also despawn zombies from x distance of player becouse that amout of AI on the server will lagout the hole server and the more players you have the grater the lag

  • Like 1

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

×