Jump to content
Sign in to follow this  
Kydoimos

Spawned Units Won't Attack

Recommended Posts

I can't seem to make some spawned units attack the enemy:

FIA = createAgent ["B_G_engineer_F", (getMarkerPos "FIA"),[], 0, "NONE"];

Spawns a unit - but I placed a group of OPFOR units in from of him and he doesn't fire? What gives? Thanks as always for any help!

Share this post


Link to post
Share on other sites

try createVehicle or createUnit, i never used createAgent, so i don't know how it's behave.

Share this post


Link to post
Share on other sites

Check the INTEL options in your editor. Make sure Independents aren't set to be friendly to OPFOR.

Share this post


Link to post
Share on other sites

You need to take care about factions and sides. I haven't used FIA units yet, but it seems as if they are sort of a special role and can be any side. Also, don't use createAgent. That is sort of a strange thing (to my consideration) and probably not what you want.

You could "manually" force them to fire though. I did it like this:

[color=#FF8040][color=#1874CD]_aiUnit[/color]    [color=#8B3E2F][b]=[/b][/color] yourFIAunitGroup [color=#191970][b]createUnit[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"B_G_engineer_F"[/color][color=#8B3E2F][b],[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#191970][b]getMarkerPos[/b][/color] [color=#7A7A7A]"FIA"[/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b],[/b][/color][color=#8B3E2F][b][[/b][/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b],[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b],[/b][/color] [color=#7A7A7A]"NONE"[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#1874CD]_aiUnit[/color] [color=#191970][b]spawn[/b][/color]
[color=#8B3E2F][b]{[/b][/color]
   [color=#191970][b]while[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#191970][b]alive[/b][/color] [color=#000000]_this[/color][color=#8B3E2F][b]}[/b][/color] [color=#191970][b]do[/b][/color]
   [color=#8B3E2F][b]{[/b][/color]
       [color=#191970][b]scopeName[/b][/color] [color=#7A7A7A]"unitAliveScope"[/color][color=#8B3E2F][b];[/b][/color]

       [color=#8B3E2F][b]{[/b][/color]
           [color=#191970][b]if[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#191970][b]side[/b][/color] [color=#000000]_x[/color] [color=#191970][b]isEqualTo[/b][/color] [color=#000000]opfor[/color] [color=#8B3E2F][b]&[/b][/color][color=#8B3E2F][b]&[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#000000]_this[/color] [color=#191970][b]distance[/b][/color] [color=#000000]_x[/color] [color=#8B3E2F][b]<[/b][/color] [color=#FF0000]200[/color][color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color]
           [color=#8B3E2F][b]{[/b][/color]
               [color=#000000]_this[/color] [color=#191970][b]doTarget[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b];[/b][/color]
               [color=#000000]_this[/color] [color=#191970][b]doFire[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b];[/b][/color]
               [color=#191970][b]waitUntil[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#191970][b]sleep[/b][/color] [color=#FF0000]3[/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]![/b][/color][color=#191970][b]alive[/b][/color] [color=#000000]_this[/color] [color=#8B3E2F][b]|[/b][/color][color=#8B3E2F][b]|[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#000000]_this[/color] [color=#191970][b]distance[/b][/color] [color=#000000]_x[/color] [color=#8B3E2F][b]>[/b][/color] [color=#FF0000]200[/color][color=#8B3E2F][b]}[/b][/color] [color=#8B3E2F][b]|[/b][/color][color=#8B3E2F][b]|[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#8B3E2F][b]![/b][/color][color=#191970][b]alive[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color]
               [color=#191970][b]breakTo[/b][/color] [color=#7A7A7A]"unitAliveScope"[/color][color=#8B3E2F][b];[/b][/color]
           [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color]
       [color=#8B3E2F][b]}[/b][/color] [color=#191970][b]forEach[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#000000]_this[/color] [color=#191970][b]nearEntities[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"Man"[/color][color=#8B3E2F][b],[/b][/color] [color=#FF0000]350[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b];[/b][/color]
   [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color][/color]

Kudos to Killzone_Kid for his SQF to BBCode Converter.

I did it a slight bit differently, but this should work, too. That way, the AI unit (your FIA unit) recognizes every unit closer than 350 m and will start shooting as soon as it's closer than 200 m.

Kind regards and good luck,

waltenberg aka Johnny

Edited by waltenberg

Share this post


Link to post
Share on other sites

Thanks for the speedy responses guys! I'm sure the problem was that I was using createAgent rather than createUnit! I completely missed the createAgent command! Quite handy to know though, that it'll spawn a unit which doesn't react to anything!

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  

×