Home   Help Search Login Register  

Author Topic: creating a unit not in a group  (Read 1595 times)

0 Members and 1 Guest are viewing this topic.

Offline Killzone

  • Members
  • *
  • War is the true Enemy
creating a unit not in a group
« on: 17 Apr 2005, 01:02:33 »
Hi, ;D


Is there a way to create a unit that is not part of a group. A unit that is all alone.

The line I usually use when creating a unit is something like this:

"civilian" createunit [getpos car1,group (leader),"a = this",1,"Private"]

I tried erasing the group (leader) but it did not work.

If I use the createvehicle command instead but he will not move when I use the move command.  

Thanks for the help
« Last Edit: 17 Apr 2005, 01:03:45 by Killzone »
"Everyone dies so deal with it and move on"

                                                      ME

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:creating a unit not in a group
« Reply #1 on: 17 Apr 2005, 03:20:02 »
Every unit is in a group, even if you only have one unit, he is in a group......all by himself, he is his own group.

And of course you can only create a unit with 'createUnit' into an existing group.

An existing group does not need to have any members, but it will still exist.
For instance if all members of that group are dead the group still exists, so you can create units to re-populate the group.

That is my understanding of the situation anyway.   ;D


Planck
I know a little about a lot, and a lot about a little.

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:creating a unit not in a group
« Reply #2 on: 17 Apr 2005, 03:34:14 »
You can always join him to a group then unjoin him.

I generally have one unit way off the map (on a small offshore island or something) and join created units to his group. Then I use:

[ unit ] join GrpNull

to unjoin him, and he's all by himself :)

voodzia

  • Guest
Re:creating a unit not in a group
« Reply #3 on: 17 Apr 2005, 11:23:47 »
Hi,
I've got similar problem so gonna post it here. I'm trying to create a chopper and crew for it. And I don't know why but I can't see the pilot. Chopper appears exactly where it should be but where's e_pilot? I just want to add that I get no error when this script is being executed.

Code: [Select]
hip = "Mi17" createVehicle getPos h
hip setDir 180
~2
"SoldierEPilot" createUnit [getpos a1, e_inf, "e_pilot=this;[this] join grpnull", 1, "SERGEANT"]

Btw, a1 is the name of game logic object and e_inf is the name of existing group.
« Last Edit: 17 Apr 2005, 11:28:20 by voodzia »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:creating a unit not in a group
« Reply #4 on: 17 Apr 2005, 11:46:55 »
the script you show seems to create an empty chopper, and then 2 seconds later creates a unit called e_pilot at the position of game logic a1.

if you want the pilot to be in the chopper, you need to add the action into the createunit command, thus -

Code: [Select]
"SoldierEPilot" createUnit [getpos a1, e_inf, {e_pilot=this;[this] join grpnull; this action ["getin driver", hip]}, 1, "SERGEANT"]

that should do it.

voodzia

  • Guest
Re:creating a unit not in a group
« Reply #5 on: 17 Apr 2005, 11:51:41 »
Thanks for reply but what to do if I don't want this pilot to be in the chopper? I'd rather him to be created and placed next to Mi17 and then board this chopper. How can I do that?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:creating a unit not in a group
« Reply #6 on: 17 Apr 2005, 12:15:23 »
mkay, well ignore the action and call it whenever you want the loon to board as pilot. assuming the GL is next to the chopper, that's where the loon will appear. so -

Code: [Select]
hip = "Mi17" createVehicle getPos h
hip setDir 180
~2
"SoldierEPilot" createUnit [getpos a1, e_inf, "e_pilot=this;[this] join grpnull", 1, "SERGEANT"]
~2
e_pilot action ["getin driver", hip]
e_pilot assignasdriver hip
 


« Last Edit: 17 Apr 2005, 12:15:53 by bedges »

voodzia

  • Guest
Re:creating a unit not in a group
« Reply #7 on: 17 Apr 2005, 12:29:32 »
Sorry but still nothing. This pilot is invisible or something? And yes, GL is right next to chopper.
« Last Edit: 17 Apr 2005, 12:30:22 by voodzia »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:creating a unit not in a group
« Reply #8 on: 17 Apr 2005, 14:54:48 »
just tested it myself, and no it doesn't work does it.

this does -

Code: [Select]
e_pilot = "SoldierEPilot" createUnit [getpos a1, e_inf, {}, 1, "SERGEANT"]

