Home   Help Search Login Register  

Author Topic: Join survivors frm other groups to make one group  (Read 2068 times)

0 Members and 1 Guest are viewing this topic.

Gooner861

  • Guest
Join survivors frm other groups to make one group
« on: 05 Aug 2004, 22:38:51 »
Ok so there is a large attack on sum place and there are gonna be heavy casualties.  

How can u make survivors frm other groups join up together to make one group?, as i want this one group to board a heli together and go fight sum place else

Cheers

Gooner

Kaliyuga

  • Guest
Re:Join survivors frm other groups to make one group
« Reply #1 on: 05 Aug 2004, 23:16:50 »
 use the join command in a script or trigger of some sort :


Command:
Join
 
Description:
Causes selected unit to join specified group.
 
Syntax:
UnitName Join GroupName

UnitName is the name of the unit to join a group.
GroupName is the group the unit should join. Use GrpNull to take a unit out of a group.
 
:cheers:

Dubieman

  • Guest
Re:Join survivors frm other groups to make one group
« Reply #2 on: 05 Aug 2004, 23:22:22 »
Never thought of doing this myself but a few checks on each attacking group. Like if groups one and two are below 5 men, they join together. And if groups 3 and 4 are below 3 men, make them join up.

Then if the new group 12 (1+2) is below 6 men, then they join the group 34 (3+4) and then it goes on from there.

Hope it helps :P  

Gooner861

  • Guest
Re:Join survivors frm other groups to make one group
« Reply #3 on: 06 Aug 2004, 22:40:11 »
Thanks for the input  ;D .

The only problem i see wud be that if i used the:

unitname join groupname

wot if that unit was already dead? he wudnt join. Actually wait cudn't u just use sumthing like i dunno:

[unit,1 unit2, unit2 etc etc] join groupname

Than whoeva's alive out of them wud join the new group.

Cheers

Gooner

Kaliyuga

  • Guest
Re:Join survivors frm other groups to make one group
« Reply #4 on: 06 Aug 2004, 23:34:15 »
theres a more complicated way you can do it... i've never been a scripter myself though

but something where you can count the units in a group and then add everyone in that group to another group..


 foreachunits this group..  something something.. some command and punctuation


I was hoping someone else that was a little better at scripting would come along and flesh out the idea ;D

:cheers:
« Last Edit: 06 Aug 2004, 23:35:03 by Kaliyuga »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Join survivors frm other groups to make one group
« Reply #5 on: 07 Aug 2004, 16:46:55 »
I have written a few scripts to do this.  Basically I have a loop with a 5 to 10 second delay.  I use the count command to count the number of units in a group. eg:

_Grp1units = count units <group1name>

etc for all the other groups.  Then join them up if the number of units falls below a set level and if joining them does not exceed 12 units in the group.

This is an extract from a script that shows an example

Code: [Select]
_smallsize = 3
_largesize = 12



#Loop

~5

_countGrp6 = count units eg6Grp
_countGrp5 = count units eg5Grp

if not ((_countGrp6 >0) and ((_countGrp6 <= _smallsize) or (_countGrp5 <= _smallsize)) and ((_countGrp6 + _countGrp5) <= _largesize)) then {goto"Checkeg8Grp"}

units eg6Grp join eg5Grp



#Checkeg8Grp
.
.
.


Notes:
- once a group has joined another group count units <groupname> will return a zero immediately thereafter
- joining a group to a dead group is no problem.  They just continue with the dead groups waypoints.
- there can be a delay of sometimes many seconds between a unit in a group being killed and this being reflected in the result of  count units <groupname>.  This is especially true when the group has been wiped out.  It can take several minutes for count unit <groupname> to return zero.  It also seems to depend on whether the dead units were seen by other members of the group.

Using a script like this you can then completely change the behaviour of the groups once the total number of units falls below some predetermined level.

Actually here is a full listing of a script I wrote that will:
- ensure any surviving crew from dead tanks join a local infantry unit.
- consolidate all the infantry groups in to one group as they shrink
- once they have shrunk to a very low total number, any surviving M2 machine gunner then abandons their post and join the infantry
- the infantry will eventually panic (set Base1Panic = true) and then any surviving tank crew will abandon the vehicle and join them.  The level at which they panic is determined by whether any tank is still alive.

Base1Panic  is a global variable used by a switch trigger to make the remaing soldiers run a long way away.

The following works, but I am about to make some further improvements to it:


Code: [Select]
; Base1Groupings.  Consolidated Russian groups as they take casualties
; called by []exec"Base1Groupings.sqs"

_smallsize = 3
_panicsize = 4
_realpanicsize = 1
_largesize = 12

_Tank5Joined = false
_Tank6Joined = false

_NearPanic = false

#Loop

~5

if ((count units eg3Grp > 9) or (alive Tank5) or _Tank5Joined) then {goto"CheckTank6"}

[Tank5C,Tank5G,Tank5D] join eg3Grp
_Tank5Joined = true


#CheckTank6

if ((count units eg3Grp > 9) or (alive Tank6) or _Tank6Joined) then {goto"CheckJoin1and2"}

[Tank6C,Tank6G,Tank6D] join eg3Grp
_Tank6Joined = true


#CheckJoin1and2

_countGrp1 = count units eg1Grp
_countGrp2 = count units eg2Grp

if ((_countGrp1 < 1) or (_countGrp2 < 1) or ((_countGrp1 > _smallsize) and (_countGrp2 > _smallsize)) or ((_countGrp1 + _countGrp2) > _largesize)) then {goto"CheckJoinPatrol1and2"}

if (_countGrp1 < _countGrp2) then {units eg1Grp join eg2Grp} else {units eg2Grp join eg1Grp}



#CheckJoinPatrol1and2

_countPatrol1 = count units Patrol1Grp
_countPatrol2 = count units Patrol2Grp

if ((_countPatrol1 < 1) or (_countPatrol2 < 1) or ((_countPatrol1 > _smallsize) and (_countPatrol2 > _smallsize)) or ((_countPatrol1 + _countPatrol2) > _largesize)) then {goto"Checkeg1to3Grp"}

if (_countPatrol1 < _countPatrol2) then {units Patrol1Grp join Patrol2Grp} else {units Patrol2Grp join Patrol1Grp}



#Checkeg1to3Grp

_countGrp1 = count units eg1Grp
_countGrp3 = count units eg3Grp

if not ((_countGrp1 >0) and ((_countGrp1 <= _smallsize) or (_countGrp3 <= _smallsize)) and ((_countGrp1 + _countGrp3) <= _largesize)) then {goto"Checkeg2to3Grp"}

units eg1Grp join eg3Grp


#Checkeg2to3Grp
_countGrp2 = count units eg2Grp
_countGrp3 = count units eg3Grp

if not ((_countGrp2 >0) and ((_countGrp2 <= _smallsize) or (_countGrp3 <= _smallsize)) and ((_countGrp2 + _countGrp3) <= _largesize)) then {goto"CheckPatrol1to3Grp"}

units eg2Grp join eg3Grp


#CheckPatrol1to3Grp
_countPatrol1 = count units Patrol1Grp
_countGrp3 = count units eg3Grp

if not ((_countPatrol1 >0) and ((_countPatrol1 <= _smallsize) or (_countGrp3 <= _smallsize)) and ((_countPatrol1 + _countGrp3) <= _largesize)) then {goto"CheckPatrol2to3Grp"}

units Patrol1Grp join eg3Grp


#CheckPatrol2to3Grp
_countPatrol2 = count units Patrol2Grp
_countGrp3 = count units eg3Grp

if not ((_countPatrol2 >0) and ((_countPatrol2 <= _smallsize) or (_countGrp3 <= _smallsize)) and ((_countPatrol2 + _countGrp3) <= _largesize)) then {goto"CheckPanic"}

units Patrol2Grp join eg3Grp


#CheckPanic

_countGrp1 = count units eg1Grp
_countGrp2 = count units eg2Grp
_countGrp3 = count units eg3Grp
_countPatrol1 = count units Patrol1Grp
_countPatrol2 = count units Patrol2Grp


_countTotal = _countGrp1 + _countGrp2 + _countGrp3 + _countPatrol1 + _countPatrol2

if (_countTotal > _panicsize) then {GoTo"Loop"}

if _NearPanic then {goto"Skip"}
_NearPanic = true

unassignVehicle gunnerMG1
unassignVehicle gunnerMG2
unassignVehicle gunnerMG3
unassignVehicle gunnerMG4

if (alive gunnerMG1) then {[gunnerMG1] join eg3Grp}
if (alive gunnerMG2) then {[gunnerMG2] join eg3Grp}
if (alive gunnerMG3) then {[gunnerMG3] join eg3Grp}
if (alive gunnerMG4) then {[gunnerMG4] join eg3Grp}

[Tank5,TankLastStand,150] exec "UnitReturn.sqs"
[Tank6,TankLastStand,150] exec "UnitReturn.sqs"

#Skip
_countGrp3 = count units eg3Grp
_countTotal = _countGrp1 + _countGrp2 + _countGrp3 + _countPatrol1 + _countPatrol2

