Modcraft - The community dedicated to quality WoW modding!

Wrath of the Lich King Modding => Serverside Modding => Tutorials => Topic started by: Valkryst on September 02, 2014, 10:50:05 pm

Title: [Trinity - SAI] How to Use Game Events with SAI
Post by: Valkryst 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 (http://www.trinitycore.org/f/files/file/17-sai-editor/); this is the SAI editor which I've found to work best.

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

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

Creating the Event:

Assuming that you've opened up whichever program you prefer to use when editing your database (http://www.heidisql.com/), 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.

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 (http://www.trinitycore.org/f/topic/1210-sai-scripting-questions/) on the official Trinity forums. I also suggest that you always use this page (http://collab.kpsn.org/display/tc/smart_scripts) 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 (http://valkryst.com/blog/).