Jump to content
Sign in to follow this  
Benny Moore

All units triggering a trigger

Recommended Posts

I searched for twenty minutes, so don't try to be smart and say "search." Not one topic in a dozen pages had anything of the sort.

How exactly does one tell a trigger to affect all units which are triggering it or another trigger? I've something in the Condition field which worked for my hand grenade removal script, but in that it was in the On Activation field.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">handgrenade="handgrenade"; "_x removemagazines handgrenade" foreach thislist

So I tried making a trigger with a radius of 500 and activated by anyone, then entered in On Activation, <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x setdammage 1" foreach thislist. But it didn't like this. So I tried several different variables of it, but came to the conclusion that it didn't work.

Okay! Now I try a different tactic. Delete that trigger, make a new one, and enter in the On Activation field, <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if thislist distance bob <500 then thislist setdammage 1. It doesn't take a genius to figure out that it didn't work.

Now I tried putting in Condition <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">thislist distance bob <500 and in On Activation <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">thislist setdammage 1. That didn't work, either.

I confess I have no idea what I'm doing here. I've gone through the command reference several times, but I'm no programmer and I have a very hard time putting together what they mean me to do with everything. Most of my meager scripting has been either pretty basic, figured out with searches here and in the command reference or original missions, or hit and miss. My problem isn't basic, I've tried searching, and I've tried hit and miss. I'm stumped.

How exactly do I tell the trigger to do something to everyone triggering it? I know that if I only wanted one unit to have the setdammage 1 if the distance <500, I could give that unit a name and put <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">billy distance bob <500 in Condition and <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">billy setdammage 1 in On Activation. But I need this trigger to affect all units that trigger it, not just one.

Share this post


Link to post
Share on other sites
Quote[/b] ]So I tried making a trigger with a radius of 500 and activated by anyone, then entered in On Activation,

Code Sample

"_x setdammage 1" foreach thislist

. But it didn't like this. So I tried several different variables of it, but came to the conclusion that it didn't work.

That's exactly how it works, I think your thislist is empty, so it doesn't work. Set activation to Anybody and repeatedly.

Wait a minute, no it doesnt... And I really don't know why. Anyway, this does:

thislist select 0 setDammage 1

Share this post


Link to post
Share on other sites

Thank you. Could you also tell me what "select 0" does, so that I can figure out other problems in the future?

Share this post


Link to post
Share on other sites

Maybe make a little more simple whistle.gif

Make your trigger over the desired location;

Press F2 and group your trigger to the leader of group bob;

In the trigger now make it activate by the "whole group".

In condition just leave this

In activation put ("_x setDammage 1.0") forEach units bob

Share this post


Link to post
Share on other sites

Hmmm.....As I am not at my PC and have not been editing as much as I would like as of late, I may be a little foggy on this one but did you try adding "units" into your line like so:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">handgrenade="handgrenade"; "_x removemagazines handgrenade" foreach units thislist

I will check back tonight when I am at home and have some time and if this does not work, I will find an example of the correct code.

Wadmann

Share this post


Link to post
Share on other sites
Make your trigger over the desired location;

Press F2 and group your trigger to the leader of group bob;

In the trigger now make it activate by the "whole group".

Thanks, but I'm trying to make this trigger apply to only those which trigger it, and it's also supposed to apply to anyone on either side.

I'm using it for several things. One of the things I am using it for is a sort of lame hand-to-hand combat script (I know there is better out there, but I'm doing this as sort of an exercise). The other is a "line of death" boundary around the edges of a mission.

Another thing I tried doing with it is making a trigger to make the repair sheds work. I made a trigger and plopped it onto the repair shed, and in Condition I put <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(vehicle player) distance repair <=10 and player in (vehicle player). In activation I put <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(vehicle player) setdammage 0.

Unfortunately, I could never get it to work perfectly, because I tried to have a three second delay to prevent people from standing in the repair zone and therefore being invincible. But the delay did not work. Also, the "repairing" text always showed up when radio alpha was used, even when the conditions were not met.

The problems became more numerous when I made an .sqs file and made an addaction for it. It inexplicably reversed and was only effective when I was on foot and ineffective when I was in the vehicle. The code was exactly the same as above.

I gave up and tried stuffing a Ural repair truck into the shed. I couldn't quite make it. I could have plopped a tank repair bay onto the repair shed and thrown a repair truck into that, but a tank repair bay looked kind of out of place at the Levie base. So I gave up on that, too, and simply placed a locked repair truck in front of the shed.

