Script help - multiple helo launch flares

ArmA editing, missions, modeling, textures, terrains

Moderators: Lone Wolf, Snake Man

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Script help - multiple helo launch flares

Post by T_Rex » 2007-11-11 20:29:27

Hey guys,

I have a trigger for an area, and I have 4 helos cycling waypoints in the area. When any one of them crosses into the trigger area, I'd like for it to drop a flare.

For the condition of the trigger, I have:

Code: Select all

this && (vehicle helo1_1 in thisList) || (vehicle helo1_2 in thisList) || (vehicle helo2_1 in thisList)
For the On Activation, I have:

Code: Select all

flareZ = execVM "flare.sqf";
And for flare.sqf, I have:

Code: Select all

"F_40mm_White" createVehicle [getPos this select 0, getPos this select 1, 
getPos this select 2];
It runs the sqf, because I get an error that it doesn't like the kind of data.

I suspect that it can't figure out which "this" I want to use to drop the flare.

I'm thinking of a case loop where I identify whatever helo is closest to the trigger or a marker. Does that make sense?
Sic Semper tyrannosauro.

Snake Man
Commander-In-Chief
Posts: 9351
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC

Post by Snake Man » 2007-11-11 22:00:39

Okay but the code samples wont give any thislist for the flare script. I personally dont know how to do it, I mean I dont have ready to go example missions but I would wildly speculate with my lame editing knowledge that you could try like:

Code: Select all

flareZ = [thislist] execVM "flare.sqf";
... but I have no idea if the list would be passed on to the script like that. Sorry that I cant help more, however this is excellent question as I would like to learn how to pass list of trigger units into a script as I do have plans for using such trigger/script setups in my scripts in near future.

But yeah try that sample I shown you before and see what it does?

Also if you know that you have only 3 helos which you want to flare with you could just make a hardcoded script. Just make the trigger a name like "TRexTrigger" and then just run the script, but inside the script check that:

Code: Select all

if (helo1_1 in TRexTrigger) then { "F_40mm_White" createVehicle [getPos helo1_1 select 0, getPos helo1_1 select 1, getPos helo1_1 select 2]; };
of course you need to repeat it for the other two helos also, which some advanced scripter would know how to easily do without copy paste. But thats the idea anyways.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Post by T_Rex » 2007-11-12 02:07:11

Hmmm... I kinda like that idea, though.

I could combine the two, though, right?

Have the activation as I already do (triggered by the helos) but then in the script have the if/then conditional determine which helos are within the trigger area.

I think I can work with that - will let you know. :)
Sic Semper tyrannosauro.

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Post by T_Rex » 2007-11-12 15:00:20

Ok, the trigger is triggering properly, but either the flares aren't very dark or they aren't firing at all. :)

I'm thinking I need to offset the "drop" a bit. If the flare is spawning at 0,0,0 relative to the helo, then that would be inside the helo, eh? :)

I'll play with that and report back. :thumbs:
Sic Semper tyrannosauro.

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Post by T_Rex » 2007-11-12 16:51:24

Ok, got it - basically. :)

Code: Select all

flarepos=getpos flareTrig;

flare1 = "F_40mm_White" createVehicle [0,0,10000];

if (helo1_1 in thislist) then
{
flarepos =getpos helo1_1;
};

if (helo1_2 in thislist) then
{
flarepos = getpos helo1_2;
};

if (helo2_1 in thislist) then
{
flarepos = getpos helo2_1;
};

if (helo2_2 in thislist) then
{
flarepos = getpos helo2_2;
};

flarex=flarepos select 0;
flarey=flarepos select 1;
flarez=flarepos select 2;

flare1 setpos [flarex+20,flarey+20,flarez+70];
Since it is a trigger that launches the script, I guess "thislist" does carry over. :)

The offsets aren't great - but there's a delay between when the flares are launched and when they light up, and my helos are pretty close to the ground, so I kinda need to offset them a bit.

Got the basic scripting paradigm from OFPEC.

Edit - also a simple deal to make it launch 2 flares per pass. I might try that, too.
Sic Semper tyrannosauro.

Snake Man
Commander-In-Chief
Posts: 9351
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC

Post by Snake Man » 2007-11-12 18:29:45

And then you of course need the setVelocity (check for correct command/parameters) to throw the flare into proper trajectory from the helo. I mean if you createVehicle it without any velocity help, it just starts to drop directly down to the ground slowly.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Post by T_Rex » 2007-11-12 19:09:31

