Vehicle Woes

Okay so here's the deal, I'm trying to create a thing similar to Dragon Quest 3-4's Return spell/Wyvern Wing, and so far it works great...except when the player is in a vehicle. Specifically, the vehicle teleports with the player, which is expected. However, the problem arises when I try to eject the player from the vehicle prior to teleport:
  1. The get on/off vehicle event command, as well as $gamePlayer.getOffVehicle() only work if the normal requirements for leaving a vehicle are met. This makes them totally worthless if used in the middle of the ocean, for example.
  2. I found I can forcibly remove the player from the vehicle with $gamePlayer._vehicleGettingOff = true however that has its own problems: The boat still follows the player even though I'm explicitly setting that value before teleporting the player, and seems to override any zone-specific settings that set the boat in a specific location. As for the airship, it doesn't even work (movement is disabled until I set _vehicleGettingOff back to false. Of the 3, only the ship is properly abandoned in the water (allowing me to set its location afterward when necessary)
  3. As item 2 suggests, I'm probably overthinking this and there's probably a better way to eject the player prior to teleporting them, but I don't know what it is. I don't want to prevent it from being used in the boat/airship, but I might end up having to resort to that if I can't get this sorted out.
So, does anyone have a proper answer for this? Something non-hackish, ideally.
You can't actually disembark on the sea.
What you can do is : save the coordinates (if needed), teleport (while beeing on the ship) to whatever land, disembark there and put the ship back to the previously saved location (or wherever).
Short version : Don't try to get off vehicle before teleporting. Teleport with the vehicle first.

In the case of the airship, don't forget it takes some frames for the player to get on and off so you need to add a wait.
You can't actually disembark on the sea.
What you can do is : save the coordinates (if needed), teleport (while beeing on the ship) to whatever land, disembark there and put the ship back to the previously saved location (or wherever).
Short version : Don't try to get off vehicle before teleporting. Teleport with the vehicle first.

In the case of the airship, don't forget it takes some frames for the player to get on and off so you need to add a wait.
You actually can abort the vehicle at any time via scripting, but I was doing so in an incomplete fashion so it was having issues. That said, I've since figured this out on my own so I'll post the solution in case someone has this question in the future and finds their way here via forum search/google/whatever:

Code:
if ($gamePlayer.isInVehicle())
{
    $gamePlayer._followers.synchronize($gamePlayer.x, $gamePlayer.y, $gamePlayer.direction());
    $gamePlayer.vehicle().getOff();
    $gamePlayer.setTransparent(false);
    $gamePlayer._vehicleGettingOff = true;
    $gamePlayer.setMoveSpeed(4);
    $gamePlayer.setThrough(false);
    $gamePlayer.makeEncounterCount();
    $gamePlayer.gatherFollowers();
}

So yeah, this can probably be closed now.
Thank you so much for working with the ingrained vehicle system and teaching about it. Very appreciated. Since you have figured out how to customize the "get on/off" experience, did you come across anything that lets you force the vehicle to point a certain direction or maintain visibility status when the player is not in the vehicle?

Basically I want to prevent the ship from appearing to "suddenly point down" when the player disembarks and making it invisible by default after disembarking seems like it would be a good way.

BTW if that's not default behavior of a ship, I would have to look into why it's doing that.
Basically I want to prevent the ship from appearing to "suddenly point down" when the player disembarks
That's a simple change of one line of code. You can paste the below into a text editor, save it as a *.js file and include it as a plugin.

Code:
Game_Player.prototype.getOffVehicle = function() {
    if (this.vehicle().isLandOk(this.x, this.y, this.direction())) {
        if (this.isInAirship()) {
//            this.setDirection(2);
        }
        this._followers.synchronize(this.x, this.y, this.direction());
        this.vehicle().getOff();
        if (!this.isInAirship()) {
            this.forceMoveForward();
            this.setTransparent(false);
        }
        this._vehicleGettingOff = true;
        this.setMoveSpeed(4);
        this.setThrough(false);
        this.makeEncounterCount();
        this.gatherFollowers();
    }
    return this._vehicleGettingOff;
};

and making it invisible by default after disembarking seems like it would be a good way.
How would you make it visible again?
Wow, that's awesome, you just commented out the "set to 2"? Let me try that. I assume if I'm changing this from airship to ship or boat, I would just have the if statements be

if (this.isInShip()) or if (this.isInBoat()) ?
and
if (!this.isInShip()) or if (!this.isInBoat()) ?

If it were the invisible/visible route, it would become visible again with another event
I assume if I'm changing this from airship to ship or boat, I would just have the if statements be
I'm not sure what you mean - the ship and boat don't change their directions. As you can see in the code I copied from the core scripts above, only the airship does. The ship and boat remain pointing in whatever direction you used to disembark.
I'm not sure what you mean - the ship and boat don't change their directions. As you can see in the code I copied from the core scripts above, only the airship does. The ship and boat remain pointing in whatever direction you used to disembark.

Ah, okay, so I must have something that changes the default behavior of ship/boat to be like the "face down" airship behavior. I will look into it!
Necro-post notice: @unikadas

Original thread: https://forums.rpgmakerweb.com/threads/vehicle-woes.104438/