Home   Help Search Login Register  

Author Topic: Check if guy is away from his group?  (Read 537 times)

0 Members and 1 Guest are viewing this topic.

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Check if guy is away from his group?
« on: 03 Oct 2005, 20:57:44 »
Helleuo!

I want something to happen to any unit in a group when he gets too far away from the other guys in the group. How can I do this? Like something with "_X distance _runguy > 1292" foreach units grp1... blah blah, or what?

The idea is that when someone leaves the group he will be attacked by an enemy squad that surrounds him and, if they get close enough, hits him over the head :tomato: and takes him prisoner.

Can you help me? Thanks
Weeee...

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Check if guy is away from his group?
« Reply #1 on: 03 Oct 2005, 21:16:17 »
Try a script with something like this:

Code: [Select]
@({_x distance leader _x > 1234} count units groupName > 0.5)
_units = []

{if (_x distance leader _x > 1234) then {_units = _units + [_x]}} forEach units groupname

_units will then be an array of all units in the group that are > 1234 from their leader

Syntax not guaranteed
« Last Edit: 03 Oct 2005, 21:16:58 by THobson »

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Re:Check if guy is away from his group?
« Reply #2 on: 03 Oct 2005, 21:40:14 »
Cool, I don't understand all of it but I guess something happens when a guy is 1234 away from the  leader of the group and not from any group member, correct?

I only want something bad to happen when he is alone, like no friendlies nearby. But then again I'm not very good at scripting and as I said don't get all of it. :-\

Couldn't you check whether the guy is 1234 meters away from any west unit instead? Like you have one big trigger over the map and use "thislist" etc or something?

_X distance _westunit blah blagh?

Thanks
Weeee...

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Re:Check if guy is away from his group?
« Reply #3 on: 03 Oct 2005, 21:50:45 »
Oh, yes you could! I solved it with the help of the other nice script you made for me earlier, THobson.

In init.sqs I put "[_x]exec{runoff1.sqs}" forEach units grp1.

Code: [Select]
;runoff1.sqs
_kidnapper = _this select 0

_units = units grp1
#mainloop
_i=0

#loop

~0.1

_unit = _units select _i

if (_kidnapper distance _unit >1234) then {goto"continue1
"}

_i = _i + 1
if (_i < count _units) then {goto"loop"}
goto"mainloop"

#continue1

;stuff will happen here

If anyone in the group wanders off it goes to #continue1

Thanks a lot man!
« Last Edit: 03 Oct 2005, 22:04:11 by Wildebeest »
Weeee...