Event AI Plugin v1.0.1 for RPG Maker MZ

Greetings RPG Makers!
I’m pleased to introduce you to the Event AI plugin for RPG Maker MZ that was created by Tyruswoo! This plugin includes features to make events more powerful and versatile, and more features are to come in later updates!
In this post, we will cover the following topics:
Overview of Features of the Event AI Plugin for RPG Maker MZ
This version of the plugin includes these new features:
- “Trigger: Region Entry” plugin command! Use this within any event page to make the event page trigger when the player enters a region on the map!
- Treasure plugin commands! These can be set up to allow easily giving treasures to the player with a consistent message style!
Future versions of this plugin are planned, and will give events more abilities to interact with the player and with other events!
How to Install the Event AI Plugin for MZ
- Download the file, and unzip it.
- Make sure the unzipped file is named Tyruswoo_EventAI.js and is saved as a .js file.
- Open the file folder of your project. Place the file in your project’s “js” folder, within the “plugins” folder.
- Open your project in RPG Maker MZ, then go to the Tools menu and select Plugin Manager. Use the Plugin Manager to add and activate the plugin.
- I recommend you place this plugin toward the bottom of your plugin list, so it has high priority.
Treasure Eventing: Quick Events vs Treasure Plugin Commands
In RPG Maker, should we use treasure quick events, or make our own custom treasure events? Treasure quick events are simple and useful, but if you want custom treasure events, use the treasure plugin commands of the Tyruswoo Event AI plugin.
In default RPG Maker, treasure chests can be easily created using treasure Quick Events.
Such treasure events are simple and work well, but if you want to customize the treasure events for your own game, you may find yourself modifying every single treasure in your project.
Modifying each treasure chest can take a long time and makes accidental eventing errors more likely. Instead, we can simplify the eventing of each treasure event by using a treasure common event and treasure plugin commands, using the Event AI plugin for RPG Maker MZ.
If you only rarely modify treasure quick events, then you don’t need treasure plugin commands. However, if you find yourself modifying treasure quick events or creating your own treasure events from scratch, then Event AI MZ’s treasure plugin commands will help you streamline your treasure events so they are easier to create and less likely to have eventing bugs!
How to Create Treasure Events with the Event AI MZ Plugin
First we will set up the Treasure Display common event, which is the most difficult part. Then, we will show how treasure plugin commands make each treasure event simple to set up.
Create the Treasure Display Common Event
For the treasure display common event to work, we must add a Treasure Display common event and define it in the Event AI MZ plugin parameters.
Write the Treasure Display Common Event’s Commands
In the Tools menu, select Database, then the Common Events tab. Here we select a common event, and give the common event a title.
In this case, we will title the common event “Treasure Display”. We then set up event commands for the common event, so that treasure is displayed to the player.
Though there are various ways to set up the Treasure Display common event, we will cover an example in detail, showing some of the possibilities.


