Jump to content
Sign in to follow this  
Recoilless

Making a ZU-23 fire at the sky

Recommended Posts

I'm trying to make a guerrilla in a ZU-23 fire into the sky when a trigger is activated.

So far I have.

AA1 doWatch [11,11,10000]; AA1 selectWeapon "ZU23_Gue"; AA1 fire "ZU23_Gue";

Where AA1 is the name of the guerrilla in the gun.

The doWatch command works and he looks at the position given but I cant get him to fire.

A little help would be appreciated.

~Thanks

Share this post


Link to post
Share on other sites

Okay I got part of it. I was selecting the vehicle name not the weapon name:icon_redface:

I now have:

AA1 doWatch [11,11,10000]; AA1 selectWeapon "2A14"; sleep 3; AA1  AA1 fire "2A14";

But i cant figure out why sleep isn't interrupting the script. The gun rotates and fires at the same time

Share this post


Link to post
Share on other sites

Ok bare with me here :D

This is supremekillers flak script I used in ARMA and with some tweaking should work in A2

flak.sqs (sorry should of put this earler heh)

; ****************************************************************
; Script file for Armed Assault
; Created by: SUPR3ME KILL3R
; Thanks to Arma Edit
; ****************************************************************


_K = _this select 0
_Target = _this select 1
_radius = _this select 2
_altitude = _this select 3

#Flakloop

_a= getpos _Target select 0
_b= getpos _Target select 1
_c= getpos _Target select 2

_gap=random _radius
_direction=random 360

_x = _a +((cos _direction)*_gap)
_y = _b +((sin _direction)*_gap)
_z = _c + _altitude - _radius + random (_radius*2)

_gap2=random _radius
_direction2=random 360

_xx = _a +((cos _direction2)*_gap2)
_yy = _b +((sin _direction2)*_gap2)
_zz =_c + _altitude - _radius + random (_radius*2)

_gap3=random _radius
_direction3=random 360

_xxx = _a +((cos _direction3)*_gap3)
_yyy = _b +((sin _direction3)*_gap3)
_zzz = _c + _altitude - _radius + random (_radius*2)

_gap4=random _radius
_direction4=random 360

_xxxx = _a +((cos _direction4)*_gap4)
_yyyy = _b +((sin _direction4)*_gap4)
_zzzz = _c + _altitude - _radius + random (_radius*2)

_K disableAI "Target"
_K disableAI "AutoTarget"
_K doWatch [_x,_y,_z]
~0.5
_K setVehicleAmmo 1
_K fire "azp85"
_K doWatch [_xx,_yy,_zz]
~0.5
_K fire "azp85"
_K doWatch [_xxx,_yyy,_zzz]
~0.5
_K fire "azp85"
_K doWatch [_xxxx,_yyyy,_zzzz]
~2
goto "Flakloop"

exit

it worked very well and gave a great effect as the round went up.

all credits to supreme killer as this is his script :)

INSTALLATION:

Simply put the demo mission in your Missions folder (my documents/arma/missions) and load it.

To use the script in another mission, just copy the "flak.sqs" to the same folder of that mission.

USAGE:

This script is my first, so its going to need some fine tuning to work for different units in different situations.

It is however, simple to use. First, place the unit you want to act as a flak battery, and name it (aagun1 for example).

Then, place an object (trigger is best because you can visually change its size to see the radius they will fire within, and no other AI units will target it) and name it also. Trigger1 for example.

Now by trigger, script, or any other event, you can execute the script like this:

[aagun1, trigger1, 250, 1000] exec "flak.sqs"

250 is the radius the gun will fire randomly inside, in this case 250 meters.

1000 is the Altitude the weapon will fire at, 1000 meters in this case.

Place the trigger in the direction you want the gun to fire, so say, place it 250 meters away with 100 meter radius set in the "exec" line. The gun will fire at the trigger, 100 meters around it, in X,y, and Z directions. Placing the trigger directly on top of the AA gun with a radius of say, 300 meters, will make the gun fire in all directions, at angles within the 300 meter radius.

