Jump to content
Sign in to follow this  
Bagel

Enemy ai artillery

Recommended Posts

Is there a way that I can run a script that will be able to run through all my units and check if a named emeny unit "KnowsAbout" them , and then take the actual unit that it knowsabout and passes it as a variable to another part of the script.

I want to simulate AI artillery by checking to see if an enemy spotter has seen a unit and which one, he will then direct artillery to the position. If I use "List" to get a list of all units detected by a trigger, how do I step through the list and check each of my units for "knowsabout" and then thereafter pass the position of the unit to another part of the script in order to direct the artillery fire to that units position.

Right now the script works fine, but I have to specify each unit I want checked for "knowsabout" in the script itself, I am looking for a more genric, dynamic solution that could be applied to any mission without having to insert the names of the units in the script itself.

Thanks sad.gif

Share this post


Link to post
Share on other sites

Just another thought folloiwng the first post,

when you create friendly units are they allocated a sequential object ID, starting at a given number. This would allow stepping through all object ID's of own forces to get the pos of the unit that the enemy spotter "Knowsabout"

Share this post


Link to post
Share on other sites

Plese copy and paste your script here. It'll be much easier and faster to do something with it then.

Share this post


Link to post
Share on other sites

Don't have it on me, it's at home.

It looks like this:

---------------------------------------------------------

?(observer knowsabout unit1): _pos = getpos unit1

?(observer knowsabout unit1): goto "ARTTY"

?(observer knowsabout unit2): _pos = getpos unit2

?(observer knowsabout unit2): goto "ARTTY"

?(observer knowsabout unit3): _pos = getpos unit3

?(observer knowsabout unit3): goto "ARTTY"

?(observer knowsabout unit4): _pos = getpos unit4

?(observer knowsabout unit4): goto "ARTTY"

~30

#ARTTY

this is where I start the loop for 10 rounds , created by camcreate at the location _pos+(random 200 + random -200)

exit

-----------------------------------------------------------

What I am trying to do is not have to manually insert every unit name (unit1, unit2 etc) as first it is a pain and secondly if the soldier called "Unit1" is killed his group will no longer attract fire.

I want to be able to run through all the units of a given side, check to see if the enemy "knowsabout" it and then if it does , get the position of the detected squad and pass it to the artillery piece of the script.

Share this post


Link to post
Share on other sites

why dont you just setup a trigger covering the desired area and set it´s activation to "detected by east / west..."

Set the trigger to repeat.

Then read out trigger content and start your barrage. Should work, shouldnt it ?

Share this post


Link to post
Share on other sites

That what I am trying to figure out , how do you "read out" the trigger content. How do you get the content of a trigger into a usable variable format that you can selct and manipulate.

Share this post


Link to post
Share on other sites

I understand how to use the list command to get the data from the trigger, what I want to know is is it possible to take that list and select from it and use anyone of the objects listed in the data list. e.g. the return on list could be [unit1,unit2,unit3,unit4]. How do I take unit3 out of the list and get its position with a getpos command for instance.

Balschoiw, the detect trigger might work, but what if the trigger returns two units that it detects ?

I want to do something like this:

_pos = getpos (list trigger select 0)

trigger being West detected by East, might work?

Share this post


Link to post
Share on other sites

Trigger returns array of units. So on activation put :

[thislist,spotter] exec "detection.sqs"

You can use area detection trigger or you can use it on startup so even eneny units splits up, script will be checking knowsabout value. (I think 2nd way is better)

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_units=_this select 0

_spot=_this select 1

#start

_i=count _units

#check

_i=_i-1

_un=_units select _i

?(_spot knowsabout _un)>2:goto "gotcha"

~1

?_i>0:goto "check"

goto "start"

#gotcha

_pos=getpos _un

;you can call artilery now by :

;[_pos] exec "artilery.sqs"

;or include it in script

<span id='postcolor'>

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  

×