Oooh.... good idea. :)

Edit: haven't figured out a way to get the same array setup used by setvelocity from the helo unit. :/ Probably some way using getdir, but for now I just applied a random velocity in x and y.
Sic Semper tyrannosauro.

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Post by T_Rex » 2007-11-13 17:40:28

Some good scripting items about my little script here:
http://www.ofpec.com/index.php?option=c ... ic=30596.0
:thumbs:
Sic Semper tyrannosauro.

Snake Man
Commander-In-Chief
Posts: 9351
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC

Post by Snake Man » 2007-11-13 20:30:51

As we dont allow linking here without some of the content, I'll help you here.
There are some things in your trigger condition I'd like to talk about. There is nothing actually wrong with your condition, since it will work correctly in this case, but I feel that explaining a few things might expand your understanding of what you are doing and help you avoid errors in the future (this isn't intended to be a noob smackdown, so please don't be disheartened, especially since a lot of non-noobs could do worse than know this info!):

- it doesn't take into account operator precedence (though in this case, it doesn't actually matter, as I explain later). That is, or/|| binds after and\&&
Thus:
Code:
a && b || c
actually runs as though it was:
Code:
(a && b) || c
and not as (as you might expect):
Code:
a && (b || c)

- In a trigger condition, this is true if the trigger has been triggered. This will usually lead to activation, since the default condition is this. That is, if it is a "detected" trigger, then the appropriate type of unit is within the zone and is known to enemy units, for a "radio" trigger, then someone has used the appropriate radio option. In your "present" trigger, this means that something, whether one of the helos or anything else, is in the trigger. Anything in the trigger is placed in thisList, so nothing can be in thisList if this isn't true. Therefore, the use of this in this case is unnecessary, though if it was necessary, then the condition might fail, as explained in the previous point.

- You don't need to use "vehicle helo1_1", since this is always the same for a vehicle as simply using the name of the vehicle. When considering a man, however, then "vehicle man1" will either be the man himself or, if he is on board a vehicle, his vehicle. Triggers won't see men inside vehicles, only vehicles and men on foot. When checking for presence of a man, rather than a vehicle, in a trigger zone, then it is important to check for the presence of "vehicle man1", since the man could be present on foot or in a vehicle.

This is therefore equivalent to what you are using for your condition:
Code:
(helo1_1 in thisList) || (helo1_2 in thisList) || (helo2_1 in thisList) || (helo2_2 in thisList)

As I said though, this is equiquivalent to what you are using, but the more you understand what you are doing and why you are doing it the less errors you will make in the future.

Nevertheless, if all your helicopters are in groups that can be grouped with the trigger, Surdus Priest's suggestion makes the most sense, since I'm explaining, rather than optimising, your technique.

Another thing you want to bear in mind is that if one helicopter enters the zone and drops a flare, then another enters the zone before the first has left, then the trigger won't be triggered a second time and that second helicopter won't drop a flare. If the first helicopter leaves before the second enters, then a flare would be dropped as you expect. This will happen because if one of your helicopters is in the zone then the trigger condition is already true and so the activation will not re-activate, regardless of more helicopters entering the trigger zone.
Remember:
- The trigger activation is performed when the condition changes from false to true.
- The trigger deactivation is performed when the condition changes from true to false.

May not be an issue for your particular mission, but is something to consider.
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

T_Rex
FreeFalcon
Posts: 848
Joined: 2001-03-04 23:01:01
Location: here

Post by T_Rex » 2007-11-14 18:45:39

This looks promising in getting the flare to take on the starting trajectory of the helo:

Code: Select all

Code Sample
_bomb setPos [getpos _object select 0, getpos _object select 1, (getpos _object select 2) +2]
_bomb setdir (getdir _object)
_vel = velocity _object;
_dir = direction _object;
_speed = 0;comment "Added speed";
_bomb setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+(cos _dir*_speed),(_vel select 2)];

Change the following:
_bomb is the createvehicle name
_object is the Target/Object name name
From this thread:
http://www.flashpoint1985.com/cgi-bin/i ... 71;t=69789

Will let you know how it comes out (when I have a chance to try it). :)
Sic Semper tyrannosauro.

Who is online

Users browsing this forum: ClaudeBot [Bot] and 0 guests