Status
Not open for further replies.

Narch

Veteran
Veteran
Joined
Jan 13, 2017
Messages
68
Reaction score
10
First Language
French
Primarily Uses
Hi everyone.

Would it possible, to make a plugin allowing the developer to add a comment inside an event's page to determinte the event Terrain Tag depending on what page it's currently on?
So when the command "Get Location Info" is used, it would return the Terrain Tag of the concerned event's page.

Here is the use I'd personally intend to do :

I already have a system scanning a square around an NPC, scanning for tiles Terrain Tag, triggering when the value 7 is found.
But I have events entering this square, with multiple pages. And I would need them to be detected like the tiles, but only on certain pages. That's where a comment tag would come handy.

Thank you for your time, I can provide more informations if needed.


Notes : - I am on MV 1.5.1
- The current Terrain Tag system prioritize upper numbers expect if it's 0.
Overriding the tile Terrain Tag in favor of the event Terrain Tag would not be a problem for me.
 
Last edited:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,086
Reaction score
15,499
First Language
English
Primarily Uses
RMMV
So if there's a comment on the event's page to indicate a terrain tag, you use that, but if there's no comment, you get it from the map?

What about other things that look at terrain tags - plugins, script calls to $gameMap.terrainId(...)? Should they also look at the specified location and see if there's an event there with a terrain tag?
 

Narch

Veteran
Veteran
Joined
Jan 13, 2017
Messages
68
Reaction score
10
First Language
French
Primarily Uses
@Shaz That's how I see that first point yes, the game should get the tile if the event is "blank".
In my specific case I have 18 variables getting the X and Y values of a virtual square of 9 tiles.
Then, each coordinates test to check if there's a Terrain Tag with a certain value on those tiles.
(Edit: just an exemple, not representative of the whole system)

For the second point, I don't have a direct utility of it, but for a global vision and flexibility the best would be that yes, it should work in the same way for other things interacting and scanning Terrain Tags, preferably on call to prevent possible CPU charge?

Do you think such a difference would impact drastically the complexity of the plugin?
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,086
Reaction score
15,499
First Language
English
Primarily Uses
RMMV
nope, not at all.

Actually, Get Location Info uses coordinates, not an event id, so that's exactly how it's going to have to do it.

I'll see if I can do this for you tonight.

Edit (so as not to double post) - here you go:

Code:
/*:
 * Event Terrain by Shaz
 * Ver 1.00 2019.01.17
 * Shaz_EventTerrain.js
 *
 *
 * @plugindesc Allow an event page to override the map's terrain.
 * @author Shaz
 *
 * @help This plugin allows you to give a terrain id to an event, so any
 * calls to check the terrain on an X/Y coordinate will return the terrain
 * specified on the event rather than the terrain on the map tile.  If there
 * is no event on that tile, or the event doesn't have a terrain override
 * on that page, the map tile will be used.
 *
 * USAGE:
 * Add <terrain:x> as a comment to an event page, where x is a number, to have
 * that event page mimic that terrain ID.
 * 
 * This will allow you to use more terrains than the 7 available in the 
 * editor.
 *
 * Example:
 * <terrain:1> in a comment on an event will override any tile that event is
 * on to have terrain 1 instead of what is specified by the map.
 *
 * NOTE:
 * This plugin has no plugin commands.
 *
 */

var Imported = Imported || {};
Imported.Shaz_EventTerrain = true;

var Shaz = Shaz || {};
Shaz.ET = Shaz.ET || {};
Shaz.ET.Version = 1.00;

(function() {

    var _Shaz_ET_Game_Event_initMembers = Game_Event.prototype.initMembers;
    Game_Event.prototype.initMembers = function() {
        _Shaz_ET_Game_Event_initMembers.call(this);
        this._terrainId = null;
    };

    var _Shaz_ET_Game_Event_clearPageSettings = Game_Event.prototype.clearPageSettings;
    Game_Event.prototype.clearPageSettings = function() {
        _Shaz_ET_Game_Event_clearPageSettings.call(this)
        this._terrainId = null;
    };

    var _Shaz_ET_Game_Event_setupPageSettings = Game_Event.prototype.setupPageSettings;
    Game_Event.prototype.setupPageSettings = function() {
        _Shaz_ET_Game_Event_setupPageSettings.call(this);

        this._terrainId = null;
        if (this.page() && this.list()) {
            this.list().filter(function(cmd) {
                if ((cmd.code === 108 || cmd.code === 408) &&
                    cmd.parameters[0].match(/<terrain:\2*(\d+)>/)) {
                    this._terrainId = parseInt(RegExp.$1);
                }
            }.bind(this));
        }
    };

    Game_Event.prototype.terrainId = function() {
        return this._terrainId;
    }

    var _Shaz_ET_Game_Map_terrainTag = Game_Map.prototype.terrainTag;
    Game_Map.prototype.terrainTag = function(x, y) {
        var event = this.eventsXy(x, y)[0];
        if (event && event.terrainId()) {
            return event.terrainId();
        } else {
            return _Shaz_ET_Game_Map_terrainTag.call(this, x, y);
        }
    }
})();

Call it Shaz_EventTerrain.js (though the name probably doesn't really matter as there are no parameters to read).

Put <terrain:x> into an event comment, where x is the id you want to use (note, you are not limited to 7!)

I suspect the order doesn't really matter, but give it a go below all your other plugins, and if that doesn't work, try it above them all.

I wouldn't put this into a parallel process event unless you've got a decent wait in there each loop, as it could cause severe lag if you're running it every frame. A 10 frame wait would probably be good.
 
Last edited:

Narch

Veteran
Veteran
Joined
Jan 13, 2017
Messages
68
Reaction score
10
First Language
French
Primarily Uses
@Shaz Ah sorry I was not used to the edit post way, I was waiting on a notification.

I am going to test that all this week and will update you if needed, or just confirm it works. I'll update the post now that I learned that from you :p

Thanks a lot for your time!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,086
Reaction score
15,499
First Language
English
Primarily Uses
RMMV
Yeah, sorry. As nobody else had replied, I would have been double posting if I'd made a new post, so I had to edit.

Double posting (multiple posts in a row, without at least 3 days between each) is not allowed on this forum. If someone has posted after you (which I now have), you can make a new post. Editing is a pain as nobody gets notified that a change has been made.
 

Narch

Veteran
Veteran
Joined
Jan 13, 2017
Messages
68
Reaction score
10
First Language
French
Primarily Uses
Hey @Shaz I tested several things with your plugin and so far it seems to do well even with complicated spaget code, running multiple times via parallel common event. Using TT7 and TT8 so far.

Thanks again for the plugin, it's a really useful feature to me, I'll be sure to showcase what I did with it when I come to demo point.

(Edit : reporting to close topic)
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,112
Reaction score
5,963
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

How goes the game make?
Broke: Relating to and acting like Sephiroth
Woke: Relating to and acting like Kefka
Took me almost a year to flesh out this concept but hey, now it works.
01.gif
Part 1 of 24 pieces of our world map
I've finished (most of) the sprites for two of my main characters, Ashlyn and Lizzabelle. And I've already drawn actual artwork of Lizzabelle and Suki months ago. I can't wait to show some of my stuff. I'm hesitant because their outfits aren't my own original design, which must be changed before I get too serious with this.

Forum statistics

Threads
116,990
Messages
1,103,578
Members
152,869
Latest member
cap0423
Top