Sign in to follow this  

How to Use Game Events with SAI

Before I start typing out this guide, I will admit that I’m no expert on SAI and that some of this information may be incorrect. If you know of any additional information, notice an error, etc.. just comment and I’ll do my best to keep this post updated. In this tutorial I will assume that you know enough to be able to insert a new record(row) into a database table and how to edit that row. If anything seems unclear or incorrect, just post below and I’ll look into it.

There are a few things that you’ll need before creating and editing your smart scripts. I’ve seen a handful of different programs for editing smart scripts, but only one of them seems to be updated and does everything that I require. So, before you continue reading, please download this; this is the SAI editor which I’ve found to work best.

Just in case anyone wants to know what I’m running:

  • Windows 8, x64 — Home
  • Debian 7, x64 — Server
  • TrinityCore — Latest version as of 20/June/2015
  • WoTLK 3.3.5a

Creating the Event: Assuming that you’ve opened up whichever program you prefer to use when editing your database, open the game_events table of the world database and insert a new record. When filling out the record you can refer to the bullet points below for a brief description of each of the fields. When filling out the start_time and end_time you can’t use zero for the month or day, it needs to be at least the first day of the first month.

  • entry – A unique ID for the record.
  • start_time – The date and time when the event will first run. The event will always run continuously from start_time to end_time.
  • end_time – The date and time when the event will stop running. The event will never run after this date/time is reached.
  • occurrence – How often the event will occur, in minutes. If this is set to, for example, 6 then the event will run every 6 minutes.
  • length – How long the event will run for, in minutes. As far as I know, this doesn’t really matter for SAI so set this to 1.
  • holiday – The ID of a Holiday from the Holiday.dbc file. This is sent to the client to update the in-game calendar. As far as I know, this doesn’t really matter for SAI so set this to 0.
  • description – A description of the event.
  • world_event – I’m not entirely sure how this is used, but it doesn’t matter for SAI as far as my tests have shown. Set this to 0.

Example of a completed record:

Creating the Script: After creating the record in game_event you’ll need to open up the SAI-Editor to create the SAI script. Before we continue I’ll mention my preferred settings:

Valkryst’s SAI-Editor Preferences:

  • Lock — CHECKED
  • List actionlists too — CHECKED
  • Use phase colors — CHECKED
  • Show basic information — CHECKED
  • Allow changing static info — UN-CHECKED
  • Use permanent tooltips — CHECKED

Now that you have successfully created a record in the game_event table for the event, you’re ready to setup a script that runs off of the event. You’ll first need to open SAI-Editor and, in the field labeled Entry or guid:, type the entry ID of whichever NPC you want to test and then press ENTER. An error box should pop-up, but you only need to click OK. Now click the New line button, set the Event drop-down menu to EVENT_GAME_EVENT_START, set the Action drop-down menu to ACTION_PLAY_EMOTE, and set the Target drop-down menu to TARGET_SELF. On the right-hand side of the screen you’ll see a section three tabs which we will now fill-out. In the Event tab set the Event field to whatever the entry of your event is and in the Action tab set the Emote Id field to 11 so that the NPC will play the laugh emote when the event occurs. Now click the Generate comments button and then the Generate SQL button and then execute the script. Anytime you create a script you’ll need to restart worldserver before you can go in-game and test the script. If you’re updating an existing script then you can use the .reload smart_scripts command, but I personally restart no-matter what just to be on the safe side. After worldserver is restarted you’ll need to go in-game, spawn the NPC you’re testing, and type .event start eventID. If you’ve done everything correctly, then the NPC should laugh after you run the command.

Before I end this tutorial I feel it best to mention that any complex questions you have should be asked in this thread on the official Trinity forums. I also suggest that you always use this page as a reference when creating any and all of your SAI scripts.

Recommended Comments

The links in the tutorial above may be out of date. If they are, then you can most-likely find an up-to-date link to the blog here.

Share this comment

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now