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

Timmy77

Villager
Member
Joined
Oct 6, 2021
Messages
29
Reaction score
20
First Language
French
Primarily Uses
RMMZ
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 !
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
34,305
Reaction score
8,750
First Language
German
Primarily Uses
RMMV
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.
 

autodidact

Veteran
Veteran
Joined
Nov 13, 2020
Messages
73
Reaction score
52
First Language
English
Primarily Uses
RMMV
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;
};
 

Timmy77

Villager
Member
Joined
Oct 6, 2021
Messages
29
Reaction score
20
First Language
French
Primarily Uses
RMMZ
@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)
 
Last edited:

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
4,685
Reaction score
1,799
First Language
Dutch
Primarily Uses
RMMV
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 :)
 

autodidact

Veteran
Veteran
Joined
Nov 13, 2020
Messages
73
Reaction score
52
First Language
English
Primarily Uses
RMMV
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;
    };

})();
 

Timmy77

Villager
Member
Joined
Oct 6, 2021
Messages
29
Reaction score
20
First Language
French
Primarily Uses
RMMZ
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 ! :)
 

Timmy77

Villager
Member
Joined
Oct 6, 2021
Messages
29
Reaction score
20
First Language
French
Primarily Uses
RMMZ
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 !
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
34,305
Reaction score
8,750
First Language
German
Primarily Uses
RMMV
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.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,138
Reaction score
15,534
First Language
English
Primarily Uses
RMMV

I've moved this thread to MZ Support. Thank you.



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
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

Apparently Amazon Prime users get free Genshin Impact stuff like primogems and whatnot every month, but I'm not sure I ever want to fall into the abyss of F2P ever again.
Doing RPG Maker News for 26th Nov to 2nd Dec (2021)

"Yeah. It's been a rough road lately. But that's the thing about the Rangers. It doesn't matter how hard it gets, or how many of them fall. They never stop fighting. The Rangers NEVER stop fighting".

Angela Deth, you are a hero of mine. Sorry for my first run of Wasteland 3.
We must press on. For all those we couldn't save. For all those we might yet save.
FirestormNeos wrote on DarkPlasmaBall's profile.
asking this here instead of the thread in question to avoid derailing it, but I'm curious; is there a particular reason you'd include a "Terms of Use" for an RPG Maker game? Like, are there multiplayer features for the game you're working on?

Forum statistics

Threads
117,143
Messages
1,104,922
Members
153,210
Latest member
hairfactory5s
Top