RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[MV] Vehicle Passability for Events 1.0.0

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2011 Best Veteran2010 Best RPG Maker User (Scripting)2010 Most Mature Member
Vehicle Passability for Events
Version: 1.0.0
Author: modern algebra
Date: 27 October 2015

Version History


  • <Version 1.0.0> 2015-10-27 - Original Release

Description


Set up events that are bound by the passability rules of boats, ships, or airships.

Features

  • Can make events that move randomly but restrict themselves to the water
  • Easy to set up through first-line comments
  • Can change vehicle passability for each page of an event

Instructions

Save the script in your plugins folder and import it through the Plugin Manager.

To set vehicle passability for an event, you must set the first command for an event page to be a comment which includes one of the following codes:

        \vehicle[boat]
        \vehicle[ship]
        \vehicle[airship]

The vehicle type is determined on a page-by-page basis. If a vehicle event should update to a new page, it will need to have a new vehicle code or else it will revert to normal passability.

Plugin


You can download the .js file from Pastebin: http://pastebin.com/RCVr2D4f

Code: [Select]
//=============================================================================
//  Vehicle Passability for Events
//  Version: 1.0.0
//  Date: 27 October 2015
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*:
 * @plugindesc Set up events that are bound by the passability rules of boats, ships, or airships
 * @author Modern Algebra (rmrk.net)
 * @help This plugin does not have any plugin parameters. It is setup through
 * comments in an event.
 *
 * To set vehicle passability for an event, you must set the first command for
 * an event page to be a comment which includes one of the following codes:
 *
 *      \vehicle[boat]
 *      \vehicle[ship]
 *      \vehicle[airship]
 *
 * The vehicle type is determined on a page-by-page basis. If a vehicle event
 * should update to a new page, it will need to have a new vehicle code or
 * else it will revert to normal passability.
 */
//=============================================================================

(function() {
   
    var _Game_Event_initMembers =
            Game_Event.prototype.initMembers;
    Game_Event.prototype.initMembers = function() {
        _Game_Event_initMembers.call(this);
        this._maVehicleType = ''; // Initialize _maVehicleType
    };

    var _Game_Event_setupPageSettings =
            Game_Event.prototype.setupPageSettings;
    Game_Event.prototype.setupPageSettings = function() {
        _Game_Event_setupPageSettings.call(this)
        var comments = this.maepoCollectCommentsAt(0);
        // Match an integer in \vehicle[x]
        var rpatt = /\\vehicle\s*\[\s*(boat|ship|airship)\s*\]/i;
        var match = rpatt.exec(comments);
        if (match) { // If there is a match (match is not null)
            vtype = match[1].toLowerCase();
            this._maVehicleType = vtype;
        } else {
            this._maVehicleType = '';   
        }
    };
   
    // Selects all comment lines at index i in the list
    Game_Event.prototype.maepoCollectCommentsAt = function(i) {
        var comments = '';
        var list = this.list(); // List of event commands for current page
        // Select only comment lines
        while (i < list.length && (list[i].code === 108 || list[i].code === 408)) {
            comments = comments + list[i].parameters[0];
            i++;
        }
        return comments
    };

    // For consistency, code below uses same structure as in Game_Player
    var _Game_Event_isMapPassable =
            Game_Event.prototype.isMapPassable;   
    Game_Event.prototype.isMapPassable = function(x, y, d) {
        var vehicle = this.vehicle();
        if (vehicle) {
            return vehicle.isMapPassable(x, y, d);
        } else {
            return _Game_Event_isMapPassable.call(this, x, y, d);
        }
    };
   
    Game_Event.prototype.vehicle = function() {
        return $gameMap.vehicle(this._maVehicleType);
    };
   
})();

Credit


  • modern algebra

Support


Post in this thread if you have any comments or questions. It is perfectly fine to post here even if this topic has not been posted in for a very long time.

Please do not message me privately, as any concerns you have are likely shared by others and they will benefit from our correspondence being public. Additionally, I am often absent, and posting publicly will allow other members to assist you when I am unable to do so quickly.

Author's Notes


So, it turns out that I know nothing about javascript. This plugin is so simple that it is barely even useful, and I still feel like I coded it poorly.

Terms of Use


You are welcome to use this script in any project of yours, whether it is commercial or non-commercial. There is no need to credit me, and please feel free to modify the plugin in whatever ways suit your project.

Basically, my plugin is your plugin, but please do not re-post this plugin or any modified version of it on another forum or website.
« Last Edit: October 31, 2015, 08:49:34 PM by modern algebra »

*
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Rep:
Level 96
&&&&&&&&&&&&&&&&&&&&&&&&&&&
GIAW 14: 2nd Place (Hard Mode)2013 Biggest Drama Whore2013 Zero to HeroParticipant - GIAW 11Secret Santa 2013 ParticipantFor taking arms in the name of your breakfast.
Jolly good show.
&&&&&&&&&&&&&&&&

