Jump to content
Sign in to follow this  
Aldo15

How to know smoke-grenade position?

Recommended Posts

Hello folks,

I'd want to know if it's possible to know position of a grenade smoke, I want to make a mission where I must a greande-smoke (RED) and then an A10 attack its real position. Is it possible?

Share this post


Link to post
Share on other sites

First, you need to attach a fired event handler, check the ammo that was used, and if it's a SmokeShellRed, then exec a script

To check the ammo, you need to use a sqf, because it's faster or you will lose a lot of fps while firing.

So, first, load the sqf in the init.sqs

init.sqs

; INIT SQS

AirstrikeFiredSmoke = loadfile "FiredSmoke.sqf"

Then, create the sqf and put it on the mission folder

firedsmoke.sqf

private ["_unit","_weapon","_ammo"];

_unit = _this select 0;

_weapon = _this select 1;

_ammo = _this select 4;

if(_weapon == "Throw")then{

if(_ammo == "SmokeShellRed")then{_this exec "checksmokepos.sqs"};

};

Now, create the script to check the position of the smokeshell and place it in the mission folder

checksmokepos.sqs

_unit = _this select 0

_grenade = _this select 4

?!(local _unit): exit

~6

_posForAirstrike = (getpos _grenade)

publicVariable "PosForAirstrike"

Now on the global variable posForAirstrike you will have the pos of the redsmoke

Now, you need to have the eventhandler to exec the sqf and check every fire that the player will do, place this on the player init.

this addeventhandler ["fired", {_this call AirstrikeFiredSmoke}]

That should do the job, it's to you to make the A10 fire at that position though, you can do it making the A10 pass over the position and then createvehicle a LGB bomb, or something like that

Edited by NacroxNicke

Share this post


Link to post
Share on other sites

You can't publicVariable an array without the ol' createUnit trick. There's no error message but it will simply not transmit. Instead, you can publicVariable the X and Y coordinates separately:

_p = getpos _nade

airstrike_pos_x = _p select 0
airstrike_pos_y = _p select 1

publicVariable "airstrike_pos_x"
publicVariable "airstrike_pos_y"

Also you can't publish a local variable. Eg:

_myVar = 123

publicVariable "myVar"

Instead use:

_myVar = 123

myVar = _myVar

publicVariable "myVar"

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  

×