Skip to content

Commit 129c31c

Browse files
author
NoFantasy
committed
[826] Added: option to define emote to play with any text from database text tables.
Added: option to define emote to play with any text from database text tables. git-svn-id: https://scriptdev2.svn.sourceforge.net/svnroot/scriptdev2@826 5f9c896b-1e26-0410-94da-f77f675e2462
1 parent ba6118d commit 129c31c

5 files changed

Lines changed: 37 additions & 15 deletions

File tree

ScriptMgr.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct StringTextData
2424
uint32 SoundId;
2525
uint8 Type;
2626
uint32 Language;
27+
uint32 Emote;
2728
};
2829

2930
// Enums used by StringTextData::Type
@@ -626,7 +627,7 @@ void LoadDatabase()
626627
LoadMangosStrings(SD2Database,"eventai_texts",-1,1+(TEXT_SOURCE_RANGE));
627628

628629
// Gather Additional data from EventAI Texts
629-
result = SD2Database.PQuery("SELECT entry, sound, type, language FROM eventai_texts");
630+
result = SD2Database.PQuery("SELECT entry, sound, type, language, emote FROM eventai_texts");
630631

631632
outstring_log("SD2: Loading EventAI Texts additional data...");
632633
if (result)
@@ -644,6 +645,7 @@ void LoadDatabase()
644645
temp.SoundId = fields[1].GetInt32();
645646
temp.Type = fields[2].GetInt32();
646647
temp.Language = fields[3].GetInt32();
648+
temp.Emote = fields[4].GetInt32();
647649

