Home   Help Search Login Register  

Author Topic: Having problems creating units dynamtically  (Read 584 times)

0 Members and 1 Guest are viewing this topic.

madwolfnemesis

  • Guest
Having problems creating units dynamtically
« on: 10 Jul 2003, 17:35:11 »
These are the objectives I wanna meet:

- Create soldiers associated with certain groups
- Specifically assign weapons and ammo to them
- Give each solider a individual name each so that it can be shown when my crosshair meets with the soldier.

I have problems using the function createUnit[]. I tried to created a Marker on the map and callde upon this:

"johnH" createUnit[getMarkerPos "marker1", groupAlpha]

I just couldn't see my solider appearing at all. But no error was generated from the script. Any suggestions or hints? Much will be appreciated, thank you.

Also, is there anyway to overwrite that commands other than the OP default. Perhaps, instead of pressing '1', '1' (Form back to my formation), '7', '6' (Prone Down), can I specify so that I change certain of the settings. Please advise.

Thank you.

ARVN Marvin

  • Guest
Re:Having problems creating units dynamtically
« Reply #1 on: 10 Jul 2003, 19:08:28 »
Straight from ComReference,

type createUnit unitInfo

Operand types:
type: String
unitInfo: Array
Type of returned value:
Nothing
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]


So it looks like you left out the "unit type"  ie: "SoldierWB"
As far as I know, "johnH" isn't a unit type.  ;)

madwolfnemesis

  • Guest
Re:Having problems creating units dynamtically
« Reply #2 on: 11 Jul 2003, 05:09:37 »
I tried, but failed again. What does the getMarkerPos means? I tried creating an empty marker by the name of barracks, yet, I dun see any soldiers at that location. Also, should should I go about grouping them up?

Say, I create 2 soldiers in design time, what should I put in init to group them together in a group by the name of groupPlatoon?

And then I create another 3 soliders in run-tim (That is to say I put the codes in init.sqs) and uses them createUnit command, how should I go about naming the individual soldiers to Tom, Jack and Henry?

Please advise. Thank you.

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Having problems creating units dynamtically
« Reply #3 on: 11 Jul 2003, 11:38:36 »
this is the line you want
"SoldierWB" createunit [getmarkerpos "Okrouhlo", Okrouhlogroup, "a1 = this",0.3,"Corporal"]

this is the explination you want
"SoldierWB" is the stringname for a standard US soldier. You can find most of the string names from the official command reference, which you can find from the editors depot under references.
createunit is the command you want to be using
getmarkerpos "Okrouhlo" tells the command to create the soldier to a spot marked with a marker that's named as Okrouhlo.
Okrouhlogroup is the name of the group the soldier will be created into. NOTE that you can't create soldiers if you don't have a group ready and waiting for them to be born so to say. To solve this you should create one unit to the map and type  Okrouhlogroup = group this  in it's init field. He will be the commander of the units you create to that group.. unless you later on unjoin the leader from the group.. anyways, that's how it goes  :)
"a1 = this" is the init field of the created soldier. You can type in there all the normal stuff you could in an init field in editor. For example   this setbehaviour "safe"  will make him born in safe behaviour mode.
0.3 is the skill of the created unit. The scale is from 0 to 1. You can also use 0.00063 if you for some reason want to.
"Corporal" is the units rank. Nothing more nothing less.

Hope that solves that because there's nothing more to it and I don't know how to make it more clear  :D ;)
Not all is lost.

madwolfnemesis

  • Guest
Re:Having problems creating units dynamtically
« Reply #4 on: 11 Jul 2003, 18:29:25 »
this is the line you want
"SoldierWB" createunit [getmarkerpos "Okrouhlo", Okrouhlogroup, "a1 = this",0.3,"Corporal"]

this is the explination you want
"SoldierWB" is the stringname for a standard US soldier. You can find most of the string names from the official command reference, which you can find from the editors depot under references.
createunit is the command you want to be using
getmarkerpos "Okrouhlo" tells the command to create the soldier to a spot marked with a marker that's named as Okrouhlo.
Okrouhlogroup is the name of the group the soldier will be created into. NOTE that you can't create soldiers if you don't have a group ready and waiting for them to be born so to say. To solve this you should create one unit to the map and type  Okrouhlogroup = group this  in it's init field. He will be the commander of the units you create to that group.. unless you later on unjoin the leader from the group.. anyways, that's how it goes  :)
"a1 = this" is the init field of the created soldier. You can type in there all the normal stuff you could in an init field in editor. For example   this setbehaviour "safe"  will make him born in safe behaviour mode.
0.3 is the skill of the created unit. The scale is from 0 to 1. You can also use 0.00063 if you for some reason want to.
"Corporal" is the units rank. Nothing more nothing less.

Hope that solves that because there's nothing more to it and I don't know how to make it more clear  :D ;)

Hey, thanks alot~! That's really helpful. I realised my mistake was that I didn't create a group of my own. Thanks agaiN!