Jump to content

Recommended Posts

Does anyone have a working example of creating a spawn AI module via a script?

Simply doing this with _pos being defined, doesn't seem to do anything.

(createGroup sideLogic) createUnit ["ModuleSpawnAI_F",_pos,[],0,"NONE"];

 

Share this post


Link to post
Share on other sites

There's lots of ways to spawn dudes. What do you want to accomplish? You can effectively create your own spawn module with a bit of script. Post what you want to do and there's probably a better way than the AI module.

If you just want to delay the Module activation attach it to a trigger.

Share this post


Link to post
Share on other sites
On 7/20/2019 at 12:58 AM, wogz187 said:

There's lots of ways to spawn dudes. What do you want to accomplish? You can effectively create your own spawn module with a bit of script. Post what you want to do and there's probably a better way than the AI module.

If you just want to delay the Module activation attach it to a trigger.

 

Agree with him, there are a lot of ways to do that.

 

For example with the createUnit command:

https://community.bistudio.com/wiki/createUnit

 

 

Here is a simple example:

 

_group = creategroup “east“;

_pos = getpos player;

_unit = "B_RangeMaster_F" createUnit [_pos, _group];

 

--> spawns 1 Soldier next to the player 

 

 

If you want to spawn more than 1 unit use (for example) the for-loop:

 

_c = 5;

_group = creategroup “east“;

for "_i" from 1 to _c do

{

_pos = getpos player;

_unit = "B_RangeMaster_F" createUnit [_pos, _group];

};

 

 

 

/////////////////////////////////\\\\\\\\\\\\\\\\\\

 

init.sqf:

[] execVm “functions.sqf“;

 

functions.sqf:

fnc_spawn =

{

_c = _this select 0;

_group = creategroup (_this select 1);

for "_i" from 1 to _c do

{

_pos = getpos player;

_unit = "B_RangeMaster_F" createUnit [_pos, _group];

sleep 0.25;

};

};

 

 

call the function (example):

[4,“east“] spawn fnc_spawn;

 

 

--> you could also spawn a random unit

(create an array with the classnames)

troops = [“cname1“, “cname2“, ...];

 

then (example):

_unit = (selectrandom troops) createUnit [_pos, _group];

 

 

 

Dont forget: 

It's just one way to spawn units

 

 

  • 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

×