Jump to content
Sign in to follow this  
jw custom

Trigger a flare

Recommended Posts

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:

Played around with it and consulted the wiki :

in the arry after createVehicle, you need coordinate x,y,z and to do an assignment, you have to do :

( getPos flaretrap select 0 ) + RandNum

The only missing things where parenthesis.

You can also make the script easier to read by using variables :)

Now, this script will spawn flares at different height and coordinates.

Pretty cool effet !

while {true} do
{	
// Random values used to select flares and positions.
myRandomVar = round(random 100);
randomX = round(random 200);
randomY = round(random 200);
randomZ = round(random 150);

// Height in meters.
initialZ = 250;

// Start at this position.
initialX = getPos flaretrap  select 0;
initialY = getPos flaretrap  select 1;

// Where we are actually going to drop the flare.
dropPosX = (getPos flaretrap  select 0) + randomX;
dropPosY = (getPos flaretrap  select 1) + randomY;
dropPosZ = initialZ + randomZ;

   if (myRandomVar <= 50 ) then
   {
       if( myRandomVar <= 25 ) then
       {
		player sideChat "White";
		flare = "F_40mm_white" createVehicle [dropPosX, dropPosY, dropPosZ];
       }
       else
       {
		player sideChat "Red";
		flare = "F_40mm_red" createVehicle [dropPosX, dropPosY, dropPosZ];
       }
   }
   else
   {
       if( myRandomVar >= 75 ) then
       {
		player sideChat "Green";
		flare = "F_40mm_green" createVehicle [dropPosX, dropPosY, dropPosZ];
       }
       else
       {
		player sideChat "Yellow";
		flare = "F_40mm_yellow" createVehicle [dropPosX, dropPosY, dropPosZ];
       }
   };

sleep 15;
};

Share this post


Link to post
Share on other sites
I have no specific condition.

#Loop

flare = "F_40mm_white" createVehicle [(getPos objName select 0), (getPos objName select 1), 110];

~20 + (Random 100)

? (any condition is true) : exit

goto "Loop";

-------------------------------------------------------------------------

objName is the location drop it you want.

And problem was this. fill this code to Trigger.

[] exec "flare.sqs";

Share this post


Link to post
Share on other sites

I know this is dumb but what program did you guys use to save it as a SQS? Im using notepad ++ but its not a listed file type and I can't find any other way.

Share this post


Link to post
Share on other sites
I know this is dumb but what program did you guys use to save it as a SQS? Im using notepad ++ but its not a listed file type and I can't find any other way.

In 'Windows Explorer' Tools->Folder Options and under 'View' you can un-check 'Hide extensions for known file types'. Now you can easily change/edit file extensions.

Share this post


Link to post
Share on other sites
I know this is dumb but what program did you guys use to save it as a SQS? Im using notepad ++ but its not a listed file type and I can't find any other way.

If you are using the version I've put, make sure you use the SQF file extension.

Share this post


Link to post
Share on other sites

so if i put the command _xhandle = execvm "flare.sqf"; in on DEA it will activate once opfor detects bluefor? and change activation to opfor dection of bluefore

Share this post


Link to post
Share on other sites

Folks,

The Tripflare rocks, I would like to be able to take it and have the abililty for a radom number of them spawn in a marker area I create. So, if I create "mymarker" 500 x 700 I would like to have from 3 to 9 random tripflares placed within the boundries of "mymarker" and the icing would be if I could randommize their detection radius from .xm to xxm.

Any thoughts and code help is appreciated all credit is and will be noted.

Thanks,

Phxfire

Share this post


Link to post
Share on other sites
Folks,

The Tripflare rocks, I would like to be able to take it and have the abililty for a radom number of them spawn in a marker area I create. So, if I create "mymarker" 500 x 700 I would like to have from 3 to 9 random tripflares placed within the boundries of "mymarker" and the icing would be if I could randommize their detection radius from .xm to xxm.

Any thoughts and code help is appreciated all credit is and will be noted.

Thanks,

Phxfire

Try this:

flareNum = ceil(random 7) + 2; // numbers of flares spawned, min 3 max 9

while {flareNum>=0} do

{

flareNum=flareNum-1;

flareSpread = ceil(random 30); // how long between flares spawned, max 30 seconds

randomX = round(random 500); // random meters X (direction x from gamelogic)

randomY = round(random 700); // random meters Y (direction Y from gamelogic)

randomZ = round(random 125); // random meters Z (height)

initialX = getPos flaretrap1 select 0;

initialY = getPos flaretrap1 select 1;

dropPosX = (getPos flaretrap1 select 0) + randomX;

dropPosY = (getPos flaretrap1 select 1) + randomY;

dropPosZ = randomZ + 100; //random height value + static 100m value

flare = "F_40mm_white" createVehicle [dropPosX, dropPosY, dropPosZ];

sleep (flareSpread);

};

Place a gamelogic and name it flaretrap1. Call above script from a trigger or something.

Share this post


Link to post
Share on other sites

