Amaranth's Super Simple Mouse System for Ace

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by Shaz, Sep 6, 2013.

  1. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Super Simple Mouse System
    Shaz
    Versions
    Current version: 1.10
    Code:
    1.0    6 Sept 2013 - Initial Release1.02   7 Sept 2013 - Fixed game crash when loading a save file made prior to adding script                   - Fixed player stuck on impassable tile error when clicking while dismounting the air ship vehicle1.03   8 Sept 2013 - Fixed player moving to diagonal tile instead of adjacent tile when event is on a counter1.04  10 Sept 2013 - Fixed vehicle pathfinding on world map                   - Fixed event triggering when no path is found1.05  14 Sept 2013 - Tweaked accessing of tilemap_offset1.06   3 Nov  2013 - Disabled mouse control while player is waiting for an NPC move route (or for any non-parallel process event to finish)                   - Fixed events not triggering after player reaches them1.07   6 Nov  2013 - Slowed down mouse scrolling, and don't loop save files1.08  24 Nov  2013 - Catered for YEA Core script where screen size can be larger than map size, and map is centered                   - Fixed early event activation bug introduced in 1.06                   - Replaced calculation of item boundaries in Windows_Selectable                   - Added ability to enable/disable mouse1.09  21 Dec  2013 - Fixed mouse re-enabled when a common event is called from an autorun or player triggered event1.10   6 Apr  2014 - Added interaction for sprites higher than 32 pixels tall (now you can click on the top of the sprite)                   - Activate an event without walking up to it (add a comment with <autoactivate> to the top of the event page)                   - Cancel mouse path when guiding the player with arrow keys                   - Menus ignore the position of the mouse when using the arrow keys                   - Fix issue where player won't walk to the other side of a counter opposite shopkeepers
    Introduction
    This is a complete overhaul and Ace conversion of the script originally written for XP by Near Fantastica and SephirothSpawn, heavily modified by Amaranth and used in all of the Aveyond games.

    Features
    - Custom mouse icons and text popups over events
    - Pathfinding for player AND events
    - Mouse control in menus and other windows
    - Easy configuration options

    Screenshots
    Mouse Icons and Event Descriptions:
    [​IMG]
    Even though it would take fewer steps to approach the shopkeeper on the left from below, the -2 0 in the comment tells the pathfinding script to move the player to the tile on the other side of the counter.
    The shopkeeper on the right will be approached via the path that takes the fewest steps (from below) since there is no position override in the comment on that event.
    The event's description (shown as text beside the icon) can be as many words as you like.
    Pathfinding:
    [​IMG]
    When you click on the top chest, the player will not open the chest while standing beside it, because of the cliff edge.
    HOWEVER, if you used the keyboard instead of the mouse, pathfinding is overridden, and you WOULD be able to open the chest while standing on the tile to the right.
    When you click on the Imp, the player will also walk up the steps to fight it.
    HOWEVER, if the imp were set to Approach Player and Event Touch, it WOULD attack the player if the imp is on the hill and the player is below the hill on an adjacent tile.

    Pathfinding and mouse processing do NOT override what the player can do via the keyboard, or what events are already programmed to do by the default scripts.
    How to Use
    The mouse system is a series of 8 scripts (kept separate for ease of maintenance). Open the .rar file below, open each .rb file in a plain text editor, and copy and paste the scripts each into new slots in Materials. Most of the methods are aliased, so this can go below other custom scripts. ALL scripts should be used together.

    Mouse Icons
    • Add, change and remove icons through the ICON hash, just below the comments in the Mouse 1 - Sprite script.
    • The hash key is the name (one word, alpha characters only, lower case), and the number value is the icon index in your System IconSet.
    • DEFAULT_ICON must have the name of one of the keys in the hash. This is what your mouse cursor will look like when it's not over an event that sets a custom cursor.
    Code:
    ICON = {'arrow' => 386, 'talk' => 4, 'look' => 3, 'fight' => 116,        'touch' => 491, 'exit' => 121}DEFAULT_ICON = 'arrow'
    If you don't want a generic 'exit' icon, but you want individual 'up', 'down', 'left' and 'right' icons, simply remove the 'exit' key and value, and add new values for each specific direction, along with the appropriate icon indexes.

    Event Icons and Descriptions
    Add comments to your event pages in the following format to control mouse and pathfinding behaviour:
     
    Code:
    <mouse icon x y name>
    • icon is the name of the icon to show when the mouse is moved over the event. This must exist in the ICON hash.
    • x y is an optional addition, to force the pathfinding to move the player to an offset from the current event.
    • name is an optional description that will be shown beside the mouse icon. It may be one or more words.
    Examples:
    • <mouse fight> will show the 'fight' icon when the mouse is over the event
    • <mouse look 0 1> will show the 'look' icon when the mouse is over the event, and will make the player walk to the tile below the event before the event is triggered (good for signs, mailboxes, etc, where you want the player to stand below the event and face up)
    • <mouse talk 0 2 Shopkeeper> will show the name Shopkeeper and a 'talk' icon when the mouse is over the event, and when clicked, will move the player to the tile two below the event (good for shopkeepers where there is a counter between the event and the player)
    • <mouse talk Nasty Girl> will show the text Nasty Girl along with a 'talk' icon when the mouse is over the event
    Pathfinding
    • To make the player, or an event, walk to a particular tile, without having to check where they currently are and adding lots of directional moves, simply add a Move Route command, choose Script, and enter find_path(x, y).
    • The script will ATTEMPT to find a path to that tile (or an adjacent tile if the original one is impassable).
    • If a path is not found, no movement will occur.
    • If a path is found, the player or event will start following the path. But if, after starting to follow the path, an obstacle moves in its way and blocks the path, the player or event will only walk as far as the obstacle.
    • Adding Wait to the move route WILL NOT make the event wait until the path has been followed. Only until the path has been determined. If you want to pause processing until the player or event has reached the destination, you will need to do that separately (keeping in mind that the player/event may not actually reach the destination).
    • Any Set Move Route on the player or event while they are following a path will cause them to stop following the path and obey the new move route, even if there are no actual movement commands.
    Enable/Disable Mouse
    The mouse is enabled by default. If you want to change this, use a Call Script command that passes a true (enabled) or false (disabled) value to the mouse:


    Code:
    $mouse.enabled = false
    This value is NOT saved anywhere - it is up to you to save it in a preferences file or as game data, and to load that value and call the command whenever your game is started or your save file loaded.

    Script
    Get it here

    Patches & Compatibility
    Engr. Adiktuzmiko wrote a script that lets you save the enabled/disabled state.
    You can find it here.

    lordosthyvel has also made a patch for this script that allows diagonal movement.
    You can find it here.

    Magno has made a patch that fixes a problem in widescreen resolution when using Tsukihime's Unlimited Resolution script.
    You can find it here.

    Known Bugs
    This does not work on maps that have horizontal or vertical looping (in Map Properties).
    F12 causes the game to crash. I do not intend to address this, as F12 is not the standard or recommended way of starting a new game.
    Script crashes if game title has non-Latin characters

    FAQ
    Q: Is this compatible with other scripts?
    A: It is compatible with RTP scripts. It SHOULD be compatible with most other scripts, with the exception of those that do their own things with player/event collision (like pixel movement scripts) and possibly custom windows that don't behave like Window_Selectable. I don't know if the mouse scripts will work with those or not, but I do NOT plan to make mods to this script to make it compatible with any non-RTP scripts.

    Credit and Thanks
    - Shaz, Near Fantastica, SephirothSpawn, Amaranth Games
    - lordosthyvel, for his diagonal movement patch

    Author's Notes
    • Okay for use in free and commercial games. Credit must be given.
    • Do NOT repost this script on other sites. Please provide a link here instead. I will NOT be going to other sites to give support for this script. 
    • Post any issues in this thread. I will attempt to fix any bugs with this script, when used with the RTP scripts. I will not attempt to fix bugs that are caused by using the mouse script with other custom scripts.
    • I do not recommend you use the find_path method on many events at a time (especially if they are likely to cross paths), or to make them walk long distances.
     
    Last edited by a moderator: Dec 6, 2015
    #1
    Nightblade50, Bex, MirageOwl and 24 others like this.
  2. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,407
    Likes Received:
    2,822
    Location:
    Philippines
    First Language:
    Tagalog
    never knew that we can access events even in cliffs... gotta try this mouse script, those text pop-ups will be really helpful...
     
    Last edited by a moderator: Sep 6, 2013
    #2
    graithallerne likes this.
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Yeah, it's really annoying.  By default, if you're on a tile right next to an event, you can activate the event (or the event can activate itself, if it's set to Event Touch and Approach) - it doesn't look at passability.  I have modified my own scripts to avoid both of these problems, but omitted the changes here, as they're really not part of the mouse script.
     
    #3
  4. Jomarcenter

    Jomarcenter jomarcenter games Veteran

    Messages:
    1,200
    Likes Received:
    130
    Location:
    philippines
    First Language:
    ENGLISH
    Well thank you... I been waiting for this conversion(or release).

    But do you have plans to release the cursor or something?

    Edit: didn't check closely there is already provided from the RTP.
     
    Last edited by a moderator: Sep 6, 2013
    #4
    Shaz likes this.
  5. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,407
    Likes Received:
    2,822
    Location:
    Philippines
    First Language:
    Tagalog
    Oh, I see... I can try to experiment on that myself... XD...

    btw, for the pathfinding: if I issue a move route command then do a mouse click somewhere, will it follow the mouse click? (because the post tells about what happens if I issue a move route during pathfinding, but not the reverse)
     
    Last edited by a moderator: Sep 6, 2013
    #5
  6. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    The cursor?  No - I've just used what's in the IconSet.  We used the individual cursors in XP, when each icon was a separate file.

    Mmm ... no - I THINK while a move route on the player is in progress, mouse clicking is ignored.

    edit: yep, confirmed.
     
    Last edited by a moderator: Sep 6, 2013
    #6
    Engr. Adiktuzmiko likes this.
  7. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,407
    Likes Received:
    2,822
    Location:
    Philippines
    First Language:
    Tagalog
    I see, then that's good... no possible problems for when you have event commands for forcing the player's movements... :)
     
    #7
  8. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Try it out - see if you can break it.  I think I did have an extra guarantee built into my original script, but when I pulled it all out into a standalone script, I couldn't remember why I needed to add it (so I think it was actually for something unrelated to the mouse).
     
    Last edited by a moderator: Sep 6, 2013
    #8
  9. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,407
    Likes Received:
    2,822
    Location:
    Philippines
    First Language:
    Tagalog
    I'll test it out at home... I really like those pop-ups and variable icons...
     
    #9
  10. Jomarcenter

    Jomarcenter jomarcenter games Veteran

    Messages:
    1,200
    Likes Received:
    130
    Location:
    philippines
    First Language:
    ENGLISH
    At least the good thing here that in all the mouse script this is the only commercial use approved ones (while some which is commercial use still have a ton of bugs).

    thanks.
     
    Last edited by a moderator: Sep 6, 2013
    #10
  11. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,407
    Likes Received:
    2,822
    Location:
    Philippines
    First Language:
    Tagalog
    plus the cursor is icon based so you can easily swap out cursors... XD
     
    #11
  12. Archeia

    Archeia Level 99 Demi-fiend Staff Member Developer

    Messages:
    14,522
    Likes Received:
    14,151
    Location:
    Game Dev Salt Mines
    First Language:
    Filipino
    Primarily Uses:
    VNM
    By the way Shaz, have you tried using this while Chrome is Open (or even better, Photoshop) and see if it actually registers a click?
     
    #12
  13. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Yep.  A click in Chrome (or anywhere outside of the game window) while the game is running will not register with the script as a click.  This is not something built into the script - it is the default behaviour of the engine (clicking outside the game window removes the focus from the game and halts script processing).  Are you asking because you've tried it and had different results?
     
    Last edited by a moderator: Sep 6, 2013
    #13
  14. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,178
    Likes Received:
    10,328
    First Language:
    English
    Primarily Uses:
    RMVXA
    Thanks so much for this.  Have just installed and tried this, with no customisation and it's come up with this error message

    Script 'Shaz Mouse 2 Mouse Module' line 36: TypeError occurred

    nil can't be coerced into Fixnum

    Is that because I've done no configuration, just used as plug and play?  Because I'm inserting this into an almost finished game I'm not intending to put in mouse events, so didn't think I needed to do anything.

    EDIT

    That error with opening from a save file.  Opening in new game gives:

    Script 'Shaz Mouse 7 Player' line 16: NoMethodError occurred

    undefined method 'push' for nil:NilClass
     
    Last edited by a moderator: Sep 6, 2013
    #14
  15. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Plug'n'play should work.  Are you loading a saved game, or starting a new game?  If you've loaded a saved game, that COULD be the issue, because that line refers to something that needs to happen during setup of the tilemap.
     
    Last edited by a moderator: Sep 6, 2013
    #15
  16. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,178
    Likes Received:
    10,328
    First Language:
    English
    Primarily Uses:
    RMVXA
    It may be that my edit got posted as you were typing your reply.  As you see, starting a new game produced a different error message.
     
    #16
  17. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Sounds like you're using another script or a script call that starts map events, bypassing the Game_Player.start_map_event method.

    Can you go to that method and change it so it looks like this (just adding one line before the one that generates the error)?

    Code:
     #--------------------------------------------------------------------------  # * Start Event  #--------------------------------------------------------------------------  def start_event(event_id)    @started_events = [] if @started_events.nil?    @started_events.push(event_id)  end
    If that fixes it, I'll have to tinker a bit more, because it does need to be reset/cleared at other times.
     
    Last edited by a moderator: Sep 6, 2013
    #17
  18. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,178
    Likes Received:
    10,328
    First Language:
    English
    Primarily Uses:
    RMVXA
    Perfection!

    I'm now ready to go.  Once again, thank you for all your work to produce this.
     
    #18
  19. Quigon

    Quigon electric boogaloo Veteran

    Messages:
    1,982
    Likes Received:
    946
    Location:
    Oklahoma
    First Language:
    English
    Primarily Uses:
    N/A
    Oooh, another mouse script I was using stopped working when I upped the resolution of my game, I wonder if this'll work or not. Trying it now!
     
    #19
  20. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Have added the above fix to the scripts and updated the download.
     
    #20

Share This Page