OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Gcfungus on 21 Apr 2008, 20:18:04

Title: Creating Units
Post by: Gcfungus on 21 Apr 2008, 20:18:04
I want to make a mission where groups can be created at a certain position and assault a town (marker "town1").
So, as a tester to see if this was possible, I made this:

Code: [Select]
_player = _this select 0
_pos = getpos _player
_x = _pos select 0 +5
_y = _pos select 1 +5
_pos1 = [_x,_y,0]

L1 = "OfficerW" createunit [_pos1,group _player]
[L1] join grpnull
_group = group L1
"SoldierWB" createunit [_pos1,_group]
"SoldierWB" createunit [_pos1,_group]
~5
_group domove getmarkerpos "town1"
exit

with: [this] exec "test.sqs" in the players init.

However, I get this message: '"SoldierWB" createunit [_pos1,_group]|# |': Error genetic error in expression

What can I do to fix this, or can't it be done?
Thx, -=GC=-Fungus1999
Title: Re: Creating Units
Post by: Mandoble on 22 Apr 2008, 01:36:57
Code: [Select]
"OfficerW" createunit [_pos1,group _player, "L1 = this"]
Title: Re: Creating Units
Post by: Gcfungus on 22 Apr 2008, 08:38:20
Thx, Mandoble, the error message went, but still nothing happens.  :dunno: ???
Is there anything else I have missed?
Title: Re: Creating Units
Post by: Mandoble on 22 Apr 2008, 16:31:37
try
Code: [Select]
_pos1 = [(getPos player select 0)+5,(getPos player select 1)+5,0]
Title: Re: Creating Units
Post by: Gcfungus on 22 Apr 2008, 17:57:13
Having updated the original to:

Code: [Select]
_player = _this select 0
_pos1 = [(getPos _player select 0)+5,(getPos _player select 1)+5,0]
"OfficerW" createunit [_pos1,group _player,"L1 = this"]
[L1] join grpnull
_group = group L1
"SoldierWB" createunit [_pos1,_group]
"SoldierWB" createunit [_pos1,_group]
~5
_group domove getmarkerpos "town1"
exit

Still nothing.  >:(
Title: Re: Creating Units
Post by: Mostly on 23 Apr 2008, 16:01:30
Try this. It works for me.
You need a game logic named "Base" (this will be the location of the spawned units), and a dead unit with this in the init field "DummyGroup = Group this". Then select whatever trigger you want to use and insert this into the Act field "[Base] exec SCRIPTNAME"
Code: [Select]
_base = _this select 0

#fillgroup

#spawnleader
"SoldierWB" createUnit [getPos _base, dummygroup]

;assign to other group
_member = (units dummygroup) select 1
[_member] join grpNull
_grp = group _member

#spawnrest
"SoldierWB" createUnit [getPos (_base), _grp]

?(count units _grp == 5):goto "groupfull"
goto "spawnrest"

#groupfull
; register new group in groupsarray for later use
?(count allgroups == 0):allgroups = [_grp]
?(!(_grp in allgroups)):allgroups = allgroups + [_grp]

EXIT
This should create a full group of men.
 :yes: