How to make a swimming system? (like old zelda games)

Hello,

my idea was to make a swimming system like in zelda a link to the past (once an item is obtained, you can swim).

I would like to put a swimming skin on the vehicle system (boat) but I would like to start (and finish) the swim only on pontoons.

The problem is that the basic boat system allows you to "drop" your boat anywhere. I would like it to be possible only in front of pontoons.

To start the swim I call the function "move the boat spawn here" then "enter the vehicle" and it works fine for the beginning but I don't want to be able to get out of the water anywhere

Here is the image of my idea, and the problem I have :

ezgif-4-ce3f1a86ed71.gif




Do you have any idea of the method I could use?

Thanks !
basically there are only two ways: get tricky with your map and tileset, or use a plugin to change the behaviour.

The first option has several different ways, but all require some sacrifices in mapping. For example you can use a ship instead of the boat (the ship cannot enter shallow water), have all land surrounded by the shallow water and pass bridges over it.

The second option you have to search for - I know such scripts exist for older makers, but I don't know if their MZ variants have been ported. For example there once was a script for Ace that defined harbour points for ships or similars.
This brief change to the core has seems to work. Of course it would need to be adjusted to work only for ships, and for any region ID of your choice, assuming it even still works in MZ.

JavaScript:
Game_Vehicle.prototype.isLandOk = function(x, y, d) {
    if (this.isAirship()) {
        if (!$gameMap.isAirshipLandOk(x, y)) {
            return false;
        }
        if ($gameMap.eventsXy(x, y).length > 0) {
            return false;
        }
    } else {
        if ($gamePlayer.regionId() == 5) {return true;}
        else {return false;}

        var x2 = $gameMap.roundXWithDirection(x, d);
        var y2 = $gameMap.roundYWithDirection(y, d);
        if (!$gameMap.isValid(x2, y2)) {
            return false;
        }
        if (!$gameMap.isPassable(x2, y2, this.reverseDir(d))) {
            return false;
        }
        if (this.isCollidedWithCharacters(x2, y2)) {
            return false;
        }
    }
    return true;
};
@Andar Indeed I had thought of your proposal number 1 but how to differentiate the deep water in the A1 tileset? In the one I'm using they have the same skin, the first square is shallow water and the second square is deep water, is that right?

For example in this tileset A1, what is the shallow water and what is the deep water ? (I put green X's on the image because it's a paying tileset and it's to respect the designer)

tileseta1.png



@autodidact Thank you for your code but I think I'm not yet good enough to use it to its full potential (and especially to edit it correctly)
you can also use "change sprite" when on a certain region to change in
order to swim, I believe Hirion als has swim plugin to use which can be
found [here] depending on varity and range you can swim 🙂
Well, ShadowDragon has a really great link! Probably the way to go for swimming plugins.
But I think it uses a different method than you are currently implementing, Timmy77.

If you are interested in avoiding tileset marking, here is a revamped version of my code. (Again, I'm working off MV here) You can paste it into a file and name it "sal_RestrictBoatLanding.js", put it in your plugins folder, and set the 1 parameter in the plugin database. Then just put the corresponding region ID number on your platoon.


JavaScript:
//=================
//sal_RestrictBoatLanding.js
//=================
/*:
 * @plugindesc (v.1.0) An experimental plugin to restrict boat landing locations.
 *
 * @author autodidact
 * 
 * @param regionIDforLanding
 * @text Region ID for Landing
 * @type number
 * 
 * @help
 * Use the plugin parameters to set a region ID that you can dock your "boat" at.
 *
 * TERMS OF USE
 * This plugin is currently free for all use.
 *
 * COMPATIBILITY
 * This plugin overwrites the Game_Vehicle.prototype.isLandOk function.
 * This means it may introduce incompatibility with any other plugin
 * using this function. In this case, try placing above or below the
 * other plugin that has the conflict. This may allow both work together.
 */

(function(){
    'use strict';

    var params = PluginManager.parameters('sal_RestrictBoatLanding');
    var boatLandingOkay = Number(params['regionIDforLanding']);

    Game_Vehicle.prototype.isLandOk = function(x, y, d) {
        if (this.isAirship()) {
            if (!$gameMap.isAirshipLandOk(x, y)) {
                return false;
            }
            if ($gameMap.eventsXy(x, y).length > 0) {
                return false;
            }
        } else {
            if ($gamePlayer.regionId() == boatLandingOkay && this.isBoat()) {return true;}
            else if (this.isBoat()) {return false;}
    
            var x2 = $gameMap.roundXWithDirection(x, d);
            var y2 = $gameMap.roundYWithDirection(y, d);
            if (!$gameMap.isValid(x2, y2)) {
                return false;
            }
            if (!$gameMap.isPassable(x2, y2, this.reverseDir(d))) {
                return false;
            }
            if (this.isCollidedWithCharacters(x2, y2)) {
                return false;
            }
        }
        return true;
    };

})();
Well, ShadowDragon has a really great link! Probably the way to go for swimming plugins.
But I think it uses a different method than you are currently implementing, Timmy77.

If you are interested in avoiding tileset marking, here is a revamped version of my code. (Again, I'm working off MV here) You can paste it into a file and name it "sal_RestrictBoatLanding.js", put it in your plugins folder, and set the 1 parameter in the plugin database. Then just put the corresponding region ID number on your platoon.


JavaScript:
//=================
//sal_RestrictBoatLanding.js
//=================
/*:
 * @plugindesc (v.1.0) An experimental plugin to restrict boat landing locations.
 *
 * @author autodidact
 *
 * @param regionIDforLanding
 * @text Region ID for Landing
 * @type number
 *
 * @help
 * Use the plugin parameters to set a region ID that you can dock your "boat" at.
 *
 * TERMS OF USE
 * This plugin is currently free for all use.
 *
 * COMPATIBILITY
 * This plugin overwrites the Game_Vehicle.prototype.isLandOk function.
 * This means it may introduce incompatibility with any other plugin
 * using this function. In this case, try placing above or below the
 * other plugin that has the conflict. This may allow both work together.
 */

(function(){
    'use strict';

    var params = PluginManager.parameters('sal_RestrictBoatLanding');
    var boatLandingOkay = Number(params['regionIDforLanding']);

    Game_Vehicle.prototype.isLandOk = function(x, y, d) {
        if (this.isAirship()) {
            if (!$gameMap.isAirshipLandOk(x, y)) {
                return false;
            }
            if ($gameMap.eventsXy(x, y).length > 0) {
                return false;
            }
        } else {
            if ($gamePlayer.regionId() == boatLandingOkay && this.isBoat()) {return true;}
            else if (this.isBoat()) {return false;}
   
            var x2 = $gameMap.roundXWithDirection(x, d);
            var y2 = $gameMap.roundYWithDirection(y, d);
            if (!$gameMap.isValid(x2, y2)) {
                return false;
            }
            if (!$gameMap.isPassable(x2, y2, this.reverseDir(d))) {
                return false;
            }
            if (this.isCollidedWithCharacters(x2, y2)) {
                return false;
            }
        }
        return true;
    };

})();
Thank you ! 🙂
Hello,

I didn't understand very well in the A1 tileset where "deep water" and "shallow water" are supposed to be located, I didn't find a MZ template with the framed areas

For example on this tileset A1, what is the deep water and the shallow water ? (I put green X's because it's a tileset from a pay pack, to respect the creator)

index.php


Thanks in advance !
how to differentiate the deep water in the A1 tileset? In the one I'm using they have the same skin,
that is actually the key to hiding the fact from the player who would not believe that the actor can't wade through shallow water if he can swim in deep water.
you'll make two different tilesheets, one of them with the water marked as obviously as possible and the other where the water is identical.

during development you'll work with the marked water so that you can see what you place where.
and just before deployment you change the picture of the tileset (both pictures better have the same name) so that the difference becomes invisible to the player.
Moved to: MZ Support

If you're not using MZ please say what engine you are using, so it can be moved to the correct forum.

I have also merged your second thread - there was no reason to start a new thread with that.

Did you look at the help file?

1635113649159.png

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-swimming-system-like-old-zelda-games.141508/