Jump to content
Sign in to follow this  
jw custom

Trigger a flare

Recommended Posts

I guess this is possible but how do i do it?

It doesn't matter if the flare is fired out of nothing or a enemy soldier is firing it as the players won't see it fire.

Thanks for any help :)

Share this post


Link to post
Share on other sites

Little example: If enemy units detected by trigger, the flare is fired.

Create a game logic an name it pos. Create a trigger with East detected by West. On activation wrote...

this exec "flare.sqs";

flare.sqs

#Loop
flare = "F_40mm_white" createVehicle [getPos pos select 0, getPos pos select 1, 150];
~20 + (Random 100)
? ([i]any condition is true[/i]) : exit
goto "Loop";

Share this post


Link to post
Share on other sites

Imutep, just seen this, how would I get different coloured flares to fire? Would I need 3 different scripts stating the different classnames then call them via the trigger or...

Share this post


Link to post
Share on other sites
Little example: If enemy units detected by trigger, the flare is fired.

Create a game logic an name it pos. Create a trigger with East detected by West. On activation wrote...

this exec "flare.sqs";

flare.sqs

#Loop
flare = "F_40mm_white" createVehicle [getPos pos select 0, getPos pos select 1, 150];
~20 + (Random 100)
? ([i]any condition is true[/i]) : exit
goto "Loop";

Awesome, gonna try this later today... thanks a bunch :thumb:

Really love this community :D

Share this post


Link to post
Share on other sites
Imutep, just seen this, how would I get different coloured flares to fire? Would I need 3 different scripts stating the different classnames then call them via the trigger or...

Yu mean randomly fired flairs? I know it is possible, but sorry, my scripting knowledge is limited. But here are the flare class names i know.

"F_40mm_white"
"F_40mm_yellow"
"F_40mm_green"
"F_40mm_red"

Share this post


Link to post
Share on other sites

I am like you mate, very limited in scripting knowledge, I might create 3 different scripts then for 3 different coloured flares unless someone else has a better idea!!

I would ideally like a script that fires randomly coloured flares continuously until all AI are dead.

Please help!

Dale.

Share this post


Link to post
Share on other sites

Very new to this and still learning this scripting language but :

using :

#Loop
flare = "F_40mm_white" createVehicle [getPos pos select 0, getPos pos select 1, 150];
~20 + (Random 100)
? (any condition is true) : exit
goto "Loop";

Can you, in the loop, do another random and test on that condition and if Random < 50, then white flare, else, red flare ?

That would give 2 flares. I dont know if there is a way to have an if, else if, else statement.

if was looking at this : http://community.bistudio.com/wiki/SQS_to_SQF_conversion

I dont know what is the difference between the SQS or SQF, but you could easily have 2 different colors from what I can see in that page.

--------------------------------- Edit ---------------------------

HaHA -> this page is now my friend : http://community.bistudio.com/wiki/Control_Structures . Structures are very similar to Bash scripting but it is missing some if , else if, else statement.

This should return 1 flare color out of 4

   myRandomVar = round(random 100);
   if (myRandomVar <= 50 ) then
   {
       if( myRandomVar <= 25 ) then
       {
             flare = "F_40mm_white" createVehicle [getPos pos select 0, getPos pos select 1, 150];
       }
       else
       {
            flare = "F_40mm_red" createVehicle [getPos pos select 0, getPos pos select 1, 150];
       }
   }
   else
   {
       if( myRandomVar >= 75 ) then
       {
            flare = "F_40mm_green" createVehicle [getPos pos select 0, getPos pos select 1, 150];
       }
       else
       {
           flare = "F_40mm_yellow" createVehicle [getPos pos select 0, getPos pos select 1, 150];
       }
   };

Edited by The_Angry_Canadian
Found stuff.

Share this post


Link to post
Share on other sites

Hi,

i tried this script:

#Loop

flare = "F_40mm_white" createVehicle [getPos pos select 0, getPos pos select 1, 150];

~20 + (Random 100)

? (any condition is true) : exit

goto "Loop";

I have a trigger with East detected by West. And On activation:

this exec "flare.sqs";

But i cant get this to work...please help

Share this post


Link to post
Share on other sites

Ok, here is the flare.sqs:

#Loop

flare = "F_40mm_white" createVehicle [getPos lichtlein select 0, getPos lichtlein select 1, 150];

~10 + Random 100

? (Ziel1) : exit

goto "Loop";

On the trigger i have Ziel1=true.

But it dosent work.

Share this post


Link to post
Share on other sites

? (Ziel1) : exit

The script works without this line. I used it in a mission and Ziel1 is a condition that is true when east units not in a list trigger. So no more flares are fired.

Thats all.

Share this post


Link to post
Share on other sites

No sorry, it dont work.

This is my flare.sqs:

#Loop

flare = "F_40mm_white" createVehicle [getPos lichtlein select 0, getPos lichtlein select 1, 150];

~10 + Random 100

goto "Loop";

I have a gemelogic that is calles "lichtlein"

The trigger is activatet correctly...i made a hint.

In On Activation it has -> this exec "flare.sqs";

Edited by Wiggum

Share this post


Link to post
Share on other sites

I used it so, and it works fine.

[] exec "flare.sqs";

#Loop
flare = "F_40mm_white" createVehicle [getPos lichtlein select 0, getPos lichtlein select 1, 150];
~10 + Random 100
goto "Loop"

Share this post


Link to post
Share on other sites

Sorry i got it working now by executing the script as you stated in you last post Imutep, thanks for you help

I couldn't get it to work :(

When a BLUFOR unit enter a trigger area a flare is supposed to fire.

Here's the exact steps of what i did:

1. I made a script named flare.sqs with following code:

#Loop

flare = "F_40mm_white" createVehicle [getPos flaretrap select 0, getPos flaretrap select 1, 150];

~10 + Random 100

goto "Loop"

2. I placed a gamelogic on the map on the location i wanted the flare to fire from and named it flaretrap.

3. I placed a Trigger on the map which is the trap itself. In the trigger i have following:

In the "Activation" field i have BLUFOR / Present

In the "On Activation" field i have: this exec "flare.sqs";

When a BLUFOR unit moves into trigger area the flare should fire but it doesn't, what am i doing wrong :confused:

Edited by JW Custom

Share this post


Link to post
Share on other sites

Fine! ;)

Has anybody tested the version with randomly fired flares?

Share this post


Link to post
Share on other sites
Fine! ;)

Has anybody tested the version with randomly fired flares?

Real noob question.

In which folder do you place you sqs or sqf files ?

Once I have that figured out, i'll try my random flares code.

Share this post


Link to post
Share on other sites
Real noob question.

In which folder do you place you sqs or sqf files ?

Once I have that figured out, i'll try my random flares code.

In the mission folder you are editing/making :cool:

Located in MyDocuments/arma2/missions -ish!

Share this post


Link to post
Share on other sites
Fine! ;)

Has anybody tested the version with randomly fired flares?

There you go.

This fires a random flare ( out of the 4 colors ) , every 10 seconds.

Possible amelioration would be to use the random number to change the position of the flare. Do you know how to do that? like [getPos flaretrap select 0] + myRandomNumber

In the trigger, on activation :

_xhandle = execvm "flare.sqf";

player sideChat "Starting Random flares script.";
while {true} do
{	
myRandomVar = round(random 100);
player sideChat "The number is :";
player sideChat format["%1",myRandomVar];

   if (myRandomVar <= 50 ) then
   {
       if( myRandomVar <= 25 ) then
       {
		player sideChat "White";
		flare = "F_40mm_white" createVehicle [getPos flaretrap  select 0, getPos flaretrap  select 1, 250];
       }
       else
       {
		player sideChat "Red";
		flare = "F_40mm_red" createVehicle [getPos flaretrap  select 0, getPos flaretrap  select 1, 250];
       }
   }
   else
   {
       if( myRandomVar >= 75 ) then
       {
		player sideChat "Green";
		flare = "F_40mm_green" createVehicle [getPos flaretrap  select 0, getPos flaretrap  select 1, 250];
       }
       else
       {
		player sideChat "Yellow";
		flare = "F_40mm_yellow" createVehicle [getPos flaretrap  select 0, getPos flaretrap  select 1, 250];
       }
   };

player sideChat "Sleeping 10 secs";
sleep 10;
};

Edited by The_Angry_Canadian

Share this post


Link to post
Share on other sites

Thats great...if this works :p

Will test it now and then i put it on our scripts section at Assault Mission Studio. Thx Angry_Canadian!

Share this post


Link to post
Share on other sites
Thats great...if this works :p

Will test it now and then i put it on our scripts section at Assault Mission Studio. Thx Angry_Canadian!

Great !

I tested the exact same script in my mission and it spawned random flares.

Has I said in my previous post, changing the spawn position of the flare using the random number would also be nice, but I dont know how to do that yet.

Share this post


Link to post
Share on other sites
Great !

I tested the exact same script in my mission and it spawned random flares.

Yes it works fine, thanks for helping :)

I edited it a bit:

flare.sqf

flareNum = round(random 15);

flareSpread = round(random 30);

while {flareNum>=0} do

{

flareNum=flareNum-1;

myRandomVar = round(random 100);

if (myRandomVar <= 50 ) then

{

if( myRandomVar <= 25 ) then

{

flare = "F_40mm_white" createVehicle [getPos flaretrap select 0, getPos flaretrap select 1, 200];

}

else

{

flare = "F_40mm_red" createVehicle [getPos flaretrap select 0, getPos flaretrap select 1, 200];

}

}

else

{

if( myRandomVar >= 75 ) then

{

flare = "F_40mm_green" createVehicle [getPos flaretrap select 0, getPos flaretrap select 1, 200];

}

else

{

flare = "F_40mm_yellow" createVehicle [getPos flaretrap select 0, getPos flaretrap select 1, 200];

}

};

sleep (flareSpread);

};

In trigger "On activation" : _xhandle = execvm "flare.sqf";

Has I said in my previous post, changing the spawn position of the flare using the random number would also be nice, but I dont know how to do that yet.

Maybe you could add like 3 "game logic's" and name them flaretrap0,flaretrap1,flaretrap2 and then do:

spawnAt = floor(random 2);

if (spawnAt=0) then

{

flare = "F_40mm_white" createVehicle [getPos flaretrap select 0, getPos flaretrap0 select 1, 200];

}

if (spawnAt=1) then

{

flare = "F_40mm_white" createVehicle [getPos flaretrap select 0, getPos flaretrap1 select 1, 200];

}

if (spawnAt=2) then

{

flare = "F_40mm_white" createVehicle [getPos flaretrap select 0, getPos flaretrap2 select 1, 200];

}

Edited by JW Custom

Share this post


Link to post
Share on other sites

The idea behind using the random number to change the position is to learn how to edit variables.

I would like to know how I could translate : Take position of flaretrap and add 10 meters in x, and then, add 15 meters in y.

Share this post


Link to post
Share on other sites

Maybe it can be done with something like this:

RanNum1 = round(random 100);

RanNum2 = round(random 100);

flare = "F_40mm_green" createVehicle [getPos flaretrap select 0 + RanNum1, getPos flaretrap select 1 + RanNum2, 200];

:shrug:

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  

×