Home   Help Search Login Register  

Author Topic: createVehicle / createUnit oddities  (Read 1103 times)

0 Members and 1 Guest are viewing this topic.

CareyBear

  • Guest
createVehicle / createUnit oddities
« on: 07 Oct 2002, 10:45:10 »
Ok, I started playing around with these with a few radio triggers so I could see how the commands behaved before I tried to implement them.

They're weird. Ok, here's what I set up

markers: "here" & "here2", someplace visible (I used intro island)

Player, init: plygroup = group this

Soldier, init: newgroup = group this

Trigger: R. Alpha, repeating "Create unit in my group"
xxxu = "SoldierWPilot" createUnit [getmarkerpos "here", plygroup]

Trigger: R. Bravo, repeating "Create unit in that group"
xxxu = "SoldierWPilot" createUnit [getmarkerpos "here", newgroup]

Trigger: R. Charlie, repeating "Create unit in new group"
xxxu = "SoldierWPilot" createUnit [getmarkerpos "here", addagroup, "addagroup = group this", 0.5, "PRIVATE"]

Trigger: R. Delta, repeating "Create Vehicle"
xxxv = "M1Abrams" createVehicle getMarkerPos "here2"

Trigger: R. Echo, repeating "Delete Vehicle and Unit"
deleteVehicle xxxv; deleteVehicle xxxu

So: Alpha creates a unit and adds it to the player's group. Bravo creates a unit and adds it to another soldier's group. Charlie creates a unit and (in theory) adds it to a new group. Delta creates a tank, and Echo deletes the created tank and unit. Pretty simple stuff & I wasn't really anticipating any problems.

WHAT HAPPENED:

Radio Alpha created a soldier in my group, at the marker position. Fine, except Radio Echo would NOT delete the unit, alive or dead. Repeat calls on Alpha did create additional units, whether the pilot was alive or dead. Much as expected, apart from not being able to delete any of them.

Radio Bravo created a soldier and added it to another group, and worked fine, regardless of whether that group contained any living units. (So, therefore, an empty group can exist - since you can't reference dead units from their group?) Radio Echo still did nothing.

Radio Charlie did nothing at all. It would appear that the group will need to exist before you can add someone to it.

Radio Delta created a tank. Then, hitting it again created a new tank.. and again, a new tank.. Nicely placed near each other. Radio Echo deleted only the most recently created vehicle.

For radio Charlie, I also tried the soldier's creation line as:
addagroup = []; xxxu = "SoldierWPilot" createUnit [getmarkerpos "here", addagroup]

but it spat the dummy at me. So I tried

addagroup = group null; xxxu = "SoldierWPilot" createUnit [getmarkerpos "here", addagroup]

and it didn't mind at all - but still no unit.

Has anyone tried this before? Have an explanation for what's goin down with deleting created units? The comref specifically states that

deleteVehicle object
Operand types:
    object: Object
Type of returned value:
    None
Compatibility:
    Version 1.34 required.

Description:
    Delete any unit or vehicle. Only vehicles inserted in editor or created during mission can be deleted. Player unit cannot be deleted.

Example:
    deleteVehicle tank

(er, there's another kind of unit that's not inserted in editor or created during mission? :-\ Must mean map objects / buildings etc)

But to solve my *specific* problem, can someone tell me how to create a group mid-mission, either by splitting a group or by creating an empty group, or by creating a unit that is the first unit in a new group.

Sorry this was so long, but I was trying to be as precise and informative as possible about this one - it's... strange...

EDIT: Did further testing using a trigger uxxx doFire player. Nothing happened. Didn't even look at me. So, it appears that createUnit does NOT assign the created unit to the variable!
?(this == True): sucks_ass = sucks_ass + [this]  ::)
« Last Edit: 07 Oct 2002, 11:51:46 by CareyBear »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:createVehicle / createUnit oddities
« Reply #1 on: 07 Oct 2002, 16:53:38 »
yeah ur prob is dat u cant name a created unit (createunit command) in da wayu did - here is how u nem it

"SoldierWPilot" createUnit [getmarkerpos "here", plygroup,"xxxu=this"]

now ur unit is named xxxu  ;D - so u can make it join grpnull to split it from group or delete it or watever

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

CareyBear

  • Guest
Re:createVehicle / createUnit oddities
« Reply #2 on: 07 Oct 2002, 17:27:08 »
Cheers for that - knew it had to be something simple.... It always is... At some point, I might actually get around to annotating a copy of the command reference with all the things that I've felt very stupid asking here.. well, felt very stupid after I've read the answer anyway.

Now, of course, the Returned: None under createUnit in the comref sticks out a mile.

Was startin to annoy me. I didn't know you could name a unit in it's init line as well as it's name field - or is that only for created units?

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:createVehicle / createUnit oddities
« Reply #3 on: 07 Oct 2002, 17:32:05 »
no if u put in a init of a unit - somthin = this - da unit wil b named somthin  ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta