Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

iMyCockpit isUnderControl. Who is it??

Discussion in 'Programming (In-game)' started by HellArea, Oct 7, 2018.

  1. HellArea Trainee Engineer

    Messages:
    21
    New sad question. I always get "this is impossible."
     
  2. Uncheat Trainee Engineer

    Messages:
    11
    Hey. Yea really sad that it's not possible to read it directly.

    But! What about entity reading? If you got sensor system on your script (for close collision detector or any other things) you can collect players names(or enemy flag) on list and then use their position.
    You'll just need to update entity list one tick before next calculations and update pilot name once isUnderControl changed:

    Code:
    if(UnderControlChanged)
    {
    Pilot = UnderControl ? (DetectedPlayerEntity.GetPosition()- WorldShipControllerPos).Length() < MinDistance ? DetectedPlayerEntity.Name : "Undetected Pilot" : "No pilot";
    }
    
    Select MinDistance that you'll find the best for your UpdateFrequency and Sensor Update Rate (it's slow :/ , you could get "Undetected Pilot" a lot)

    Also if you want to use script on server you'll have to go over all detected player entities and use list of possible pilots and update sensor scan again! To find what possible pilot gone from sensor at
    MinDistance
    It's the only way you can do it right now :/
    Also pilotname could be saved on storage to survive recompiles or reloads
     
    Last edited: Nov 4, 2018
  3. HellArea Trainee Engineer

    Messages:
    21
    Thanks. Good idea, really good one. I even didn't think about it from this way. My problem appears from the Remote Control, as ShipController actually.
    Anyway, thanks a lot.
     
  4. Uncheat Trainee Engineer

    Messages:
    11
    I believe that the game checks only the enemy/friendly/owner flags (depends is block shared with friendly faction) when anyone try to get acess to the ShipController. If is not made by like IMyEntity interface that holds playername then I sure the will be no chance to get pilot name from ShipController in future. But if it was made by like IMyEntity interface I hope that the PilotName field will appear on IMyShipController once. Even if game does not check who already pilots the ship after game load I hope that something like "LastPilotAccessed" field could be added and then we could work with it on scripts(and make them much more perfomance friendly).
     
  5. XkyDiver Apprentice Engineer

    Messages:
    360
    I thought, at some point, there were plans to get .CurrentPilot or some equivalent added to the IMyCockpit, but it hasn't happened yet. :(
     
    • Agree Agree x 1
  6. HellArea Trainee Engineer

    Messages:
    21
    I decided to try this way, but did not find any
    . Even in the SE sources. How I can find it.