Computer: 1. Human: 0.

Share this post


Link to post
Share on other sites
I may be a little foggy on this one but did you try adding "units" into your line like so:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">handgrenade="handgrenade"; "_x removemagazines handgrenade" foreach units thislist

Actually, the handgrenade script already works and has for a long time. It was given to me by someone here many months ago. But thank you for your help, and I shall certainly try it with my current problem.

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">handgrenade="handgrenade"; "_x removemagazines handgrenade" foreach units thislist

why have <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">handgrenade="handgrenade"? You can might as well use

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x removemagazines "handgrenade"" foreach units thislist

that's like setting a = 1, and then unit setdammage a, instead of just writing unit setdammage 1 whistle.gificon_rolleyes.gif

Share this post


Link to post
Share on other sites
Thank you. Could you also tell me what "select 0" does, so that I can figure out other problems in the future?

Or you could look it up from the command reference...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">array select index

Operand types:

array: Array

index: Number

Type of returned value:

Any Value

Description:

select index element of array, index 0 denotes the first element, 1 the second

Example:

[1, 2, 3] select 1 , result is 2

Share this post


Link to post
Share on other sites
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x removemagazines "handgrenade"" foreach units thislist

should be:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x removeMagazines ""handgrenade""" foreach units thislist

Share this post


Link to post
Share on other sites

The problem is :

"_x setdammage 1" foreach thislist, with a "repeatedly activated by anybody" trigger, works.

But :

Let's say that you've got a 10 men team running towards the trigger ; the leader activates the trigger ("thislist" equals the leader only); the time that the trigger kills the leader, the whole squad is in the trigger. So the trigger is still activated (cause there is somebody in its area, "thislist" equals the whole squad but the leader) but it has never been de-activated. Or the trigger must be de-activated so that it can be re-activated again and that the "on activation" command can be launched again.

Solution :

put in the player's init field (or anywhere else): KILL=true

then in a trigger (repeatedly, by anybody) :

condition field : this and KILL

on activation field : "_x setdammage 1" foreach thislist;KILL=false

on de-activation field : KILL=true

Then : once all "thislist" units are killed, the trigger is de-activated (KILL=false) then re-activated (KILL=true) if some is left in its area. pistols.gif

Share this post


Link to post
Share on other sites
Thank you. Could you also tell me what "select 0" does, so that I can figure out other problems in the future?

Or you could look it up from the command reference...

Ah! I never thought of that. Thanks!

Speaking of command reference, I've searched it inside and out for how to make the following line work. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">not (group bob in truckone) and alive group bob I finally narrowed it down to the term "group," since <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">not (bob in truckone) and alive bob works.

I tried making another trigger with the condition "true," with the line "groupbob = groupbob" and modifying my original trigger accordingly. That, obviously, was less than successful. I also tried fiddling with the wretched "foreach thislist" thing again, but that doesn't help. So, how do I tell the "alive" and "in" functions to affect the whole group?

Share this post


Link to post
Share on other sites
Quote[/b] ]I tried making another trigger with the condition "true," with the line "groupbob = groupbob" and modifying my original trigger accordingly.  That, obviously, was less than successful.  I also tried fiddling with the wretched "foreach thislist" thing again, but that doesn't help.  So, how do I tell the "alive" and "in" functions to affect the whole group?

You cannot affect "alive" or "in" directly to a group, but you can use the count command to create a valid condition in a trigger for example :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"alive _x" count (units group bob) == 0

which will be true when every unit of the group "bob" are dead,

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x in car" count (units group bob) == count (units group bob)

which will be true when every unit of the group "bob" are in a vehicle named "car".

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"groupbob = groupbob" doesn't mean anything, "=" is used to affect a value to a variable.

"groupbob = group player" means something (the variable "groupbob" is an array composed of the units of the group of the player).

"Foreach" is used to execute a command on an array, "thislist" is the array that activated a trigger, "units group" in the array of all alive units of a group.

If you wanna get the first element of an array like "thislist", you must use the select command, for example :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"(thislist select 0) setdammage 1" which will kill the first element of thislist. "thislist select 1" will select the second element of the array, etc..."units group select 0" selects the first element of a group, which is the leader in fact.

Is it a little clearer ?? goodnight.gif

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  

×