Big Events

● ARCHIVED · READ-ONLY
Started by Shaz 20 posts View original ↗
  1. Big Events
    2018.01.13
    by Shaz

    Introduction
    This plugin allows you to set an event's collision area to cover more than one tile.
    This is ONLY for events that do not move.

    How to use
    Add plugin to your js/plugins folder - name must be Shaz_BigEvents.js - and enable in plugin manager.
    Place an event in the top left corner of the area you want to cover.
    If you want the collision area to be set the same for all pages of the event, put <bigEvent:wxh> into the event's note box, where w is the total width and h the total height of the collision area.
    If you want a single event page to have a different sized collision area, put <bigEvent:wxh> into a Comment command on the event page.

    Plugin
    Download from pastebin
    make sure to save it as Shaz_BigEvents.js

    Credit
    - Shaz

    Terms
    - free for use in commercial games
    - do not post elsewhere - link back to this page

    Notes
  2. This looks really useful. Thanks Shaz. Less copying events means less mistakes. Plus each page can change? Super versatile!
  3. I used this one on Ace. I'm sure someone has written one for MV, but I needed a small, easy one to get back into the swing of things :)
  4. I went ahead and made a little extension for myself of this plugin. What it does now: adds the optional "offset" parameter so that it shifts the big square by ox and oy (more instructions on how to use it in the help section).

    Maybe someone else can find it useful as well. Here it is:
    Spoiler
    Code:
    /*:
     * Big Events by Shaz and Akumu Games
     * Ver 1.0.AG 2018.01.31
     * Shaz_BigEvents.js
     *
     *
     * @plugindesc Set an event's collision area to cover more than one tile.
     * @author Shaz
     *
     * @help This plugin allows you to set an event to cover more than one tile
     * for collision purposes.  You can specify the entire event (all pages) to
     * have the large collision area, or just individual pages.
     *
     * USAGE:
     * Place the event in the top left corner of the area to be covered.
     * Enter <bigEvent:wxh|offset:ox,oy> in the event's note box (affects all event pages),
     * or as a comment on the event page (affects just that page), where w is
     * the number of tiles across and h is the number of tiles down that the
     * event will occupy and ox and oy is the collision box offset.
     * A <bigEvent:...> comment on an event page will override a <bigEvent...>
     * tag in the note box.
     *
     * Example:
     * <bigEvent:1x3|offset:-1,0> in the notebox of an event will expand the collision area
     * of that event to cover the current tile plus two tiles below (total width
     * is 1 and total height is 3) and offset the collision box one tile to the left.
     * <bigEvent:4x4> in a comment on an event page will expand the collision
     * area to a 4x4 square, just while that page is active.
     *
     * NOTE:
     * This plugin has no plugin commands.
     * This plugin is only to be used for events that will not move.
     *
     */
    
    var Imported = Imported || {};
    Imported.Shaz_BigEvents = true;
    
    var Shaz = Shaz || {};
    Shaz.BE = Shaz.BE || {};
    Shaz.BE.Version = 1.00;
    
    (function() {
       var _Shaz_BE_Game_Event_initMembers = Game_Event.prototype.initMembers;
       Game_Event.prototype.initMembers = function() {
           _Shaz_BE_Game_Event_initMembers.call(this);
           this._xr = null;
           this._yb = null;
           this._xro = 0;
           this._ybo = 0;
       };
    
       var _Shaz_BG_Game_Event_pos = Game_Event.prototype.pos
       Game_Event.prototype.pos = function(x, y) {
           if (this._xr) {
                 return (this._x + this._xro) <= x && (this._x + this._xr + this._xro) >= x && (this._y + this._ybo) <= y && (this._y + this._yb + this._ybo) >= y;
             } else {
                 return _Shaz_BG_Game_Event_pos.call(this, x, y);
             }
       };
    
       var _Shaz_BE_Game_Event_clearPageSettings = Game_Event.prototype.clearPageSettings;
       Game_Event.prototype.clearPageSettings = function() {
           _Shaz_BE_Game_Event_clearPageSettings.call(this);
           this._xr = null;
           this._yb = null;
           this._xro = 0;
           this._ybo = 0;
       };
    
       var _Shaz_BE_Game_Event_setupPageSettings = Game_Event.prototype.setupPageSettings;
       Game_Event.prototype.setupPageSettings = function() {
           _Shaz_BE_Game_Event_setupPageSettings.call(this);
           this._xr = null;
           this._yb = null;
           this._xro = 0;
           this._ybo = 0;
           var param = null;
           if (this.page() && this.list()) {
               this.list().filter(function(cmd) {
                   if ((cmd.code === 108 || cmd.code === 408)) {
                       if(cmd.parameters[0].match(/<bigEvent:\s*(\d+)x(\d+)\s*\|\s*offset:\s*(-?\d+),(-?\d+)>/)) {
                           param = [RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$4];
                           return true;
                       } else if (cmd.parameters[0].match(/<bigEvent:\s*(\d+)x(\d+)>/)) {
                           param = [RegExp.$1,RegExp.$2,0,0];
                           return true;
                       } else {
                           return false;
                       }
                   } else {
                       return false;
                   }
               });
           }
           
           if (!param){
               if (this.event().note.match(/<bigEvent:\s*(\d+)x(\d+)\s*\|\s*offset:\s*(-?\d+),(-?\d+)>/)) {
                   param = [RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$4];
               }else if (this.event().note.match(/<bigEvent:\s*(\d+)x(\d+)>/)) {
                   param = [RegExp.$1,RegExp.$2,0,0];
               }
           }
           
           if (param) {
               this._xr = parseInt(param[0]) - 1;
               this._yb = parseInt(param[1]) - 1;
               this._xro = parseInt(param[2]);
               this._ybo = parseInt(param[3]);
           }
       };
    
    })();
    Let me know if you find any bugs :kaoswt2:

    And thank you for this plugin, Shaz!
  5. You know, in my Ace version, it was based on centering the event along the bottom, so you could say how many squares to the left and right, and how many above. I only remembered why I did that after I converted the project to Ace and realised I had some "big" events that had sprites covering more than one tile, and the event needed to be at the bottom.

    The only change I would make to your extension is to remove the calculations from this:
    Code:
    return (this._x + this._xro) <= x && (this._xr + this._xro) >= x && (this._y + this._ybo) <= y && (this._yb + this._ybo) >= y;

    and put them into the setupPageSettings function and store the results into new variables. That way, you're only doing the comparisons each time the pos() function is called, and not up to 4 lots of additions as well. You can do this because the event isn't moving around, so those coordinates won't change. I think pos() is called on every event on the map, by every moving event on the map as well as the player, on every frame, so that could be a lot of calculations it's trying to do and could make things slow.
  6. Oh, I see. Now I wanna try something else. Will edit the update :) Thanks!

    Edit: Based on what you just wrote, I made a little tweak. Probably not for the best in terms of performance, like you said, but now you are able to transfer the event to other coordinates and keep the big size (I tested this and you couldn't do this before). It may come in handy for some cut-scenes, don't you think (like moving a big boulder or I dunno)?
  7. Can you make it work for moving events? I mean, if event doesn't move, you might as well surround it with invisible "same level as character" events and you get the same result.
  8. No, it specifically only works for static events. Have a look around though as I think someone did make one of these for moving events.
  9. Good afternoon, Thanks for the cool plugin, but here's the question. Can you add the ability to make the expansion of tiles not only down but up?
  10. Hi Shaz, I've been trying the notetag:
    Code:
    <bigEvent:1x3>

    but it doesn't work. Oddly enough, 2x3 works.
  11. @Archeia that's strange - I use it with 1 all the time and have no issues.

    Can you give me a screenshot of the map with the event highlighted, and a screenshot of the event?
  12. Strange it works now and I didn't do anything. Maybe I was just tired. Sorry Shaz :kaoeh:
  13. I am having trouble getting this plugin to work. The player just floats through the event. Any suggestions? shaz.png
  14. My guess is it's because you have Through on.

    For Player Touch and Above Characters, I think you need to be standing on the same tile as the event. I'm not really sure what this plugin would do there.
  15. LeetMusic said:
    I am having trouble getting this plugin to work. The player just floats through the event. Any suggestions?
    You have the "Through" box ticked, and also the event priority is Above characters. You want Through off, and the priority to be Same as characters. Then they'll bump into the event, i.e. it won't be passable.
  16. C64_Mat said:
    You have the "Through" box ticked, and also the event priority is Above characters. You want Through off, and the priority to be Same as characters. Then they'll bump into the event, i.e. it won't be passable.
    It's still not helping. Only the 1 tile with the event is blocked.
  17. LeetMusic said:
    It's still not helping. Only the 1 tile with the event is blocked.
    Well, that's one thing tried!

    Ok: Looking at your image, it appears you've selected the centre of an image.

    In the OP it states the event starts from the TOP LEFT when calculating the size based on the note tags.

    Try selecting the top left tile/character/whatever for the event you're making, and see if that works :)

    Oh, and make sure the plugin is switched ON in your plugin list! Occam's Razor and all that...
  18. I made the event 8x8 which is larger than it actually is. Still no change.

    Yes, the plugin is turned on. :)
  19. Question, Does this plugin work with the player?
  20. This is great, I've been using it for clickable UI events for a character select menu :yswt: