MrZig 0 Posted May 9, 2004 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
rouge1 0 Posted May 9, 2004 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
Metalmalte 0 Posted May 9, 2004 and how do i import this nice thing into a mission? Share this post Link to post Share on other sites
rouge1 0 Posted May 9, 2004 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
General Barron 0 Posted May 13, 2004 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 . Share this post Link to post Share on other sites
MrZig 0 Posted May 13, 2004 Because with nearestobject, when it's near a plane, it explodes.. Share this post Link to post Share on other sites
General Barron 0 Posted May 14, 2004 OHHH.... I see now . 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? ). 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
MrZig 0 Posted May 14, 2004 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
General Barron 0 Posted May 14, 2004 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 Share this post Link to post Share on other sites
MrZig 0 Posted May 14, 2004 Yeah it is odd, but it does work. Share this post Link to post Share on other sites