OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Mad Pup on 24 Feb 2010, 22:02:55
-
Hello All..... Mad Pup here.... I have a question about the createUnit command. I am using a unit that comes from an addon called MiG Animals... The unit is called "Cow" (In the mission editor anyhow). What would I put in the script for createUnit?
THANKS
~ Mad Pup
-
What part about createunit are you stuck on? Have you succeeded in creating any units? If not, try putting a game logic called someplace, a unit with initialization "alpha = group this", and execute
"SoldierEB" createunit [getpos someplace, alpha]
in a script somewhere.
If you need the name of the cow vehicle type, consult the documentation for MiG Animals. Or, place a cow unit, save mission, and look at mission.sqm to see what was placed. The relevant entry should look like this:
class Item3
{
position[]={5152.100586,16.334999,3999.496094};
azimut=270.000000;
special="NONE";
id=9;
side="WEST";
vehicle="SoldierWB";
rank="CORPORAL";
skill=1.000000;
};
Except that vehicle="SoldierWB" will say something else.
-
A fairly quick way of discovering the class name for an object is to insert the below code into it's init field and preview the mission. It will display the classname in the form of a hint.
Hint format ["%1", typeof this]
-
Okay, I Tried This..
"MiG_Cow" createVehicle [getpos HERE, alpha]
and it said "Error Type Array, expected Number
... This means??
~ Mad Pup
-
You've got createvehicle (http://www.ofpec.com/COMREF/index.php?action=details&id=86&game=All) confused with createunit. (http://www.ofpec.com/COMREF/index.php?action=details&id=85&game=All) ;)
FYI, that error message means that there's an array where there's supposed to be a number. The command is trying to operate on something that it wasn't designed to work with. This can happen because you're using the wrong command, inserting the wrong values, mistyped a command, mistyped a value, misplaced parentheses, etc.
-
Okay..... I tried
"MiG_Cow" createUnit [getpos HERE, alpha]
and now it doesn't do anything... no errors, and no cow...... (sorry, I'm not that good with Mission Editing lol)
so what code would you use?
~Mad Pup
-
so what code would you use?
First I would replace "MiG_Cow" with "SoldierWB" to test to see if the position and group are valid. If they are it should create a basic West soldier, group alpha, wherever HERE is.
"SoldierWB" createUnit [getpos HERE, alpha]
If that works, then "MiG_Cow" does not refer to an existing class name. If the code above doesn't work, then either the position is not valid or the group is not valid. Check to make sure that HERE is the name of a unit or gamelogic, and alpha refers to a real group.
Here, compare whatever you're doing with the mission attached below. Unzip, place folder in user missions, load in mission editor, hit preview, and hit Radio Alpha to spawn a soldier in the group of the man in front of you.
EDIT: Hey Mad Pup, I just realized that there's a good chance that MiG_Cow is considered a vehicle rather than a unit. In that case, you will in fact need createvehicle rather than createunit. But createvehicle has a different syntax than createunit. Try this code:
cow1 = "MiG_Cow" createvehicle getpos HERE