Jump to content

Recommended Posts

Hello all,

 

I'm trying to get the following script to work, but I get the following error when the AI tries to call artillery fire: 'scalar  |# |bool array string 0xfcffffefo': Error unknown operator bool

 

Script:

Spoiler

;----------------------------------------------------------
; Easy AI Unified Artillery
;
; By General Barron
; aw_barron@hotmail.com
; 8/11/04   v1.0
;----------------------------------------------------------
;
; NOTE: THIS SCRIPT REQUIRES THE CHAIN OF COMMAND'S UNIFIED ARTILLERY ADDON

; This script lets the specified AI call for artillery fire automatically. 
;The AI will try to call arty whenever enemies are detected. They will 
;only call a strike if no friendlies are within 75 meters of the target.
;
; To adjust how many rounds are fired per strike, as well as the radio 
;chatter used, go to the bottom of this script.
;
; Note that this is a simple script, and the AI won't do things like adjust
;theiraimpoints. I suggest you use the "zero bias error" gamelogic with this 
;script, or else the arty strikes won't be very accurate. I also suggest you
;set the skill of the artillery units to 100%.
;
;      TO USE THE SCRIPT:
;
;Place a CoC Obelisk for whichever side(s) will be using the artillery.
;
;Place the following files in your mission directory:
;   ai_arty_ua.sqs
;   findUnits.sqf
;   knownUnits.sqf
;
;Place these lines in your init.sqs:
;   knownUnits = preprocessFile "knownUnits.sqf"
;   findUnits = preprocessFile "findUnits.sqf"
;
;Place this line in the init field of each AI artillery spotter:
;   [this, "enemy array name", "friendly array name", arty group name] exec "ai_arty_ua.sqs"
;
;"enemy/friendly array name" - the name of the arrays that will be considered
;   friendly/enemy to this observer. NOTE: This is the variable name IN QUOTES.
;   Note that you could also put civilians in the friendly array, to prevent AI from
;   causing civilian casulties.
;   I suggest that you DO NOT add your artillery units to the enemy array. Doing so could cause the AI to call
;   artillery down on the opposing side's artillery, without actually seeing where it is.
;   For info on why it must be in quotes, check here: http://www.ofpec.com/editors/comref.php?letter=3#Array assignment
;
;arty group name - group that is in the artillery guns. MAKE SURE TO PLACE THIS GROUP BEFORE
;    PLACING OTHER UNITS. Otherwise, the group might not "exist" yet before the script is executed.
;
;EXAMPLE: Place a trigger, activation: west present. On activation: west_units = thislist
;   Place another trigger, activation: east present. On activation: east_units = thislist
;   Place a howitzer, and put this in his init field: west_arty = group this
;   Place a west soldier, and put this in his init field:
;      [this, "east_units", "west_units", west_arty] exec "ai_arty_ua.sqs"
;
;----------------------------------------------------------

_observer = _this select 0
_enemies = _this select 1
_friends = _this select 2
_arty = _this select 3

;wait for UA to initialize
~60
_Artyposture = ((leader _arty) call CoCfIFFindAsset) + "p"

#Loop
~15
;loop until enemy detected or unit is killed
? !(alive _observer) : exit
? ("Land" countType ([_observer, call _enemies, false] call knownUnits)) > 0 : goto "Next"
goto "Loop"

#Next
;go back if arty is unavailable
? (Call _ArtyPosture) > 0 : goto "Loop"
_knownEnemies = [_observer, call _enemies, true] call knownUnits
_i = 0
_max = count _knownEnemies

;loop until a target is found with no friendlies nearby
#FindTarget
     _target = _knownEnemies select _i
;    The number below (after _target) is the distance around the target that must be clear of friendlies to call the strike
;    EG: 75 means no strike can be called on that target if any friends are within 75 meters of the target.
;    This number should be increased if the arty you are using covers a larger strike area (such as MLRS)
     ?  count ([_target, 150, call _friends, false] call findUnits) == 0 AND "Land" countType [_target] == 1 : goto "CallStrike"
     _i = _i + 1
     ? _i < _max : goto "FindTarget"

