Jump to content
CryptEarth

attach object to vehicle

Recommended Posts

// update

I opened a feedback tracker ticket: https://feedback.bistudio.com/T180317

// original

So, maybe this is already asked a lot - so, please feel free to point me to topics already have solutions ...

 

I'm currently design my first mission. It should be a simple one contain a series of tasks. One thing that should be done is to load a barrel (Land_MetalBarrel_F) to a vehicles back like an offroad (C_Offroad_01_F) or truck (C_Van_01_transport_F).

The rough background story:

- steal a truck or offroad - something with an open flatbed

- steal an empty barrel from some storage and load it onto the truck

- drive the vehicle with the empty barrel to some spot

- do something there (current plot goes towards "filling the barrel with some raw fluid")

- drive it somewhere else to "process it" (kinda like AltisLife: process crude oil into refined gasoline)

- drive the "processed" stuff to some drop off

- get rid of the vehicle

 

I want to keep it simple - so, there doesn't has to be some fancy animation like a player "picking up" the barrel and physically load it onto the flatbed - but a simple script checking if the player is pointing at the barrel and if a suitable vehicle is parked near - and then "loading the barrel onto the flatbed" - and fix it at some position relative to the vehicle.

From some scripts I looked at there seems something like "attaching" the barrel to the vehicle with some relativ coordinates.

 

Why not use one of the fuel trucks in the first place? It's about the overall story: "do the first job with a stolen barrel on a stole offroad/truck" - then to progress you do the next turn with a fuel truck or a zamak fuel - and maybe after a third with a tempest fuel you end up doing a run with the very large hemtt fuel - like getting bigger at your business starting all with just an offroad and an old barrel.

 

Maybe someone can give me some advice how to achieve this?

 

Thanks in advanace =D

  • Like 1

Share this post


Link to post
Share on other sites

@CryptEarth,
 

Quote

I want to keep it simple - so, there doesn't has to be some fancy animation like a player "picking up" the barrel and physically load it onto the flatbed

Picking up the barrel and moving it is the same command as attaching it to the vehicle (without animation)

Quote

- but a simple script checking if the player is pointing at the barrel

This is an addAction

Quote

and if a suitable vehicle is parked near - and then "loading the barrel onto the flatbed"

This would be "typeOf" and,

Quote

- and fix it at some position relative to the vehicle.

an array of memory points.

Your object may need a variable. Something like,

//first stage
_barrel setVariable ["you_state", "empty"];

//second stage
_barrel setVariable ["you_state", "filled"];

//third stage
_barrel setVariable ["you_state", "refined"];

to define each stage.
You can use those variables to easily determine the conditions of addactions like,

When it is "empty" it can be picked up/loaded.
When it is "filled" it can be refined.
When it is "refined" it can be sold.

Keep in mind NPCs don't like driving vehicles with objects attached.

Following topic,

Have fun!
 

  • Like 2

Share this post


Link to post
Share on other sites

Well, although it's over 3 years I haven't touched this I just played around in the editor today.

As some recent update added the function to manage Vehicle-in-Vehicle cargo within the editor I found the function group to manage Vehicle-in-Vehicle cargo - which fits my idea exactly.

For testing I used a HEMTT flatbed and a Huron container, added the following code at was able to get my result.

this addAction ["load",{transporter setVehicleCargo transportee},nil,1.5,true,true,"","(isVehicleCargo transportee) isEqualTo objNull"];

I named the HEMTT "transporter" and the container "transportee" and added a condition so the option only shows up when the container is not already on a truck.

Unfortunately I was only able to get it work with a HEMTT and not with an Offroader or the small Truck - but I guess there's some trick around it.

At least I finally found a starting point to get it done properly from within the engine instead of fiddle around myself with attachTo.

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, CryptEarth said:

...

 

Unfortunately I was only able to get it work with a HEMTT and not with an Offroader or the small Truck - but I guess there's some trick around it.

At least I finally found a starting point to get it done properly from within the engine instead of fiddle around myself with attachTo.

 

setVehicleCargo only works with certain combinations of vehicles and cargo. As an FYI, for the command to work the following must be true:

  • The vehicle needs to have a defined capacity ( mass and volume  ) 
  • The cargo needs to be defined with appropriate values for the same.
  • The cargo must no exceed the capacity of the vehicle.

You can read more details here but to summarise that's all defined on the config side so as a mission creator at best you can test the combination using:

 

vehicle canVehicleCargo cargo

 

Note that the returned value is not true/false but rather an array of Booleans: [ willFitIntoCurrentVehicle, willFitIntoEmptyVehicle ]

 

  • Thanks 1

Share this post


Link to post
Share on other sites

As far as I played around it seems an issue with the small Truck and the Offroader as I was able to load many different containers from the small Ammo Box all the way up to the Taru Containers.

But I wasn't able to load even the small Ammo Box onto the small Truck - although it can fit 4 people on the back.

There seems an override possible with the config.

I also found a mod on the workshop - basicaly a loading framework - its description warns about issues with nested loading like a Quad in a Van on a Flatbed. I guess it could be that small Truck and Offroader not got the ability to load small containers to prevent issues when they get loaded on a Flatbed - or maybe they were just missed/forgotten. Guess I'll file a report on the bug tracker to have devs look into it.

Share this post


Link to post
Share on other sites

So I dug a bit deeper and the info here gave me some clue: https://steamcommunity.com/workshop/filedetails/discussion/1199318917/3183345000081944292/#:~:text=For%20vehicles%20with,this%20to%20work.

The point is that a vehicle which has infantry spots, like the offroader or the small truck, can not load cargo in these (whic the BoxLoader scripts somehow override).

A special case seems the van which can be configured to "add passenger spots" in the editor: when set one can add several infantry but no cargo into the bag of the van - when unset cargo can be added but only a few passenger seats (the one at the side door and the two at the rear door).

As I wasn't able to figure out how to play around with that via script (as I wasn't able to extract the differences in config) I guess a good option would be to file a ticket on the feedback track for the offroader and the small truck get the same ability added.

Share this post


Link to post
Share on other sites

After some more playing in the editor and looking at the configs I figured that Offroad (covered) and Offroad (comms) can load cargo - and they also can be loaded onto a HEMTT Flatbed although the config page says otherwise.

Unfortunately they can only hold very small containers like the Supply Box and Uniform Box or the various Basic Ammo/Weapons/Explosives and even the long Launcher and Special Weapons - basically all that one can find with "ammo" in the props.

And - at least most important to me: They also can fit the Metal and Plastic Barrels - and even the big Water Barrel - NICE!

So - the base function is already in the game - I'll request some additions to that in my ticket https://feedback.bistudio.com/T180317.

  • Like 1

Share this post


Link to post
Share on other sites

attachto, attachobject, attachedobject, with an addaction  on the barrel should be able to make the barrel do what you want. It will work on any truck or even a car. It will look funny on the car but you can put it in the bed of the pickup truck easily with the right coordinates. The barrel can be named  which makes it even easier, as can the truck.

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

×