Once you do it a few times, you can copy/paste and create flak batteries very quickly, in a few minutes at the most.

Edited by Whiskey Tango
to add supreme killers instructions from the read me

Share this post


Link to post
Share on other sites
Ok bare with me here :D

This is supremekillers flak script I used in ARMA and with some tweaking should work in A2

; ****************************************************************
; Script file for Armed Assault
; Created by: SUPR3ME KILL3R
; Thanks to Arma Edit
; ****************************************************************


_K = _this select 0
_Target = _this select 1
_radius = _this select 2
_altitude = _this select 3

#Flakloop

_a= getpos _Target select 0
_b= getpos _Target select 1
_c= getpos _Target select 2

_gap=random _radius
_direction=random 360

_x = _a +((cos _direction)*_gap)
_y = _b +((sin _direction)*_gap)
_z = _c + _altitude - _radius + random (_radius*2)

_gap2=random _radius
_direction2=random 360

_xx = _a +((cos _direction2)*_gap2)
_yy = _b +((sin _direction2)*_gap2)
_zz =_c + _altitude - _radius + random (_radius*2)

_gap3=random _radius
_direction3=random 360

_xxx = _a +((cos _direction3)*_gap3)
_yyy = _b +((sin _direction3)*_gap3)
_zzz = _c + _altitude - _radius + random (_radius*2)

_gap4=random _radius
_direction4=random 360

_xxxx = _a +((cos _direction4)*_gap4)
_yyyy = _b +((sin _direction4)*_gap4)
_zzzz = _c + _altitude - _radius + random (_radius*2)

_K disableAI "Target"
_K disableAI "AutoTarget"
_K doWatch [_x,_y,_z]
~0.5
_K setVehicleAmmo 1
_K fire "azp85"
_K doWatch [_xx,_yy,_zz]
~0.5
_K fire "azp85"
_K doWatch [_xxx,_yyy,_zzz]
~0.5
_K fire "azp85"
_K doWatch [_xxxx,_yyyy,_zzzz]
~2
goto "Flakloop"

exit

it worked very well and gave a great effect as the round went up.

all credits to supreme killer as this is his script :)

INSTALLATION:

Simply put the demo mission in your Missions folder (my documents/arma/missions) and load it.

To use the script in another mission, just copy the "flak.sqs" to the same folder of that mission.

USAGE:

This script is my first, so its going to need some fine tuning to work for different units in different situations.

It is however, simple to use. First, place the unit you want to act as a flak battery, and name it (aagun1 for example).

Then, place an object (trigger is best because you can visually change its size to see the radius they will fire within, and no other AI units will target it) and name it also. Trigger1 for example.

Now by trigger, script, or any other event, you can execute the script like this:

[aagun1, trigger1, 250, 1000] exec "flak.sqs"

250 is the radius the gun will fire randomly inside, in this case 250 meters.

1000 is the Altitude the weapon will fire at, 1000 meters in this case.

Place the trigger in the direction you want the gun to fire, so say, place it 250 meters away with 100 meter radius set in the "exec" line. The gun will fire at the trigger, 100 meters around it, in X,y, and Z directions. Placing the trigger directly on top of the AA gun with a radius of say, 300 meters, will make the gun fire in all directions, at angles within the 300 meter radius.

Once you do it a few times, you can copy/paste and create flak batteries very quickly, in a few minutes at the most.

Christ whomever programmed this needs a baseball bat to the head for naming their variables

Share this post


Link to post
Share on other sites
Christ whomever programmed this needs a baseball bat to the head for naming their variables

:confused:

Share this post


Link to post
Share on other sites

Naming variables x, xx, xxx, xxxx, and y,yy etc. is a great way to end up with a completely fucked program.

Never the less it works like a charm. Thank you this script is great.

Share this post


Link to post
Share on other sites

It does say it was his first script and still way over what I can do :D

But it did work very well.

That one is old tho so I'm sure there have been more made since I got that one.

search thru the ARMA stuff and your bound to find one that works well.

@recoiless, no probs mate :)

Edited by Whiskey Tango

Share this post


Link to post
Share on other sites
Christ whomever programmed this needs a baseball bat to the head for naming their variables

Yes, otherwise the least they could have done is include descriptive comments.

Share this post


Link to post
Share on other sites

I took a look at it and it seems as if it would give a good effect but it doesn't want to fire.

I can see it turning about targeting but there is no shooting, do I need any modules to get it to work?

Share this post


Link to post
Share on other sites
I took a look at it and it seems as if it would give a good effect but it doesn't want to fire.

I can see it turning about targeting but there is no shooting, do I need any modules to get it to work?

I had to change it a bit to get it to work. The script tries to fire a gun. You need to change it so that it fires the appropriate gun.

; ****************************************************************
; Script file for Armed Assault
; Updated for Arma 2 Zu-23 by Recoilless
; Created by: SUPR3ME KILL3R
; Thanks to Arma Edit
; ****************************************************************


_K = _this select 0
_Target = _this select 1
_radius = _this select 2
_altitude = _this select 3

#Flakloop

_a= getpos _Target select 0
_b= getpos _Target select 1
_c= getpos _Target select 2

_gap=random _radius
_direction=random 360

_x = _a +((cos _direction)*_gap)
_y = _b +((sin _direction)*_gap)
_z = _c + _altitude - _radius + random (_radius*2)

_gap2=random _radius
_direction2=random 360

_xx = _a +((cos _direction2)*_gap2)
_yy = _b +((sin _direction2)*_gap2)
_zz =_c + _altitude - _radius + random (_radius*2)

_gap3=random _radius
_direction3=random 360

_xxx = _a +((cos _direction3)*_gap3)
_yyy = _b +((sin _direction3)*_gap3)
_zzz = _c + _altitude - _radius + random (_radius*2)

_gap4=random _radius
_direction4=random 360

_xxxx = _a +((cos _direction4)*_gap4)
_yyyy = _b +((sin _direction4)*_gap4)
_zzzz = _c + _altitude - _radius + random (_radius*2)

_K disableAI "Target"
_K disableAI "AutoTarget"
_K doWatch [_x,_y,_z]
~0.5
_K setVehicleAmmo 1
_K fire "2A14"
_K doWatch [_xx,_yy,_zz]
~0.5
_K fire "2A14"
_K doWatch [_xxx,_yyy,_zzz]
~0.5
_K fire "2A14"
_K doWatch [_xxxx,_yyyy,_zzzz]
~2
goto "Flakloop"

exit

This version should work for any zu-23

Share this post


Link to post
Share on other sites

Thanks!

It shoots for me, but not up in the air.

The friendly units around my AA are not safe :eek:

Share this post


Link to post
Share on other sites

Can any one help me? I'm trying to get the battery to sleep a "random" amount of time(really radius/10 or /100). I have this but I cant figure out why it doesn't work.

; ****************************************************************
; Script file for Armed Assault
; Updated for Arma 2 Zu-23 by Recoilless
; Created by: SUPR3ME KILL3R
; Thanks to Arma Edit
; ****************************************************************


_K = _this select 0
_Target = _this select 1
_radius = _this select 2
_altitude = _this select 3

sleep ;(_radius/10);
#Flakloop

_a= getpos _Target select 0
_b= getpos _Target select 1
_c= getpos _Target select 2

_gap=random _radius
_direction=random 360

_x = _a +((cos _direction)*_gap)
_y = _b +((sin _direction)*_gap)
_z = _c + _altitude - _radius + random (_radius*2)

_gap2=random _radius
_direction2=random 360

_xx = _a +((cos _direction2)*_gap2)
_yy = _b +((sin _direction2)*_gap2)
_zz =_c + _altitude - _radius + random (_radius*2)

_gap3=random _radius
_direction3=random 360

_xxx = _a +((cos _direction3)*_gap3)
_yyy = _b +((sin _direction3)*_gap3)
_zzz = _c + _altitude - _radius + random (_radius*2)

_gap4=random _radius
_direction4=random 360

_xxxx = _a +((cos _direction4)*_gap4)
_yyyy = _b +((sin _direction4)*_gap4)
_zzzz = _c + _altitude - _radius + random (_radius*2)