Play a Sound Effect, with Optional Condition of Sprite Name
If : Script: '!Chest' == Tyruswoo.EventAI.sprite.name
Play SE: Chest1 (70, 110, 0)
:Else
Play SE: Item3 (70, 100, 0)
:EndWe can play a sound effect using the Play SE event command.
Optionally, you can use a conditional branch and script call to check Tyruswoo.EventAI.sprite.name. This checks the name of the sprite, so you can adjust your sound effect accordingly.
Other script calls can be found in the Help Documentation (included with the plugin and at the bottom of this post). By using script calls you can have one common event work for a variety of different treasure events!
Show an Animation
Set Movement Route: This Event (Wait)
Direction Fix OFF
Turn Left
Wait: 3 Frames
Turn Right
Wait: 3 FramesThis Set Movement Route: This Event (Wait) is copied and pasted from Quick Event Creation: Treasure. This gives chests a small amount of animation when opening instead of just instantly opening.
Note that animations can also be optional. If you want some treasure events to show an animation, and others to not show an animation, you can again use a conditional branch with a script check such as for Tyruswoo.EventAI.sprite.name.
Display a Message, and Set Self Switch to On (If Treasure Added to Inventory)
If: Script: 'gold' == Tyruswoo.EventAI.treasure.type
Text: None, None, Window, Bottom
\P[1] found <TreasureAmount>\G!
Control Self Switch: A = ON
:Else
If: Script: Tyruswoo.EventAI.treasure.success
Text: None, None, Window, Bottom
\P[1] found <TreasureIcon><TreasureName>!
Control Self Switch: A = ON
:Else
Text: None, None, Window, Bottom
\P[1] found <TreasureIcon><TreasureName>, but had not space
so <TreasureIcon><TreasureName> was left behind.
:End
:End
The next section of the Display Treasure Common Event is nested if/then statements that display different messages depending on the treasure found.
- First, Script: ‘gold’ == Tyruswoo.EventAI.treasure.type is used to see if the player found the gold treasure type. (The other three treasure types are “item”, “weapon”, and “armor”.) If the player found gold, then a message is displayed showing how much gold he or she found, using the <TreasureAmount> text code. Self Switch A is also set to ON so that the treasure cannot be acquired again.
- Second, if gold is not found then Script: Tyruswoo.EventAI.treasure.success is used to see if the player was successful in getting the treasure. (The reason the player wouldn’t be able to pick up the treasure is if the player’s inventory is full). If the player successfully got the treasure, then a message is displayed with the treasure’s icon and name using the <TreasureIcon> and <TreasureName> text codes. Self Switch A is also set to ON so that the treasure cannot be acquired again.
- Finally, if the treasure is not gold and it cannot be obtained, then a message will display telling what the treasure is using the <TreasureIcon> and <TreasureName> text codes but that it was left behind due to lack of space. The Self Switch A is not used, so the player could return a later time and try again to get the treasure.
The Treasure Display common event may take a bit of set up but it helps with consistent eventing when the player finds treasure!
A big bonus is that if you ever decide to change the style of the treasure messages then you only need to update the common event instead of updating each individual treasure event. For example, if I decided that “discovered” is a more exciting verb than “found,” then I could simply update the Treasure Display common event. All treasures in the game would be affected. No need for me to update each and every one!
Please Note: The Treasure Display common event should not include anything within it that actually gives the player treasure. Giving the player treasure is handled by the treasure plugin commands on the events that award the player treasure.
Set the Treasure Display Common Event in the Plugin Parameters
For a treasure plugin command to activate our Treasure Display common event, we must tell the Event AI MZ plugin which common event to activate. This is done in the Event AI MZ plugin parameters.
To assign the Treasure Display Common Event:
- Go to the Tools menu, select Plugin Manager, then the Tyruswoo_EventAI plugin. This opens the plugin parameters.
- Now, select the “Treasure Display Common Event” plugin parameter, and choose the Treasure Display common event you created.

When Placing Treasures, Use the Treasure Plugin Commands
Using treasure plugin commands, each treasure event is easy to create. This is where our hard work pays off!
Treasure events could be treasure chests, barrels, pots, or non-player characters (NPCs). Below is an example of a treasure chest event using treasure plugin commands.



Help Documentation
Tyruswoo Event AI for RPG Maker MZ
Overview: This plugin helps your events do more, with fewer commands.
* Place a Trigger: Region Entry command in your event, and stepping anywhere
into a region of your choice will trigger it.
* Define your Treasure Display Common Event, and you can easily set up
treasure containers your way anywhere in the game with a treasure plugin
command.
============================================================================
Basics of how to use this plugin:
How to Set Up a Region Entry Event on a Map
--------------------------------------------
1. Make a new event anywhere on the map. Its location doesn't
matter, as long as it's on the same map as the region it affects.
2. At the top of the event page's command list, create a plugin command:
Tyruswoo_EventAI > Trigger: Region Entry
Set the plugin command's Region ID argument to the region of your choice.
3. Switch to tile editing mode and paint the region you've chosen wherever
you want the event to occur when the player steps in.
The Region Entry Event will now run whenever the party leader steps
from a tile outside the region, to a tile inside the region,
provided that the event page's other conditions are also met.
How to Set Up a Region Entry Common Event
------------------------------------------
1. Set up a common event doing what should happen on region entry.
2. Its first command must be the plugin command Tyruswoo_EventAI >
Trigger: Region Entry, with the Region ID argument set to a region
number of your choice.
3. Paint that region number on any maps in your game, and the common event
will run whenever the party leader steps into that region.
How to Set Up Your Game for the Treasure Plugin Command
--------------------------------------------------------
1. Open the database and set up a Treasure Display Common Event.
Copy in movement, sound, & self switch setting from a treasure
chest made with Quick Event Creation, or customize display behavior
however you wish. (DO NOT give the item or gold here; the plugin command
handles that beforehand!)
2. You'll probably want the Treasure Display Common Event to tell the player
what the party has received. The text codes <TreasureName>,
<TreasureAmount>, and <TreasureIcon> can help with this.
Treasure script snippets can help you set conditions for different
eventing based on treasure type, quantity, etc. Refer to the Text Codes
and Script Calls sections below for specifics.
3. Once your Treasure Display Common Event is ready, open Tyruswoo_EventAI
in the Plugin Manager, edit the plugin parameter Treasure Display Common
Event, and pick from the list of common events.
Now the Treasure plugin commands will run the common event you made.
How to Use Treasure Plugin Commands
------------------------------------
1. Create a new event. Set its appearance to whatever holds the treasure,
as it looks before the player gets the treasure.
2. Add a plugin command to the event. Pick Tyruswoo_EventAI plugin, and one
of the Treasure plugin commands. Set the treasure item or amount
using the plugin command's arguments. That's all you need in the list!
3. To make the treasure obtainable only once, add a new page to the treasure
event. This page's condition should be the same self switch the Treasure
Display Common Event turns on. Set this page's appearance to what you
want the player to see when the treasure has already been taken. Since
this second page doesn't give treasure, it needs no treasure plugin
command.
4. This treasure event is now ready to run. Making more treasure events
like this one will be even easier; copy-paste them, open each copy, and
change its treasure plugin command to give whatever treasure you want,
wherever you place the event.
============================================================================
Plugin parameters:
Treasure Display Common Event
This is the common event that an event will call when it runs any treasure
plugin command, _after_ the party receives the treasure. (Do not use this
common event to give treasure; the plugin command has already done that!)
The Treasure Display Common Event can show the treasure chest opening,
play a sound, show text telling what item the party received, set
a self switch to ensure that the treasure can be opened only once, and
anything else you write into it.
============================================================================
Trigger Plugin Commands:
Trigger plugin commands are placed at the beginning of the command list of
any event page that should have their custom trigger.
A custom trigger overrides its page's RMMZ-defined trigger
(e.g. Action Button, Player Touch, ...)
As with pages with standard RMMZ triggers, a page with a custom trigger
runs only if the page's conditions (switch, variable, etc.) are met.
Trigger: Region Entry
Put this plugin command at the top of the command list of any event page
that should run when the player steps into a given region, specified in the
plugin command's Region ID argument. The page so marked will run only when
the player steps into the region from another region. It will not run when
the player starts the game in the region, nor when the player is placed in
the region by a transfer command.
The region entry event itself can be placed anywhere on the map.
============================================================================
Treasure plugin commands:
Every treasure plugin command first gives the indicated treasure to the
party, and then calls the Treasure Display Common Event.
Treasure: Item
Give a non-equippable item (regular item or key item) as treasure.
Treasure: Weapon
Give a weapon as treasure.
Treasure: Armor
Give an armor as treasure.
Treasure: Gold
Give some amount of the game's currency as treasure.
============================================================================
Treasure text codes:
Use these in text commands to show information about the loot given by the
most recent treasure plugin command. They're designed for your convenicence
in writing your Treasure Display Common Event.
------------------+---------------------------------------------------------
Text code | Description
------------------+---------------------------------------------------------
<TreasureName> | The name of the item, weapon, or armor most recently
| given. If gold, the name is the currency term.
|
<TreasureIcon> | The icon, if any, corresponding to the treasure most
| given.
|
<TreasureAmount> | How many items, or how much gold, came from the most
| recent treasure.
------------------+---------------------------------------------------------
Example sentence using our text codes (plus an RMMZ text code):
\P[1] found <TreasureIcon><TreasureName> x<TreasureAmount>!
============================================================================
Script calls:
The following script phrases may be useful when checking for conditions
or doing other custom processing during eventing.
------------------------------------+--------------------------------------
Attribute | Description
------------------------------------+--------------------------------------
Tyruswoo.EventAI.sprite.name | The name (without extension) of the
| active event's sprite file.
| This is readable/writable.
|
Tyruswoo.EventAI.sprite.index | The index giving the position of the
| active event's sprite in its file.
| This is readable/writable.
|
Tyruswoo.EventAI.sprite.tileId | The ID of the tile used for this
| event's image, if a tile is used.
| This is readable/writable.
|
Tyruswoo.EventAI.treasure.amount | How much gold came from the latest
| treasure. If an item, amount is 1.
|
Tyruswoo.EventAI.treasure.data | The treasure's full database entry.
|
Tyruswoo.EventAI.treasure.iconIndex | The index of the treasure's icon
|
Tyruswoo.EventAI.treasure.id | The database index of this item,
| weapon, or armor.
|
Tyruswoo.EventAI.treasure.name | Name of this item, weapon, or armor.
| If gold, name is the currency term.
|
Tyruswoo.EventAI.treasure.success | Boolean value. True if the treasure
| was given. False if it couldn't be
| given, such as when the party's
| inventory can't fit that item.
|
Tyruswoo.EventAI.treasure.type | 'item', 'weapon', 'armor', or 'gold'
------------------------------------+--------------------------------------
Tyruswoo.EventAI.sprite refers to the image of the event that's currently
running. It can be used for a variety of purposes, including treasure
container style checking.
Tyruswoo.EventAI.treasure and its attributes refer to the most recent
treasure given by a Tyruswoo.EventAI treasure plugin command. The Treasure
Display Common Event, or other events if needed, can reference it.
Examples below.
The following script condition checks if treasure was gold:
'gold' == Tyruswoo.EventAI.treasure.type
This script condition checks if more than 100 gold were given:
Tyruswoo.EventAI.treasure.amount > 100
This condition is met if the item could NOT be given:
false == Tyruswoo.EventAI.success
This condition is met if the event's image file is !Barrel.png:
'!Barrel' == Tyruswoo.EventAI.sprite.name
============================================================================
For more help using the Event AI plugin, see Tyruswoo.com.
============================================================================
Version History:
v1.0 Nov. 5, 2021
- Event AI released for RPG Maker MZ!
- Region Entry events and common events
- Treasure plugin command calls your treasure common event
============================================================================
Terms of Use:
1. You joined Tyruswoo.com as a paying member when you downloaded this
plugin. You do not have to remain a paying member to use the plugin
you downloaded. However, your support is greatly appreciated, and allows
us to continue improving and updating plugins.
2. You agree to not redistribute this plugin. You agree to direct others to
Tyruswoo.com if they want the plugin.
3. You may use this for any game for which you are one of the main
developers. This includes any commercial or non-commercial game you are
creating.
4. Adding "Tyruswoo and McKathlin", "Tyruswoo Studio", or "Tyruswoo Team" to
your game's credits is greatly appreciated, but not required.
5. Likewise, listing which Tyruswoo Team plugins you used is appreciated,
but not required.
6. A free copy of your game is awesome, but not required.
============================================================================
Remember, only you can build your dreams!
-Tyruswoo