Orange Custom Events

F.H.

Fang.H.
Member
Joined
Jun 27, 2017
Messages
4
Reaction score
1
First Language
Chinese
Primarily Uses
RMMV
clearCustomEvents remove the events that are saved, but it doesn't erase them from the current map until you reload it.


At the moment there's no script call to remove the spawned events.
What I'm doing with my toy project is to pop out all the custom events from $gameMap._events when they are no longer needed. This works well to keep $gameMap._events small in my project since most of the custom events are only used in a flash. But I don't know a good way to delete them when they are in the middle of $gameMap._events without messing event Ids.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,529
Reaction score
3,679
First Language
Java's Crypt
Primarily Uses
RMMZ
What I'm doing with my toy project is to pop out all the custom events from $gameMap._events when they are no longer needed. This works well to keep $gameMap._events small in my project since most of the custom events are only used in a flash. But I don't know a good way to delete them when they are in the middle of $gameMap._events without messing event Ids.
You can just call the erase method on them. If you think that is not enough, just replace them by null in the $gameMap._events array.
 

F.H.

Fang.H.
Member
Joined
Jun 27, 2017
Messages
4
Reaction score
1
First Language
Chinese
Primarily Uses
RMMV
You can just call the erase method on them. If you think that is not enough, just replace them by null in the $gameMap._events array.
Thank you for the reply.
Due to the use of many parallel process (I know that is not recommended in general, but I really want to try it) in my project, the size of $gameMap._events does matter, when it is large the frame rate drops sharply. That's why I want to reduce its length as much as possible.
 

MitchelQ

Warper
Member
Joined
Jul 5, 2017
Messages
1
Reaction score
0
First Language
Dutch
Primarily Uses
RMMV
Hi Hudell,

Thanks for your plugins, they help a lot.

Is there a way to remove/change the regionID from a tile? I would like to add an event to a random tile in a region but I want to adjust the regionID's before doing so.

Best regards,

Mitchel
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,529
Reaction score
3,679
First Language
Java's Crypt
Primarily Uses
RMMZ
Thank you for the reply.
Due to the use of many parallel process (I know that is not recommended in general, but I really want to try it) in my project, the size of $gameMap._events does matter, when it is large the frame rate drops sharply. That's why I want to reduce its length as much as possible.
Then you'll need to manually check all events that are erased and remove them from the array, resizing it and changing the ID of every event that changed positions :/

Hi Hudell,

Thanks for your plugins, they help a lot.

Is there a way to remove/change the regionID from a tile? I would like to add an event to a random tile in a region but I want to adjust the regionID's before doing so.

Best regards,

Mitchel
That seems like something that can be achieved with a separate plugin. Maybe someone even made one already.
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Has anyone else encountered oddities if you put a plugin command in a loop?

Through SRD's plugin command eval script, I can run commands such as "spawn event ${v[x]} from map ${v[y]} on region ${v[z]}".
It works if I call them one after another (editing the variables inbetween), but if I try to do it in a loop (instead of one after another), I encounter problems (such as duplicates (which can be stopped by adding one wait command)). My solution was running multiple commands after another instead of once in a loop :|

I then encountered a weird problem where, even if the variables are updated, the event gets spawned later (when I want them to spawn somewhere different) to their first spawn location. Eg:

A: Spawn event 1 at region 4
B: Refresh Map / Leave Map
C: Spawn event 1 at region 5 (spawns at region 4)
 

OcRam

Servant of the Universe
Veteran
Joined
Aug 2, 2016
Messages
597
Reaction score
711
First Language
Finnish
Primarily Uses
RMMZ
It appears that this plugin captures ALL plugin commands therefore it might be a good idea to check if there are any arguments present. If this is not done, plugin will give error (if there is no arguments).

var oldGameInterpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
oldGameInterpreter_pluginCommand.call(this, command, args);
if (args !== null && args !== undefined) { // Check if this command has arguments...
this.checkCopyCommands(command, args);
this.checkDeleteCommand(command, args);
}
};

