Jump to content
Sign in to follow this  
BlenderRUS

Check if vehicle's cargo indexed position is empty?

Recommended Posts

Hello.

I'm writing some VBS2-like vehicle interaction menu for A2.

Job is almost done but I want to add empty positions check to change images in dialog.

I've used: commander _veh, driver _veh, gunner _veh, and turret [_veh, [_index]] but there is no cargo _veh command to know if certain position is empty.

emptyPositions nor crew cant solve this problem.

Will be glad for any help.

Thank you.

P.S.:

Little video of what is done now:

Share this post


Link to post
Share on other sites

I'm not complete sure about this subject, so I'm just throwing in some thoughts and hopefully you didnt try them out yet. I dont know how you handle the GUI, does it pull the data of the crew every time it is opened? Like does it check the crew every time it is opened or do you store the occupied seats in a variable that gets updated whenever a player jumps in a seat? That would be the way I would do it. Save the number of seats for the vehicle (I assume you can get them out of the config) with a bool that represents occupied or not and the object reference ( [cargo1,true,solider1]) You only have to ensure that the variables get updated like when a solider gets shot out of the vehicle, the seat is set to free again. Maybe the getOut eventhandler does trigger when a body gets thrown out of a vehicle? Or whenever the GUI gets opened you check if there are all the units inisde the car you have stored a variable for and if not check for the missing one and seit their seats as free?

Another idea would be to use moveInCargo to check if the desired cargo position is availiable or not, like checking for the unit being in the vehicle afterwards or maybe it even throws an error when the desired slot is occupied.

Share this post


Link to post
Share on other sites

Thank you for your reply.

I've tried to use EH but GetIn and GetOut doesnt trigger when you change positions. And because of same reason variables method is useless too.

I'm using "player action" method which doesnt return anything and if seat is not empty it will automatically try to find another free cargo seat.

Vehicle Dialog is updating realtime so checking with moveInCargo is a bad idea also there may be some collisions with different players trying to use same cargo seat.

Tomorrow I will check how A2 movein mouse wheel actions work .. but I think that it uses emptyPositions count.

Share this post


Link to post
Share on other sites

How did you get the position for the UI? Did you do trial and error for the different vehicle types or did you find a way to get the position of the vehicles seats? If there is a way to get those positions you can try to use modelToWorld to get the positons of the crew and calculate the crew<->vehicle offset and then just compare those results to seat positions relative to the vehicle.

Share this post


Link to post
Share on other sites

For now I wrote a script that creates all vehicles from vehicles config with player jumping into every seat and building array with [_vehType, worldToModel, seatType (driver, cargo..), seat index] then creating a config for every vehicle type.

UI just gets an array for vehicle type and converts position to screen.

I tried to use selectionPosition but seems its not working with proxies, only selections in memory/geometry LODs.

So I've created a feature request on dev-heaven to add a new command like in VBS2's getCrewPos or extend existing command functionality.

Share this post


Link to post
Share on other sites

Then you could use the very same method to check which seats are occupied. When the UI has to be updated go through all the units inside the vehicle, get their models relative positions, compare with the seat positions and compute the free and occupied seats.

Share this post


Link to post
Share on other sites

Good idea! Thank you!

Just need to spend some time determining players min/max offsets from the original position.

I'll publish addon when it will be finished :)

Share this post


Link to post
Share on other sites

Hey BlenderRus, have you tried this with the C130? I was doing something very similar(not the UI, but mapping cargo seats) and found all my worldToModel positions in the cargo of the C130 returned [0,0,0].

Didn't have that problem with any other vehicle I had tried.

Share this post


Link to post
Share on other sites
Hey BlenderRus, have you tried this with the C130? I was doing something very similar(not the UI, but mapping cargo seats) and found all my worldToModel positions in the cargo of the C130 returned [0,0,0].

Didn't have that problem with any other vehicle I had tried.

Yes there are some problems with model position on the seats which have viewCargo LOD (especially for units inside armored vehicles).

C130 have the same viewCargo LOD for cargo positions. I didnt solve this problem yet.

UPD: I found some solution to get positions in vehicles with seat proxies in another LODs...

Move all proxies to the main LOD (0.000).

After that you can return real position in model.

Yeah I know its not an ideal solution but it works for me... at least untill A2 dont have certain command for that purpose.

Edited by BlenderRus

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  

×