Home   Help Search Login Register  

Author Topic: Make helos drop flares when over a trigger  (Read 2033 times)

0 Members and 1 Guest are viewing this topic.

Offline Trexian

  • Members
  • *
Make helos drop flares when over a trigger
« on: 12 Nov 2007, 18:05:58 »
Ok guys - I thought I'd try to "give back" a little, after using this forum so much.  I'm a n00b, so if this isn't cool or something, let me know.

Anyway, I have a mission where I want some helos passing over the target area to drop flares to help the guys in the trenches.

Set up a trigger "flareTrig" with condition:
Code: [Select]
this && (vehicle helo1_1 in thisList) || (vehicle helo1_2 in thisList) || (vehicle helo2_1 in thisList) || (vehicle helo2_2 in thisList)

The OnActivation calles flares.sqf, which is:
Code: [Select]


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];

The offsets are to try to compensate for the 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 here so - THANKS!.

Also a simple deal to make it launch 2 flares per pass. I might try that, too.
Sic semper tyrannosauro.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: Make helos drop flares when over a trigger
« Reply #1 on: 12 Nov 2007, 20:34:30 »
if its just so the heli passes the trigger you want to do, just group the trigger to the unit like you would with unit groups, and the trigger will activate when the heli enters
Campaigns are hard, I'll stick with scripting for now!

Offline Trexian

  • Members
  • *
Re: Make helos drop flares when over a trigger
« Reply #2 on: 12 Nov 2007, 21:26:45 »
Got it. :)

Easy way to glean the right parameters from the helo to give to a setvelocity so that it at least looks kinda like the helo is dropping the flares as it travels?

Not a big deal - I added a random x,y to the setvelocity just for a little variation.

Thanks!
Sic semper tyrannosauro.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Make helos drop flares when over a trigger
« Reply #3 on: 13 Nov 2007, 14:46:54 »
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: [Select]
a && b || c
actually runs as though it was:
Code: [Select]
(a && b) || c
and not as (as you might expect):
Code: [Select]
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: [Select]
(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.
« Last Edit: 13 Nov 2007, 14:49:28 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Trexian

  • Members
  • *
Re: Make helos drop flares when over a trigger
« Reply #4 on: 13 Nov 2007, 18:33:47 »
Oooh ROCK on!

Thanks for the info (printed to a pdf for me to keep handy).

Don't worry about smackdowns - I come from Falcon4 development, been there/done that/have the scars. ;)

And thanks for the "what you did could also be done this way" - options (and understanding them) are always good.

Question:
Your point about the trigger only triggering once doesn't quite square with what I observed, although my observation may be skewed.  Now, I couldn't quite tell from my vantage point if the first one was out.  I have seen two helos dropping flares, in relative close proximity to each other, though.  I guess I figured that the script had finished for the first one before the second one entered.  (Not a big deal, either way.) :)

Hey - how sensitive are the mods around here to Off Topic stuff?  I've got a question about whether invisible targets have damage that you can use getdamage for. :)  And, is it just me, or is the doTarget/doFire combination really a cruel joke on how many different ways a scripter can try commands before they give up? :D

Thanks VERY much.
Sic semper tyrannosauro.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Make helos drop flares when over a trigger
« Reply #5 on: 13 Nov 2007, 18:51:40 »
As far as the two helos dropping flares in close proximity, I can't really comment, since whether that should work rather depends on the relative position of the helos and the trigger. If the second helo entered the trigger zone after the first one left (at least based on what the trigger sees, which tests the condition about every 0.5 seconds), then it would work fine.

If you have new questions, just start a new thread (or threads). Since these forums are intended to be a resource for everyone, not just the person who has a question answered, this makes it much easier to find answers.
« Last Edit: 13 Nov 2007, 19:10:46 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Trexian

  • Members
  • *
Re: Make helos drop flares when over a trigger
« Reply #6 on: 13 Nov 2007, 19:07:36 »
Roger.

:thumbs: :)
Sic semper tyrannosauro.