Jump to content
Sign in to follow this  
charlis

How to detect specific cargo positions

Recommended Posts

Hi all, I did a lot of research and have no idea on how to do this.

This intention is to use in my OA mission where I want setcaptive true some soldiers while they are in the back seats of the SUV ( the one with tints in the windows) and setcaptive false if they are on the driver or front passenger seat and outside of it. The intention is to use it like a Trojan horse in the mission.

I was able to do the check in a trigger if the units are in or out, but could not take out the driver and front-passenger seat issue. I know it´s a little too much perfectionism, but if it´s not that hard, I mean in a point i can handle (I suck at scripting), that would be by far much cooler!!!

Thanks very much!!!

Share this post


Link to post
Share on other sites

just get a civi to driver the SUV - he will drive past the enemy with out a worry :)

Just make sure the civi wont jump out of the car when he spots the enemy :)

Share this post


Link to post
Share on other sites

I already know that civilians aren´t shot freelly, but the point is that I have to do it how asked, letting the units from the 4 existent backseats not being shot.

I thought that this can´t be done without more complex scripting, which I suck very much.

Thank´s anyway!

Share this post


Link to post
Share on other sites

I use 3 civi's in the front of a truck - players board that truck and the AI drive past all the enemy straight to the drop off point.

no scripts

the truck is seen as civilian not matter whats in its cargo but u have to make sure the civilians are moved into the truck before you add the player units and make sure the civi's don't jump out of the truck when they spot the enemy or the truck becomes enemy and you end up getting shot.. ;)

Demo Mission

Edited by Junker

Share this post


Link to post
Share on other sites

To move cargo into the back seats just use the cargo index command.

soldierOne moveInCargo [jeepOne, 1] 1 being the 1st cargo position, increase this to find the seat you need.

Share this post


Link to post
Share on other sites

@Junker

thank you very much for your effort!

I understood what you mean and also had already did that before, but in this case, the problem is that the driver could be anyone of the players, that´s exactly the purpose of my question.

It´s a way to force the player in the "regular soldier" role to keep hidden in the backseats, only other players in "civilian infiltrated" role can drive through the city occupied by enemy. ( this civInfil have to drop the soldiers covertly into a specific building for an assault).

@F2K Sel

Thanks for helping with another question.

I also did that before but that´s not the case now.

The idea is to "setcaptive true" the "regular army soldier" players only if they are at #2, #3, #4 or #5 positions (the backseats with black tint glasses) of the OA´s SUV.

What I need is a way to check "who" are in the specific cargo position for me to setcaptive "false" as I couldn´t find a command that check or gives me back this info.

The "civilian infiltrated" players, had already a setcaptive true if they don´t hold any weapon (as Kylania and F2K Sel helped me in other tread).

Thanks all again

Share this post


Link to post
Share on other sites
To move cargo into the back seats just use the cargo index command.

soldierOne moveInCargo [jeepOne, 1] 1 being the 1st cargo position, increase this to find the seat you need.

