Home   Help Search Login Register  

Author Topic: CreateUnit in AI group?  (Read 589 times)

0 Members and 1 Guest are viewing this topic.

kevind2003

  • Guest
CreateUnit in AI group?
« on: 04 Jan 2004, 01:11:31 »
Hi,

Can someone teach me how to createunit in AI group? (the group is not existing yet). Thanks
« Last Edit: 04 Jan 2004, 01:12:05 by kevind2003 »

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:CreateUnit in AI group?
« Reply #1 on: 04 Jan 2004, 11:17:48 »
Place a lone unit in a save place (don't let it die) on your map. Put
Code: [Select]
AIgroup = group this into its init-line.

Now you've got an AI group called AIgroup.
(You only use this group for spawning the leader of a new group you want to spawn, the rest of the new group will be spawned directly into the new group.)

You need a position where to spawn the new group, for example just place a tent in the editor and name it "tent".

Now you can spawn the leader:
Code: [Select]
"OfficerE" createUnit [(getpos tent), AIgroup,""];
The leader is the 2nd unit in the AIgroup. We take him and move him to his own group that will be created by OpF automaticly:
Code: [Select]
_member = (units AIgroup) select 1
[_member] join grpNull;
_newteam = group _member

Now _newteam is your new group that you can spawn the other soldiers into:
Code: [Select]
#spawn_rest
"SoldierEB" createUnit [(getPos tent), _newteam,""]

?(count units _newteam == 12):goto "teamfull"
goto "spawn_rest"
#teamfull

This will spawn 11 more normal Soldiers to your leader.

Btw: you'll notice a little lag when spawning the group the 1st time. That's because OpF needs to load 3dmodels, textures and whatever for a russian Officer and a russian Soldier. OpF can't know what units you want to spawn with a script, so these resources are loaded at the very moment they'll spawn, creating annoying lags. If you want to get rid of this, you'll have to place an Officer and a Soldier anywhere else on your map. You could place them over the ocean, it's not neccessary they live - they are just there to let OpF load the resources at missionstart.
« Last Edit: 04 Jan 2004, 11:24:41 by DrStrangelove »

kevind2003

  • Guest
Re:CreateUnit in AI group?
« Reply #2 on: 05 Jan 2004, 10:01:45 »
Thanks  8)