problem being he won't unjoin a group it seems, nor does he want to get into the chopper.

okay, problem solved i think.

create the pilot using some throwaway variable

Code: [Select]
ep = "SoldierEPilot" createUnit [getpos a1, e_inf, {e_pilot = this}, 1, "SERGEANT"]

[e_pilot] join grpnull

e_pilot action ["getin driver", hip]
e_pilot assignasdriver hip



that will create the pilot, put him in the chopper and tell him he'll be flying it.
« Last Edit: 17 Apr 2005, 15:12:29 by bedges »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:creating a unit not in a group
« Reply #9 on: 17 Apr 2005, 15:04:14 »
I think you need some sort of delay between creating the chopper and creating/putting the pilot in.

When you create a vehicle with createVehicle it can sometimes take quite a few seconds before you can actually get in it....or anyone else for that matter.



Planck
« Last Edit: 17 Apr 2005, 15:05:26 by Planck »
I know a little about a lot, and a lot about a little.

voodzia

  • Guest
Re:creating a unit not in a group
« Reply #10 on: 17 Apr 2005, 15:51:40 »
@bedges
I copied your code to my script and still nothing :( I get no errors but the pilot isn't being created.

@Planck
I added 5 sec. delay but it didn't help either :(

Also I removed this GL object and now I refer to "h" object when creating this unit. I just have no clue what's going on here!?

CrashnBurn

  • Guest
Re:creating a unit not in a group
« Reply #11 on: 17 Apr 2005, 16:28:07 »
@ bedges- you are steering him wrong. Steer clear of the thread if you aren't sure of the answer.  :-X ( nice of u to try and help tho)  ;)

@ voodzia- Try what Sui suggested. If you don't want the unit on the map then delete him in his ini. -

alpha = group this; deletevehicle this

Now you have a group name to work with and the unit is gone. I do this all day long and it works just fine. Use any group name you like. If you want the pilot to board the helo later, it could take several minutes for him to recognize the helo. However, you can move him into it almost immediately after creating it with the moveindriver/moveingunner command. Give it at least a 1 second delay before doing so. If you don't want him flying it right away set the fuel to 0 on the helo.

_helo1 = "Mi24" createvehicle getpos logic1
~1
"SoldierEPilot" createunit [getpos logic1, alpha, "p1 = this", 1, "CAPTAIN"]
"SoldierEPilot" createunit [getpos logic1, alpha, "p2 = this", 1, "LIEUTENANT"]
~1
p1 moveindriver _helo1
p2 moveingunner _helo1

This code is correct and is taken from the createunit tutorial at the editors depot. I know...I wrote it.  :) Make sure you have the correct version of OFP that allows you to use the createunit/createvehicle commands (1.34).
« Last Edit: 17 Apr 2005, 16:31:04 by CrashnBurn »

voodzia

  • Guest
Re:creating a unit not in a group
« Reply #12 on: 17 Apr 2005, 17:32:13 »
Thank you CrashnBurn for your help. At last I did what I wanted to. Here's my code and it works just fine.

Code: [Select]
hip = "Mi17" createVehicle getPos h
hip setDir 180
~1
"SoldierEPilot" createUnit [getPos h, sn_rcn, "hip_pilot=this", 1, "LIEUTENANT"]
[hip_pilot] join grpnull
e_plts = group hip_pilot
hip_pilot assignAsDriver hip
~1
"SoldierEPilot" createUnit [getPos h, e_plts, "hip_gunner=this", 1, "SERGEANT"]
hip_gunner assignAsGunner hip
(Units e_plts) orderGetIn TRUE

Btw, when crew gets in halo they don't fly away or even turn the engine on. So why should I set fuel to zero?

And one more thing - I think I know why this code wasn't working at the beginning. The group I was using initially has already 12 units so I guess there couldn't be created another unit who belongs to this group. Am I right? And that's why I find this trick with creating and deleting unit very useful. Thanks again CrashnBurn.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:creating a unit not in a group
« Reply #13 on: 17 Apr 2005, 17:52:51 »
alternatively (just to show i do know what i'm talking about  ::) ) see attached...

voodzia

  • Guest
Re:creating a unit not in a group
« Reply #14 on: 17 Apr 2005, 18:09:35 »
Yep, that's right - I've just tested this demo mission and it works fine. Thanks bedges for your help.