_K disableAI "Target"
_K disableAI "AutoTarget"
_K doWatch [_x,_y,_z]
~0.5
_K setVehicleAmmo 1
_K fire "2A14"
_K doWatch [_xx,_yy,_zz]
~0.5
_K fire "2A14"
_K doWatch [_xxx,_yyy,_zzz]
~0.5
_K fire "2A14"
_K doWatch [_xxxx,_yyyy,_zzzz]
~2
goto "Flakloop"

exit

Also if any one knows how to make them fire for a sustained time that would be great.

---------- Post added at 08:41 PM ---------- Previous post was at 08:40 PM ----------

Thanks!

It shoots for me, but not up in the air.

The friendly units around my AA are not safe :eek:

What values are you calling for the script? I had the same prob, but your probably not aiming high enough.

Edited by Recoilless

Share this post


Link to post
Share on other sites

; ****************************************************************
; Script file for Armed Assault
; Updated for Arma 2 Zu-23 by Recoilless
; Created by: SUPR3ME KILL3R
; Thanks to Arma Edit
; ****************************************************************


_K = _this select 0
_Target = _this select 1
_radius = _this select 2
_altitude = _this select 3

#Flakloop

_a= getpos _Target select 0
_b= getpos _Target select 1
_c= getpos _Target select 2

_gap=random _radius
_direction=random 360

_x = _a +((cos _direction)*_gap)
_y = _b +((sin _direction)*_gap)
_z = _c + _altitude - _radius + random (_radius*2)

_gap2=random _radius
_direction2=random 360

_xx = _a +((cos _direction2)*_gap2)
_yy = _b +((sin _direction2)*_gap2)
_zz =_c + _altitude - _radius + random (_radius*2)

_gap3=random _radius
_direction3=random 360

_xxx = _a +((cos _direction3)*_gap3)
_yyy = _b +((sin _direction3)*_gap3)
_zzz = _c + _altitude - _radius + random (_radius*2)

_gap4=random _radius
_direction4=random 360

_xxxx = _a +((cos _direction4)*_gap4)
_yyyy = _b +((sin _direction4)*_gap4)
_zzzz = _c + _altitude - _radius + random (_radius*2)

_K disableAI "Target"
_K disableAI "AutoTarget"
_K doWatch [_x,_y,_z]
~0.5
_K setVehicleAmmo 1
_K fire (weapons _K select 0)
_K doWatch [_xx,_yy,_zz]
~0.5
_K fire (weapons _K select 0)
_K doWatch [_xxx,_yyy,_zzz]
~0.5
_K fire (weapons _K select 0)
_K doWatch [_xxxx,_yyyy,_zzzz]
~2
goto "Flakloop"

exit

This one copies from my SQS

Share this post


Link to post
Share on other sites

Recoilless is this really a valid command?

sleep ;(_radius/10);

even if it did sleep it isn't inside the loop if I'm reading it correctly.

---------- Post added at 10:29 PM ---------- Previous post was at 10:26 PM ----------

Thanks!

It shoots for me, but not up in the air.

The friendly units around my AA are not safe :eek:

Are you calling it correctly

[aagun1, trigger1, 250, 1000] exec "flak.sqs"

"1000" is the height.

Share this post


Link to post
Share on other sites

[aagun1, trigger1, 250, 1000] exec "flak.sqs"

Yep the above is what I have.

Bedtime now, ill be back on friday.

:Thanks!:

Share this post


Link to post
Share on other sites

Does any one know the correct syntax so that instead of writing the triggers name I can just do "this". From what i understand this returns a boolean in a trigger.

Share this post


Link to post
Share on other sites
Recoilless is this really a valid command?
sleep ;(_radius/10);

even if it did sleep it isn't inside the loop if I'm reading it correctly.

'sleep' is a SQF command and not a SQS to start with. Use tilde ( ~ ) to cause a pause in a SQS script.

Secondly two commands can't be on the same line in SQS, since each line is a new command.

So indeed the above example is faulty.

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  

×