Home   Help Search Login Register  

Author Topic: repeated trigger should NOT be activated by same unit.  (Read 2990 times)

0 Members and 1 Guest are viewing this topic.

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Hey all.

Got a new question and hope someone can help me with this.

I got a trigger of lets say 150 x 80, activated by bluefor, repeatadly.
On activation it activates a script which is following the unit (who activated the trigger) until he leaves the trigger area.
The thing is, that all the time this particular unit is in the trigger area the trigger wont get fired by another bluefor unit. Only as soon as the first unit is out the trigger will be executed on the new unit.
I would like to find a way how I can make any unit entering the trigger area, no matter if another unit has activated the trigger already, to activate that trigger. Just so they all get the script to run over them for the entire duration of them being inside the trigger area.

I have tried many things including setting a variable in the trigger condition. This allows me to reactivate the trigger if I want, but still it will than just be activated again by the same unit.
I have tried it same as above only in the script I added a line to see if the new unit is the same as the old unit, doesnt work since they are local so they are never the same.

Its for a MP mission.

Does anyone knows a way to make the trigger see each unit inside its area?
Any help is very welcome on this, and thank you in advance :)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: repeated trigger should NOT be activated by same unit.
« Reply #1 on: 20 Aug 2006, 23:43:17 »
If you give the trigger a name - say:  trig1

Then in your script the command:  list trig1
will give you a list of all the units that are currently causing the trigger to be acivated.  So by checking list trig1 in your script you can get to all the units you want.


Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: repeated trigger should NOT be activated by same unit.
« Reply #2 on: 20 Aug 2006, 23:53:26 »
 :-[
Oww, that so much easier than I could think of.

Thank you very much. I am going to give this a try  :good:

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: repeated trigger should NOT be activated by same unit.
« Reply #3 on: 21 Aug 2006, 00:02:41 »
There are three subtleties to the list triggername command.

Firstly, the array is dynamically updated.

Secondly, vehicles count as one.   It doesn't return each member of the crew or cargo.  (I think.)

Thirdly, its the units in the first part of the Activation box that count.   If you have East Not Present, then all East units will be in the array.  West detected by Resistance will give you West units and so on.   It doesn't matter what you have in the Condition line.
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: repeated trigger should NOT be activated by same unit.
« Reply #4 on: 21 Aug 2006, 09:02:18 »
Quote
Secondly, vehicles count as one.   It doesn't return each member of the crew or cargo.  (I think.)
Indeed.  To get the two legged units even if they are inside a vehicle you should use the command Crew:

http://www.ofpec.com/COMREF/index.php?action=list&letter=c#crew

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: repeated trigger should NOT be activated by same unit.
« Reply #5 on: 21 Aug 2006, 20:41:22 »
Thanks all, you have been really helpfull. Leanred some new stuff  :)

But,  :banghead: if I use "list" to get all the units in a trigger area how can I than be able to let the script check if the unit in "list" is a tank, a car or a unit?

Right now I have the following script. test.sqs is a script which executes something for the appropreate unit (if I can get it to work :))
Code: [Select]
#start

_list = list test1

? ("tank" CountType ThisList) > 0 : Goto "tank"
? ("car" CountType ThisList) > 0 : Goto "car"
? ("man" CountType ThisList) > 0 : Goto "man"
goto "end"

#tank
_tanks = list test1
_type1 = _tanks
~2
[_x] exec {test.sqs} foreach _tanks
_tanknumber = count _tanks
?_tanknumber < 1 : goto "end"
goto "tank"

#car
_cars = list test1
_type2 = _cars
~2
[_x] exec {test.sqs} foreach _cars
_carnumber = count _cars
?_carnumber < 1 : goto "end"
goto "car"

#man
_units = list test1
_type3 = _units
~2
[_x] exec {test.sqs} foreach _units
_unitnumber = count _units
?_unitnumber < 1 : goto "end"
goto "man"

#end
_nrunits = count units _list
?!_nrunits == 0 : goto "start"
exit

But now, what happens if there are cars, tanks and units at the same time in the trigger area? This script will just list all units, first unit listed will make the script go to appropriate section and the rest will just follow right?
How can I make sure each unit in "list" is triggering the correct script? ie tank, man and car?
So if there are multiple and different units I want my list to be splitted in corresponding section so those sections all have the correct script running over them.

Sorry for another question, but this problem is actually stopping me to finish a script I am already working on for a few months (on and off offcourse :))
I hope my explanation makes any sense.

Thanks in advance again.



Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: repeated trigger should NOT be activated by same unit.
« Reply #6 on: 21 Aug 2006, 20:48:52 »
for sure some of the scripting guru's in here will give a better answer, but just to give you an idea:

 typeOf vehicle
Operand types:
vehicle: Object
Type of returned value:
String
Description:
Returns the class type of a given object or vehicle.
Example:
_class = typeOf _mi24

maybe the use of "typeOf" instead of "CountType" may help to solve the problem.

Even if this answer doesn't help, i hope at least it may give ideas ;-)

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: repeated trigger should NOT be activated by same unit.
« Reply #7 on: 22 Aug 2006, 09:21:36 »
Thanks.
I didnt understand the use of this command but I spend whole night searching the forums and read a lot about it.
Problem in my case is that I am trying to see wether a unit is a tank, a car or a man. This means its checking an array. I cant compare typeOf against an array since its expecting an object. TypeOf also needs to be checked for each unit in the list. Couldnt get that to work neither.

I know its me being to stupid with this scripting but I decided to completely drop this approach, cause while I was trying, reading and testing last night it suddenly came to be I could go a complete different way to achieve what I want. This means I can complete skip what I got now and start over.
But I do really think I found a very good solution, and much easier.........................I hope  :P


