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 these new features:

  • “Trigger: Region Entry” plugin command! Use this within any event page to make the event page trigger when a region on the map is entered!
  • Treasure plugin commands! These can be set up to allow easily giving treasures to the player with a consistent message style!

Download Event AI MZ Plugin

How to Install

  1. Download the file, and unzip it.
  2. Make sure the unzipped file is named Tyruswoo_EventAI.js and is saved as a .js file.
  3. Open the file folder of your project. Place the file in your project’s “js” folder, within the “plugins” folder.
  4. 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.
  5. I recommend you place this plugin toward the bottom of your plugin list, so it has high priority.

Example: Treasure Plugin Commands and Treasure Display Common Event

This plugin allows for creating a consistent message style with the use of the Treasure Plugin Commands and a Common Event. The Treasure Plugin Commands are used on events that award treasures such as treasure chests, barrels, pots, or NPCs after the player has completed their quest. The Treasure Plugin Commands determine what the player receives, and then calls the Treasure Display Common Event. The Treasure Display Common Event then runs and displays to the player the treasure that they just found.

We will start by creating a Treasure Display Common Event for displaying treasure that the player finds. Here is an example of a Treasure Display Common Event that does this called “Treasure Display”.

An example of a Treasure Display Common Event for showing the player their loot called "Treasure Display".
An example of a Treasure Display Common Event for showing the player their loot called "Treasure Display".

An example of a Treasure Display Common Event for showing the player their loot called “Treasure Display”. A more detailed breakdown is below.

If : Script: '!Chest' == Tyruswoo.EventAI.sprite.name
  Play SE: Chest1 (70, 110, 0)
:Else
  Play SE: Item3 (70, 100, 0)
:End

The Display Treasure Common Event starts out with an if/else statement to check if the event using EventAI is using an image from the !Chest sprite sheet. If the event uses the !Chest sprite sheet then the Chest1 sound effect will play. Otherwise, the Item3 sound effect will play.

This check is done with the Tyruswoo.EventAI.sprite.name script call. 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 that players find!

Set Movement Route: This Event (Wait)
  Direction Fix OFF
  Turn Left
  Wait: 3 Frames
  Turn Right
  Wait: 3 Frames

This 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.

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 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 they found with 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 main reason they wouldn’t be is if their inventory is full). If they 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 Common Event may take a bit of set up but it helps with consistent message style for 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 Display Treasure Common Event and then all of the treasures in the game would be effected. No need for me to update each and every one!

Please Note: The Common Event should not include anything within it that actually gives the player treasure. Giving the player treasures is handled through Treasure Plugin Commands on the events that are award the player treasure.

Don't forget to assign the Display Treasure Common Event in the Tyruswoo_EventAI Plugin Settings under Parameters! In this example, the Common Event for displaying treasure happens to be the first one in the database.

Don’t forget to assign the Display Treasure Common Event in the Tyruswoo_EventAI Plugin Settings under Parameters! In this example, the Common Event for displaying treasure happens to be the first one in the database.

Now that the Treasure Display Common Event is ready, let’s move onto the Treasure Plugin Commands. Below is an example of a simple treasure chest event using Treasure Plugin Commands.

Page 1 shows the closed treasure chest. The plugin command Tyruswoo_EventAI, Teasure: Item is used to award the player the chosen item (ID 30; Luck Increase in the database) and to run the Display Treasure Common Event that we previously created. The common event shows the player what they found and then turns on Self Switch A.
Page 2 is the event when Self Switch A is on; simply an open chest and nothing else.

Page 1 shows the closed treasure chest. The plugin command Tyruswoo_EventAI, Teasure: Item is used to award the player the chosen item (ID 30; Luck Increase in the database) and to run the Display Treasure Common Event that we previously created. The common event shows the player what they found and then turns on Self Switch A. Page 2 is the event when Self Switch A is on; simply an open chest and nothing else.

This is what the event looks like in action! What a lucky girl Priscilla is!

This is what the event looks like in action! What a lucky girl Priscilla is!

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
Share this blog post!
Lawenia
Lawenia

Website Editor and Lead Playtester for the Tyruswoo Team. Fan of Japanese language, culture, food, and RPGs!

Articles: 12

Leave a Reply