So I have to know somehow if a specific unit is at passanger seat (cargo pos #1) or driver. The driver part is easy, put I can´t figure out how to check the specific cargo pos.

I already searched for these commmands:

-crew

-AssignedVehicleRole

-in vehicle

-cargo

Any idea? Any command/function that returns cargo indexes?

Share this post


Link to post
Share on other sites

AssignedCargo is the array you're looking for. It contains the units assigned as cargo in the given vehicle. I guess checking something like

myunit in assignedcargo nameofvehicle

should work. Never tried though.

Share this post


Link to post
Share on other sites

Thnx Prof but it still doesn´t , only the list of the units in the cargo, but not their positions.

Share this post


Link to post
Share on other sites
Thnx Prof but it still doesn´t , only the list of the units in the cargo, but not their positions.

Maybe you could check if the first position of the array is the first cargo position (ie the front passenger seat ?), as units always board vehicle seats in the same order IIRC (the order of the proxy names in the p3d model). So something like "(assignedcargo nameofvehicle) select 0" should be the front passenger, isn't it ? (unless the front passenger has been killed while you were at the rear of the vehicle, because then the "assignedcargo" array would be updated).

Share this post


Link to post
Share on other sites

crewSetCaptive.jpg

It can be made into a single action as well if your units start in the vehicle. You can change the 1 in the condition to 3 so that captives are only in the last seat row of the car.

Share this post


Link to post
Share on other sites

It seems the problem is that you cant tell who is sitting next to the driver?

In other words the front seat can have a player in it as driver and the player in it as passenger? The front seat may have only driver at other times?

If the front passengers are allready setcaptive TRUE then I cant see why it matters to just re add the command to all vehicle crew but I guess you cant do that so....

My best guess would be to separate the front seat riders from the back somehow by either loading them first and saving them into an array. If you could somehow separate the loading of the vehicle in such a way then you have an array to check against later....

;load front passengers (not entered here)
_frontpassengers = crew HummyVee

;load rest of passengers (not entered here)

_allcrew = crew HummyVee


;setcaptive true all units in crew with a loop UNLESS they are IN _frontpassengers

_unit = _allcrew select _number
? _unit in _frontpassengers:goto "Skip"
_unit setcaptive TRUE

thats rough draft code you will have to add loops etc.

The only other way I can think of is to use something like modeltoworld to check if the current unit in vehicle crew is just to the right of the driver and not behind the driver but that could be tricky to do.

You can get the static distance between driver to front passenger like this:

Set up a test mission in editor...

first just name two units one called driver and the other front seat.

Moveindriver the driver, moveincargo the passenger into a vehicle with their init lines

ensure the passenger is in the front seat.

Then hint with a trigger the distance from driver to passenger. The game should correctly hold the exact positions of the units in the vehicle. I know this because if you getpos a pilot in a chopper on the ground it shows up as .2 meters (seat height) and not 0 which would be the choppers height on ground (skid height).....

remember the driver to front seat passenger distance.....

Then in your mission you can add this code:

_frontpassengerseat = _driver modeltoworld [distancetopassenger,0,0]

Im just guessing there as the coordinates coulld be the negative of what I wrote you have to test it out.

Anyway, you could establish the known front passenger position with modeltoworld and then check every non driver crew member distance to that position and skip the unit that has zero distance to that position because he is the front seat passenger. This should be done while the vehicle is stationary which should not be a problem as its hard to board a moving vehicle :D !!

Its a bit convoluted but I think it might just work.....

If we can get an infrontseat check in the commands that would save all this work. Maybe I will add it to the new script command request thread in general section.

Edited by TJ72

Share this post


Link to post
Share on other sites

Thnx ProfTournesol and SHK, will try both aproachs

@SHK

Actually, Players will have to "kidnap" the SUV so they won´t start on it

Let see if I understood, pls correct me if I´m wrong:

as the crew command return will return crew in order [driver,gunner,commander,turrets,cargo] (as seen in biki), so I compare the unit (players in case) to the position of the cargo in the returned array, right?

But I believe that won´t solve it because probably, the passenger seat , beside the driver, would be considered the first cargo pos, wouldn´t it?

I´ll try that anyway for learning purposes and them report here.

Thnx again for the help!

Share this post


Link to post
Share on other sites

crew select 0 == driver

crew select 1 == front seat

crew select 2 and 3 are middle seats

crew select 4 and 5 are last row

Share this post


Link to post
Share on other sites
crew select 0 == driver

crew select 1 == front seat

crew select 2 and 3 are middle seats

crew select 4 and 5 are last row

crew vehicle select 0 could return the first cargo guy if there is no driver in the vehicle.

Share this post


Link to post
Share on other sites

@SHK

I´ll try

On Cond Field: (crew suv) find player <= 1

On act: setcaptive false

On Dea: setcaptive true

So when the SF guys are in the backseats they are setcaptive true, and when in the front seats the are setcaptive false. Teorically, it will work just as I need.

I´ll try to Hint the units in the suv to check/study with different combinations os seats taken, just hope, I´m able to do it.

crew vehicle select 0 could return the first cargo guy if there is no driver in the vehicle.

...maybe I can put a gamelogic occupying the seat before doing the check or something like this if there is no driver. I´ll do some tests.

thnx guys

---------- Post added at 09:05 PM ---------- Previous post was at 08:28 PM ----------

Hi TJ, I missed your post sorry.

It seems the problem is that you cant tell who is sitting next to the driver?

In other words the front seat can have a player in it as driver and the player in it as passenger? The front seat may have only driver at other times?

Hmmm.. ..not exactly, in the mission, the players will be TAkistani soldiers, some as army (Tak SF) and some infiltrated as civilians/militia. Basically, they have to infiltrate Zargabad, wich was taken by UN Forces and extract a local warlord.

The infiltrated ones (civ/militia) are setcaptive true if have no weapons. They are supposed to act as informants/undercover assassination and to direct TakSF mortar fire (if wanted).

Also, I want that the Tak SF guys, can pass undetected through enemy checkpoints, if on stolen SUV (from an clear pass convoy, again if squad leader desires).

The idea is to make the infiltration a little easier if squad leader decide to ambush a convoy.

For now, I can make all SF guys captive true anywhere in the vehicle, but it would be perfect if they can´t be driving nor besides him, as SUV has tint in the backward windows. This is another option for both SF and infiltrated cooperation along the mission.

Anyway, you could establish the known front passenger position with modeltoworld and then check every non driver crew member distance to that position and skip the unit that has zero distance to that position because he is the front seat passenger. This should be done while the vehicle is stationary which should not be a problem as its hard to board a moving vehicle :D !!

Good idea, a different approach based on distance, very clever!

In the context I´d like to use it, maybe it will be a little easier to measure distance from the front seats (the ones which would make SF setcaptive false) to, lets say, the car engine, for example, the Sf guys closest to engine, the ones on front seats will setcative false.

If we can get an infrontseat check in the commands that would save all this work. Maybe I will add it to the new script command request thread in general section.

That would be awesome! As far I try to "missions edit", since OFP, I´ll always stop at a little more advanced scripting, even having a good idea on how it works. I apreciate any help in make it happen (always MP compatible if possible).

I´ll try to test some of all this ideas but might take some time with my "trials and errors" procedure.

Thanks all.

Edited by Charlis

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  

×