Is there a possibility to make the script end when not detected by bluefor annymore.

I'm asking this question cause i ahve a mission where spetznas has to enter a town and eliminate a officer as quit as possible. But when they get detected by bluefor a alarm sounds and the flares start firing.

But if you stay undetected for a while the alarm stops only to get reactivated when i get detected by bluefor again.

But the Flares don't stop firing. They just continue firing forever. Is there a way to make it like the alarm, that it stops firing when you stay undetected for as long the trigger doesn't consider you detected?

Code:

while {true} do

{

// Random values used to select flares and positions.

myRandomVar = round(random 100);

randomX = round(random 200);

randomY = round(random 200);

randomZ = round(random 150);

// Height in meters.

initialZ = 250;

// Start at this position.

initialX = getPos flaretrap select 0;

initialY = getPos flaretrap select 1;

// Where we are actually going to drop the flare.

dropPosX = (getPos flaretrap select 0) + randomX;

dropPosY = (getPos flaretrap select 1) + randomY;

dropPosZ = initialZ + randomZ;

if (myRandomVar <= 50 ) then

{

if( myRandomVar <= 25 ) then

{

flare = "F_40mm_white" createVehicle [dropPosX, dropPosY, dropPosZ];

}

else

{

flare = "F_40mm_red" createVehicle [dropPosX, dropPosY, dropPosZ];

}

}

else

{

if( myRandomVar >= 75 ) then

{

flare = "F_40mm_green" createVehicle [dropPosX, dropPosY, dropPosZ];

}

else

{

flare = "F_40mm_yellow" createVehicle [dropPosX, dropPosY, dropPosZ];

}

};

sleep 15;

};

sleep 40;

};

Share this post


Link to post
Share on other sites
Is there a possibility to make the script end when not detected by bluefor annymore.

I'm asking this question cause i ahve a mission where spetznas has to enter a town and eliminate a officer as quit as possible. But when they get detected by bluefor a alarm sounds and the flares start firing.

But if you stay undetected for a while the alarm stops only to get reactivated when i get detected by bluefor again.

But the Flares don't stop firing. They just continue firing forever. Is there a way to make it like the alarm, that it stops firing when you stay undetected for as long the trigger doesn't consider you detected?

Do something like this:

[b]alarmStop = false;[/b]
[b]alarmOn = true;[/b]

while {[b]alarmOn[/b]} do
{

[b]if ([color="Red"]alarmStop[/color]) exitWith {};[/b]

// Random values used to select flares and positions.
myRandomVar = round(random 100);
randomX = round(random 200);
randomY = round(random 200);
randomZ = round(random 150);

// Height in meters.
initialZ = 250;

// Start at this position.
initialX = getPos flaretrap select 0;
initialY = getPos flaretrap select 1;

// Where we are actually going to drop the flare.
dropPosX = (getPos flaretrap select 0) + randomX;
dropPosY = (getPos flaretrap select 1) + randomY;
dropPosZ = initialZ + randomZ;

if (myRandomVar <= 50 ) then
{
if( myRandomVar <= 25 ) then
{
flare = "F_40mm_white" createVehicle [dropPosX, dropPosY, dropPosZ];
}
else
{
flare = "F_40mm_red" createVehicle [dropPosX, dropPosY, dropPosZ];
}
}
else
{
if( myRandomVar >= 75 ) then
{
flare = "F_40mm_green" createVehicle [dropPosX, dropPosY, dropPosZ];
}
else
{
flare = "F_40mm_yellow" createVehicle [dropPosX, dropPosY, dropPosZ];
}
};

sleep 15;
};

sleep 40;
};

I have high lighted the edited parts. Set the alarmStop boolean to true the same place where you stop the alarm when intruders are not detected anymore, then flares will stop too.

Edited by JW Custom

Share this post


Link to post
Share on other sites

I will check if this works. But what i forgot to say is that the Alarm is already in the trigger under effects than trigger music. That alarm is working perfectly. It go's on when you are detected and switches off when the opfor don't see you anymore for a while. But when you are re-detected the alarm go's on like it should. i wanted the flare script do the same as that alarm in the trigger. The flare script is activated in that same trigger but doesn't switch of when undetected.

So does it mean i have to put in something extra like if (alarmOn) startWith {};

I'm just gonna try.. see how it works.

Edited by Winchester Delta_1

Share this post


Link to post
Share on other sites
I will check if this works. But what i forgot to say is that the Alarm is already in the trigger under effects than trigger music. That alarm is working perfectly. It go's on when you are detected and switches off when the opfor don't see you anymore for a while. But when you are re-detected the alarm go's on like it should. i wanted the flare script do the same as that alarm in the trigger. The flare script is activated in that same trigger but doesn't switch of when undetected.

So does it mean i have to put in something extra like if (alarmOn) startWith {};

I'm just gonna try.. see how it works.

if (alarmStop) exitWith {};

This breaks the flare loop when alarmStop is true, so when you need to stop the flare do:

alarmStop = true;

Share this post


Link to post
Share on other sites

