Results 1 to 7 of 7

Thread: How to tell which exact position a Player is currently in--2 possible, which active?

  1. #1
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    How to tell which exact position a Player is currently in--2 possible, which active?

    So I'm scripting and I know that a player can be "filling" two positions in a given aircraft.

    The int values of the two places in the aircraft the player is in are given via player.PlacePrimary() and player.PlaceSecondary().

    So far so good.

    But even though a player is in two positions at any given time, they are really only sitting on one at a time. That is the one they see on their screen, where they can mouse around, run the controls, etc.

    So the question is--how to you tell which of the two positions the player is actually sitting in & looking out of?

    I checked player.PlacePrimary(), player.PlaceSecondary(), player.PersonPrimary().Place() and player.PersonSecondary().Place().

    Say you're in the Stuka and using both positions. Then there is no difference in all of those values whether you are currently sitting in/looking out of the pilot's seat or the gunner's seat.

    Any way to tell which of those two the pilot is actually looking out of currently?
    System: Microsoft Windows 10 Pro 64 bit, 10.0.18362 N/A Build 18362, 20,437 MB |
    ASUS GeForce GTX 1060 3GB | Intel Core i5-2500 Quad-Core Processor 3.3 GHz 6 MB Cache LGA 1155 | Intel DB65AL motherboard | ARCTIC Freezer i11 CPU Cooler | SVGA 500 watt power supply | Microsoft Sidewinder 2 Force Feedback joystick

  2. #2
    varrattu
    Guest

    Re: How to tell which exact position a Player is currently in--2 possible, which acti

    Hello TWC_Flug,

    do you search for something like this?

    ~V~

    Code:
    /// @author Varrattu
    /// @date 2020-02-16
    
    using System;
    using maddox.game;
    using maddox.game.world;
    
    public class Mission : AMission {
    
    	public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    	{
    		base.OnPlaceEnter(
    			player,
    			actor,
    			placeIndex
    			);
    
    		if (placeIndex == 0) placeIndex++;
    
    		string PlayerPlace = Enum.GetName(typeof(CrewFunction), placeIndex);
    		
    		GamePlay.gpHUDLogCenter(PlayerPlace);
    	}
    }

  3. #3
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    Re: How to tell which exact position a Player is currently in--2 possible, which acti

    Quote Originally Posted by varrattu View Post
    Hello TWC_Flug,

    do you search for something like this?

    ~V~

    Code:
    	public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    
    
    		string PlayerPlace = Enum.GetName(typeof(CrewFunction), placeIndex);
    Aha, that's a good thought. Just keep track of where they are via OnPlaceEnter.

    So trying it out, it almost works. Like if you jump into a JU88, what happens in one place always stays as the pilot, and then the other moves. So for example if you jump into the plane, you're in the pilot's seat and you see "Pilot".

    Then you move to Bombardier and you see "Bombardier".

    Now you can move back & forth from pilot to bombardier as many times as you like and you see nothing new--no new placeenter.

    But switch to Nose Gunner & now you're in Pilot+Nose Gunner. You see "Nose Gunner" show up as the place/CrewFunction.

    So now you can switch between pilot & nose gunner all you like, and nothing new shows up.

    But go to the Ventral Gunner position and you see that show up on the screen and now you're in pilot+ventral gunner.

    More to the point, what I was hoping to was track a person in a JU87 or a 111 and tell which position they are actually in/looking out of - pilot or gunner.

    In a JU87 what you see if "pilot" when you jump in that position, then "Gunner" when you change views to that position, then nothing thereafter--because you're already "in" both Pilot & Gunner so you can switch between those two with no new notification.

    So . . .

    Anyway, I think this little experiment answered my question.

    You have to keep one of the positions as the Pilot at all times, or AI takes over the pilot position and starts flying you around.

    For for my purposes, I can just snap the player into the pilot position and remove them from the other one.
    System: Microsoft Windows 10 Pro 64 bit, 10.0.18362 N/A Build 18362, 20,437 MB |
    ASUS GeForce GTX 1060 3GB | Intel Core i5-2500 Quad-Core Processor 3.3 GHz 6 MB Cache LGA 1155 | Intel DB65AL motherboard | ARCTIC Freezer i11 CPU Cooler | SVGA 500 watt power supply | Microsoft Sidewinder 2 Force Feedback joystick

  4. #4
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    Re: How to tell which exact position a Player is currently in--2 possible, which acti

    By the way, here is the code that worked for me, to show the crew position the player just entered.

    The OnPlaceEnter placeIndex tells you which place within the "Carter" the player is.

    Then you have to ask the Carter what the name of that particular position is.

    So something like this:

    Code:
       
    public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) {
            base.OnPlaceEnter(player, actor, placeIndex);
    
    
               int crewFunctionNum = (actor as AiCart).CrewFunctionPlace(placeIndex);
    
                string PlayerPlace = Enum.GetName(typeof(crewFunctionNum), );
                //tells the name of the position the player just entered - Pilot, Bombardier, Nose Gunner, etc.
    
                GamePlay.gpHUDLogCenter(PlayerPlace + " " + placeIndex.ToString("F0") + " " + crewFunctionNum.ToString ("F0"));
    
    }
    EDIT: Code above broken, see two replies below for possible fix.
    Last edited by TWC_Flug; Feb-19-2020 at 18:51.
    System: Microsoft Windows 10 Pro 64 bit, 10.0.18362 N/A Build 18362, 20,437 MB |
    ASUS GeForce GTX 1060 3GB | Intel Core i5-2500 Quad-Core Processor 3.3 GHz 6 MB Cache LGA 1155 | Intel DB65AL motherboard | ARCTIC Freezer i11 CPU Cooler | SVGA 500 watt power supply | Microsoft Sidewinder 2 Force Feedback joystick

  5. #5
    varrattu
    Guest

    Re: How to tell which exact position a Player is currently in--2 possible, which acti

    Sorry to say:

    C# cannot implicitly convert "(actor as AiCart).CrewFunctionPlace(placeIndex)" to "int crewFunctionNum".

    ~V~

  6. #6
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    Re: How to tell which exact position a Player is currently in--2 possible, which acti

    Quote Originally Posted by varrattu View Post
    Sorry to say:

    C# cannot implicitly convert "(actor as AiCart).CrewFunctionPlace(placeIndex)" to "int crewFunctionNum".

    ~V~

    Aack, I must have copy-pasted something halfway finished. The exact line I was using successfully:

    Code:
    //string PlayerPlace = Enum.GetName(typeof(CrewFunction), (actor as AiCart).CrewFunctionPlace(placeIndex));

    A fixed version of the above code (maybe, I haven't tested it):

    Code:
    public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) {
            base.OnPlaceEnter(player, actor, placeIndex);
    
    
               int crewFunctionNum = (actor as AiCart).CrewFunctionPlace(placeIndex);
    
                string PlayerPlace = Enum.GetName(typeof(crewFunction), crewFunctionNum );
                //tells the name of the position the player just entered - Pilot, Bombardier, Nose Gunner, etc.
    
                GamePlay.gpHUDLogCenter(PlayerPlace + " " + placeIndex.ToString("F0") + " " + crewFunctionNum.ToString ("F0"));
    
    }
    Last edited by TWC_Flug; Feb-19-2020 at 18:50.
    System: Microsoft Windows 10 Pro 64 bit, 10.0.18362 N/A Build 18362, 20,437 MB |
    ASUS GeForce GTX 1060 3GB | Intel Core i5-2500 Quad-Core Processor 3.3 GHz 6 MB Cache LGA 1155 | Intel DB65AL motherboard | ARCTIC Freezer i11 CPU Cooler | SVGA 500 watt power supply | Microsoft Sidewinder 2 Force Feedback joystick

  7. #7
    varrattu
    Guest

    Re: How to tell which exact position a Player is currently in--2 possible, which acti

    Quote Originally Posted by TWC_Flug View Post
    A fixed version of the above code (maybe, I haven't tested it)
    Thanks, TWC_Flug - that was an incredibly helpful post

    ~V~
    Last edited by varrattu; Feb-23-2020 at 06:18.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •