Jump to content
Sign in to follow this  
chronicsilence

Determining nearest vehicle entry point

Recommended Posts

Let's say a player is standing next to a vehicle. You know how the action menu (scroll menu) items change based on which part of the vehicle the player is looking at? e.g. looking at the driver's door it will say "Get in Driver", looking at the passenger side door it will say "Get in Passenger", etc.

What I need to do is find a way, via script, to determine what part of a vehicle the player is looking at. i.e. how can I determine with a script whether the player is looking at the driver's side door or passenger side door?

The reason I ask is because I need to make the player get into the position they're looking at, without them having to use the action menu or press any buttons to do it (i.e. do it automatically).

Share this post


Link to post
Share on other sites

Poll the object for it's selections and use selectionPosition and modelToWorld to find nearest one.

Share this post


Link to post
Share on other sites

If you look at say "C_SUV_01" and go through the config viewer, you can see there's a number of defined get in points like:

memoryPointsGetInCargo = "pos cargo";
memoryPointsGetInCoDriver = "pos codriver";
memoryPointsGetInDriver = "pos driver";

You can get the selection names with getText and add them all to an array.

so you use that array and run it through selectionPosition command.

EG for driver on that car (called car1 here but you would use cursorTarget) it's:

_pos = car1 selectionPosition "pos driver"; hintSilent format ["%1", _pos]

Which returns: "[-1.21878,0.118077,-1.39034]"

If they return anything but [0,0,0] then you use the modelToWorld command to get the real world pos of the selection.

car1 modelToWorld _pos;

Then add that to another array and then select the closest one from that new array.

There's probably other ways to do it but that should get you started.

As for then entering the vehicle at that point, I'm not too sure as it's 8.22AM and I haven't slept yet!

Edited by Das Attorney

Share this post


Link to post
Share on other sites

I like this approach, but I'm finding it to be only semi-functional. For example, the Offroad (Armed) has a turret in the back but it does not have a CFG entry for "memoryPointsGetInGunner". So, there's no way for me to find the entry point for the gunner.

Share this post


Link to post
Share on other sites

If the vehicle position has a turret path then the getin memory points will be found under that turret. e.g

configfile >> "CfgVehicles" >> "B_G_Offroad_01_armed_F" >> "Turrets" >> "M2_Turret" >> "memoryPointsGetInGunner"

Same for things like the littlebird side seats, they are cargo but have a turret path..

configfile >> "CfgVehicles" >> "B_Heli_Light_01_F" >> "Turrets" >> "CargoTurret_01" >> "memoryPointsGetInGunner"

I think only the driver is 100% likely to be in the base memory points. eg.

although a littlebird copilot can be seen under the base memorypoints like..

configfile >> "CfgVehicles" >> "B_Heli_Light_01_F" >> "memoryPointsGetInCoDriver"

the turrret path for a littlebird copilot is [0]

configfile >> "CfgVehicles" >> "B_Heli_Light_01_F" >> "Turrets" >> "CopilotTurret" >> "memoryPointsGetInGunner"

The turret path is the selection from Turrets. eg littlebird copilot [0]

_coPilotTurret = (configfile >> "CfgVehicles" >> "B_Heli_Light_01_F" >> "Turrets") select 0

For each index in a turret path you traverse down another Turret eg. the assignedVehicleRole for a B_MBT_01_cannon_F commander is ["Turret",[0,0]]

So his getin position is

configfile >> "CfgVehicles" >> "B_MBT_01_cannon_F" >> "Turrets" >> "MainTurret" >> "Turrets" >> "CommanderOptics" >> "memoryPointsGetInGunner"

_baseCfg = ( configFile >> "CfgVehicles" >> "B_MBT_01_cannon_F" );
_turretpath = [ 0, 0 ];

_turretCfg = _baseCfg;
{
_turretCfg = _turretCfg >> "Turrets";
_turretCfg = ( _turretCfg select _x );
}forEach _turretPath ;

_getOutSelection = getText ( _turretCfg >> "memoryPointsGetInGunner" );

Hope that helps.

Share this post


Link to post
Share on other sites

This looks very helpful. It brings up a couple questions:

1) where does "CargoTurret" fit into all this?

2) Some vehicles (such as the "B_Boat_Armed_01_minigun_F") have more Cfg entries in "Turrets" then they actually have on the model. For example, that minigun boat has the "FrontTurret", "MainTurret", and "RearTurret", but only the "FrontTurret" and "RearTurret" appear to be used.

EDIT: ok, I think I got it working. But there's one thing I'm having difficulty with. Consider a Hunter ("MRAP_02_base_F"). You can get into the passenger seats from either side, when you're within about 2m of the vehicle. The memory point for getting into the passenger seats, though, ("pos cargo") is on the left side of the vehicle just behind the driver side door (x-coordinate is -1.33). This means that if I'm on the opposite side of the vehicle, things get really wonky. Are there multiple selection points or something, one for each side of the vehicle? Maybe hidden ones?

Edited by ChronicSilence

Share this post


Link to post
Share on other sites
where does "CargoTurret" fit into all this?

I believe its where you sit for just general cargo ie like back of helicopter or truck.

For example, that minigun boat has the "FrontTurret", "MainTurret", and "RearTurret", but only the "FrontTurret" and "RearTurret" appear to be used.

Even weirder is that stepping though the turrets never displays it as an option e.g from watch line in debugConsole do..

configName ((configFile >> "CfgVehicles" >> "B_Boat_Armed_01_minigun_F" >> "Turrets") select 0)

and step through 0 , 1 , 2. As soon as you get to 2 you get an out of range error.

Even something like

turs = [];
"turs pushback (configname _x)"configclasses (configFile >> "CfgVehicles" >> "B_Boat_Armed_01_minigun_F" >> "Turrets");
hint str turs;

Does not show it as a child class :?

The memory point for getting into the passenger seats, though, ("pos cargo") is on the left side of the vehicle just behind the driver side door (x-coordinate is -1.33). This means that if I'm on the opposite side of the vehicle, things get really wonky. Are there multiple selection points or something, one for each side of the vehicle?
Yes there are multiple points. Trouble is they are all called "pos cargo" and i have never figured out a way to get hold of them. Open the car example in the tools in Object Builder and examine the memorypoints for the three passenger positions and youll see what i mean. Same with the direction points aswell. I can only presume that as the engine handles the actions they are radius based so it knows what one you are closest to. If you find a way let me know, pulled my hair out a few times trying to figure that one out. Closest i got was measuring the perpendicular length to the selection from the vehicles facing direction and then used that distance based on what side of the vehicle you were on.

Share this post


Link to post
Share on other sites

That's crazy. So there are multiple "pos cargo" but the "selectionPosition" script command will only return the coordinates of one of them, and there's no way to find the positions of the others. Could you describe a little more what you mean about measuring the "perpendicular length" and using it somehow?

Share this post


Link to post
Share on other sites

Easiest way to get the positions is -x in the selectionPosition rather than (looking at some old code i wrote) working out the positions. e.g

B_MRAP_01_F selectionPosition "pos cargo" returns the rear left position (no idea why, maybe first or last added to model ?).

_pos = _vehicle selectionPosition "pos cargo";
_posRearRight = _pos set [ 0, -( _pos select 0) ];
_driverPos = _vehicle selectionPosition "pos driver";
_posFrontRight = _driverPos set [ 0, -( _driverPos select 0) ];

Basically flipping the known positions across the vehicles facing direction.

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  

×