I just tested it. And it works like a charm. The scripts do activate an reactivate when detected. Now i only have to convert it so the script will stay stable in MP. Thanks man... And all the others for the wonderful scripts. :)

Share this post


Link to post
Share on other sites
I just tested it. And it works like a charm. The scripts do activate an reactivate when detected. Now i only have to convert it so the script will stay stable in MP. Thanks man... And all the others for the wonderful scripts. :)

Thats great :)

Btw. you can leave these out:

alarmOn = true;

while {alarmOn} do

and use it original part

while {true} do

Share this post


Link to post
Share on other sites

Could someone make an example mission with JW Custom's post? I am still a bit confused as to how to put all of this together, but really want to use it.

Share this post


Link to post
Share on other sites
;1515220']Could someone make an example mission with JW Custom's post? I am still a bit confused as to how to put all of this together' date=' but really want to use it.[/quote']

Bump.

Share this post


Link to post
Share on other sites
;1515220']Could someone make an example mission with JW Custom's post? I am still a bit confused as to how to put all of this together' date=' but really want to use it.[/quote']

Point me to which post exactly(there's several in this thread) and i will make you an example :)

Share this post


Link to post
Share on other sites

What I would like is to have on BLUFOR detected by OPFOR, multiple flares of random numbers and colors are ignited mid-air in random places with a certain marker/trigger area and are spread out. Assuming flares hit the ground after about 15 seconds, I want more flares igniting at similar (not the same, but close) intervals and keep igniting as an 'alarm' until BLUFOR is no longer detected.

Question: Say you kill a guy who is not in a group with a silenced weapon. No other forces react. Are you 'detected' ?

Share this post


Link to post
Share on other sites

JW - Quick question...is there a way to simplify this to work without the sound file you have for siren as the game can use the alarm effects (i.e. just have one flares file rather than two, alarm and flares), but also more importantly, what do you need to adjust to the script to work for multiple different areas?

For example if you have 3 regions that have the flare system covering, and blufor walks in and out of any of them, then the flares fire...?

Probably very noon question but what I just tried failed horribly...

Cheers

Edited by BD1

Share this post


Link to post
Share on other sites

So I have a script running for flares and it is not quite doing what I would like it to do. I took JW's and modified it a bit, but it could use a little more modifying! ;)

I set a trigger area, activated by Blufor, repeatedly to those present.

In effects I use the alarm in the trigger section.

In activation field I use: [] exec flares1.sqf

When blufor enters the first flare goes up but then no mre flares, when it should be continuous as long as the Blufor soldier is in the trigger area. If I take the blufor soldier out of the area,the alarm stops and then if I enter the area again, the alarm starts again and one flare goes up, but no more...and repeat, etc.

Here is the code I am using in the Flares1.sqf

if (!isServer) exitWith {};

sleep 3;

while {true} do
{	

_iniposX = (getPos Trigger3 select 0) - 150;
_iniposY = (getPos Trigger3 select 1) - 150;
_initialZ = 100;
_randomZ = round(random 150);
_dropPosZ = _initialZ + _randomZ;
_dropPosX = _iniposX + (random 300);
_dropPosY = _iniposY + (random 300);
flare = "F_40mm_red" createVehicle [_dropPosX, _dropPosY, _dropPosZ];

sleep random 30;
};
if (false) exitWith {};

Any ideas how to get the flares to do the multiple launches as long as Blufor are in the trigger area? Thanks and Merry Christmas all! :D

Share this post


Link to post
Share on other sites

You're using .sqs syntax to call that script - for .sqf, use

execVM[] "script.sqf"

I've re-written the code a bit to make it easier on the eye, and hopefully easier to understand. I just re-packed it in to JW's mission, but here's the guts of it

while {flare} do
{	

_posX = (getPos Trigger1 select 0) + (random 300) - (random 300);
_posY = (getPos Trigger1 select 1) + (random 300) - (random 300);
_posZ = 100 + (random 150);


_flarecolour = [("F_40mm_red"),("F_40mm_white"),("F_40mm_green"),("F_40mm_yellow")];

flare1 = (_flarecolour select floor(random(count _flarecolour))) createVehicle [_PosX, _PosY, _PosZ];

sleep random 5;
};

I suppose an isServer check is called for, but I forgot. The select part is selecting from the array, rounding down the number (or should I have rounded up (ceil)?), and counting the number of items in the array.

FlareAlarm.utes_.rar

Share this post


Link to post
Share on other sites

Many thanks Reimann,

Unfortunately that revised code only produces 1 flare, when I need several being fired continuously until the Blufor leave the target area.

Also when I tried to input your syntax to call the script the editor kept telling me there was an error with it missing a ;

[] exec Flares1.sqf seems to call the script ok.

Edited by BD1

Share this post


Link to post
Share on other sites

I'm looking to do a mission where opfor have set out some trip flares for Bluefor. I've got the script working, but want it to be a one shot only. And I want to use one script to work at several different positions, what sort of language do I need to use?

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  

×