Home   Help Search Login Register  

Author Topic: Create Unit  (Read 1738 times)

0 Members and 1 Guest are viewing this topic.

LAPD

  • Guest
Create Unit
« on: 16 Jan 2003, 17:01:37 »
Hi :wave:

Does someone know how can i can suddenly create units in the game?

In the coop mission i'm making you need to conquer a base and then hold it. Since I want the mission to work swift, i want less objects or units on the screen. Altough the counter-attacks are far positioned from the base, I want them you be created only when the base has been conquered. The enemy are the east forces.

Thanks in advance :)
« Last Edit: 16 Jan 2003, 17:03:55 by LAPD »

SpecOps

  • Guest
Re:Create Unit
« Reply #1 on: 16 Jan 2003, 17:18:56 »
i am not sure but i believe it has something to do with
createUnit
but i dont know how to use it.
try to play with it.

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Create Unit
« Reply #2 on: 16 Jan 2003, 19:37:15 »
You need to use the createUnit command.

type createUnit unitInfo
Operand types:
    type: String
    unitInfo: Array
Type of returned value:
    Nothing
Compatibility:
    Version 1.34 required.

Description:
    Create unit of given type . Format of unitInfo is: [pos ( Position ),group ( Group ), init ( String ), skill ( Number ), rank ( String )] Note: init, skill, and rank are optional, default values are "", 0.5, "PRIVATE".

Example:
    "SoldierWB" createUnit [getMarkerPos "barracks", groupAlpha]


The key to using this command is that you need to have a predefined group to which this unit will join.  Do the following steps:

1. Add a unit using the editor, and in its initialization field, name the group.  For example: enemy1 = group this

2. Also, in the initialization field, delete the unit immediately.  deleteVehicle this.  This creates an empty group that you may later use to create the new units.  In effect, it initializes the group.

3. When it comes time to create the new enemy units, use the createUnit command to create the units at the locations where you want them to start.

4. Repeat steps 1-3 as many times as necessary, using a different group name in step 1 for each new group.
Ranger

LAPD

  • Guest
Re:Create Unit
« Reply #3 on: 17 Jan 2003, 13:57:22 »
Thanks Speck ( ;) ) and Ranger

Well, I did what you said Ranger, and I got the first 2 steps done. When it comes to the third step, I don't know how to use the CreateUnit command. My Group now is Enemy1?
and my Unitname is S1. I created a marker on the map and named it barracks.

So i tried to do this:

"S1" createUnit [getMarkerPos "barracks", groupEnemy1]

I tried many things but none of them work. How exactly do I use this command?

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Create Unit
« Reply #4 on: 17 Jan 2003, 19:08:24 »
Thanks Speck ( ;) ) and Ranger

No problem at all.

Not that this seems to be your problem, but I should have been more clear in what to put in the initialization field.  Make sure there's a semicolon between the two commands.  E.g.:

enemy1 = group this; deleteVehicle this

Quote
Well, I did what you said Ranger, and I got the first 2 steps done. When it comes to the third step, I don't know how to use the CreateUnit command. My Group now is Enemy1?
and my Unitname is S1. I created a marker on the map and named it barracks.

So i tried to do this:

"S1" createUnit [getMarkerPos "barracks", groupEnemy1]

The syntax is as follows (to clarify the comref's listing):

"unitType" createUnit [[pos, group, init, skill, rank ]

unitType = The class name of the unit, such as SoldierWB, SoldierEB, SoldierWLAW, etc.  This is not an arbitrary name that you choose.  You can only use the class names (unit types) defined by the game's .pbo files (add-ons).

pos = 3-dimensional position of the unit.

group = The name of the group into which this unit will be created.  The group must already exist.

init = Optional.  The initialization field (string) of the unit.

skill = Optional.  The skill rating of the unit, ranging from 0.2 to 1.

rank = Optional.  The rank of the unit.


So, examining what you posted, you made two mistakes.  First, you specified the unit type as "S1", which does not exist.  You need specify the type of unit you want to create, instead.

Second, you tried to create the unit into a group named "groupEnemy1".  However, you didn't create any such group, since your group is really named "enemy1".

A working example of this command could be as follows:

"OfficerWHG" createUnit [getMarkerPos "barracks", enemy1]

This will create a west officer with the M9 at the same position as the marker named "barracks", and put this officer into the group named "enemy1".  Since I did not specify the optional parameters init, skill, and rank, those will all acquire the default values of "", 0.5, and "PRIVATE", respectively.
« Last Edit: 17 Jan 2003, 19:11:40 by Ranger »
Ranger