[CGMZ] Hooks (Patreon)
Downloads
Content
Run your own custom JavaScript after certain actions, such as leveling up or getting a [CGMZ] Achievement!
! SEE BOTTOM OF POST FOR UPDATES !
Hi all, introducing [CGMZ] Hooks!
This plugin allows you to write and run custom JavaScript code when certain actions occur. Some of these actions are from the base code, while others are CGMZ functions. Below is a list of the current hooks you can write custom JS for via this plugin:
RMMZ:
Common Event
Gold Changed
Item Changed
Equip Changed
Actor Added
Actor Removed
Level Up
Level Down
Learn Skill
Forget Skill
Skill Use
Change Class
Get On Vehicle
Get Off Vehicle
Battle Start
Battle Win
Battle Escape
Battle Escape Fail
Enemy Kill
Switch Change
Variable Change
Self Switch Change
Player Transfer
CGMZ:
After Load
Mouse enter / leave
Toast Window
Screenshot
Achievement Earned
Profession Level Up
Profession Level Down
Craft
Fast Travel
Difficulty Change
Skill Purchase
Dungeon Tool Use
Dungeon Tool Interact
New Game Plus
Actor Recruit
Skill Level Up
Quest Discover
Quest Start
Quest Complete
Quest Fail
Quest Pin
Quest Unpin
Jukebox Discover
Jukebox Played
On Gather
Picture Gallery Discover / Undiscover
Picture Gallery Show / Hide
Encyclopedia Discovery
Gamepad Connect / Disconnect
Skill Equip / Unequip
You can also make custom hooks, assign them an ID, and then call that hook via plugin command. This is useful if you have a script command you use frequently, you can write (and edit it) once as a custom hook and then run it in many different places via the plugin command, similar to how my Sound IDs plugin works.
Of course over the course of the alpha/beta process this list will expand quite a lot! But, it will be helpful for me to know which other actions you'd like to run your own custom JavaScript code for. Leave suggestions below or in the #suggestions channel on my Discord!
Happy RPG Making!
This plugin was updated today with 2 new hooks as requested by users of the plugin: On Skill Use and On Enemy Kill. On Skill use will run the hook whenever a skill is used by either an actor or an enemy. This could be in battle, or from the menu for healing skills. On Enemy Kill will run the hook when an enemy dies in battle. This was suggested as a way to track enemy kills for a quest in [CGMZ] Quest System, but could also be used for other purposes too.
This plugin was updated with a new hook: Skill Purchase. This hook will run whenever you buy a skill from the [CGMZ] Skill Shop, and it will provide you easy access to the skill that was purchased, the price it was purchased at, and the actor that learned the skill in your JS parameter.
This update also fixes a bug with learning skill hooks, as they would fail to run due to a previous update causing the hook to run after the skill was already learned. Finally, this plugin will no longer crash when invalid JSON is detected, it will instead warn you in the dev tools console. These errors are still important to fix, as they will prevent your hook with the JSON error from working properly.
This update added some new hooks for you to try out and fixed a bug. For default RMMZ hooks, this update adds a hook for game variable and game switch changes. Now you can run custom JS whenever you change a variable or switch.
For CGMZ hooks, this update adds hooks for dungeon tool use and interact. Now you can run custom JS whenever a dungeon tool is used, and whenever a dungeon tool interacts with an event.
This update also fixed a bug with the Skill Purchase hook for [CGMZ] Skill Shop, so the actor argument should now correctly populate.
This update massively changes the hook parameters, from a single hook to an array of hooks. It also adds an unused note parameter so you can see what your hook does from a glance at the hook list.
This means you can now have multiple hooks run anywhere a hook could be used previously. This change was made to help alleviate the need to run long hooks in the event you had multiple different things you wanted to code when some action occurred. A simple example: if you want a common event to run on level up and a balloon icon to show over the player's head, you can make those separate hooks that both run on level up rather than putting both of those actions' code in one hook. Hopefully this will make your use of the plugin much easier and more manageable. While the above example is simple, some hooks could be fairly complicated and long and confusing when combined with other complicated and long hook actions.
This version adds some new hooks for [CGMZ] plugins which were missing hooks that I thought you may want to run custom JS code for. This new hooks include:
New Game Plus - Run custom JS code when a new game plus is started through [CGMZ] New Game Plus.
Actor Recruit - Run custom JS code when an actor is recruited through the [CGMZ] Recruitment Board
Skill Level Up - Run custom JS code when a skill levels up. Requires [CGMZ] Skill Levels.
This version adds some new hooks. The new hooks include:
Equip Change - Run custom JS code when an equipment is changed. You have access to the slot that was changed (starting from 0) and the item object that was changed. Please be careful as unequipping will have a null object.
Quest - Run custom JS code when a [CGMZ] Quest System quest is discovered, started, completed, failed, pinned, or unpinned. Each state change has its own hook.
This version adds some new hooks. The new hooks include:
Jukebox - Some hooks were added for the jukebox track discovery as well as a jukebox track play (note that play refers to when the play count increases, which does not only occur when the player plays the track within the jukebox scene).
Gathering - A hook was added that runs on a successful gather. This allows you to run code when a gathering node is harvested.
This version adds some new hooks. The new hooks include:
Battle Escape Fail - Run a hook when the party fails to escape from a battle.
Self Switch Change - Run a hook when a self switch changes value
This version adds some new hooks for CGMZ plugins. These include:
[CGMZ] Picture Gallery - Hooks now exist for discover / undiscover and show / hide.
[CGMZ] Encyclopedia - Hooks now exist for discovering an entry
This version adds hooks for gamepad connect and gamepad disconnected events. These will run when a new gamepad is connected or if a gamepad loses connection. You could use this to pause the game when the controller disconnects, for example.
This version adds hooks for the mouse entering and leaving the game window. I recently added this to my core plugin for additional tracking of mouse behavior, and thought some of you might want to use these listeners too.
This update also fixed a bug that occurred when crafting split between instant and non-instant crafts, as they go through different code flows now. Previously, only instant craft hooks were working. Now, the craft hook will run for both craft types.
This version adds hooks for [CGMZ] Skill Equip, both for equipping a skill and unequipping a skill. These will run even if equip or unequip is not successful, so if necessary you should also check if the operation will be successful.
This update also adds the Player Transfer default MZ hook, which runs when a player transfer is reserved.