*
RMRK's dad-in-training
Rep:
Level 72
Busy Husband, Dad, and Youth Minister
GIAW 14: 2nd Place (Easy Mode)2014 Best WriterBronze - GIAW 11 (Normal)Secret Santa 2013 ParticipantFor taking arms in the name of your breakfast.2012 Best NewbieContestant - GIAW 9
Was hoping MA would get to know Java.

Was not disappointed.

Looking forward to more!

**
Rep: +0/-0Level 37
RMRK Junior
OMG! MA is back for MV! :D :D Thanks!

やれやれだぜ。

*
The Hero of Rhyme
Rep:
Level 83
( ͡° ͜ʖ ͡°)
Project of the Year 20142014 Best RPG Maker User - Story2014 Queen of RMRK2011 Best Newbie2014 Best RPG Maker User - Creativity2014 Kindest Member2013 Queen of RMRKBronze SS AuthorBronze Writing ReviewerSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.GOOD!For frequently finding and reporting spam and spam bots2012 Best Yuyubabe Smiley2012 Best RPG Maker User (Creativity);o
Yay! It's nice to see you on the Javascript side, too! :D
Spoiler for My Games and Art:
ℒℴѵℯ❤


My Artwork Thread

The Lhuvia Tales [Current]

Ambassador [Complete]

The Postman [Complete]

The Wyvern [Complete]

Phoenix Wright: Haunted Turnabout [Complete]

Major Arcana [Cancelled]


*
Rep:
Level 82

So, it turns out that I know nothing about javascript. This plugin is so simple that it is barely even useful, and I still feel like I coded it poorly.


I know exactly how you feel. I don't remember RGSS/Ruby being quite as, er, fun as this.

Still, any progress is progress and as time goes on you can only get better and feel more confident. That's what I keep telling myself at least.
(Why do I always feel like it's the end of the world and I'm the last man standing?)

*
The Hero of Rhyme
Rep:
Level 83
( ͡° ͜ʖ ͡°)
Project of the Year 20142014 Best RPG Maker User - Story2014 Queen of RMRK2011 Best Newbie2014 Best RPG Maker User - Creativity2014 Kindest Member2013 Queen of RMRKBronze SS AuthorBronze Writing ReviewerSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.GOOD!For frequently finding and reporting spam and spam bots2012 Best Yuyubabe Smiley2012 Best RPG Maker User (Creativity);o
So, it turns out that I know nothing about javascript. This plugin is so simple that it is barely even useful, and I still feel like I coded it poorly.

It definitely looks pretty, though (all of your scripts do)! :D It'll be that much easier to go back later and simplify stuff.

Half of the other students in my c++ class produce some pretty messy code. T-T
Spoiler for My Games and Art:
ℒℴѵℯ❤


My Artwork Thread

The Lhuvia Tales [Current]

Ambassador [Complete]

The Postman [Complete]

The Wyvern [Complete]

Phoenix Wright: Haunted Turnabout [Complete]

Major Arcana [Cancelled]


*
A-pow 2015
Rep:
Level 81
2014 Best RPG Maker User - GraphicsFor frequently finding and reporting spam and spam bots2013 Most Unsung MemberSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.a^2 + b^2 = c^2How can I help you? :DSecret Santa 2012 ParticipantSilver - GIAW 10Silver - GIAW 9Bronze - GIAW HalloweenGold - Game In A Week VII
As someone who only knows visual basic, I envy all of you. ;9

*
The Hero of Rhyme
Rep:
Level 83
( ͡° ͜ʖ ͡°)
Project of the Year 20142014 Best RPG Maker User - Story2014 Queen of RMRK2011 Best Newbie2014 Best RPG Maker User - Creativity2014 Kindest Member2013 Queen of RMRKBronze SS AuthorBronze Writing ReviewerSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.GOOD!For frequently finding and reporting spam and spam bots2012 Best Yuyubabe Smiley2012 Best RPG Maker User (Creativity);o
I wouldn't envy anyone that has to take c++. ;9

It's  e v i l  . . .
Spoiler for My Games and Art:
ℒℴѵℯ❤


My Artwork Thread

The Lhuvia Tales [Current]

Ambassador [Complete]

The Postman [Complete]

The Wyvern [Complete]

Phoenix Wright: Haunted Turnabout [Complete]

Major Arcana [Cancelled]


*
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Rep:
Level 96
&&&&&&&&&&&&&&&&&&&&&&&&&&&
GIAW 14: 2nd Place (Hard Mode)2013 Biggest Drama Whore2013 Zero to HeroParticipant - GIAW 11Secret Santa 2013 ParticipantFor taking arms in the name of your breakfast.
Please stay on topic.
Spoiler for:
:^V
&&&&&&&&&&&&&&&&

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2011 Best Veteran2010 Best RPG Maker User (Scripting)2010 Most Mature Member
haha, thanks guys. Your enthusiasm is misplaced but inspiring.
« Last Edit: October 30, 2015, 12:29:18 AM by modern algebra »