Jump to content
Sign in to follow this  
zorilya

AI spawning behaviour problem

Recommended Posts

I've been condensing a mission into script form so it can be spawned at will and used as an objective (it's a small smash and grab mission) anyway...

problem is when i create my group of enemies i use the createUnit command and a for var loop:

_grpeast = createGroup EAST;

"RU_Commander" createUnit [[0,0,0],_grpeast,"this = leader _grpeast;nul = [this,_area] execVM 'Garrison_script.sqf';",0.5,"LIEUTENANT"];

for "_i" from 0 to 8 do {(_enemymen select (round (random ((count _enemymen) -1)))) createUnit [[0,0,0],_grpeast];};

{_x setPos (getPos _location);} foreach units _grpeast;

The _enemymen var is an array full of unit class names which as you can see, it randomly pick from.

despite my group being of side EAST the units spawned by this command are passive to WEST units.

any thoughts?

Share this post


Link to post
Share on other sites

For some reason it may be fucking up try doing this after your script.

EAST setFriend [WEST, 0];
WEST setFriend [EAST, 0];
{_x setCaptive false;} forEach units _grpeast;

If it still isn't working after that, I don't know what to tell you :P.

Share this post


Link to post
Share on other sites

the setFriend worked fine man thanks...... any ideas why your AI spawnees come out without an enemy in mind?

Share this post


Link to post
Share on other sites

I would have no idea. I've written random spawning scripts before and never had to use setFriend. Odd one, but I guess just be happy there's a solution and who cares about an answer, amiright?

Share this post


Link to post
Share on other sites

well not exactly.... i've personally believe that full understanding of anything allows for further and greater, use and appreciation. If you build something but don't understand why it is the way it is, then you can't diagnose and repair effectively which is almost as bad as not having created it in the first place. Best you can do in those circumstances is take the opportunity to watch and draw a better understanding from what you don't understand.

just my thoughts :)

thanks again.

Share this post


Link to post
Share on other sites

When units are spawned they seem to be neutral unless there is a unit of that side on the map, the unit can have probability of presence set to zero.

The above Setfriend seems to mimic this to some degree.

I've tried it and it seems a little hit and miss.

Sometimes I can walk right through them and other times they open fire.

It seems distance related.

Have them spawn on top of you and they don't fire, spawn them about 150 meters away and they shoot you.

Share this post


Link to post
Share on other sites

Oh now I remember, yeah F2k is right. Place down a non-playable unit of each faction in like the corner of the map with possibility of presence set to 0 and you should never get that problem :D That's what MSO did.

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  

×