if (_countTotal <= _realpanicsize) then {goto"Panic"}

if ((_countTotal > _panicsize) or (alive Tank5) or (alive Tank6))  then {GoTo"Loop"}

#Panic
unassignVehicle Tank5C
unassignVehicle Tank5G
unassignVehicle Tank5D
unassignVehicle Tank6C
unassignVehicle Tank6G
unassignVehicle Tank6D

[Tank5C,Tank5G,Tank5D,Tank6C,Tank6G,Tank6D] join eg3Grp


Base1Panic = true


exit
« Last Edit: 07 Aug 2004, 17:43:08 by THobson »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Join survivors frm other groups to make one group
« Reply #6 on: 07 Aug 2004, 17:25:12 »
PS:   I am working on a more generic script that will run for a group and will join the group to another group when it gets below a specified size.

I have the code but have not yet had chance to test it.
« Last Edit: 07 Aug 2004, 17:43:45 by THobson »

Gooner861

  • Guest
Re:Join survivors frm other groups to make one group
« Reply #7 on: 07 Aug 2004, 17:58:13 »
Hi there THobson, thanks for the reply  ;D . Looks like complicated stuff. Not that good at scripting but im up for trying it at least.

Another wont the looping of the script cause quite abit of lag.


Cheers

Gooner

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Join survivors frm other groups to make one group
« Reply #8 on: 07 Aug 2004, 18:38:26 »
The script is long but not really complicated - just repetative.  The generic script I am working on will be very short - but more complicated.

One thing I should have said is that each of the groups are given names outside the script.  I put <groupname> = group this

in the init field of the leader of each group and then use the names in the script

On lag - remember that every trigger you have is checked several (I think 5) times a second.  This script only runs once every 5 seconds - so no, lag should not be a problem with this script.  You could make the delay 10 seconds if you wish but I bet you will not notice the difference.

Gooner861

  • Guest
Re:Join survivors frm other groups to make one group
« Reply #9 on: 08 Aug 2004, 14:17:53 »
I was thinking, cos that script looks difficult to understand, wud this work even though its abit of a long way to do it.

Name all the units in each group (unit1, unit2 etc etc) and than once u reach the centre of the town, which u can only get to by killing every bad dude, there is a trigger with every units number in who if any are left join ur group.

So it wud look like:

[unit1, unit2, unit3, unit4, unit5, unit6 etc etc] join mygroup

It wud be huge but wudn't that work?

Thanks

Gooner

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Join survivors frm other groups to make one group
« Reply #10 on: 08 Aug 2004, 14:48:26 »
The short answer is yes it should work but it would be huge and you might end up trying to make a group that has > 12 soldiers in it.

