#current player vehicle

1 messages ยท Page 1 of 1 (latest)

shadow crescent
#

This depends on the context you are in. Where did you want to put the code to control this?

deft night
#

ignore the first part

#

SCR_CharacterCameraHandlerComponent

#

this code right now disables forces 1p when player isnt in vehicle

#

I would like to modfy it so it dorces 1p everywhere expect in btr and mi 8

#

my final goal is to only allow 3p on commander and navigatoe seat but I dont even know if that is possible and how much modding it would require

shadow crescent
#

okay, that is doable ๐Ÿ™‚ but I am afraid for today my mental capacity is exhausted. Some general pointers would be to get the parent vehicle, probably available on either the char controller or the character itself you can get from it.
then you can check for the parent prefab and so some whitelisting.
you can also get the seat a person occupies for sure if you have the player and vehicle entity.

I can give you a few method names tomorrow if you want to wait, otheriwse feel free to look at the script apis you have from the char controller and see where you can navigate from there to get entities and additional components ๐Ÿ™‚

deft night
#

thank you so much

#

whenever you have time

fickle basin
#

@deft night

fickle basin
#
modded class SCR_CharacterCameraHandlerComponent
{
    override int CameraSelector()
    {
        if (IsInThirdPerson() && !m_OwnerCharacter.IsInVehicle())
        {
            SetThirdPerson(false);
            return CharacterCameraSet.CHARACTERCAMERA_1ST;
        }
        
        if(m_OwnerCharacter.IsInVehicle())
        {
            CompartmentAccessComponent compartmentAccess = m_OwnerCharacter.GetCompartmentAccessComponent();
            IEntity vehicle = compartmentAccess.GetVehicleIn(m_OwnerCharacter);
            if(vehicle.GetPrefabData().GetPrefabName().Contains("Mi8"))
            {
                SetThirdPerson(true);
                return CharacterCameraSet.CHARACTERCAMERA_3RD_VEHICLE;            
            }    
        }    

        return super.CameraSelector();
    };
};
deft night
#

but I dont think this is a good solution id I want to target the seat or?

fickle basin
#

i've just made you a simple solution to get started. You can do whatever logic you want after you get the vehicle.

deft night
#

๐Ÿซก

deft night
#

ok so I changed the code a bit it works great

#

excatly what I wanted now just to figure out the seat

deft night
#

this is what I found for seats

#

I guess if I could check if player is in passenger_r01 it could work

#

or would this be a bad method?

deft night
#

@shadow crescent did you refuel your mental capacity ๐Ÿ˜€

shadow crescent
#

Yes. How far did you get with the code posted above from Zelik? What is missing?

#

To find out what slot your character is in, there is actually an easier way. The vehicle defines what slots are available, but the character knows which slot he entered for script logic such as a gunner HUD etc.

#

Found on the character prefab

#

So what you can do is ```cs
BaseCompartmentSlot currentCompartment = compartmentAccess.GetCompartment()
if (currentCompartment && currentCompartment.GetType() == ECompartmentType.Pilot)
// do something

#

or if you want to do it the other way around you can say != piliot and then apply your restrictions ๐Ÿ™‚

deft night
shadow crescent
#

the camera is local for each player. each player knows which slot they are in, so yes.

deft night
#

yes I understand thank you do much

#

ECompartmentType has only 3 types?

#

pilot for driver
turret
cargo for passengers

#

right?

shadow crescent
#

right now yes, this can change in the future so please use an enum value for comparision and not do something like == 1

deft night
#

yes but if I understand correctly I could only chose what happens to camera when the player is driver, turret or passenger? my goal is to limit the 3p in every case expect if he is in commander seat in BTR but commander seat counts as cargo?

deft night
shadow crescent
#

probably because you already checked that the player is in a vehicle

#

if you did not do that this might be null if he is currently not in one and then blow up, so i put it there in case somebody else comes to copy or adapt my message under other conditions

deft night
#

ah ok

#

but this solution cant work because it would give all passengers 3p

#

or is there way to be more specific?

shadow crescent
#

your goal was only pilots right?

deft night
#

sorry if my english is bad hahahaha

#

I want only so commander hast the acces to 3p

#

not the driver

shadow crescent
#

ahhhh ok, then we can something else

deft night
deft night
deft night
shadow crescent
#

Okay it looks like in script there is no easy way to tell which slot is the commander one for certain

#

its not special, its just a passanger seat with a special name on the action but apart from that not much

#

For vanila vehicles you could note which compartment will be the commander but with mods it might not always be passanger_r01

deft night
shadow crescent
#

We will look into this in the future, for now I am not aware of any ways to do what you need to easily. you can only allow thrid person for driver, but comamnder not so easily

deft night
#

yes I see thank you

#

still I learned a lot

deft night
# deft night

I see this sometimes what does it mean do not modify, this script is generated. Where from?

shadow crescent
#

This is from the games code. These scripts only serve as interface between our c++ code and the game scripts. You can not mod them

deft night
#

I see

#

thank you

deft night
#

also the game is coded in c ++?

shadow crescent
#

you can not just replace the && by || that makes no sense there. you check for "i have a compartment instance and if so, what type is it". if you have no compartment you do not need to check the type. if you put and or there you have null or null.gettype() which will blow up ๐Ÿ˜‰

#

Yes anything you see in the game, that is not in the scripts in workbench, is written in c++ as part of the main game executable ๐Ÿ™‚

deft night
#
BaseCompartmentSlot currentCompartment = compartmentAccess.GetCompartment()
if (currentCompartment && (currentCompartment.GetType() == ECompartmentType.Pilot))
    // do something
deft night
shadow crescent
#

it depends on the operator priority. in this case the == comparison on the right will have higher prioprity than the &&

#

so the code does what you put in () already. but you can always put it if you are not sure about the order

deft night
#

ah I see ok thank you

#

wouldnt this give me the slot name?

#

then I could compare it to passanger_r01

shadow crescent
#

you are looking at the wrong component. compartments on vehicle are managed by BaseCompartmentManagerComponent

#

and there you do not have access to the slot name

#

you could get the UI info for the slot via compartment.GetUIInfo().GetName() and check that as a workaround maybe

fickle basin
shadow crescent
#

only by prefab. you check if a prefab inherits the one you care about to catch the base vehicle and all derived variants the game or mods might offer from it

deft night
#

what about pivot ID?

deft night
#

@shadow crescent @fickle basin I will probably update the mod only allowing 3p in the BTR driver seat. If you would like a credit for the help just DM your Bohemia email. Thanks for taking your time to help me.

shadow crescent
#

I do not need credits. I am just helping you learning about the game which is part of my job ๐Ÿ˜‰

deft night
#

ah ok

#

๐Ÿ‘

#

I would still love to find a way to limit the 3p only to the commander seat but I need to focus on other things

#

still thank you

shadow crescent
#

As I said, try doing the way through UIInfo, it might be the most reliable right now

deft night
#

How would I go about that I don't see a simple way to get the UI, I would guess something like getUI.name or something