648650
if (i >= 0)
649651
{
@@ -690,7 +692,7 @@ void LoadDatabase()
690692
LoadMangosStrings(SD2Database,"script_texts",TEXT_SOURCE_RANGE,1+(TEXT_SOURCE_RANGE*2));
691693

692694
// Gather Additional data from Script Texts
693-
result = SD2Database.PQuery("SELECT entry, sound, type, language FROM script_texts");
695+
result = SD2Database.PQuery("SELECT entry, sound, type, language, emote FROM script_texts");
694696

695697
outstring_log("SD2: Loading Script Texts additional data...");
696698
if (result)
@@ -708,6 +710,7 @@ void LoadDatabase()
708710
temp.SoundId = fields[1].GetInt32();
709711
temp.Type = fields[2].GetInt32();
710712
temp.Language = fields[3].GetInt32();
713+
temp.Emote = fields[4].GetInt32();
711714

712715
if (i >= 0)
713716
{
@@ -754,7 +757,7 @@ void LoadDatabase()
754757
LoadMangosStrings(SD2Database,"custom_texts",TEXT_SOURCE_RANGE*2,1+(TEXT_SOURCE_RANGE*3));
755758

756759
// Gather Additional data from Custom Texts
757-
result = SD2Database.PQuery("SELECT entry, sound, type, language FROM custom_texts");
760+
result = SD2Database.PQuery("SELECT entry, sound, type, language, emote FROM custom_texts");
758761

759762
outstring_log("SD2: Loading Custom Texts additional data...");
760763
if (result)
@@ -772,6 +775,7 @@ void LoadDatabase()
772775
temp.SoundId = fields[1].GetInt32();
773776
temp.Type = fields[2].GetInt32();
774777
temp.Language = fields[3].GetInt32();
778+
temp.Emote = fields[4].GetInt32();
775779

776780
if (i >= 0)
777781
{
@@ -1796,11 +1800,11 @@ void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target)
17961800
return;
17971801
}
17981802

1799-
debug_log("SD2: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u",textEntry,(*i).second.SoundId,(*i).second.Type,(*i).second.Language);
1803+
debug_log("SD2: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",textEntry,(*i).second.SoundId,(*i).second.Type,(*i).second.Language,(*i).second.Emote);
18001804

18011805
if((*i).second.SoundId)
18021806
{
1803-
if( GetSoundEntriesStore()->LookupEntry((*i).second.SoundId) )
1807+
if (GetSoundEntriesStore()->LookupEntry((*i).second.SoundId))
18041808
{
18051809
WorldPacket data(4);
18061810
data.SetOpcode(SMSG_PLAY_SOUND);
@@ -1811,6 +1815,16 @@ void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target)
18111815
error_log("SD2: DoScriptText entry %i tried to process invalid sound id %u.",textEntry,(*i).second.SoundId);
18121816
}
18131817

1818+
if((*i).second.Emote)
1819+
{
1820+
if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER)
1821+
{
1822+
((Unit*)pSource)->HandleEmoteCommand((*i).second.Emote);
1823+
}
1824+
else
1825+
error_log("SD2: DoScriptText entry %i tried to process emote for invalid TypeId (%u).",textEntry,pSource->GetTypeId());
1826+
}
1827+
18141828
switch((*i).second.Type)
18151829
{
18161830
case CHAT_TYPE_SAY:

docs/Text-tables.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ content_loc8 This is the actual text presented in the Localization #8 C
3737
sound This value is the Sound ID that corresponds to the actual text used (Defined in SoundEntries.dbc).
3838
type Variables used to define type of text (Say/Yell/Textemote/Whisper).
3939
language This value is the Language that the text is native in (Defined in Languages.dbc).
40+
emote Value from enum Emote (defined in Emotes.dbc). Only source of text will play this emote (not target, if target are defined in DoScriptText)
4041
comment This is a comment regarding the text entry (For ACID, accepted format is to use Creature ID of NPC using it).
4142

4243
Note: Fields `content_loc1` to `content_loc8` are NULL values by default and are handled by seperate localization projects.

sql/Updates/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ pkgdata_DATA = \
3232
r823_scriptdev2_script_texts.sql \
3333
r824_mangos.sql \
3434
r824_scriptdev2_script_texts.sql \
35-
r825_scriptdev2_script_texts.sql
35+
r825_scriptdev2_script_texts.sql \
36+
r826_scriptdev2.sql

sql/Updates/r826_scriptdev2.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE custom_texts ADD COLUMN emote tinyint(3) UNSIGNED DEFAULT '0' NOT NULL AFTER language;
2+
ALTER TABLE eventai_texts ADD COLUMN emote tinyint(3) UNSIGNED DEFAULT '0' NOT NULL AFTER language;
3+
ALTER TABLE script_texts ADD COLUMN emote tinyint(3) UNSIGNED DEFAULT '0' NOT NULL AFTER language;

sql/scriptdev2_structure.sql

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ CREATE TABLE `custom_texts` (
1010
`content_loc6` text,
1111
`content_loc7` text,
1212
`content_loc8` text,
13-
`sound` mediumint(8) unsigned NOT NULL default '0',
14-
`type` tinyint unsigned NOT NULL default '0',
15-
`language` tinyint unsigned NOT NULL default '0',
13+
`sound` mediumint(8) unsigned NOT NULL DEFAULT '0',
14+
`type` tinyint(3) unsigned NOT NULL DEFAULT '0',
15+
`language` tinyint(3) unsigned NOT NULL DEFAULT '0',
16+
`emote` tinyint(3) unsigned NOT NULL DEFAULT '0',
1617
`comment` text,
1718
PRIMARY KEY (`entry`)
1819
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Custom Texts';
@@ -69,9 +70,10 @@ CREATE TABLE `eventai_texts` (
6970
`content_loc6` text,
7071
`content_loc7` text,
7172
`content_loc8` text,
72-
`sound` mediumint(8) unsigned NOT NULL default '0',
73-
`type` tinyint unsigned NOT NULL default '0',
74-
`language` tinyint unsigned NOT NULL default '0',
73+
`sound` mediumint(8) unsigned NOT NULL DEFAULT '0',
74+
`type` tinyint(3) unsigned NOT NULL DEFAULT '0',
75+
`language` tinyint(3) unsigned NOT NULL DEFAULT '0',
76+
`emote` tinyint(3) unsigned NOT NULL DEFAULT '0',
7577
`comment` text,
7678
PRIMARY KEY (`entry`)
7779
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Script Texts';
@@ -88,9 +90,10 @@ CREATE TABLE `script_texts` (
8890
`content_loc6` text,
8991
`content_loc7` text,
9092
`content_loc8` text,
91-
`sound` mediumint(8) unsigned NOT NULL default '0',
92-
`type` tinyint unsigned NOT NULL default '0',
93-
`language` tinyint unsigned NOT NULL default '0',
93+
`sound` mediumint(8) unsigned NOT NULL DEFAULT '0',
94+
`type` tinyint(3) unsigned NOT NULL DEFAULT '0',
95+
`language` tinyint(3) unsigned NOT NULL DEFAULT '0',
96+
`emote` tinyint(3) unsigned NOT NULL DEFAULT '0',
9497
`comment` text,
9598
PRIMARY KEY (`entry`)
9699
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Script Texts';

0 commit comments

Comments
 (0)