Jump to content
Sign in to follow this  
kyfwana

How to reference a specific unit placed in the mission editor?

Recommended Posts

I want to assign to a variable a reference to a specific unit placed in the editor, no matter whom is controlling that unit, ai or player. I assume there is some way to get a specific unit reference from it's "name"?

Share this post


Link to post
Share on other sites

Isnt it just giving it a name?

And call that name, in you scripts?

Thats what i have done before :)

Share this post


Link to post
Share on other sites

What do you mean exactly by "call that name".

Unfortunately all search results I find are people trying to do the opposite of what I want, people who want to get the name of a unit they already know. I'm trying to get the unit itself only knowing its name.

Share this post


Link to post
Share on other sites

Well, give them a name in the editor and then call that name in a script.

If you give a unit in the editor a name, you can call it from scripts, to check if its alive/dead/whatever :)

Share this post


Link to post
Share on other sites

A search for "call name" returns no relevant info. Can you be more exact with what you mean by "call that name in a script"? Maybe give an example? Is it just literally "_unit = call unitname"? Will that assign to _unit a reference pointing to the unit with name unitname, which in this example is the name given to it in the mission editor?

Edited by kyfwana

Share this post


Link to post
Share on other sites

Place a unit on the map.

Look at the top right corner and see a list

Rank

Unit

Special

Name

Skill

In the Name box type a name.

I like to use blue1 and red1 for blue force soldiers and op force soldiers

When I have a team I might call them: blue11, blue12, blue13

A second team might be named: blue21, blue22, blue23

That way things are organisd.

---------- Post added at 10:26 AM ---------- Previous post was at 10:23 AM ----------

I name a soldier blue7

I name a mortar mortar1

Here is a mini script. I am "calling' blue7 and have him get in that mortar.

blue7 moveInGunner mortar1

.

Share this post


Link to post
Share on other sites

Thanks for the reply. In your example, would all computers be able to see the names "blue7" and "mortar1" and be able to make changes to the units that correspond to those names? Or would only the computer that those units are local to be able to do that?

For example, if "blue7" is controlled by a player from a machine which is not the server, will the server be able to see the name "blue7" and access that unit through its name?

Edited by kyfwana

Share this post


Link to post
Share on other sites

No.

When you write a script only you the author can see the script. Unless you send to others by email.

And when you are playing the game you cannot see the script.

Now place 7 units on the map. Make yourself blue1 and name one of them blue7

Now preview

Which one is blue7? The answer is that it is impossible to know. It is a flaw in the game.

.

.

---------- Post added at 12:31 PM ---------- Previous post was at 11:41 AM ----------

I want to assign to a variable a reference to a specific unit placed in the editor, no matter whom is controlling that unit, ai or player.

If the unit is controlled by the AI, my solution above works.

If the unit is controlled by human, you need to order the human to do something. Call him on the radio.

If you want a script to give an order to a human, eg the human fires a trigger and you want him to man a mortar then when the trigger fires, write a command that places words on the screen: Blue7, please get in that mortar.

Share this post


Link to post
Share on other sites

Okay, so let me get this strait.

If I put a unit in the editor and name it "Blue7",

And a player joins the game and takes control of "Blue7",

and a script running on the server contains the following code: _blue7 = blue7

Will _blue7 point to the unit with the name "blue7" or wont it?

Share this post


Link to post
Share on other sites

I can't answer that.

But in your example blue7 is a human so he will do what ever he wants. Your script cannot make a human player to get in that mortar.

Share this post


Link to post
Share on other sites
I can't answer that.

But in your example blue7 is a human so he will do what ever he wants. Your script cannot make a human player to get in that mortar.

Of course it can. If you moveInGunner a player, he is put into the vehicle you specify. Of course, the player can choose to exit the vehicle, but he will be in when the command is executed.

You can verify yourself: place a player in the editor, and an empty mortar, name it mortar, preview, and type 'player mobeInGunner mortsr' on the console.

By the way, giving a unit a name basically creates a variable with that name whose value is the object. So _blue7 = blue7 does work

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×