OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Ryu on 28 Dec 2003, 11:43:01

Title: createunit
Post by: Ryu on 28 Dec 2003, 11:43:01
Can anyone tell me what's wrong with this?

"KEGSSoldierEB" createunit [getpos pos1, officer1, "sol1 = this; this setbehaviour safe", 0.8, "PRIVATE"]

It creates the unit but not in safe mode. Officer1 is already in safe mode.

cheers
Title: Re:createunit
Post by: Artak on 28 Dec 2003, 23:02:36
The syntax for setbehaviour is unitname setbehaviour "safe".

To get it working you'd put the 'safe' in {}'s

"KEGSSoldierEB" createunit [getpos pos1, officer1, "sol1 = this; this setbehaviour {safe}", 0.8, "PRIVATE"]

like so.
Title: Re:createunit
Post by: Ryu on 29 Dec 2003, 09:31:56
No, that doesn't work. No error message but not safe mode
Title: Re:createunit
Post by: deaddog on 29 Dec 2003, 15:03:42
If Officer1 is a UNIT, then you're using createunit wrong.  Try this:

"KEGSSoldierEB" createunit [getpos pos1, group officer1, "sol1 = this; this setbehaviour {safe}", 0.8, "PRIVATE"]

You have to create units into an existing group (which can be empty of units).
Title: Re:createunit
Post by: Artak on 29 Dec 2003, 18:30:43
If the group was not defined right the unit would not have been created at all I think.

What a puzzle.

Ok, consider this. Maybe the unit is not created to safe mode because the group leader of the group the unit is created in is not in safe mode.(?)
Title: Re:createunit
Post by: Ryu on 30 Dec 2003, 05:39:48
 :( NO, still no luck. The officer is on patrol and set to safe.
Title: Re:createunit
Post by: deaddog on 30 Dec 2003, 06:24:15
The answer is to set the behaviour separate from the createunit command:

"SoldierEB" createunit [getpos officer1, group officer1, "sol1 = this", 0.8, "PRIVATE"]; group officer1 setbehaviour {safe}

You can put the setbehaviour command after all units have been created.  This also means you won't have to name each unit as you create it.
Title: Re:createunit
Post by: Ryu on 30 Dec 2003, 10:41:03
 :)Great, that did it.
BTW I like to name the units I create to deleate them when they are no longer needed.

Thanks guys