Jump to content
Sign in to follow this  
MrZig

*real* flak script

Recommended Posts

Since Korax told me you can use nearestobject with [x,y,z] instead of defining an object (found at the tornado addon), I decided to make a "flak" script.

It's not great, made real quick, exec via an eventhandler like

this addEventHandler ["fired",{_this exec "fired.sqs"}]

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_shooter = _this select 0

_projectile = nearestObject [vehicle(_shooter), _this select 4]

_c = 700

#loop

_c = _c - 1

_x = getpos _projectile select 0

_y = getpos _projectile select 1

_z = getpos _projectile select 2

_obj = NearestObject [_x,_y,_z]

?_obj == _projectile : _obj = objnull

?!isnull _obj : goto "CT"

?_c == 0 : goto "CT"

?alive _projectile or isnull _projectile : goto "loop"

#ct

_pos = [(getpos _projectile select 0) + random 20 - random 40,(getpos _projectile select 1) + random 20 - random 40,(getpos _projectile select 2) + random 20 - random 40]

_b = "heat73" camcreate _pos

_b = "heat73" camcreate _pos

drop ["cl_basic", "", "Billboard", 30, 30, [0,0,0], [0,0,0], 0, 1.2, 1, 0, [10,20,0], [[0,0,0,1], [0,0,0,0], [1,1,1,.2], [1,1,1,0]], [0,0], 0, 0, "", "",_b]

deletevehicle _projectile

exit

Share this post


Link to post
Share on other sites

hey good work for an quick script! Looks good and give's the effect of flak

Share this post


Link to post
Share on other sites

you copy the text there into somthing like Notepad then Save as this Fired.sqs and then put that in ur Users/Missions/xxxx Mission Name Directory then in the editor (in the Unit init Field) write in the unit you want to have Flak put this.

this addEventHandler ["fired",{_this exec "fired.sqs"}]

Share this post


Link to post
Share on other sites

Am I missing something, or does this script just make a bullet explode after a certain amount of time in the air? If so, why not increase performance by doing it like this instead?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_projectile = nearestObject [vehicle(_this select 0), _this select 4]

_burstTime = 1.25

_time = 0

#loop

_pos = getpos _projectile

~0.001

_time = _time + 0.001

?_projectile == _projectile && _time < _burstTime : goto "loop"

_ExPos = [(_pos select 0) + random 20 - random 40,(_pos select 1) + random 20 - random 40,(_pos select 2) + random 20 - random 40]

_b = "heat73" camcreate _ExPos

_b = "heat73" camcreate _ExPos

drop ["cl_basic", "", "Billboard", 30, 30, [0,0,0], [0,0,0], 0, 1.2, 1, 0, [10,20,0], [[0,0,0,1], [0,0,0,0], [1,1,1,.2], [1,1,1,0]], [0,0], 0, 0, "", "",_b]

? _projectile == _projectile : deletevehicle _projectile

exit

Basically, I don't see why you need the nearestObject call rock.gif.

Share this post


Link to post
Share on other sites

Because with nearestobject, when it's near a plane, it explodes..

Share this post


Link to post
Share on other sites

OHHH.... I see now smile_o.gif. But I think there is a problem: you use the exact position of the bullet to do your nearestObject calls. That should ALWAYS return the bullet, unless the bullet no longer exists (how could the plane be closer to the bullet than the bullet is to itself? rock.gif).

Maybe you should check for only planes with the nearestObject command, so you don't end up returning the bullet. Use this function HERE and you can return the nearestObject from an array of object types.

But anyway, does AA fire really detonate when it is close to aircraft? I thought it was just on a timer, or was set to detonate at a certain altitude.... but I really don't know anything on the subject, so I'm not saying I'm right :P.

Share this post


Link to post
Share on other sites

Did you see this line?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?_obj == _projectile : _obj = objnull

:P

I tested it fully, it works good.

Share this post


Link to post
Share on other sites

Yeah, I saw that line, but I figured that since the nearestObject command is always passed the exact position of the bullet, then the nearestObject to that position would always be the bullet, even if there is a plane a few meters away. But if it works, then obviously it works, it just seems odd to me, thats all smile_o.gif

Share this post


Link to post
Share on other sites

Yeah it is odd, but it does work.

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  

×