Jump to content
BigPoppa898

Air Strike at Smoke Grenade Location

Recommended Posts

Hey All,

I'd like to write/get a script that executes an airstrike at the location where my smoke grenade lands (most likely using the BAS smoke grenades. I checked here and in the OFP Editing Center, but didn't find any that did that exactly. Any help is appreciated.

Peace and Thanks,

Big Poppa

Share this post


Link to post
Share on other sites

Well, you basicly need an EventHandler on the unit, which should call the airstrike. So place in its init line (or in the trigger, which enables it to call for the airstrike - in this case you would have to replace 'this' with the name of the unit):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fCallAirstrike = loadFile "fCallAirstrike.sqf"; EHCallAirstrike = this addEventHandler["fired",{this call fCallAirstrike}]

Then the function fCallAirstrike.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private["_a","_o"];

comment { Get the ammo and check if its the grenade };

_a = _this select 4;

if(_a=="BAS_WhateverAmmoGrenade")

{

comment { Remove the Event Handler };

(_this select 0) removeEventhandler EHCallAirstrike;

comment { Get the object = smoke grenade and call a script };

_o = nearestObject [_this select 0, _a];

_o exec "airstrike.sqs";

};

true

Another script named airstrike.sqs:

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

; wait until it reaches the ground

@( (position _this select 2) < .5)

; position where the airstrike should be launched at

_pos = position _this

;;; AIRSTRIKE CODE HERE;;;

Of course you should replace "BAS_WhateverAmmoGrenade" with the appropriate ammo name of the BAS (or any other) smoke grenades, which you should find in the readmes.

I think there are several airstrike scripts on OFPEC.

Share this post


Link to post
Share on other sites

Good looking out, Hardrock. I will give it a try this weekend and let you know how it goes.

Big Pop

Share this post


Link to post
Share on other sites

I'm just curious, hardrock: is there any specific reason to make you make a function to catch the fired ammo? I mean will this .sqf-method work better/faster/anything than an .sqs-one or it's just the question of elegance?

Share this post


Link to post
Share on other sites
I'm just curious, hardrock: is there any specific reason to make you make a function to catch the fired ammo? I mean will this .sqf-method work better/faster/anything than an .sqs-one or it's just the question of elegance?

There are several reasons, why one should use the function method instead of the SQS-method:

- the function is in memory available as a variable

- the function is guaranteed to be executed at once (and is faster because of a stricter syntax)

Instead the SQS has to be reread each time, the FIRED-handler is called, and it's possibly more complex to parse and execute (and in some cases the script is not executed at once but it sleeps until the next frame and therefore eating unnecessary CPU-time and memory).

Imagine you have a Machine Gun with an extreme high rate of fire. Now every time you fire that MG, your Fired-Handler-script is first read and then executed. With many scripts running this will produce lag.

Share this post


Link to post
Share on other sites

I've had lock-up and CTD issues using nearestObject in a function, can anyone confirm if I am alone in this, or is it a problem with the command?

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

×