;if no safe targets, wait, then go back to beginning
~60
goto "Loop"


;----------------------------------------------------------
; EDITABLE PORTION OF SCRIPT BELOW
;----------------------------------------------------------

#CallStrike

;Replace this with the text of your choosing.
;I suggest you use this function to display the actual grid coords of the strike:
; http://www.ofpec.com/editors/funcref.php?filter_func=11
_observer sidechat format ["Requesting artillery support at grid %1.", [getpos _target] call GridCoord]
_observer sidechat "Requesting artillery support!"

;The number after [getpos _target] is how many rounds each unit will fire for the strike.
;EG: Putting a '5' here will make each arty unit fire 5 rounds each time the AI calls for fire.
;Check your UA documentation for a description of the other parameters.
[_arty, [getpos _target], 3, 0, 0, 0, true] Call CoCfIFCallFire

~60
goto "Loop"
;----------------------------------------------------------

 

I'm not a scripter, so I'm not sure what the exact problem is. Any assistance appreciated!

Share this post


Link to post
Share on other sites

Hey Snafu,

 

Looks like it uses CoC UA. If you also have that you might be missing the Preprocess line required in the Description.exe file. This is covered in the docs for CoC UA.

 

You also need two of GenB's functions with their Preprocess lines in the description file too.

 

findUnits.sqf
knownUnits.sqf

 

If you don't have these I can dig them up for you.

  • Like 1

Share this post


Link to post
Share on other sites

Are you referring to this? - #include <CoC_FED\FED.hpp>

 

I have that in my description.ext, but I still get the error.

 

I have those two functions as well, so they go in the description.ext? The script states init.sqs. 

Share this post


Link to post
Share on other sites

Ok init.sqs for the other functions.

 

Was there some kind of demo or template that came with the script and does it work?

 

You want the earlier CoC UA addon I believe, ver. 1.0.

 

Since you supplied the script maybe I'll see if I can make it work.

Share this post


Link to post
Share on other sites

No, I pulled the script from a user mission. I couldn't find an original copy anywhere. The only instructions are the ones in the script itself.

 

I implemented UA 1.0 into my mission, but it still didn't work. I'll try it in a new mission from scratch tomorrow.

 

Thanks, zulu1.

Share this post


Link to post
Share on other sites

Hi,

 

Ok I played around some and I got it to work. The tip about placing the artillery units first seems to be the key to it. My first attempt give me the scalar booleen error that you got.

I made 3 basic scenario's for you to try. The 3rd shows you can have multiple observers ordering multiple batteries (or even a single one).

Try these out.

http://www.mediafire.com/file/mnhh73hq1rlqatp/UA_AI_Test.zip/file

 

The only beef I have with UA is the long delays and it's really not too accurate.

  • Like 1

Share this post


Link to post
Share on other sites

Glad to help.

 

Here are some thoughts I have.

 

1. Fwd Observer will start calling fire missions as soon as the enemy is in sight, so placing him is critical like I did in the first demo.

 

2. The observer will continue to call fire missions as long as enemy is in view. Gen.Barron did not provide a way to end or kill the script,

so I guess you need to use deletevechicle to get rid of the observers at some point. You can use an alive check in a trigger.

Here are some examples of conditions to use in a trigger.

!alive shilka && !alive t80 && !alive bmp

"alive _x" count units eg1 < 2

"alive _x" count units egrp1 <= 3 && "alive _x" count units egrp2 <= 3

"alive _x" count thisList > NUMBER

("alive _x" count units groupname) == count units groupname

("not alive _x" count units natz) == count units natz

(("alive _x" count ConvoyArray) <= 10)

Another solution may be to move the observer with the trigger instead of deleting him???

 

3. With the delays this script only works good when units are stationary or confined to an area. Trying to hit moving targets will not work very well.

 

  • Like 1

Share this post


Link to post
Share on other sites

Very useful tips, thank you.

 

The artillery is mostly for show. The player is a tank platoon commander, so the Soviet arty is never a threat due to, as you say, constant movement.

 

I included spotters with the friendly infantry units so it should be helpful to them if they get in a bind.

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

×