Home   Help Search Login Register  

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

0 Members and 1 Guest are viewing this topic.

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 »