Otherwise great plugin +1 for that.
 

Black Mamba

Veteran
Veteran
Joined
Mar 6, 2014
Messages
266
Reaction score
88
First Language
pt-br
Primarily Uses
how to copy a event from another map to the character position?

and in "spawn event 1 from map 5 on region 2" is possible to set quantity? like i wanna to summon randon or fixed quantity of this event
 
Last edited:

Xalezar

Villager
Member
Joined
Dec 2, 2017
Messages
8
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hi @Hudell, when I use your plugin to copy events into the current map, the event displays correctly, but my player is not able to interact with this copied event. For example, the original event has:

Priority:
Same as characters

Trigger:
Action Button

Contents:
◆Text:None, Window, Bottom
:Text:Hello
I expect that a message window pops up when I walk up to the copied event and press the action key. But nothing happens. Is this the normal behaviour for the plugin? Thanks.
 
Last edited:

Sanyee

Just a Random but really Cool NPC
Veteran
Joined
Dec 1, 2012
Messages
40
Reaction score
34
First Language
Portuguese
Primarily Uses
RMMV
Hey Hudell,

I’m using this plugin, and its perfect for what I needed, but recently I tried to use it with Galv's Tools, and when I try to use the tools with the copied events, it gives a error, “cannot read property ‘(notetag)’ of undefined”, it seems the plugin can't get the ID of the events? Do you think there is a way for me to solve this issue? :)

Thank you anyways~
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,529
Reaction score
3,679
First Language
Java's Crypt
Primarily Uses
RMMZ
Galv's plugin is probably trying to load the notetags from the map file instead of the event reference. Since the event doesn't exist in the map file, it is crashing the game. I'll look into that plugin later.
 

Sanyee

Just a Random but really Cool NPC
Veteran
Joined
Dec 1, 2012
Messages
40
Reaction score
34
First Language
Portuguese
Primarily Uses
RMMV
Thanks for taking a look at it, you're awesome :kaojoy:

If there is no chance of using them together, I'll try something else lol
 

EagleOne

Villager
Member
Joined
Mar 22, 2018
Messages
18
Reaction score
0
First Language
English
Primarily Uses
N/A
Hi, I am using this plugin quite extensively. I have secondary maps which act as event stores, and I load them into my map using

Code:
copyEventFrom()
So far so good. I also manage to delete my events after some time, I do a

Code:
$gameMap.events().forEach()
and for each event I want to delete I do:

Code:
event.erase();
$gameSystem.removeCustomEvent(event._mapId, event.eventId());
It works good. However, I noticed that after generating hundreds of events the game becomes laggy.

I came to the conclusion that the inflating array of events in gameMap has no performance impact, if not for the memory it uses. However there are a lot of sprites that are left behind deleted events.

The function I made:
1 - Deletes erased events from GameMap array without touching the array size or event IDs, in an attempt to optimize memory (though I did not test the impact)
2 - Deletes character sprites of erased events in SceneManager and reshapes the underlying array
3 - Deletes Tilemap children for erased events in SceneManager and reshapes the underlying array

It solved my performance issue entirely, or maybe not entirely but lag is gone anyway. It removes all the events that are in "erased" state and preserves all the others.

Function is here:
Code:
var flushBackupIndex = 0; // Keeps track of the next position to use  in events array
var nextFlush = 50; // Flush when events quantity is above nextFlush
var eventsFlushInterval = 50; // Adds to nextFlush

EventEngine.flushCustomEventsFromGamemap = function() {
    if ($gameMap._events.length < nextFlush) {
        return;
    }
    nextFlush += eventsFlushInterval;
    // Delete event entries
    for (var i = flushBackupIndex; i < $gameMap._events.length; i++) {
        if ($gameMap._events[i] && $gameMap._events[i]._erased === true) {
            delete($gameMap._events[i]);
        }
    }
    flushBackupIndex = i;
    // Flush Character Sprites
    SceneManager._scene.children.forEach(function(child) {
        if (child._characterSprites === undefined) {
            return;
        }
        var newSprites = [];
        child._characterSprites.forEach(function(sprite) {
            if (!sprite._character || sprite._character._erased !== true) {
                newSprites.push(sprite);
            }
        });
        child._characterSprites = newSprites;
    });
    // Flush Tilemap
    newChildren = [];
    SceneManager._scene._spriteset._tilemap.children.forEach(function(child) {
        if (!child._character || child._character._erased !== true) {
            newChildren.push(child);
        }
    });
    SceneManager._scene._spriteset._tilemap.children = newChildren;
};

No guarantee offered, if it helped let me know ;-D
 
Last edited:

RainbowGrenade

Paint Princess
Veteran
Joined
Jan 21, 2013
Messages
278
Reaction score
326
First Language
English
Primarily Uses
RMMV
Hi @Hudell, when I use your plugin to copy events into the current map, the event displays correctly, but my player is not able to interact with this copied event. For example, the original event has:



I expect that a message window pops up when I walk up to the copied event and press the action key. But nothing happens. Is this the normal behaviour for the plugin? Thanks.
@Hudell I want to take a moment to thank you for sharing this amazing script. It really is great, and it's clear that you've put a lot of work into it. I hate to trouble you, but I'm having the same issue as Xalezar. I would really like to be able to interact with the copied events. Am I just doing something wrong? Everything is working great aside from this one issue. Thank you for your time.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,529
Reaction score
3,679
First Language
Java's Crypt
Primarily Uses
RMMZ
It should be working. Maybe one of the MV updates made it incompatible, I'll have to take a look.
 

RainbowGrenade

Paint Princess
Veteran
Joined
Jan 21, 2013
Messages
278
Reaction score
326
First Language
English
Primarily Uses
RMMV
It should be working. Maybe one of the MV updates made it incompatible, I'll have to take a look.
I really appreciate you looking into it. I'm sure you're busy.

Edit: I played around with the other plugins in my project, and it seems there is an incompatibility with the QABS plugin or one of it's dependencies. Below is a link to it. I understand if you don't have time to look into it further. I'll let you know if I find a solution or work around.

https://quxios.github.io/plugins/QABS


With QPlus, QMovement, and QABS on, I am able to interact with events tagged as enemies in the note box that are copied from another page, but regular events spawned will not react to input. I tried turning these three plugins off, and events responded appropriately again.
 
Last edited:

Martin

Veteran
Veteran
Joined
Apr 8, 2015
Messages
191
Reaction score
46
First Language
swe
Primarily Uses
RMMV
Hey @Hudell What a fantastic plugin! This enables to make games of other genres! Thank you!

One minor thing I cant find out. How can I get one of the copied events ID# stored to a variable?

Edit: solution was of course: $gameVariables.setValue(n, Number(this._eventId));
 
Last edited:

Shuta

Warper
Member
Joined
Mar 9, 2020
Messages
2
Reaction score
1
First Language
Japanese
Primarily Uses
N/A
Hello! I want Orange Custom Events.
But I click "Get it from here" I send message me "Download file not found".
Therefore I want you to help me...
 

fizzly

Veteran
Veteran
Joined
Mar 23, 2012
Messages
706
Reaction score
433
First Language
Polish
Primarily Uses
RMMV
Hello! I want Orange Custom Events.
But I click "Get it from here" I send message me "Download file not found".
Therefore I want you to help me...
 

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Profile Posts

I'm back from my visit to my family. Was really great to see them again after a year even if I had to get tested for covid for the visit.
Sometimes... I do absolutely genius things... But then I counteract that by spending all day trying to figure out what's wrong with my event creator... Only to learn I commented out some lines in MV... Not even in my plugin. This must be why villains "true heroes" don't win in the end. :kaoswt:
Procrastination at it's finest.
annnnd after 2 days lol... and I still feel I need to work out a few kinks

Forum statistics

Threads
104,263
Messages
1,005,063
Members
135,773
Latest member
Krin92
Top