Thanks to all for helping me, this is a great place for help and reference :D

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: repeated trigger should NOT be activated by same unit.
« Reply #8 on: 22 Aug 2006, 10:18:08 »
Even though you have scrapped this approach...


Checking whether a unit type is one of few possible types
Code: [Select]
? ((typeOf unitname) in ["car","tank","man"]): do stuff
However, typeOf returns the exact class of a unit, ie. standard west soldier would return SoldierWB instead of Man (or Soldier), so in a case like this countType is the way to go as it can 'handle' base classes (like Man, Car, Tank, etc..)..

Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: repeated trigger should NOT be activated by same unit.
« Reply #9 on: 22 Aug 2006, 10:56:39 »
Yes, thats correct. And thats also what I used earlier. But I couldnt get that to work neither since of the list of units inside the trigger area contains all (man, car and tank) how will the script know the difference of each unit????? All it will do is check first unit in the list, when that is a "man" it will execute my man.sqs, also over tanks and cars  :(

Quote
? ((typeOf unitname)

And this is where the whole problem is. I dont have a unit, I have a unit list (all the units inside the trigger area). I cant get "typeOf" of a list since its not a unit but an array. My limited scripting skills couldnt figure out how to get each unit out of the list and tan compare the unit (individually) to the array ("tank", "man", "car") to know if the unit should execute my tank.sqs, my car.sqs or my man.sqs.

Dropped in my case means its dropped until I figure out something new, most of the times I than just run back  :)
Thats why a folder containing all scriptsI made is kind of full :D

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: repeated trigger should NOT be activated by same unit.
« Reply #10 on: 22 Aug 2006, 18:04:15 »
Have a forEach check for each  object type:

Code: [Select]
{if ((typeOf _x) == "CAR") then {[_x] exec "car.sqs"}} forEach  list triggername
{if ((typeOf _x) == "TANK") then {[_x] exec "tank.sqs"}} forEach  list triggername
{if ((typeOf _x) == "MAN" and _x == vehicle _x) then {[_x] exec "man.sqs"}} forEach  list triggername
« Last Edit: 22 Aug 2006, 18:07:17 by Mr.Peanut »
urp!

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: repeated trigger should NOT be activated by same unit.
« Reply #11 on: 23 Aug 2006, 21:53:04 »
Thanks for that Mr peanut  :)
Spend another night, but I keep going in circles, I need it to be able to compare to an array and typeof cant.
If I use "counttype" it works until I put different types in the trigger area, if a "man" is list than the script will also execute for tanks since its executed foreach in list.  :confused:

Pfeww, I know there must be a way to get each unit out of the list, but thats maybe something for the future for me.

Thanks all for the help, I learned really a lot of good stuff with this  :clap:

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: repeated trigger should NOT be activated by same unit.
« Reply #12 on: 24 Aug 2006, 00:09:22 »
The final line I posted shows how to prevent man/vehicle duplication:
Code: [Select]
if ((typeOf _x) == "MAN" and _x == vehicle _x
If the vehicle of a unit is the same as the unit, then the unit is not in a vehicle.

As for comparing to an array. What I posted above with loop through all  elements of an array using forEach so I don't really understand what the problem is.  The forEach list triggername could just as well be forEach arrayname.
urp!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: repeated trigger should NOT be activated by same unit.
« Reply #13 on: 24 Aug 2006, 01:11:10 »
Okay,
You want one list for each different type. Then, you have two issues, adding the items to the lists and acting on the lists.  You  want one main script for each type that loops over and over again, and generates the list each time.

For example:
Code: [Select]
[triggername] exec "mancheck.sqs"mancheck.sqs
Code: [Select]
_trigger = _this select 0
#mainloop
;make list
_list = []
{if ((typeOf _x) == "MAN" and _x == vehicle _x) then {_list = _list + [ _x] }} forEach  list _trigger
;execute code for each item in list
_i = 0
#actionloop
_unit = _list select _i
.
your code here that acts on _unit
.
_i = _i + 1
if (_i < (count _list)) then {goto "actionloop"}
;small pause maybe?
~1
goto "mainloop"

Similarly you would have  carcheck.sqs and armourcheck.sqs, but for vehicles you do not need the _x == vehicle _x check:
Code: [Select]
[triggername] exec "carcheck.sqs"carcheck.sqs
Code: [Select]
_trigger = _this select 0
#mainloop
;make list
_list = []
{if ((typeOf _x) == "CAR") then {_list = _list + [ _x] }} forEach  list _trigger
;execute code for each item in list
_i = 0
#actionloop
_unit = _list select _i
.
your code here that acts on _unit
.
_i = _i + 1
if (_i < (count _list)) then {goto "actionloop"}
;small pause maybe?
~1
goto "mainloop"


If you are only calling a script for each _unit in the list, you can replace the loop structure:
Code: [Select]
;execute code for each item in list
_i = 0
#actionloop
_unit = _list select _i
.
your code here that acts on _unit
.
_i = _i + 1
if (_i < (count _list)) then {goto "actionloop"}

with a single line:

Code: [Select]
;execute script on each item in list
{[_x] exec "test.sqs"} forEach _list

Hope this helps.
« Last Edit: 24 Aug 2006, 01:18:45 by Mr.Peanut »
urp!

Offline GRFoxhound

  • OFPEC Patron
  • ****
    • Armaholic.com
Re: repeated trigger should NOT be activated by same unit.
« Reply #14 on: 24 Aug 2006, 09:28:47 »
Thank you very much for this, when I get home tonight I am going to give this a shot but it sure looks good.  :thumbsup:
I will post the results here :D