Home   Help Search Login Register  

Author Topic: Trigger and groups - asking for help  (Read 554 times)

0 Members and 1 Guest are viewing this topic.

Offline Grizzlie

  • Members
  • *
Trigger and groups - asking for help
« on: 25 Jan 2005, 22:54:08 »
I have a problem with script i'm working on.
Idea is:
Some single soldiers, whose names is stored in array survivors1 are moving to position of trigger (name trigger1, radius 60, activation by west, present west, [evac1, trigger1] exec "survivors.sqs). When soldier "hits" the trigger, it has to go prone, join group evac1, and wait. And only soldiers "inside" trigger has to be proned, other in array survivors1 should stay running. When all soldiers are "inside" trigger, leader of group should say they r waiting in position. I have wrote script like that:

;surviwors.sqs
_group = _this select 0
_trig = _this select 1

#loop
_tmp = list _trig - survivors1
_ar = list _trig - _tmp
_l = count _ar
? _l == 0 : exit
_i = _l - 1
_ar select _i setunitpos "down"
[_ar select _i] join _group
_group move [(getpos _trig select 0) + 15, (getpos _trig select 1) + 15]
? (count units _group == "alive _x" count survivors1) : _point == "ALPHA" ; rescue1 = true; goto "sa"
~.5
goto "loop"
#sa
leader _group sideChat "Survivors are waiting in Evac point " + _point
_group setformation "column"
exit  

And sometimes it works, sometimes not. I really do not know why..  >:(
I mean sometimes soldiers r added to group, sometimes not, sometimes they go prone sometimes not. Group is "declared" by putting soldier with "evac1 = group this; deletevehicle this" in init field.

I was trying without loop, just changing type of trigger to "revealed by west", but it always worked only for the first soldier.
Maybe someone can find easier way?

StonedSoldier

  • Guest
Re:Trigger and groups - asking for help
« Reply #1 on: 26 Jan 2005, 12:05:51 »
instead of "leader _group sideChat "Survivors are waiting in Evac point " + _point"

try,

leader _group sidechat format ["Survivors are waiting in Evac point %1",_point]

Offline Grizzlie

  • Members
  • *
Re:Trigger and groups - asking for help
« Reply #2 on: 26 Jan 2005, 23:41:26 »
I did this way, thanks.
Reading other topics about triggers seems only one solution is make very small trigger and hope one soldier would leave it before next hits (to avoid using loop).
Well still hope that someone can find better way.


Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Trigger and groups - asking for help
« Reply #3 on: 27 Jan 2005, 01:25:38 »
What about this:

Code: [Select]
_group = _this select 0
_triggerpos = getpos (_this select 1)

_tempsurvivors = []

#waitfortroops
_myArray = []
@"_x distance _triggerpos < 60" count (survivors1-_tempsurvivors) > 0 or (count units _group == "alive _x" count survivors1)
? (count units _group == "alive _x" count survivors1) : goto "MoveOut"
"call{if (_x distance _triggerpos < 60) then {_myarray = _myarray+[_x]};}"  foreach (survivors1-_tempsurvivors)
_i = 0
#loop
?_i >= count _myarray:goto "waitfortroops"
_soldier = _myarray select _i
_soldier setunitpos "down"; [_soldier] join _group
_tempsurvivors = _tempsurvivors + [_soldier]
_i = _i + 1
goto "loop"
#moveout
_point == "ALPHA"
rescue1 = true
leader _group sidechat format ["Survivors are waiting in Evac point %1",_point]
_group setformation "column"
exit  
Instead of bothering with a trigger, simply call this at the beginning of the mission (or when ever you feel like it), with the same parameters (you can still use a trigger as _this select 1), and it *should* work every rtime (unless i made a mistake - no guarantees at all ) ;)
EDIT: should be [_soldier] join _group
« Last Edit: 27 Jan 2005, 01:28:41 by Fragorl »

Offline Grizzlie

  • Members
  • *
Re:Trigger and groups - asking for help
« Reply #4 on: 28 Jan 2005, 00:46:54 »
Thank you Fragorlfor suggestion.
I'm working on it - i haven't put there all my needs, so it needs some polishing yet, but idea works  ;)
When i finish i will publish final version.

Offline Grizzlie

  • Members
  • *
Re:Trigger and groups - asking for help
« Reply #5 on: 28 Jan 2005, 18:47:03 »
Finally script looks this way:

_pad = _this select 0
_tempsurvivors = []
_s = []
_sur = []

#start
@ (count survivors1 + count survivors2 > 0) or rescue_stop
? rescue_stop : exit
? (_pad == resc1) : _sur = + survivors1
? (_pad == resc2) : _sur = + survivors2
@ {_x distance _pad < 30} count (_sur - _tempsurvivors) > 0  
{if (_x distance _pad < 30) then {_s = _s + [_x]}} foreach (_sur - _tempsurvivors)
_sur = []
? (_pad == resc1) : {if(alive _x) then {_sur = _sur + [_x]}} foreach survivors1
? (_pad == resc2) : {if(alive _x) then {_sur = _sur + [_x]}} foreach survivors2
_i = (count _s) - 1
_soldier = _s select _i
_soldier setunitpos "down"
_tempsurvivors = _tempsurvivors + [_soldier]
_soldier move [(getpos _pad select 0) + 25 + _i*5, (getpos _pad select 1) + 25]
? (count _s == count _sur) : goto "end"
goto "start"
#end
? _pad == resc1 : tmp1 = + _s; rescue1 = true; _soldier sideChat "Passengers r waiting at ALPHA taxi-stop"; _s = []; _tempsurvivors = []; survivors1 = []; goto "start"
? _pad == resc2 : tmp2 = + _s; rescue2 = true; _soldier sideChat "Passengers r waiting at BRAVO taxi-stop"; _s = []; _tempsurvivors = []; survivors2 = []; goto "start"


It works repeatidly, as i wanted, grouping units was removed, so i got rid of groups at all and can be used simultaneously for 2 pads.

Thanks for help  :)

I'I will keep this topic open for 1-2 days to allow additional discussion.