A slightly simpler way than what you are suggesting is to give each group a name (put
<groupname> = group this
 in the init field of every group leader.  Then instead of having to specify each unit you only need to specify each group as follows:

units Group1 join mygroup
units Group2 join mygroup

etc.

I have not tested it but
units Group1 + units Group2 +...etc  join mygroup

may also work - or it may need some brackets

But you could still end up trying to create a group that has > 12 soldiers in it.

I would encorage you to have a look at the script.  It is only long because it is repetative.
« Last Edit: 08 Aug 2004, 14:57:37 by THobson »

Gooner861

  • Guest
Re:Join survivors frm other groups to make one group
« Reply #11 on: 08 Aug 2004, 19:26:06 »
Thanks i'll give it a test once i've sorted out this radio command stuff im trying to learn.

Gooner

Gooner861

  • Guest
Re:Join survivors frm other groups to make one group
« Reply #12 on: 09 Aug 2004, 21:55:44 »
Well i got the radio commands stuff to work so ive been working on this. So far so good with the units group1 join mygroup command. I may look into the script at a later date though.

Gooner

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Join survivors frm other groups to make one group
« Reply #13 on: 09 Aug 2004, 23:15:39 »
No worries.  I now have my generic script working bye the way

Gooner861

  • Guest
Re:Join survivors frm other groups to make one group
« Reply #14 on: 10 Aug 2004, 13:58:38 »
Well seeing that its dun i wudnt mind just having a look at it. If u dnt wanna put it up on here u cud PM me. Thats if u want to  ;D .

Thanks

Gooner

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Join survivors frm other groups to make one group
« Reply #15 on: 11 Aug 2004, 07:41:14 »
I have thought of a few improvements.  Will show it to you when I have 'really' finished

Offline Ottie

  • Members
  • *
  • And you think this is personal
Re:Join survivors frm other groups to make one group
« Reply #16 on: 11 Aug 2004, 07:52:17 »
Remember when making the script that wounded units can hold up the group, for example a unit that can not walk anymore, will make slow dowm the new group.

Make a check where you decide if you wanna take the wounded groups also.

If you can't beat them, buy them

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Join survivors frm other groups to make one group
« Reply #17 on: 11 Aug 2004, 14:46:11 »
Good point.  In the situation I am in I make no distinction for wounded , but there are hostiptal tents nearby so the leader can direct his wounded units there.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Join survivors frm other groups to make one group
« Reply #18 on: 11 Aug 2004, 21:18:58 »
OK here is the code for a reasonably generic combining of infantry groups.  The names of some of the variables reflect the particular mission I wrote it for.  I expect the code can be tightened up significantly but at least what follows seems to work.

In the init.sqs file put:

CheckInProgress = false

You also need to give each of the infantry groups a name.  You should then create an array of all the names of the groups you want to consolidate together.  This is an extract from my mission:

Base2Groups = [eg12Grp,eg6Grp,eg8Grp,eg14Grp,eg15Grp,eg13Grp,eg5Grp]

(The sequence is relevant but I wouldn't worry about it)

Note you can add to this array during the mission as reinforcing groups arrive.

You can use a different name for the array providing you edit the scripts below (only one line needs to be changed in each script.)

Now you need to decide if you want all survivors to consolidate ultimately to one specific group, or do you not care which group is the last one standing.

If one specific group is to be the last one standing then put:

[this] exec "JoinToThisGroup.sqs" in the initialisation field of the group leader for that one group.

and put:

[this] exec "JoinToOtherGroup.sqs"   in the initialisation field of the leaders of all the other groups.

If you don't care which is the last group standing just use the JoinToOtherGroups script for all of the groups.

JoinToThisGroup.sqs
Code: [Select]
; JoinToThisGroup.sqs.  Consolidated Russian groups as they take casualties
; called by [unit]exec"JoinToThisGroup.sqs"


; unit is one unit in the specific group that all join to in the end

; a global array called Base2Groups should exist and contain each of the groups to be
; considered for joining together


_unit = _this select 0
_group = group _unit


_smallsize = 3
_largesize = 12


goto"FirstTime"

#Loop

CheckInProgress = false

#FirstTime

~10

#NotReady
~ random 1
if CheckInProgress then {goto"NotReady"}

CheckInProgress = true

_othergroups = Base2Groups - [_group]

_NumOfGrps = count _othergroups
_i = 0

#LoopOthGroups

_OthGroup = _othergroups select _i

_SizeThisGroup = count units _group
_SizeOthGroup = count units _OthGroup

if ((_SizeOthGroup < 1) or ((_SizeThisGroup + _SizeOthGroup) > _largesize) or ((_SizeThisGroup > _smallsize) and (_SizeOthGroup > _smallsize))) then {goto"SkipGrp"}

units _OthGroup join _group


#SkipGrp
_i = _i + 1
if (_i <_NumOfGrps) then {goto"LoopOthGroups"}

goto"Loop"

#End

CheckInProgress = false

exit


JoinToOtherGroup.sqs
Code: [Select]
; JoinToOtherGroup.sqs.  Runs for selected Russian groups
; checks the size of the group and when it is small seeks other groups to join with
; called by [unit]exec"JoinToOtherGroup.sqs"

; unit is one unit in the specific group

; a global array called Base2Groups should exist and contain each of the groups to be
; considered for joining together

_unit = _this select 0
_group = group _unit


_smallsize = 3
_largesize = 12


~ 5 + random 10

goto"FirstTime"

#Loop

CheckInProgress = false

#FirstTime

~10

#NotReady
~ random 1
if CheckInProgress then {goto"NotReady"}

CheckInProgress = true

_othergroups = Base2Groups - [_group]


_SizeThisGroup = count units _group

if (_SizeThisGroup > _smallsize) then {goto"Loop"}
if (_SizeThisGroup < 1) then {goto"End"}

_NumOfGrps = count _othergroups
_i = _NumOfGrps - 1

#LoopOthGroups

_OthGroup = _othergroups select _i

_SizeOthGroup = count units _OthGroup

if ((_SizeOthGroup < 1) or ((_SizeThisGroup + _SizeOthGroup) > _largesize)) then {goto"SkipGrp"}

units _group join _OthGroup

goto"End"

#SkipGrp
_i = _i - 1
if (_i >= 0) then {goto"LoopOthGroups"}

goto"Loop"

#End

CheckInProgress = false

exit
« Last Edit: 11 Aug 2004, 21:21:05 by THobson »