MV Event Spawner

FEATURES
This plugin adds the ability to duplicate/spawn events from a specified “Spawn Map” to the current map the player is on.
These events can be temporary (which disappear when player leaves the map) or permanent (they remain even when player leaves the map and returns) and can be cleared with script commands if required.
Events can be spawned to a specific x,y location or a random tile with specified region ID.

VERSION 1.8 – RPG Maker MV
Download Plugin file
Download Demo

Advertisements

92 thoughts on “MV Event Spawner

  1. This is not a request or a suggestion, just a question:
    Galv are in your plans to make a grid inventory system at some point? just curiosity

  2. Farbulon says:

    Hello Galv. First I want to thank you for this awesome plugin. It allows a lot of new options (e.g randomly spawning treasures in dungeans). However it seems to be incompatible to TerraxLighting. After a few seconds ingame, I become the following error: ‘TypeError – Cannot read property ‘note’ of null.’ Switching the order of plugins doesn’t help. Is there a way to make both of them compatible?

    • Galv says:

      Had a quick look, the TerraxLighting plugin references the stored $dataMap events and not the existing $gameMap events. So the two plugins are not compatible, but I would try asking Terrax.

      • Farbulon says:

        I see. Fortunately I found an alternative plugin that works fine with yours. Thanks for your quick reply.

  3. Pep says:

    Seems you can’t set variables and then set the events position based on said variables. What I’m tyring to do is have events spawn at player X and Y, but it only spawn in the place suggested, despite an event transfer being use after that but before it executes any of the routes. Using ‘this event’ works for moveroutes, but it doesn’t for event transfer.

    • Galv says:

      To spawn at player location you could use:
      Galv.SPAWN.event(5,$gamePlayer.x,$gamePlayer.y);

      • Klunk says:

        Hello, I have a problem I cannot use any javascript commands like: Galv.SPAWN.event(1, $gamePlayer.x, $gamePlayer.y, true); It just doesn’t want to work. I don’t know why.

      • Galv says:

        Please provide more details. “Just doesn’t want to work” doesn’t help diagnose the issue.
        Does it crash? If so, when? What’s the error (and screenshot of F8 console would help).

        Are you using the ‘Script’ event command (Not the ‘Plugin’ event command)?

        Here’s a list of error trapping ideas:
        https://galvs-scripts.com/errors-using-plugins/

      • Hey sorry for being really late.
        I’m attempting to spawn an item (the way you do by spawning a treasure chest), except I’m spawning it in when the player presses the “L” key. I’m attempting to make the event spawn at the player’s X,Y location, yet it doesn’t do it. I have no errors when this is done. I know that the command block is being run, but the event just isn’t spawning at the player’s location.

        I have attempted a fix by setting it to a location outside of the player’s field of view and having the event that is being spawned in, autorun (i’ve also tried parallel) an event move command to have it move to the specific Player.X and Player.Y coordinates. This has also come back not working properly, for what I suspect to be the issue of it being in a different map before being spawned in. I have even tried using switches to go from the spawn event to the spawned event.

        I can provide more details and even show you what I mean, but I was wondering if maybe there is something I’m doing wrong.
        I’ll send my specific code below: “Galv.SPAWN.event(1,4,66);” which works and “Galv.SPAWN.event(1,$gamePlayer.x,$gamePlayer.y);” which doesn’t work.

        Thanks for your help!

      • Galv says:

        Did you see the script in the documentation for Galv.SPAWN.overlap = type; ?

      • favbot says:

        WOW.. I entirely missed that part. Thank you so much for your help, Galv!
        3 years later and you’re still following through with your fantastic plugin! I really appreciate it! Will be placing your username and link into the game!

  4. Pep says:

    Think you could add support for spawning dependant based on two variables? I’d wanna have things be spawnable at an events location, too.

  5. Galv says:

    Could you please tell me the steps you took to encounter the bug? I have just tested saving and loading and cannot replicate this issue.

    Please make sure to have the latest version also

    • Pep says:

      I go into your demo.

      I open the menu and save the game.

      I load the game and try to spawn stuff, which worked before the fact, it doesn’t now. :0

      Unless turning ‘Galv.SPAWN.overlap = ‘all’;’ makes a difference?

      Demo I have is the 1.1 version.

  6. Galv says:

    I cannot replicate what you are talking about at all.
    Did you change anything in the demo before you saved it and then tried loading it?

    I have uploaded a v.1.2 demo but the only thing it has changed is compatibility with an upcoming plugin. Download that and see if it works.

    If not, are you able to create a video of the issue?

    • Pep says:

      Well, the demo worked, but it didn’t work in my game, but I think I found the culprit, and have made a video as suggested.

      Here’s the script I believe may be incompatible.
      https://dl.dropboxusercontent.com/u/37043775/Collision_Detection.js

      • Galv says:

        You said it happened specifically in my plugin demo and had me spending a lot of time trying to replicate it. Whyyy :(

        Please try to replicate the bug in my demo. For example if you think it’s that collision detection plugin conflicting – put it in the plugin demo (with no other plugins) and do some tests to confirm.

        Unfortunately, you crazy monkey, I don’t have time to error trap your game to see if it is a bug in this plugin or not, sorry.

  7. Pep says:

    This bug is very strange. It also appears to occur in my project when a new map is loaded, I’ve checked this script in your project with both YEPy_coreEngine and my collision detection script in and it seems to be okay, that said, I haven’t attempted to check a collision, but that’s redundant seeing as in mine no collisions may be being checked, the events just don’t spawn.

    I’m going to have to do a more thorough analysis on all this, if I find the problem, I’ll letchu know.

  8. Vectorinox says:

    This plugin has amazing potential! So the event can be spawned on random tile on a region. Is it possible for the script to check if there’s already an event on the tile? Then it will select another random tile on the region to spawn the event.

    • Galv says:

      It already does that if you haven’t changed the default:
      Galv.SPAWN.overlap = ‘none’;

      • Vectorinox says:

        Oh, didn’t notice that. I was using;
        for (var i =0; i<6; i++){ Galv.SPAWN.event(11,5); }
        to spawn 6 events at once, but sometimes it spawns less than that. Does this script consider an event still occupy a tile even after it is erased?

  9. Galv says:

    You could test it out to see :)

  10. Hello Galv, thanks for the plugin!
    I have just a problem: i cannot make the event spawn in the right region… if i use the script command ” Galv.SPAWN.event(id,r,s);” the “r” it is considered like x position, so the event is always spawned at x(r), 0. Any ideas about this?
    Thanks again, have a nice day!

    • Galv says:

      Please don’t ask me the same question in multiple places :(

      • I am really sorry about this!
        However i tested it in my game (both in a game with other plugins either with a blank test) and i noticed that this happens when you set the event temporary, that is “false”: with that the region ID is not considered and it is spawned at x,0. I hope it helps!
        Have a nice day!

      • Galv says:

        If you can take a screenshot of your setup or post the exact script call you used it would help

  11. Galv says:

    Updated to version 1.4 correcting incorrect information in the help file

  12. StyX92 says:

    Hey galv, if i spawn a enemy that will have a move route and shoots with your map projectiles, than it will not shoot.
    I dont know where i have to post it, here or at your map projectiles, but its unimportant :D

    • StyX92 says:

      Hmm mabye not your fault. The selfswitch script will not trigger, if the event spawns with your event spawner.

      • Northnroro says:

        This is because of a bug of this plugin. I found that this plugin does not fully support self-switch. When spawning a new event, its self-switch might be wrong (initialized as the same value as the previously spawned event).

        This is because ‘Game_Map.prototype.spawnEvent()’ does not reset the self-switches. To fix this, just add the below lines after ‘this._events[eId] = new Game_SpawnEvent(this._mapId,eId,x,y,id,save);’.

        $gameSelfSwitches.setValue([$gameMap.mapId(), eId, ‘A’], false);
        $gameSelfSwitches.setValue([$gameMap.mapId(), eId, ‘B’], false);
        $gameSelfSwitches.setValue([$gameMap.mapId(), eId, ‘C’], false);
        $gameSelfSwitches.setValue([$gameMap.mapId(), eId, ‘D’], false);

      • Galv says:

        I cannot seem to replicate what you are describing – can you please give a scenario when this issue would occur?

  13. Mike says:

    Looks like it does not work with “build & decod”, too bad for me :(

  14. Psycoris says:

    This is quite excellent, I do have a question though what is the difference between your scripted Unspawn vs the Erase event?

    • Galv says:

      If you spawn an event permanently to a map, erase event won’t unspawn it. Erase event doesn’t delete an event, it just erases it while the player is on the map. If the player leaves and returns the event will also return.

  15. Psycoris says:

    Not sure if I am missing something. I am attempting to use another event to delete one of the created events. I attempted to use this ” Galv.SPAWN.unspawn($gameVariables.value(4));”

    I have the spawned event load its event ID into the variable 4 when it gets created. I am assuming there is no way to know what the event ID is ahead of time before creation if multiples are spawned and despawned.

    I am getting an Undefined error though. Not sure if there is a work around.

    • Psycoris says:

      I know just enough to get myself into trouble.
      I pulled your script and found $gameMap.unspawnEvent(eId);
      $gameMap.unspawnEvent($gameVariables.value(4));

      This works like a champ to unspawn the event. But I don’t know how to refresh or update the screen without opening a menu.

    • Galv says:

      The script call is:
      Galv.SPAWN.unspawn(this); // Unspawns event code is executed in.

      You cannot use a number in it. As you said, you can’t tell what the event id’s are, you need to run the code from within the event itself.
      I didn’t take into account doing this using an id.

      • Psycoris says:

        I finally found a work around for anyone that might have had the need.

        Set the first page of the event to be spawned as a parallel process and set a “control variable > script” = this._eventID. Toss a self switch in to stop the Parallel process. Then set up the normal function of the event on the new self switch page.
        Now with any event (beware with common events though) on the same map you can call the script:

        $gameMap.unspawnEvent($gameVariables.value(the variable number you set in the event)); //this deletes the event
        SceneManager.goto(Scene_Map) //this redraws the scene

  16. Yo Galv, I know your script probably wasn’t designed with hectic systems like an ABS in mind, but there’s a bit of an error.

    Basically I have another script called Collision_detection.js which was made to my specifications, what I do is spawn in projectiles from a spawn map and then check if either batch id [pick a number] collides with the player, or with another batch id.

    This works fine if the event is merely erased afterwords, however, using your unspawn method makes it error and the collisions after the first don’t work, my theory is that it’s destroying the presence of a batch ID rather than just the event.

    unspawn.this is important because if I use erase event the events stay on the map, result is even though they just become uninteractive and invisible, the pile up leads to a memory leak. This exact behavior can be witnessed in Perseverance: Full Clearance. https://www.youtube.com/watch?v=NSteqOVUf68

    Here’s the collision_detection.js script: https://drive.google.com/open?id=0B2CvOYXTy9fkVmFQbXREN2tENlk
    and this is the error I get when galv_unspawn(this) or whatever is used.

    Hope this helps! Hopefully you can find the time to fix.

    • Galv says:

      You are right, this plugin wasn’t designed for that and unfortunately I don’t have any time to modify it.

      I do, however, have a projectile plugin that might be of interest that does not use events to create projectiles.

      • I’ve looked into that, but it doesn’t have the level of flexibility this does. If you can’t find time to fix it, it’s not the end of the world. Means I either make sure I don’t allow too much event bloat to happen or I get another coder to fix it.

  17. John Doe says:

    Hey Galv

    I set up a parallel spawn point and I notice it wont spawn if the player ism more then 14 tiles away from the event?

    is this by design? or is it rpg maker not having loaded that part of the map yet?

    • Galv says:

      If it’s a parallel process, I think it should work. I’ll have to try that out.

      If you’re doing it within a move route then that’s an rpgmaker lag reduction thing.

  18. itsMiatch says:

    Hello! I’ve had a five-minute look around and I can’t find what I’m looking for.
    I was wondering if you were able to spawn lots of the same event on a specific Region ID? I want to have lots of coin pickups on my map without filling it with events.
    Thanks for any help.

  19. vectorinox says:

    Found a bug. When I use show animation to play animation on the spawned event, then run unspawn.this before the animation finish playing. The animation particles got stuck and suspended on the screen. Any way you could fix this?

  20. Rinku says:

    I believe I’ve found a compatibility issue with Mr Trivel’s Event Names script: https://mrtrivelrpg.wordpress.com/2016/02/14/above-event-names-pictures-icons/

    When I have their script turned on, I get a “TypeError: Cannot read property ‘parent’ of null”, but when I turn it off, your script functions well (so far).

    The command I’m using is:
    Galv.SPAWN.event(num,reg);

    • Galv says:

      If you have tested this in a fresh project with just the two plugins, tried them in different orders and made sure all script calls are correct, I recommend asking Mr Trivel.

  21. Fenc says:

    Can’t seem to get Set Event Location to work after spawning any events. This is a fresh project with only this plugin on it. (the parallel trigger is just for testing purposes)

    spawns — > Galv.SPAWN.event(10,0,0,true);
    “random” variable set to Math.floor(Math.random()*$dataMap.width)
    “random2” variable set to Math.floor(Math.random()*$dataMap.height)

    event10: http://imgur.com/a/QZOTP

    Reason why I do not just add the variable to the spawn script call is because I need it to be able to repeatedly go to random locations.

    • Fenc says:

      I believe it has to do with the fact that set event location when being used specifies a coord of current map (being the spawn map) but the event is being spawned in a different map.

    • Fenc says:

      Further testing shows that if the event moves after spawning, the set event location defaults to where you spawned the event (i.e. I spawn event at coord 5,5 and it moves at random then I trigger said event which has set event location to 0,0, it’ll teleport to 5,5 rather than 0,0)

      I tested this using the chickens in the demo

  22. Fenc says:

    To clarify Set Event Location with spawned events

    • Galv says:

      I’ll have a look into this when I get some time.

      • Fenc says:

        Found a workaround that looks very bad. Setting both event._x/y and event._realX/Y to the coords I want teleport it. However, I don’t know what problems directly changing that would cause. Either way looks bad.

      • Galv says:

        I’ll have a look into this when I get some time… I have not had time yet.

      • Fenc says:

        didnt mean the problem looked bad, i meant the workaround looked bad

      • Galv says:

        I assume you are spawning and event and saving it and that’s why you want to run a new command to set it’s location?
        Could you spawn the event every time the map loads and use the variables in the script call to spawn it then?

      • Fenc says:

        Its a monster that routinely teleports within the map as an ability so it would have to move locations while the player stays in the same map. Is this an engine limitation? I couldnt find any way to enable set location by looking at the source code as well.

      • Galv says:

        I don’t think so – I believe I just have to update the plugin so that the set event location event command works correctly for the event

  23. Alex says:

    This Plugin is exactly what i hoped to find when i searched for something that can put events on the map WITHIN the game itself.
    I’m working on an own Plugin, that requries event spawning in order to easly create a bridge. I made a spawn map, created an event, set the image to a bridge part and set priority on “below character” and made sure that passage settings on said tile were correct.
    Then I tried and failed. It seems despite successfully creating the event above unpassable terrain, the player cant walk on it. So i made some experiments and found out, that a simple $gameMap.requestRefresh() at the end of your Galv.SPAWN.event() function has fixed my problem.

    I thought i should share this information with you.

    Thanks for the Plugin, really made my day.

  24. Cameron says:

    Hi Galv, I’m making a Zelda game, and I want to make it so when I hack down a bush, items randomly drop. I managed to get random items to drop but is there a way I can make an event spawn at the same location as the bush? Because there are so many bushes in the game I don’t want to have to set an individual coordinate for every bush… Thanks

    • Galv says:

      Galv.SPAWN.event(id,x,y,s);

      you need to get the x,y value of the event you want. I recommend asking in a forum how to do this and will depend on where you are running the code.

      • Cameron says:

        Hi, I know that part but since there are tons of bushes on every map I’d have to open every bush event and make the item spawn on the X,y of that bush… What I’m asking is if there’s a code similar to the code to spawn on player to make it spawn on “this event” since the code is written from the bush event itself.

      • Galv says:

        I know what you are asking and I’m suggesting ask that in a forum because someone will be able to tell you the “this event” code. I cannot at this time. :(

  25. Sakyawira Nanda Ruslim says:

    May I use this in a game jam ? This is only for education purpose though :D

  26. Sarcastic Sloth says:

    Hi Galv! I just recently found this and it works really well. Thank you for making it. I am trying to use it with another plugin called ‘Alpha ABS,’ an action battle system. For the ABS to work, the events on the map need to have note tags. Does your event spawner copy the note tags of the events it spawns? I ask because I am having trouble getting these two plugins to work together.

  27. Mr. X says:

    I think there may be an incompatibility with this script and your Character Animations script? I downloaded this demo and then installed that plugin and whenever I try to spawn an event it says “TypeError: Cannot read property charAnims of undefined”. Same thing if I download the character animation demo and install the spawner script. Any chance you could fix it or offer a suggestion? Thank you.

  28. Matthew says:

    Question: Is there a way to make an event spawn in front of the player?

  29. woop says:

    Is it possible to store an event’s x, y into variables from the Spawn Map and use the variables in a different map, or reference the event’s x,y directly from the Spawn Map?

    • Galv says:

      I’m sure it is possible, but the plugin wasn’t intended to do that. If you’d like to work that out I recommend asking in a forum.

      • woop says:

        I managed to get the event to store itself into 2 variables and successfully got that event to interact with other events, yay!

        But, I may have inadvertently found a bug with Galv.SPAWN.unspawn(this); command, it doesn’t seem to actually erase the spawned event’s x, y coordinates.

        I made it so that the player can spawn in an event in front of them self by pressing a button (shift in this case), it plays an animation and then despawns itself. If the spawned event is played over another map event, that map event erases itself with the “erase event” command. But, when the player re-enters the same map, the map event is supposed to respawn but the game thinks the spawned event is still there, so it erases itself again.

        I made a small demo file that demonstrates it here:
        https://drive.google.com/drive/folders/1Aj1tk68e56PNKfhoObB8R5nKr4S90e4a?usp=sharing

      • Galv says:

        The ‘Erase Event’ event command only erases the event until the player leaves and re-enters the map. That’s how RPG Maker works by default.

  30. woop says:

    Yes, that’s precisely the reason why I used the ‘Erase Event’ command in this example, I want the map event to respawn if re-entering the room. I’ve also tested it using your Event Spawn Timers as well, setting the map event to respawn at a later time, but the result is still the same. If the player spawns the event a second time in a different location, the map event respawns as intended.

    I’m guessing the plugin wasn’t really intended to be used in this way? Nonetheless, this plugin is really awesome!

    • Galv says:

      It’s a little hard to picture what you’re doing exactly but it doesn’t sound like it was intended for that use, no – sorry about that. One day if I get time I might try and look into this and see what the issue is.

  31. Jentaia says:

    Hi Galv,
    I’m trying to spawn at random, but it says “r is undefined”…
    Tried this command:
    Galv.SPAWN.event(001,r,s);
    I put that in the script part of the event:
    for (var i = 1; i <= 20; i++) {
    Galv.SPAWN.event(001,r,s);
    }
    So, the map got the ID "005", the event got the ID "001"…
    But I also tried "5" and "1", but the error still occurs.
    MV is up to date with version 1.6.1 on Ubuntu Linux (also up to date).
    Am I missing something?
    Regards
    Jentaia

    • Galv says:

      You haven’t used the script call properly. A little further down in the plugin documentation there are examples of the script calls.

      The example for using the random region:
      Galv.SPAWN.event(1,12,true); // spawn event 1 on random region 12, saved

      You need to replace the ‘r’ with a region ID and the ‘s’ with either true or false depending if you want the event to save or not.

      • Jentaia says:

        Thanks for the very quick reply.
        I now placed region 1 on the map (50×50) and altered the command:
        Galv.SPAWN.event(1,1,true);
        Try 1:
        The game doesn’t load the target map completely. I can see the char, I can see the spawned trees, but the game is stuck at “I want to load the map completely”. It has a dark hue and I can’t move.
        Try 2:
        I removed the “for” loop so it would do the command 1 time.
        The map seems to be loaded completely, but I can’t move the char. No trees visible in the radius of my char (maybe 20×20 tiles?!)

        I disabled all other plugins just to be sure nothing is interfering.
        The console shows nothing.

      • Galv says:

        The plugin itself shouldn’t freeze your game like that… could it be you have an autorun or parallel process running that needs to be turned off? I recommend asking in a forum for more assistance.

      • Jentaia says:

        The command itself is running as autorun.
        On the map there is no other event running. It is just a big field with grass ground.
        As I’m just starting doing a game, I wouldn’t know of any other event disturbing your plugin…

      • Jentaia says:

        Just for your notice: I’m not the only one with the freezing problem:
        https://forums.rpgmakerweb.com/index.php?threads/galvs-event-spawner.109398/
        I think I will give a last final try to understand object oriented programming -.-

      • Galv says:

        Without seeing the autorun event you have this in, I think it might be hard to error trap what went wrong. Try not using autorun as see if the same thing happens.

      • Jentaia says:

        https://forums.rpgmakerweb.com/index.php?threads/autorun-events-or-why-cant-i-move.54123/
        It’s not a bug, it’s a feature: RMMV seems to have an anti-feature. Who needs an endless loop as autorun? (Can’t remember RM2000 had this).
        As I didn’t understand anything from the thread above (maybe because English isn’t my native), here’s the solution:
        1. Put an empty page into the event. Make it start by action button. It has to be PAGE 1
        2. Put everything you want the event should do into page 2. Set a switch as condition.
        3. Turn that switch to OFF at the end of your commands.
        4. Your char has to get to this map somehow. Set the switch to ON in the event that moves the char to the map with the autorun event.

        I can’t believe I wasted 2 days because I wanted some random placed trees on the map. -.-

        Thanks for your help and the ever quick replies!
        I hope this answer can help everyone else new to RMMV.

Leave a Reply to Pep Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s