Home   Help Search Login Register  

Author Topic: creating new groups  (Read 1376 times)

0 Members and 2 Guests are viewing this topic.

Offline ezol

  • Members
  • *
  • blah
creating new groups
« on: 10 Jun 2005, 00:36:55 »
Is it possible to create a group from a script out of units you've
created in the same script?

I don't know what group to put the first soldier I create in.
Or if I stick him in an existing group how to make him leave and form
his own?

I know it's possible to define lots of groups in the mission editor and
respawn units etc.  But a scripted example would be so much more elegant as well as easy to replicate in new missions.

i.e. To have a script that creates a copy of a given group ( defined in editor ), in a position, to move to a point etc..

I'm sure I can do everything except the group bit of the createunit.


Right that's all working now and I've posted an example script and function in
pending scripts.
« Last Edit: 10 Jun 2005, 23:53:17 by ezol »

qqqqqq

  • Guest
Re:creating new groups
« Reply #1 on: 10 Jun 2005, 00:39:22 »
Quote
Is it possible to create a group from a script

Nope.



[loon1] join grpNull

Offline ezol

  • Members
  • *
  • blah
Re:creating new groups
« Reply #2 on: 10 Jun 2005, 00:54:45 »
cheers qqqqqq

For anyone remotely interested a basic group creation
script is then

_movehere = _this SELECT 0
_i = 0
_bt = typeof player

_bt createUnit [getpos t2, g1,"",0.4,"SERGEANT"]
_aunits = list t2
;t2 being a trigger, with no-one in it etc.


[(_aunits SELECT 0)] join grpNull
_grp = group ( _aunits SELECT 0 )

#Here
_bt createunit[(getpos t2), _grp,"",0.5, "Private" ]
_i = _i + 1
~1
?(_i < 11):goto "Here"

_grp move (getpos _movehere)
Exit


; I'll post a function with the abilty to copy a group and return
; the new grp as soon as I'm up to speed with ofp functions
« Last Edit: 10 Jun 2005, 01:01:32 by ezol »

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:creating new groups
« Reply #3 on: 10 Jun 2005, 07:45:38 »
Welcome to the forums, guys :)

It definitely is possible, in much the same way you've got it there, ezol.

I'd suggest not making the group name local though (_grp), as then you can use it in the mission editor and triggers as well.

When I spawn groups in, I generally have one guy off the map area somewhere (offshore on an island), in a group called newgrp.
I then createunit the leader of my created group into newgrp, and join him to GrpNull.

Then I do what you did, and assign him a group name by:
grpname = group spawnedguy

Then I can create the rest of his group into grpname

The disadvantage with using the same local variable over and over is that you'll get (very wierd) errors if you spawn more than 12 guys into the same local variable ;)

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:creating new groups
« Reply #4 on: 10 Jun 2005, 11:36:35 »
I thought new groups could be created but had to be assigned to a pre-exisitng group? Is this still true?
urp!

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:creating new groups
« Reply #5 on: 10 Jun 2005, 12:02:47 »
No you can create entirely new groups.  Also bear in mind that even a single unit is a group.  In my signature is a link to a script for joining groups together.  It works by finding all the groups that already exist on the map (including those that have only one unit) and then joing the small ones together.

Offline ezol

  • Members
  • *
  • blah
Re:creating new groups
« Reply #6 on: 10 Jun 2005, 15:11:40 »
Mr.Peanut

I've now posted a script to copy a group and send it on its way etc.
This is wrapped up with an Example. No Addons Needed.