Jump to content
timmiej93

What does "&Vehicle" and "TARGET_ANY" mean?

Recommended Posts

Hey guys,

 

I've found above statements in the LAFireStation script in the LA mod, but I assume this works for every mod.

 

The statements are used in a dummy and  command where the target vehicle is random, namely the dummy that spawns personnel for vehicles that are empty in the firestation, and a command that repairs any damaged vehicles in the fire station (by spawning an engineer and making it repair them).

 

Considering above bit of text, I assume the & thingy is something like a location finder? It finds where the vehicle is so it can send the personnel to the right spot?

 

And the TARGET_ANY thingy, is that something like Actors, Roles and Behaviors? If so, how does it work? If not, how does it work?

 

Hope you can help

 

Tim

Link to comment
Share on other sites

TARGET_ANY just means that the person can run to any place at the target.
If you for example use TARGET_EQUIPMENTDOOR the person will run to the equipment doors or TARGET_PASSENGERDOOR will make the person run to the passenger doors :)

 

Possible targets: 

TARGET_ANY,TARGET_EQUIPMENTDOOR,TARGET_SHEARSDOOR,TARGET_PASSENGERDOOR,TARGET_REARDOOR,TARGET_FIREHOSE_HOOKUP,TARGET_ENGINE,TARGET_EXTINGUISH,TARGET_ENGINE_EXTINGUISH,TARGET_AXE,TARGET_CHAINSAW,TARGET_ENTRANCEDOOR,TARGET_MEGAPHONE_DISTANCE,TARGET_DLK_BASKET,TARGET_LOADUP,TARGET_ENTRY_WINDOW_PARKING,TARGET_DLK_BASKET_BASE,TARGET_TREATMENT,TARGET_UNLOAD,TARGET_ENTRY_WINDOW,TARGET_INSTALL_FGRB,TARGET_SHOOT,TARGET_FOLLOW,TARGET_DLK_EXTINGUISH,TARGET_UNLOAD_TFMB,TARGET_FLAME_EFFECT,TARGET_CROSS_BRIDGE,TARGET_OPPOSITE_BRIDGE,TARGET_EXTINGUISH_PERSON,TARGET_PONTON_BRIDGE,TARGET_TOUCHPERSON,TARGET_USE,TARGET_OBJECTSURFACE,TARGET_FREE_CONNECTOR,TARGET_RANDOM,TARGET_HOUSE_SAFE_DISTANCE,
Link to comment
Share on other sites

All the sdk's for emergency4 can be downloaded here: http://www.emergency-forum.de/index.php?page=DatabaseItem&id=1771 

They are a must have for scripters! 

 

And the & usually means that they refer to an already named object 

so if it says: 

Dog.PushActionMove(ACTION_APPEND, &Evi, TARGET_ANY);

the dog moves to the already specified object called Evi 

Link to comment
Share on other sites

  On 8/19/2014 at 10:58 PM, bma said:
And the & usually means that they refer to an already named object 

so if it says: 

Dog.PushActionMove(ACTION_APPEND, &Evi, TARGET_ANY);

the dog moves to the already specified object called Evi 

 

Not exactly true. The ampersand '&' simply denotes a pass by reference as opposed to a pass by value.

 

The difference?

 

&Evi means you are passing the entire object into the function. Any modification to the value of Evi inside of the function will also take effect outside of the function.

Without the &, a copy of Evi is passed into the function so that any modification made to Evi inside of the function will have no effect on its value outside of the function.

 

Its sort of like sharing your sandwich with your friend (whatever he does to it, also effects you) [Pass by reference] versus making your friend his own sandwich (whatever he does to his 'copy' of the sandwich does not effect your own sandwich) [ pass by value].

 

The sandwich analogy is a bit lame but hey...I was winging it :P

 

More information about pass by value and pass by reference.

Link to comment
Share on other sites

I think I get it, but could you explain to me why that's used in below bit of code?

p.SetUpgradeLevel(3);Game::FindFreePosition(&p, Spawn, 250);p.SetPosition(Spawn);p.PushActionMove(ACTION_NEWLIST, &v, TARGET_ANY);p.PushActionTurnTo(ACTION_APPEND, &v);p.PushActionEnterCar(ACTION_APPEND, &v);

Entire script if you need it:

  Reveal hidden contents

Link to comment
Share on other sites

p.PushActionMove(ACTION_NEWLIST, &v, TARGET_ANY);p.PushActionTurnTo(ACTION_APPEND, &v);p.PushActionEnterCar(ACTION_APPEND, &v);

Each of these functions are written to require that a reference to the Vehicle object be passed in. If you try and take the '&' out and just pass the 'v', we'll probably get an error.

 

Since you're passing in the actual Vehicle object (as denoted by &v) instead of just a copy, the function is able to directly modify the Vehicle's properties, which allows it to change position (move), change orientation (TurnTo) or edit the content information such as passengers (EnterCar).

 

If you were to just pass v instead of &v, the functions would be modifying a COPY of the Vehicle Object...leaving the original Vehicle object unchanged. For example:

p.PushActionMove(ACTION_NEWLIST, v, TARGET_ANY); //Note the 'v' and not '&v'

You would be telling PuchActionMove() function: "Hey! I don't want you touching the vehicle object directly...instead, I want you to have your own copy of it to do as you please."

So the language interpreter makes a copy of the vehicle object in memory, and passes that copy into the function.

In that case, the function would change THE COPY's position, leaving your vehicle in-game unchanged since it's data was never altered.

 

Pass by Value....Pass by Reference....It's all a method of controlling data access in a program.

 

Hope that helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...