<h1>[GUIDE] Introduction to Database content for SD2</h1>
</div>
<divid="content">
<divid="preamble">
<divclass="sectionbody">
<divclass="paragraph"><p>This guide is intended to help people</p></div>
<divclass="ulist"><ul>
<li>
<p>
to understand which information of the database is used with SD2
</p>
</li>
<li>
<p>
who want to contribute their patches as complete as possible
</p>
</li>
</ul></div>
<divclass="paragraph"><p>All sql-related files are located in the ScriptDev2/sql and subsequent directories.</p></div>
</div>
</div>
<divclass="sect1">
<h2id="_sql_files">1. SQL-Files</h2>
<divclass="sectionbody">
<divclass="sect2">
<h3id="_files_that_contain_full_sd2_database_content">1.1. Files that contain full SD2-Database content</h3>
<divclass="paragraph"><p>For a script we usually have to take care of these files:</p></div>
<divclass="ulist"><ul>
<li>
<p>
mangos_scriptname_full.sql
</p>
<divclass="paragraph"><p>This file is applied to the world database (default: mangos), and contains the ScriptNames</p></div>
</li>
<li>
<p>
scriptdev2_script_full.sql
</p>
<divclass="paragraph"><p>This file is applied to the sd2 database (default: scriptdev2), and contains texts, gossip-items and waypoints</p></div>
</li>
</ul></div>
</div>
<divclass="sect2">
<h3id="_patchfiles_for_incremental_updates">1.2. Patchfiles for incremental Updates</h3>
<divclass="paragraph"><p>Patches for the databases are stored in the files:</p></div>
<divclass="ulist"><ul>
<li>
<p>
Updates/rXXXX_mangos.sql
</p>
<divclass="paragraph"><p>This file contains the changes that should be done with the patch to the world-databse</p></div>
</li>
<li>
<p>
Updates/rXXXX_scriptdev2.sql
</p>
<divclass="paragraph"><p>This file contains the changes that should be done with the patch to the scriptdev2-database</p></div>
</li>
</ul></div>
</div>
</div>
</div>
<divclass="sect1">
<h2id="_world_database">2. World-Database</h2>
<divclass="sectionbody">
<divclass="sect2">
<h3id="_scriptnames_of_npcs">2.1. ScriptNames of NPCs:</h3>
<divclass="paragraph"><p>If we need to assign a ScriptName to a NPC (GameObject-Scripts are similar) the statement is:</p></div>
<divclass="listingblock">
<divclass="content">
<pre><tt>UPDATE creature_template SET ScriptName='npc_and_his_name' WHERE entry=XYZ;</tt></pre>
</div></div>
<divclass="paragraph"><p>or</p></div>
<divclass="listingblock">
<divclass="content">
<pre><tt>UPDATE creature_template SET ScriptName='npc_something_identifying' WHERE entry IN (XYZ, ZYX);</tt></pre>
</div></div>
<divclass="paragraph"><p><em>Remark:</em> For creatures with many difficulty entries, only the one for normal difficulty needs the ScriptName.</p></div>
</div>
<divclass="sect2">
<h3id="_scriptnames_for_scripted_areatrigger">2.2. ScriptNames for scripted_areatrigger:</h3>
<divclass="paragraph"><p>For Areatriggers (or scripted_event_id) we usally cannot use UPDATE, hence we need to DELETE possible old entries first:</p></div>
<divclass="listingblock">
<divclass="content">
<pre><tt>DELETE FROM scripted_areatrigger WHERE entry=XYZ;
INSERT INTO scripted_areatrigger VALUES (XYZ, at_some_place);</tt></pre>
<divclass="paragraph"><p>so our first text entry will be -1000590.</p></div>
</div>
<divclass="sect3">
<h4id="_example_gossip_item_in_instance">3.1.2. Example: Gossip-Item in Instance</h4>
<divclass="paragraph"><p>Let’s say we want to add a new gossip item to a NPC in Culling of Stratholme, this map has the ID 595.
At this moment there is already some gossip_text, and the last one is</p></div>
<divclass="listingblock">
<divclass="content">
<pre><tt>(-3595005,'So how does the Infinite Dragonflight plan to interfere?','chromie GOSSIP_ITEM_INN_3');</tt></pre>
</div></div>
<divclass="paragraph"><p>so our first gossip-text entry will be -3595006.</p></div>
</div>
</div>
<divclass="sect2">
<h3id="_format_for_texts">3.2. Format for texts</h3>
<divclass="paragraph"><p>The format is <tt>(entry,content_default,sound,type,language,emote,comment)</tt> with these meanings:</p></div>
<divclass="dlist"><dl>
<dtclass="hdlist1">
entry
</dt>
<dd>
<p>
should now be clear ;)
</p>
</dd>
<dtclass="hdlist1">
content_default
</dt>
<dd>
<p>
is the text (in english) enclosed with '.<br/>
There are a few placeholders that can be used:
<br/>
</p>
<divclass="hdlist"><table>
<tr>
<tdclass="hdlist1">
%s
<br/>
</td>
<tdclass="hdlist2">
<pstyle="margin-top: 0;">
self, is the name of the Unit saying the text<br/>
The $-placeholders work only if you use DoScriptText with a <em>target</em>.
</p>
</td>
</tr>
<tr>
<tdclass="hdlist1">
$N, $n
<br/>
</td>
<tdclass="hdlist2">
<pstyle="margin-top: 0;">
the [N, n]ame of the target
</p>
</td>
</tr>
<tr>
<tdclass="hdlist1">
$C, $c
<br/>
</td>
<tdclass="hdlist2">
<pstyle="margin-top: 0;">
the [C, c]lass of the target
</p>
</td>
</tr>
<tr>
<tdclass="hdlist1">
$R, $r
<br/>
</td>
<tdclass="hdlist2">
<pstyle="margin-top: 0;">
the [R, r]ace of the target
</p>
</td>
</tr>
<tr>
<tdclass="hdlist1">
$GA:B;
<br/>
</td>
<tdclass="hdlist2">
<pstyle="margin-top: 0;">
if the target is male then A else B is displayed, Example:
</p>
<divclass="listingblock">
<divclass="content">
<pre><tt>'Time to teach you a lesson in manners, little $Gboy:girl;!'</tt></pre>
</div></div>
<divclass="paragraph"><p>Remember to escape <spanclass="red">'</span> with <spanclass="red">\'</span>, Example:</p></div>
<divclass="listingblock">
<divclass="content">
<pre><tt>'That \'s my favourite chocolate bar'.</tt></pre>
</div></div>
</td>
</tr>
</table></div>
</dd>
<dtclass="hdlist1">
sound
</dt>
<dd>
<p>
is the sound ID that shall be played on saying, they are stored in SoundEntries.dbc
</p>
<divclass="quoteblock">
<divclass="content">
<divclass="paragraph"><p>Sound Ids are stored within the SoundEntries.dbc file. Within that dbc file you will find a reference to the actual file that is played. We cannot help you with reading these files so please do not ask how.</p></div>
</div>
<divclass="attribution">
— Ntsc
</div></div>
</dd>
<dtclass="hdlist1">
type
</dt>
<dd>
<p>
is the type of the text, there are these possibilities:
</p>
<divclass="listingblock">
<divclass="content">
<pre><tt>0 CHAT_TYPE_SAY - 'white' text
1 CHAT_TYPE_YELL - 'red' text
2 CHAT_TYPE_TEXT_EMOTE - 'yellow' emote-text (no <Name>... )
3 CHAT_TYPE_BOSS_EMOTE - 'big yellow' emote-text displayed in the center of the screen
4 CHAT_TYPE_WHISPER - whisper, needs a target
5 CHAT_TYPE_BOSS_WHISPER - whipser, needs a target
6 CHAT_TYPE_ZONE_YELL - 'red' text, displayed to everyone in the zone</tt></pre>
</div></div>
</dd>
<dtclass="hdlist1">
language
</dt>
<dd>
<p>
is the language of the text (like LANG_GNOMISH), see <tt>enum Language</tt> in <tt>game/SharedDefines.h</tt> — usually zero (LANG_UNIVERSAL)