Home   Help Search Login Register  

Author Topic: How to destroy an empty group ?  (Read 475 times)

0 Members and 1 Guest are viewing this topic.

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
How to destroy an empty group ?
« on: 24 Aug 2003, 12:25:42 »
Hi there.

I ran into problems with a big script that spawns groups and let them fight against each other. After about 1 hour of great fights, the spawns stop.

By adding a debug mode i have targeted the problem: no more soldiers can be spawned into a group, but since i run it within a loop, it never ends:

Code: [Select]

_teamscale = 10

#spawn_groupleader
(patrolunits_west select _leader) createUnit [getPos _mybase, westdummygroup,"this exec {patroldead.sqs}"]

;assign to other group
_member = (units westdummygroup) select 1
[_member] join grpNull
_grp = group _member

#spawn_patrolrest
~(random 1)
(patrolunits_west select 1+(random (count patrolunits_west - 1))) createUnit [getPos _mybase, _grp,"this exec {patroldead.sqs}"]

?(count units _grp >= _teamscale):goto "patrolteamfull"
goto "spawn_patrolrest"

#patrolteamfull

I register each spawned group in my Allgroups array:

Code: [Select]
; register new group in groupsarray

;if _grp is already registered, make a new one
?(_grp in _patrolteams):hint "WARNING";"deletevehicle _x" forEach units _grp;goto "spawn_groupleader";

?(count _patrolteams == 0):_patrolteams = [_grp]
?(!(_grp in _patrolteams)):_patrolteams = _patrolteams + [_grp]


After my groupleader joins grpNull, OpF inits a new group named automaticly (Alpha,Bravo,Charlie,etc). Now i believe once in a while it all starts at Alpha again and because Alpha does exist already i can't spawn new units into it. Maybe there are still infos of dead units in it ?

I could imagine that by 'destroying' a group name, could be a solution. Is it ? How can it be done ? How do other scripts handle group spawns ?

HELP !  :P

deaddog

  • Guest
Re:How to destroy an empty group ?
« Reply #1 on: 24 Aug 2003, 16:00:52 »
Try setting _grp to nil:

nil
Type of returned value:
    Any Value
Description:
    Nil value. This value can be used to undefine existing variable.

Example:
    variableToDestroy = nil


And then redefine it later.

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:How to destroy an empty group ?
« Reply #2 on: 26 Aug 2003, 23:00:25 »
Doesn't work with <groupname> = nil

But i found out how to refill an existing group: just delete the bodies of all dead (former) group members. If you do not, they 'block' the group somehow.

This can be easily archieved with a little 'dead-script' that delete them when the appropiate !(alive soldier). All dead members need to be deleted before you try to refill the group, otherwise problems occur.