OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Kundich on 04 Jun 2005, 00:55:16

Title: Needed: Solution for CreateUnit to MoveInDriver CreateVehicle...
Post by: Kundich on 04 Jun 2005, 00:55:16
I have a script that:

_car = _veh createVehicle getMarkerPos _start
_civ = _unit createUnit [[(getPos _car select 0)+5, (getPos _car select 1)+5, (getPos _car select 2)], _grp]

Basically, it creates the units the way I want it to.  The problem is,  _civ neither starts in _car, nor seems able to be coaxed into moving to the driver's position.  And I've thrown everything but the kitchen sink at it:

_car lock FALSE
_grp Move getPos _car
[_civ] allowGetIn TRUE
_civ assignAsDriver _car
[_civ] orderGetIn TRUE
_civ action ["getin driver",_car]
_civ moveInDriver _car

Heck, I've even written delays into the script to give _civ a chance to get his head out of his @#&%*$@!!!  What in the world am I doing wrong?!!  


Thanks,
ADM
Title: Re:Needed: Solution for CreateUnit to MoveInDriver CreateVehicle...
Post by: Planck on 04 Jun 2005, 02:07:51
Try leaving a pause of about 10 secs after creating the car before ordering him in.

There is often a delay after using createvehicle, where you can't get in for several seconds after creation.


Planck
Title: Re:Needed: Solution for CreateUnit to MoveInDriver CreateVehicle...
Post by: Kundich on 04 Jun 2005, 02:24:46
Thanks, but it did not seem to work.  I even extended the delay to sixty seconds, but no dice on the _civ in the _car.

What could be causing this little...glitch?
Title: Re:Needed: Solution for CreateUnit to MoveInDriver CreateVehicle...
Post by: THobson on 04 Jun 2005, 09:11:15
_grp  needs to be a real group that already exists and _unit needs to be a known unit type.  Then after creating _civ it should be removed from the group and then a moveInDriver will work

This is an extract from a script of mine:

Code: [Select]
if (_side == west) then {_man = "SoldierWPilot"}
if (_side == east) then {_man = "SoldierEPilot"}
_i = (count units _grp)
_man createUnit [getPos _ch,_grp,"",1]
_Plt = units _grp select _i
[_Plt] join grpNull
_Plt moveInDriver _ch

_man createUnit [getPos _ch,_grp,"",1]
_Gnr = units _grp select _i
[_Gnr] join _Plt
_Gnr moveInGunner _ch

Title: Re:Needed: Solution for CreateUnit to MoveInDriver CreateVehicle...
Post by: CrashnBurn on 05 Jun 2005, 12:10:08
Naming the unit in the createunit command line always works.

_group = _this select 0
_position = getmarkerpos "mymarker"

_helo = "Mi24" createVehicle _position
~1 + (random 1)
"SoldierEpilot" createunit [_position, _group, "p1=this", 1, "CAPTAIN"]
"SoldierEpilot" createunit [_position, _group, "p2=this", 1, "LIEUTENANT"]
~1 + (random 1)
p1 moveindriver _helo
p2 moveingunner _helo
_group setcombatmode "RED"
_helo move getpos blah blah .....
Title: Re:Needed: Solution for CreateUnit to MoveInDriver CreateVehicle...
Post by: THobson on 05 Jun 2005, 12:32:01
That is a neat way to give a unit a name.  But the code will leave the chopper crew as members of _group.

Also - should there not be a " after  = this  ?
Title: Re:Needed: Solution for CreateUnit to MoveInDriver CreateVehicle...
Post by: CrashnBurn on 06 Jun 2005, 21:47:29
Yes the crew is still part of the group. That's easy to change if need be. I use dummy groups for createunit (usually) by placing a soldier on the map, group naming him and deleting him. I also give him waypoints so the created units can use them. Works like a charm!


Also - should there not be a " after  = this  ?
Yes that was a typo on my part...oops!