This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [Trinity - SAI] How to Use Game Events with SAI  (Read 2786 times)

Valkryst

  • Moderators
  • Model Change Addict
  • *****
  • Posts: 224
    • View Profile
    • http://valkryst.com/blog/
[Trinity - SAI] How to Use Game Events with SAI
« on: September 02, 2014, 10:50:05 pm »
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 x32 — Server
       
  • TrinityCore — Latest version as of 18/August/2014
       
  • 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:
Code: [Select]
INSERT INTO `game_event` VALUES (1, '2014-01-01 00:00:00', '2020-01-01 00:00:00', 2, 1, 0, 'Pastor Moore - Speech', 0, 0);
-----------------------------------------------------------------------------------------------

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:
Quote
Valkryst's SAI-Editor Preferences:
  • Lock smart_scripts.id -- 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 Eventtab 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 worldserverbefore 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.

-----------------------------------------------------------------------------------------------

If you want to stay up-to-date with my latest tutorials or if you just want an easier way to view all of my tutorials and releases in one place then take a look at my blog.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
MY BLOG IS NOW HERE.