[10500] Extend SCRIPT_COMMAND_TALK to support random selected text

In addition to adding fields for text id storage (in total 4 text id's), also added a comments field for developers notes in scripts (it may help those being old of age to remember what goes on in a script).

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-09-18 01:54:53 +02:00
parent 869acb2a24
commit 0245efecb7
9 changed files with 127 additions and 37 deletions

View file

@ -43,7 +43,7 @@ The action to execute.
## dataint
-- --------------------------
1 multipurpose field, store raw data as signed values
4 multipurpose fields, store raw data as signed values
Note: currently used only for text id
-- --------------------------
@ -96,7 +96,7 @@ spell_scripts
* data_flags = flag_target_player_as_source = 0x01
flag_original_source_as_target = 0x02
flag_buddy_as_target = 0x04
* dataint = text entry from db_script_string -table
* dataint = text entry from db_script_string -table. dataint2-dataint4 optionally, for random selection of text
1 SCRIPT_COMMAND_EMOTE source = unit
* datalong = emote_id

View file

@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0',
`required_10457_01_mangos_spell_proc_event` bit(1) default NULL
`required_10500_01_mangos_scripts` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
--
@ -1063,10 +1063,14 @@ CREATE TABLE `creature_movement_scripts` (
`datalong4` int(10) unsigned NOT NULL default '0',
`data_flags` tinyint(3) unsigned NOT NULL default '0',
`dataint` int(11) NOT NULL default '0',
`dataint2` int(11) NOT NULL default '0',
`dataint3` int(11) NOT NULL default '0',
`dataint4` int(11) NOT NULL default '0',
`x` float NOT NULL default '0',
`y` float NOT NULL default '0',
`z` float NOT NULL default '0',
`o` float NOT NULL default '0'
`o` float NOT NULL default '0',
´comments´ varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
@ -1480,10 +1484,14 @@ CREATE TABLE `event_scripts` (
`datalong4` int(10) unsigned NOT NULL default '0',
`data_flags` tinyint(3) unsigned NOT NULL default '0',
`dataint` int(11) NOT NULL default '0',
`dataint2` int(11) NOT NULL default '0',
`dataint3` int(11) NOT NULL default '0',
`dataint4` int(11) NOT NULL default '0',
`x` float NOT NULL default '0',
`y` float NOT NULL default '0',
`z` float NOT NULL default '0',
`o` float NOT NULL default '0'
`o` float NOT NULL default '0',
´comments´ varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
@ -1960,10 +1968,14 @@ CREATE TABLE `gameobject_scripts` (
`datalong4` int(10) unsigned NOT NULL default '0',
`data_flags` tinyint(3) unsigned NOT NULL default '0',
`dataint` int(11) NOT NULL default '0',
`dataint2` int(11) NOT NULL default '0',
`dataint3` int(11) NOT NULL default '0',
`dataint4` int(11) NOT NULL default '0',
`x` float NOT NULL default '0',
`y` float NOT NULL default '0',
`z` float NOT NULL default '0',
`o` float NOT NULL default '0'
`o` float NOT NULL default '0',
´comments´ varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
@ -2133,10 +2145,14 @@ CREATE TABLE `gossip_scripts` (
`datalong4` int(10) unsigned NOT NULL default '0',
`data_flags` tinyint(3) unsigned NOT NULL default '0',
`dataint` int(11) NOT NULL default '0',
`dataint2` int(11) NOT NULL default '0',
`dataint3` int(11) NOT NULL default '0',
`dataint4` int(11) NOT NULL default '0',
`x` float NOT NULL default '0',
`y` float NOT NULL default '0',
`z` float NOT NULL default '0',
`o` float NOT NULL default '0'
`o` float NOT NULL default '0',
´comments´ varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
@ -13812,10 +13828,14 @@ CREATE TABLE `quest_end_scripts` (
`datalong4` int(10) unsigned NOT NULL default '0',
`data_flags` tinyint(3) unsigned NOT NULL default '0',
`dataint` int(11) NOT NULL default '0',
`dataint2` int(11) NOT NULL default '0',
`dataint3` int(11) NOT NULL default '0',
`dataint4` int(11) NOT NULL default '0',
`x` float NOT NULL default '0',
`y` float NOT NULL default '0',
`z` float NOT NULL default '0',
`o` float NOT NULL default '0'
`o` float NOT NULL default '0',
´comments´ varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
@ -13890,10 +13910,14 @@ CREATE TABLE `quest_start_scripts` (
`datalong4` int(10) unsigned NOT NULL default '0',
`data_flags` tinyint(3) unsigned NOT NULL default '0',
`dataint` int(11) NOT NULL default '0',
`dataint2` int(11) NOT NULL default '0',
`dataint3` int(11) NOT NULL default '0',
`dataint4` int(11) NOT NULL default '0',
`x` float NOT NULL default '0',
`y` float NOT NULL default '0',
`z` float NOT NULL default '0',
`o` float NOT NULL default '0'
`o` float NOT NULL default '0',
´comments´ varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
@ -17391,10 +17415,14 @@ CREATE TABLE `spell_scripts` (
`datalong4` int(10) unsigned NOT NULL default '0',
`data_flags` tinyint(3) unsigned NOT NULL default '0',
`dataint` int(11) NOT NULL default '0',
`dataint2` int(11) NOT NULL default '0',
`dataint3` int(11) NOT NULL default '0',
`dataint4` int(11) NOT NULL default '0',
`x` float NOT NULL default '0',
`y` float NOT NULL default '0',
`z` float NOT NULL default '0',
`o` float NOT NULL default '0'
`o` float NOT NULL default '0',
´comments´ varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--

View file

@ -0,0 +1,36 @@
ALTER TABLE db_version CHANGE COLUMN required_10457_01_mangos_spell_proc_event required_10500_01_mangos_scripts bit;
ALTER TABLE creature_movement_scripts ADD COLUMN dataint2 int(11) NOT NULL default '0' AFTER dataint;
ALTER TABLE creature_movement_scripts ADD COLUMN dataint3 int(11) NOT NULL default '0' AFTER dataint2;
ALTER TABLE creature_movement_scripts ADD COLUMN dataint4 int(11) NOT NULL default '0' AFTER dataint3;
ALTER TABLE creature_movement_scripts ADD COLUMN comments varchar(255) NOT NULL AFTER o;
ALTER TABLE event_scripts ADD COLUMN dataint2 int(11) NOT NULL default '0' AFTER dataint;
ALTER TABLE event_scripts ADD COLUMN dataint3 int(11) NOT NULL default '0' AFTER dataint2;
ALTER TABLE event_scripts ADD COLUMN dataint4 int(11) NOT NULL default '0' AFTER dataint3;
ALTER TABLE event_scripts ADD COLUMN comments varchar(255) NOT NULL AFTER o;
ALTER TABLE gameobject_scripts ADD COLUMN dataint2 int(11) NOT NULL default '0' AFTER dataint;
ALTER TABLE gameobject_scripts ADD COLUMN dataint3 int(11) NOT NULL default '0' AFTER dataint2;
ALTER TABLE gameobject_scripts ADD COLUMN dataint4 int(11) NOT NULL default '0' AFTER dataint3;
ALTER TABLE gameobject_scripts ADD COLUMN comments varchar(255) NOT NULL AFTER o;
ALTER TABLE gossip_scripts ADD COLUMN dataint2 int(11) NOT NULL default '0' AFTER dataint;
ALTER TABLE gossip_scripts ADD COLUMN dataint3 int(11) NOT NULL default '0' AFTER dataint2;
ALTER TABLE gossip_scripts ADD COLUMN dataint4 int(11) NOT NULL default '0' AFTER dataint3;
ALTER TABLE gossip_scripts ADD COLUMN comments varchar(255) NOT NULL AFTER o;
ALTER TABLE quest_end_scripts ADD COLUMN dataint2 int(11) NOT NULL default '0' AFTER dataint;
ALTER TABLE quest_end_scripts ADD COLUMN dataint3 int(11) NOT NULL default '0' AFTER dataint2;
ALTER TABLE quest_end_scripts ADD COLUMN dataint4 int(11) NOT NULL default '0' AFTER dataint3;
ALTER TABLE quest_end_scripts ADD COLUMN comments varchar(255) NOT NULL AFTER o;
ALTER TABLE quest_start_scripts ADD COLUMN dataint2 int(11) NOT NULL default '0' AFTER dataint;
ALTER TABLE quest_start_scripts ADD COLUMN dataint3 int(11) NOT NULL default '0' AFTER dataint2;
ALTER TABLE quest_start_scripts ADD COLUMN dataint4 int(11) NOT NULL default '0' AFTER dataint3;
ALTER TABLE quest_start_scripts ADD COLUMN comments varchar(255) NOT NULL AFTER o;
ALTER TABLE spell_scripts ADD COLUMN dataint2 int(11) NOT NULL default '0' AFTER dataint;
ALTER TABLE spell_scripts ADD COLUMN dataint3 int(11) NOT NULL default '0' AFTER dataint2;
ALTER TABLE spell_scripts ADD COLUMN dataint4 int(11) NOT NULL default '0' AFTER dataint3;
ALTER TABLE spell_scripts ADD COLUMN comments varchar(255) NOT NULL AFTER o;

View file

@ -96,6 +96,7 @@ pkgdata_DATA = \
10430_01_mangos_spell_chain.sql \
10454_01_mangos_spell_proc_event.sql \
10457_01_mangos_spell_proc_event.sql \
10500_01_mangos_scripts.sql \
README
## Additional files to include when running 'make dist'
@ -172,4 +173,5 @@ EXTRA_DIST = \
10430_01_mangos_spell_chain.sql \
10454_01_mangos_spell_proc_event.sql \
10457_01_mangos_spell_proc_event.sql \
10500_01_mangos_scripts.sql \
README

View file

@ -2260,20 +2260,35 @@ void Map::ScriptsProcess()
target = source;
uint64 unit_target = target ? target->GetGUID() : 0;
int32 textId = step.script->talk.textId[0];
// May have text for random
if (step.script->talk.textId[1])
{
int i = 2;
for(; i < MAX_TEXT_ID; ++i)
{
if (!step.script->talk.textId[i])
break;
}
// Use one random
textId = step.script->talk.textId[rand() % i];
}
switch(step.script->talk.chatType)
{
case CHAT_TYPE_SAY:
pSource->MonsterSay(step.script->talk.textId, LANG_UNIVERSAL, unit_target);
pSource->MonsterSay(textId, LANG_UNIVERSAL, unit_target);
break;
case CHAT_TYPE_YELL:
pSource->MonsterYell(step.script->talk.textId, LANG_UNIVERSAL, unit_target);
pSource->MonsterYell(textId, LANG_UNIVERSAL, unit_target);
break;
case CHAT_TYPE_TEXT_EMOTE:
pSource->MonsterTextEmote(step.script->talk.textId, unit_target);
pSource->MonsterTextEmote(textId, unit_target);
break;
case CHAT_TYPE_BOSS_EMOTE:
pSource->MonsterTextEmote(step.script->talk.textId, unit_target, true);
pSource->MonsterTextEmote(textId, unit_target, true);
break;
case CHAT_TYPE_WHISPER:
if (!unit_target || !IS_PLAYER_GUID(unit_target))
@ -2281,7 +2296,7 @@ void Map::ScriptsProcess()
sLog.outError("SCRIPT_COMMAND_TALK (script id %u) attempt to whisper (%u) 0-guid or non-player, skipping.", step.script->id, step.script->talk.chatType);
break;
}
pSource->MonsterWhisper(step.script->talk.textId, unit_target);
pSource->MonsterWhisper(textId, unit_target);
break;
case CHAT_TYPE_BOSS_WHISPER:
if (!unit_target || !IS_PLAYER_GUID(unit_target))
@ -2289,10 +2304,10 @@ void Map::ScriptsProcess()
sLog.outError("SCRIPT_COMMAND_TALK (script id %u) attempt to whisper (%u) 0-guid or non-player, skipping.", step.script->id, step.script->talk.chatType);
break;
}
pSource->MonsterWhisper(step.script->talk.textId, unit_target, true);
pSource->MonsterWhisper(textId, unit_target, true);
break;
case CHAT_TYPE_ZONE_YELL:
pSource->MonsterYellToZone(step.script->talk.textId, LANG_UNIVERSAL, unit_target);
pSource->MonsterYellToZone(textId, LANG_UNIVERSAL, unit_target);
break;
default:
break; // must be already checked at load

View file

@ -4383,7 +4383,7 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
scripts.clear(); // need for reload support
QueryResult *result = WorldDatabase.PQuery( "SELECT id, delay, command, datalong, datalong2, datalong3, datalong4, data_flags, dataint, x, y, z, o FROM %s", tablename );
QueryResult *result = WorldDatabase.PQuery( "SELECT id, delay, command, datalong, datalong2, datalong3, datalong4, data_flags, dataint, dataint2, dataint3, dataint4, x, y, z, o FROM %s", tablename );
uint32 count = 0;
@ -4414,10 +4414,13 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
tmp.raw.data[3] = fields[6].GetUInt32();
tmp.raw.data[4] = fields[7].GetUInt32();
tmp.raw.data[5] = fields[8].GetInt32();
tmp.x = fields[9].GetFloat();
tmp.y = fields[10].GetFloat();
tmp.z = fields[11].GetFloat();
tmp.o = fields[12].GetFloat();
tmp.raw.data[6] = fields[9].GetInt32();
tmp.raw.data[7] = fields[10].GetInt32();
tmp.raw.data[8] = fields[11].GetInt32();
tmp.x = fields[12].GetFloat();
tmp.y = fields[13].GetFloat();
tmp.z = fields[14].GetFloat();
tmp.o = fields[15].GetFloat();
// generic command args check
switch(tmp.command)
@ -4439,15 +4442,19 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
sLog.outErrorDb("Table `%s` has datalong2 = %u in SCRIPT_COMMAND_TALK for script id %u, but search radius is too small (datalong3 = %u).", tablename, tmp.talk.creatureEntry, tmp.id, tmp.talk.searchRadius);
continue;
}
if (tmp.talk.textId == 0)
if (tmp.talk.textId[0] == 0)
{
sLog.outErrorDb("Table `%s` has invalid talk text id (dataint = %i) in SCRIPT_COMMAND_TALK for script id %u", tablename, tmp.talk.textId, tmp.id);
continue;
}
if (tmp.talk.textId < MIN_DB_SCRIPT_STRING_ID || tmp.talk.textId >= MAX_DB_SCRIPT_STRING_ID)
for(int i = 0; i < MAX_TEXT_ID; ++i)
{
sLog.outErrorDb("Table `%s` has out of range text id (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u", tablename, tmp.talk.textId, MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID, tmp.id);
continue;
if (tmp.talk.textId[i] && (tmp.talk.textId[i] < MIN_DB_SCRIPT_STRING_ID || tmp.talk.textId[i] >= MAX_DB_SCRIPT_STRING_ID))
{
sLog.outErrorDb("Table `%s` has out of range text id (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u", tablename, tmp.talk.textId[i], MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID, tmp.id);
continue;
}
}
// if(!GetMangosStringLocale(tmp.dataint)) will checked after db_script_string loading
@ -9059,15 +9066,15 @@ void ObjectMgr::CheckScriptTexts(ScriptMapMap const& scripts,std::set<int32>& id
{
for(ScriptMap::const_iterator itrM = itrMM->second.begin(); itrM != itrMM->second.end(); ++itrM)
{
switch(itrM->second.command)
if (itrM->second.command == SCRIPT_COMMAND_TALK)
{
case SCRIPT_COMMAND_TALK:
for(int i = 0; i < MAX_TEXT_ID; ++i)
{
if(!GetMangosStringLocale (itrM->second.talk.textId))
sLog.outErrorDb( "Table `db_script_string` is missing string id %u, used in database script id %u.", itrM->second.talk.textId, itrMM->first);
if (itrM->second.talk.textId[i] && !GetMangosStringLocale (itrM->second.talk.textId[i]))
sLog.outErrorDb( "Table `db_script_string` is missing string id %u, used in database script id %u.", itrM->second.talk.textId[i], itrMM->first);
if (ids.find(itrM->second.talk.textId) != ids.end())
ids.erase(itrM->second.talk.textId);
if (ids.find(itrM->second.talk.textId[i]) != ids.end())
ids.erase(itrM->second.talk.textId[i]);
}
}
}

View file

@ -76,7 +76,7 @@ enum eScriptCommand
// data_flags = flag_target_player_as_source = 0x01
// flag_original_source_as_target = 0x02
// flag_buddy_as_target = 0x04
// dataint = text entry from db_script_string -table
// dataint = text entry from db_script_string -table. dataint2-4 optional for random selected text.
SCRIPT_COMMAND_EMOTE = 1, // source = unit, datalong = emote_id
SCRIPT_COMMAND_FIELD_SET = 2, // source = any, datalong = field_id, datalong2 = value
SCRIPT_COMMAND_MOVE_TO = 3, // source = Creature, datalong2 = time, x/y/z
@ -100,6 +100,8 @@ enum eScriptCommand
// datalong2 = creature entry (searching for a buddy, closest to source), datalong3 = creature search radius
};
#define MAX_TEXT_ID 4 // used for SCRIPT_COMMAND_TALK
struct ScriptInfo
{
uint32 id;
@ -115,7 +117,7 @@ struct ScriptInfo
uint32 searchRadius; // datalong3
uint32 unused1; // datalong4
uint32 flags; // data_flags
int32 textId; // dataint
int32 textId[MAX_TEXT_ID]; // dataint to dataint4
} talk;
struct // SCRIPT_COMMAND_EMOTE (1)
@ -233,7 +235,7 @@ struct ScriptInfo
struct
{
uint32 data[6];
uint32 data[9];
} raw;
};

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10499"
#define REVISION_NR "10500"
#endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_10332_02_characters_pet_aura"
#define REVISION_DB_MANGOS "required_10457_01_mangos_spell_proc_event"
#define REVISION_DB_MANGOS "required_10500_01_mangos_scripts"
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
#endif // __REVISION_SQL_H__