[11940] Rewrite and cleanup DB Script Engine

* Moved actual script processing code to ScriptMgr
* Unifed and improved log output. Now table-name is passed to each script execution
* Added the "buddy concept" to all commands (except the outdated direct field change commands):
Now all commands support to search a creature (or go for some commands) in a radius, with which to do some stuff.
See doc/script_commands.txt for more details and information

Attention DB Devs:
Current DB-Scripts are converted automatically as far as possible, but some old target selecting mechanics were not reasonable to do automated.
For such cases the command is marked with data_flags & 0x10 (==16), which will throw DB-Errors to track them down faster

Thanks to NeatElves and especially Grz3s for testing!

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
Schmoozerd 2012-04-06 21:56:21 +02:00
parent fe3f4a43ee
commit 8e0edc0383
18 changed files with 1530 additions and 1803 deletions

View file

@ -33,20 +33,39 @@ The action to execute.
## datalong
-- --------------------------
4 multipurpose fields, store raw data as unsigned values
2 multipurpose fields, store raw data as unsigned values
-- --------------------------
## buddy_entry
-- --------------------------
1 field to store the entry of a "buddy" (depending on command can be both GameObject and Creature entry)
-- --------------------------
## search_radius
-- --------------------------
Range in which the buddy defined in buddy_entry will be searched
-- --------------------------
## data_flags
-- --------------------------
1 multipurpose field, generally intended for bitmask based data
Field which holds a combination of these flags:
SCRIPT_FLAG_BUDDY_AS_TARGET = 0x01
SCRIPT_FLAG_REVERSE_DIRECTION = 0x02
SCRIPT_FLAG_SOURCE_TARGETS_SELF = 0x04
SCRIPT_FLAG_COMMAND_ADDITIONAL = 0x08 (Only for some commands possible)
Detailed meaning described below!
-- --------------------------
## dataint
-- --------------------------
4 multipurpose fields, store raw data as signed values
Note: currently used only for text id
Note: currently used only for text ids
-- --------------------------
## x y z o
@ -69,14 +88,14 @@ event_scripts
`gameobject_template`
Source: User (player/creature). Target: GO
Spell (effect 61)
Source: caster. Target: GO (spell focus)
Source: caster. Target: Target
gameobject_scripts
Gameobject use
Source: user: Target: GO (only type door/button)
Source: user: Target: GO
gossip_scripts
`gossip_menu_option`
Source: creature. Target: player
Source: player. Target: GO
Source: creature. Target: player (in case of NPC-Gossip)
Source: player. Target: GO (in case of GO-Gossip)
quest_end_scripts
`quest_template`
Source: quest taker (creature/GO). Target: player
@ -87,31 +106,49 @@ spell_scripts
Spell (effect 77)
Source: caster: Target: target of spell (Unit)
-- --------------------------
## Buddy concept
-- --------------------------
Commands except the ones requiring a player (like KILL_CREDIT) have support for the buddy concept.
This means that if an entry for buddy_entry is provided,
aside from source and target as listed above also a "buddy" is available.
Which one on the three (originalSource, originalTarget, buddy) will be used in the command, depends on the data_flags
Note that some commands (like EMOTE) use only the resulting source for an action.
Possible combinations of the flags
SCRIPT_FLAG_BUDDY_AS_TARGET = 0x01
SCRIPT_FLAG_REVERSE_DIRECTION = 0x02
SCRIPT_FLAG_SOURCE_TARGETS_SELF = 0x04
are:
0: originalSource / buddyIfProvided -> originalTarget
1: originalSource -> buddy
2: originalTarget -> originalSource / buddyIfProvided
3: buddy -> originalSource
4: originalSource / buddyIfProvided -> originalSource / buddyIfProvided
5: originalSource -> originalSource
6: originalTarget -> originalTarget
7: buddy -> buddy
Where "A -> B" means that the command is executed from A with B as target.
-- --------------------------
## Each command has different parameters, and are as follows:
-- --------------------------
0 SCRIPT_COMMAND_TALK source = WorldObject, target = any/none
0 SCRIPT_COMMAND_TALK resultingSource = WorldObject, resultingTarget = Unit/none
* datalong (see enum ChatType for supported CHAT_TYPE_'s)
* datalong2 = creature entry (searching for a buddy, closest to source)
* datalong3 = creature search radius
* datalong4 = language
* data_flags = flag_target_player_as_source = 0x01
flag_original_source_as_target = 0x02
flag_buddy_as_target = 0x04
* datalong2 = language
* dataint = text entry from db_script_string -table. dataint2-dataint4 optionally, for random selection of text
1 SCRIPT_COMMAND_EMOTE source = Unit (or WorldObject when creature entry defined), target = Unit (or none)
1 SCRIPT_COMMAND_EMOTE resultingSource = Unit, resultingTarget = Unit/none
* datalong = emote_id
* datalong2 = creature entry (searching for a buddy, closest to source)
* datalong3 = creature search radius
* data_flags = flag_target_as_source = 0x01
2 SCRIPT_COMMAND_FIELD_SET source = any
* datalong = field_id
* datalong2 = field value
3 SCRIPT_COMMAND_MOVE_TO source = Creature
3 SCRIPT_COMMAND_MOVE_TO resultingSource = Creature
If position is very near to current position, or x=y=z=0, then only orientation is changed
* datalong2 = travel time
* x/y/z/o
@ -136,32 +173,31 @@ spell_scripts
* datalong = creature entry
* datalong2 = bool (0=personal credit, 1=group credit)
9 SCRIPT_COMMAND_RESPAWN_GAMEOBJECT source = any (summoner)
* datalong=db_guid
9 SCRIPT_COMMAND_RESPAWN_GAMEOBJECT source = any, target = any
* datalong=db_guid (can be skipped for buddy)
* datalong2 = despawn_delay
10 SCRIPT_COMMAND_TEMP_SUMMON_CREATURE source = any (summoner)
10 SCRIPT_COMMAND_TEMP_SUMMON_CREATURE source = any, target = any
* datalong = creature entry
* datalong2 = despawn_delay
* data_flags = summon_as_active_object = 0x01
* data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: summon as active object
11 SCRIPT_COMMAND_OPEN_DOOR source = unit
* datalong = db_guid
11 SCRIPT_COMMAND_OPEN_DOOR source = any
* datalong = db_guid (can be skipped for buddy)
* datalong2 = reset_delay
12 SCRIPT_COMMAND_CLOSE_DOOR source = unit
* datalong = db_guid
12 SCRIPT_COMMAND_CLOSE_DOOR source = any
* datalong = db_guid (can be skipped for buddy)
* datalong2 = reset_delay
13 SCRIPT_COMMAND_ACTIVATE_OBJECT source = unit, target=GO
14 SCRIPT_COMMAND_REMOVE_AURA source (datalong2!=0) or target (datalong==0) unit
14 SCRIPT_COMMAND_REMOVE_AURA resultingSource = Unit
* datalong = spell_id
* datalong2 = bool source is target of action
15 SCRIPT_COMMAND_CAST_SPELL source/target cast spell at target/source
15 SCRIPT_COMMAND_CAST_SPELL resultingSource = Unit, cast spell at resultingTarget = Unit
* datalong = spell id
* datalong2 = 0: s->t 1: s->s 2: t->t 3: t->s 4: cast triggered
* data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: cast triggered
16 SCRIPT_COMMAND_PLAY_SOUND source = any object, target=any/player
* datalong = sound_id
@ -171,69 +207,46 @@ spell_scripts
* datalong = item entry
* datalong2 = amount
18 SCRIPT_COMMAND_DESPAWN_SELF source or target must be creature
18 SCRIPT_COMMAND_DESPAWN_SELF resultingSource = Creature
* datalong = despawn delay
19 SCRIPT_COMMAND_PLAY_MOVIE target can only be a player
* datalog = movie id
20 SCRIPT_COMMAND_MOVEMENT source or target must be creature
20 SCRIPT_COMMAND_MOVEMENT resultingSource = Creature
* datalong = MovementType (0:idle, 1:random or 2:waypoint)
* datalong2 = creature entry (searching for a buddy, closest to source)
* datalong3 = creature search radius
21 SCRIPT_COMMAND_SET_ACTIVEOBJECT source=worldobject, target=creature
21 SCRIPT_COMMAND_SET_ACTIVEOBJECT resultingSource = Creature
* datalong=bool 0=off, 1=on
* datalong2=creature entry
* datalong3=search radius
22 SCRIPT_COMMAND_SET_FACTION source=worldobject, target=creature
22 SCRIPT_COMMAND_SET_FACTION resultingSource = Creature
* datalong=factionId OR 0 to restore original faction from creature_template
* datalong2=creature entry
* datalong3=search radius
* data_flags = enum TemporaryFactionFlags
* datalong2=enum TemporaryFactionFlags
TEMPFACTION_NONE = 0x00, // When no flag is used in temporary faction change, faction will be persistent. It will then require manual change back to default/another faction when changed once
TEMPFACTION_RESTORE_RESPAWN = 0x01, // Default faction will be restored at respawn
TEMPFACTION_RESTORE_COMBAT_STOP = 0x02, // ... at CombatStop() (happens at creature death, at evade or custom scripte among others)
TEMPFACTION_RESTORE_REACH_HOME = 0x04, // ... at reaching home in home movement (evade), if not already done at CombatStop()
23 SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL source=worldobject, target=creature
23 SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL resultingSource = Creature
* datalong=creature entry/modelid (depend on data_flags) OR 0 to demorph
* datalong2=creature entry
* datalong3=search radius
* dataflags= 0x01 to use datalong value as modelid explicit
* data_flags= 0x01 to use datalong value as modelid explicit
24 SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL source=worldobject, target=creature
24 SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL resultingSource = Creature
* datalong=creature entry/modelid (depend on data_flags) OR 0 to dismount
* datalong2=creature entry
* datalong3=search radius
* dataflags= 0x01 to use datalong value as modelid explicit
* data_flags= 0x01 to use datalong value as modelid explicit
25 SCRIPT_COMMAND_SET_RUN source=worldobject, target=creature
25 SCRIPT_COMMAND_SET_RUN resultingSource = Creature
* datalong= bool 0=off, 1=on
* datalong2=creature entry
* datalong3=search radius
26 SCRIPT_COMMAND_ATTACK_START source = WorldObject (but Creature must be final source/attacker, set with datalong-fields where needed), target = Unit/none
* datalong2 = creature entry (searching for a buddy, closest to source)
* datalong3 = creature search radius
* data_flags = flag_original_source_as_target = 0x02
flag_buddy_as_target = 0x04 (When this flag is not set, buddy will be the attacker when buddy is defined)
26 SCRIPT_COMMAND_ATTACK_START resultingSource = Creature, resultingTarget = Unit
27 SCRIPT_COMMAND_GO_LOCK_STATE source or target must be WorldObject
27 SCRIPT_COMMAND_GO_LOCK_STATE resultingSource = GO
* datalong = flag_go_lock = 0x01, flag_go_unlock = 0x02,
flag_go_nonInteract = 0x04, flag_go_interact = 0x08
* datalong2 = go entry (searching closest to source (if worldobject) or target
* datalong3 = go search radius
28 SCRIPT_COMMAND_STAND_STATE source = Unit (or WorldObject when creature entry defined), target = Unit (or none)
28 SCRIPT_COMMAND_STAND_STATE resultingSource = Creature
* datalong = stand state (enum UnitStandStateType)
* datalong2 = creature entry (searching for a buddy, closest to source)
* datalong3 = creature search radius
* data_flags = flag_target_as_source = 0x01
29 SCRIPT_COMMAND_MODIFY_NPC_FLAGS source=worldobject or target=worldobject (datalong1==0), else source or target = creature
29 SCRIPT_COMMAND_MODIFY_NPC_FLAGS resultingSource = Creature
* datalong=NPCFlags
* datalong2=creature entry
* datalong3=search radius
* data_flags = 0x00=toggle, 0x01=add, 0x02=remove
* datalong2= 0x00=toggle, 0x01=add, 0x02=remove

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_11926_01_mangos_creature_template` bit(1) default NULL
`required_11940_07_mangos_spell_scripts` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
--
@ -1111,8 +1111,8 @@ CREATE TABLE `creature_movement_scripts` (
`command` mediumint(8) unsigned NOT NULL default '0',
`datalong` mediumint(8) unsigned NOT NULL default '0',
`datalong2` int(10) unsigned NOT NULL default '0',
`datalong3` int(10) unsigned NOT NULL default '0',
`datalong4` int(10) unsigned NOT NULL default '0',
`buddy_entry` int(10) unsigned NOT NULL default '0',
`search_radius` 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',
@ -1519,8 +1519,8 @@ CREATE TABLE `event_scripts` (
`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',
`buddy_entry` int(11) NOT NULL default '0',
`search_radius` int(11) NOT NULL default '0',
`x` float NOT NULL default '0',
`y` float NOT NULL default '0',
`z` float NOT NULL default '0',
@ -2024,8 +2024,8 @@ CREATE TABLE `gameobject_scripts` (
`command` mediumint(8) unsigned NOT NULL default '0',
`datalong` mediumint(8) unsigned NOT NULL default '0',
`datalong2` int(10) unsigned NOT NULL default '0',
`datalong3` int(10) unsigned NOT NULL default '0',
`datalong4` int(10) unsigned NOT NULL default '0',
`buddy_entry` int(10) unsigned NOT NULL default '0',
`search_radius` 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',
@ -2207,8 +2207,8 @@ CREATE TABLE `gossip_scripts` (
`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',
`buddy_entry` int(11) NOT NULL default '0',
`search_radius` int(11) NOT NULL default '0',
`x` float NOT NULL default '0',
`y` float NOT NULL default '0',
`z` float NOT NULL default '0',
@ -14086,8 +14086,8 @@ CREATE TABLE `quest_end_scripts` (
`command` mediumint(8) unsigned NOT NULL default '0',
`datalong` mediumint(8) unsigned NOT NULL default '0',
`datalong2` int(10) unsigned NOT NULL default '0',
`datalong3` int(10) unsigned NOT NULL default '0',
`datalong4` int(10) unsigned NOT NULL default '0',
`buddy_entry` int(10) unsigned NOT NULL default '0',
`search_radius` 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',
@ -14173,8 +14173,8 @@ CREATE TABLE `quest_start_scripts` (
`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',
`buddy_entry` int(11) NOT NULL default '0',
`search_radius` int(11) NOT NULL default '0',
`x` float NOT NULL default '0',
`y` float NOT NULL default '0',
`z` float NOT NULL default '0',
@ -17853,8 +17853,8 @@ CREATE TABLE `spell_scripts` (
`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',
`buddy_entry` int(11) NOT NULL default '0',
`search_radius` int(11) NOT NULL default '0',
`x` float NOT NULL default '0',
`y` float NOT NULL default '0',
`z` float NOT NULL default '0',

View file

@ -0,0 +1,50 @@
ALTER TABLE db_version CHANGE COLUMN required_11926_01_mangos_creature_template required_11940_01_mangos_creature_movement_scripts bit;
ALTER TABLE creature_movement_scripts ADD COLUMN temp MEDIUMINT(8) DEFAULT 0 AFTER command;
-- Move datalong4 -> 2, 3 -> 4, 2 -> 3 (right shift)
UPDATE creature_movement_scripts SET temp=datalong4 WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
UPDATE creature_movement_scripts SET datalong4=datalong3, datalong3=datalong2, datalong2=temp WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
ALTER TABLE creature_movement_scripts CHANGE COLUMN datalong3 buddy_entry MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE creature_movement_scripts CHANGE COLUMN datalong4 search_radius MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
UPDATE creature_movement_scripts SET temp=0;
/* Chat*/
UPDATE creature_movement_scripts SET temp=temp | 0x04 WHERE command=0 AND (data_flags & 0x02) > 0; -- target self
UPDATE creature_movement_scripts SET temp=temp | 0x01 WHERE command=0 AND (data_flags & 0x04) > 0; -- buddy as target
UPDATE creature_movement_scripts SET temp=temp | 0x10 WHERE command=0 AND (data_flags & 0x01) > 0; -- will produce error
-- Note that old flag 0x01 // flag_target_player_as_source 0x01 could not be converted automatically, need to check every script
/* Emote*/
UPDATE creature_movement_scripts SET temp=temp | 0x02 WHERE command=1 AND (data_flags & 0x01 > 0) AND buddy_entry = 0; -- reverse order if no buddy defined
/*Summon */
UPDATE creature_movement_scripts SET temp=temp | 0x08 WHERE command=10 AND (data_flags & 0x01 > 0); -- Summon as active
/* Remove Aura */
UPDATE creature_movement_scripts SET temp=0x02 WHERE command=14 AND datalong2=1;
UPDATE creature_movement_scripts SET datalong2=0 WHERE command=14;
/* Cast */
UPDATE creature_movement_scripts SET temp=temp | 0x08 WHERE command=15 AND (datalong2 & 0x04 > 0); -- cast triggered
UPDATE creature_movement_scripts SET temp=temp | 0x04 WHERE command=15 AND datalong2=0x01; -- s->t
UPDATE creature_movement_scripts SET temp=temp | 0x06 WHERE command=15 AND datalong2=0x02; -- t->t
UPDATE creature_movement_scripts SET temp=temp | 0x02 WHERE command=15 AND datalong2=0x03; -- t->s
UPDATE creature_movement_scripts SET datalong2=0 WHERE command=15;
/* change faction */
UPDATE creature_movement_scripts SET datalong2=data_flags WHERE command=22;
/* morph/ mount */
UPDATE creature_movement_scripts SET temp=temp | 0x08 WHERE command IN (23, 24) AND (data_flags & 0x01 > 0); -- Summon as active
/* attack start */
UPDATE creature_movement_scripts SET temp=temp | 0x03 WHERE command=26 AND data_flags=0x02; -- b->s
UPDATE creature_movement_scripts SET temp=temp | 0x01 WHERE command=26 AND data_flags=0x04 AND buddy_entry!=0; -- s->b/t
UPDATE creature_movement_scripts SET temp=temp | 0x14 WHERE command=26 AND data_flags=0x06 AND buddy_entry!=0; -- s->s -- Throw error, this would be unreasonable if buddy defined
UPDATE creature_movement_scripts SET temp=temp | 0x04 WHERE command=26 AND data_flags=0x06 AND buddy_entry=0; -- s->s
/* stand state */
UPDATE creature_movement_scripts SET temp=temp | 0x02 WHERE command=28 AND (data_flags & 0x01 > 0) AND buddy_entry=0;
/* change npc flag */
UPDATE creature_movement_scripts SET datalong2=data_flags WHERE command=29;
UPDATE creature_movement_scripts SET data_flags=temp;
ALTER TABLE creature_movement_scripts DROP COLUMN temp;

View file

@ -0,0 +1,50 @@
ALTER TABLE db_version CHANGE COLUMN required_11940_01_mangos_creature_movement_scripts required_11940_02_mangos_event_scripts bit;
ALTER TABLE event_scripts ADD COLUMN temp MEDIUMINT(8) DEFAULT 0 AFTER command;
-- Move datalong4 -> 2, 3 -> 4, 2 -> 3 (right shift)
UPDATE event_scripts SET temp=datalong4 WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
UPDATE event_scripts SET datalong4=datalong3, datalong3=datalong2, datalong2=temp WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
ALTER TABLE event_scripts CHANGE COLUMN datalong3 buddy_entry MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE event_scripts CHANGE COLUMN datalong4 search_radius MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
UPDATE event_scripts SET temp=0;
/* Chat*/
UPDATE event_scripts SET temp=temp | 0x04 WHERE command=0 AND (data_flags & 0x02) > 0; -- target self
UPDATE event_scripts SET temp=temp | 0x01 WHERE command=0 AND (data_flags & 0x04) > 0; -- buddy as target
UPDATE event_scripts SET temp=temp | 0x10 WHERE command=0 AND (data_flags & 0x01) > 0; -- will produce error
-- Note that old flag 0x01 // flag_target_player_as_source 0x01 could not be converted automatically, need to check every script
/* Emote*/
UPDATE event_scripts SET temp=temp | 0x02 WHERE command=1 AND (data_flags & 0x01 > 0) AND buddy_entry = 0; -- reverse order if no buddy defined
/*Summon */
UPDATE event_scripts SET temp=temp | 0x08 WHERE command=10 AND (data_flags & 0x01 > 0); -- Summon as active
/* Remove Aura */
UPDATE event_scripts SET temp=0x02 WHERE command=14 AND datalong2=1;
UPDATE event_scripts SET datalong2=0 WHERE command=14;
/* Cast */
UPDATE event_scripts SET temp=temp | 0x08 WHERE command=15 AND (datalong2 & 0x04 > 0); -- cast triggered
UPDATE event_scripts SET temp=temp | 0x04 WHERE command=15 AND datalong2=0x01; -- s->t
UPDATE event_scripts SET temp=temp | 0x06 WHERE command=15 AND datalong2=0x02; -- t->t
UPDATE event_scripts SET temp=temp | 0x02 WHERE command=15 AND datalong2=0x03; -- t->s
UPDATE event_scripts SET datalong2=0 WHERE command=15;
/* change faction */
UPDATE event_scripts SET datalong2=data_flags WHERE command=22;
/* morph/ mount */
UPDATE event_scripts SET temp=temp | 0x08 WHERE command IN (23, 24) AND (data_flags & 0x01 > 0); -- Summon as active
/* attack start */
UPDATE event_scripts SET temp=temp | 0x03 WHERE command=26 AND data_flags=0x02; -- b->s
UPDATE event_scripts SET temp=temp | 0x01 WHERE command=26 AND data_flags=0x04 AND buddy_entry!=0; -- s->b/t
UPDATE event_scripts SET temp=temp | 0x14 WHERE command=26 AND data_flags=0x06 AND buddy_entry!=0; -- s->s -- Throw error, this would be unreasonable if buddy defined
UPDATE event_scripts SET temp=temp | 0x04 WHERE command=26 AND data_flags=0x06 AND buddy_entry=0; -- s->s
/* stand state */
UPDATE event_scripts SET temp=temp | 0x02 WHERE command=28 AND (data_flags & 0x01 > 0) AND buddy_entry=0;
/* change npc flag */
UPDATE event_scripts SET datalong2=data_flags WHERE command=29;
UPDATE event_scripts SET data_flags=temp;
ALTER TABLE event_scripts DROP COLUMN temp;

View file

@ -0,0 +1,50 @@
ALTER TABLE db_version CHANGE COLUMN required_11940_02_mangos_event_scripts required_11940_03_mangos_gameobject_scripts bit;
ALTER TABLE gameobject_scripts ADD COLUMN temp MEDIUMINT(8) DEFAULT 0 AFTER command;
-- Move datalong4 -> 2, 3 -> 4, 2 -> 3 (right shift)
UPDATE gameobject_scripts SET temp=datalong4 WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
UPDATE gameobject_scripts SET datalong4=datalong3, datalong3=datalong2, datalong2=temp WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
ALTER TABLE gameobject_scripts CHANGE COLUMN datalong3 buddy_entry MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE gameobject_scripts CHANGE COLUMN datalong4 search_radius MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
UPDATE gameobject_scripts SET temp=0;
/* Chat*/
UPDATE gameobject_scripts SET temp=temp | 0x04 WHERE command=0 AND (data_flags & 0x02) > 0; -- target self
UPDATE gameobject_scripts SET temp=temp | 0x01 WHERE command=0 AND (data_flags & 0x04) > 0; -- buddy as target
UPDATE gameobject_scripts SET temp=temp | 0x10 WHERE command=0 AND (data_flags & 0x01) > 0; -- will produce error
-- Note that old flag 0x01 // flag_target_player_as_source 0x01 could not be converted automatically, need to check every script
/* Emote*/
UPDATE gameobject_scripts SET temp=temp | 0x02 WHERE command=1 AND (data_flags & 0x01 > 0) AND buddy_entry = 0; -- reverse order if no buddy defined
/*Summon */
UPDATE gameobject_scripts SET temp=temp | 0x08 WHERE command=10 AND (data_flags & 0x01 > 0); -- Summon as active
/* Remove Aura */
UPDATE gameobject_scripts SET temp=0x02 WHERE command=14 AND datalong2=1;
UPDATE gameobject_scripts SET datalong2=0 WHERE command=14;
/* Cast */
UPDATE gameobject_scripts SET temp=temp | 0x08 WHERE command=15 AND (datalong2 & 0x04 > 0); -- cast triggered
UPDATE gameobject_scripts SET temp=temp | 0x04 WHERE command=15 AND datalong2=0x01; -- s->t
UPDATE gameobject_scripts SET temp=temp | 0x06 WHERE command=15 AND datalong2=0x02; -- t->t
UPDATE gameobject_scripts SET temp=temp | 0x02 WHERE command=15 AND datalong2=0x03; -- t->s
UPDATE gameobject_scripts SET datalong2=0 WHERE command=15;
/* change faction */
UPDATE gameobject_scripts SET datalong2=data_flags WHERE command=22;
/* morph/ mount */
UPDATE gameobject_scripts SET temp=temp | 0x08 WHERE command IN (23, 24) AND (data_flags & 0x01 > 0); -- Summon as active
/* attack start */
UPDATE gameobject_scripts SET temp=temp | 0x03 WHERE command=26 AND data_flags=0x02; -- b->s
UPDATE gameobject_scripts SET temp=temp | 0x01 WHERE command=26 AND data_flags=0x04 AND buddy_entry!=0; -- s->b/t
UPDATE gameobject_scripts SET temp=temp | 0x14 WHERE command=26 AND data_flags=0x06 AND buddy_entry!=0; -- s->s -- Throw error, this would be unreasonable if buddy defined
UPDATE gameobject_scripts SET temp=temp | 0x04 WHERE command=26 AND data_flags=0x06 AND buddy_entry=0; -- s->s
/* stand state */
UPDATE gameobject_scripts SET temp=temp | 0x02 WHERE command=28 AND (data_flags & 0x01 > 0) AND buddy_entry=0;
/* change npc flag */
UPDATE gameobject_scripts SET datalong2=data_flags WHERE command=29;
UPDATE gameobject_scripts SET data_flags=temp;
ALTER TABLE gameobject_scripts DROP COLUMN temp;

View file

@ -0,0 +1,50 @@
ALTER TABLE db_version CHANGE COLUMN required_11940_03_mangos_gameobject_scripts required_11940_04_mangos_gossip_scripts bit;
ALTER TABLE gossip_scripts ADD COLUMN temp MEDIUMINT(8) DEFAULT 0 AFTER command;
-- Move datalong4 -> 2, 3 -> 4, 2 -> 3 (right shift)
UPDATE gossip_scripts SET temp=datalong4 WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
UPDATE gossip_scripts SET datalong4=datalong3, datalong3=datalong2, datalong2=temp WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
ALTER TABLE gossip_scripts CHANGE COLUMN datalong3 buddy_entry MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE gossip_scripts CHANGE COLUMN datalong4 search_radius MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
UPDATE gossip_scripts SET temp=0;
/* Chat*/
UPDATE gossip_scripts SET temp=temp | 0x04 WHERE command=0 AND (data_flags & 0x02) > 0; -- target self
UPDATE gossip_scripts SET temp=temp | 0x01 WHERE command=0 AND (data_flags & 0x04) > 0; -- buddy as target
UPDATE gossip_scripts SET temp=temp | 0x10 WHERE command=0 AND (data_flags & 0x01) > 0; -- will produce error
-- Note that old flag 0x01 // flag_target_player_as_source 0x01 could not be converted automatically, need to check every script
/* Emote*/
UPDATE gossip_scripts SET temp=temp | 0x02 WHERE command=1 AND (data_flags & 0x01 > 0) AND buddy_entry = 0; -- reverse order if no buddy defined
/*Summon */
UPDATE gossip_scripts SET temp=temp | 0x08 WHERE command=10 AND (data_flags & 0x01 > 0); -- Summon as active
/* Remove Aura */
UPDATE gossip_scripts SET temp=0x02 WHERE command=14 AND datalong2=1;
UPDATE gossip_scripts SET datalong2=0 WHERE command=14;
/* Cast */
UPDATE gossip_scripts SET temp=temp | 0x08 WHERE command=15 AND (datalong2 & 0x04 > 0); -- cast triggered
UPDATE gossip_scripts SET temp=temp | 0x04 WHERE command=15 AND datalong2=0x01; -- s->t
UPDATE gossip_scripts SET temp=temp | 0x06 WHERE command=15 AND datalong2=0x02; -- t->t
UPDATE gossip_scripts SET temp=temp | 0x02 WHERE command=15 AND datalong2=0x03; -- t->s
UPDATE gossip_scripts SET datalong2=0 WHERE command=15;
/* change faction */
UPDATE gossip_scripts SET datalong2=data_flags WHERE command=22;
/* morph/ mount */
UPDATE gossip_scripts SET temp=temp | 0x08 WHERE command IN (23, 24) AND (data_flags & 0x01 > 0); -- Summon as active
/* attack start */
UPDATE gossip_scripts SET temp=temp | 0x03 WHERE command=26 AND data_flags=0x02; -- b->s
UPDATE gossip_scripts SET temp=temp | 0x01 WHERE command=26 AND data_flags=0x04 AND buddy_entry!=0; -- s->b/t
UPDATE gossip_scripts SET temp=temp | 0x14 WHERE command=26 AND data_flags=0x06 AND buddy_entry!=0; -- s->s -- Throw error, this would be unreasonable if buddy defined
UPDATE gossip_scripts SET temp=temp | 0x04 WHERE command=26 AND data_flags=0x06 AND buddy_entry=0; -- s->s
/* stand state */
UPDATE gossip_scripts SET temp=temp | 0x02 WHERE command=28 AND (data_flags & 0x01 > 0) AND buddy_entry=0;
/* change npc flag */
UPDATE gossip_scripts SET datalong2=data_flags WHERE command=29;
UPDATE gossip_scripts SET data_flags=temp;
ALTER TABLE gossip_scripts DROP COLUMN temp;

View file

@ -0,0 +1,50 @@
ALTER TABLE db_version CHANGE COLUMN required_11940_04_mangos_gossip_scripts required_11940_05_mangos_quest_end_scripts bit;
ALTER TABLE quest_end_scripts ADD COLUMN temp MEDIUMINT(8) DEFAULT 0 AFTER command;
-- Move datalong4 -> 2, 3 -> 4, 2 -> 3 (right shift)
UPDATE quest_end_scripts SET temp=datalong4 WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
UPDATE quest_end_scripts SET datalong4=datalong3, datalong3=datalong2, datalong2=temp WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
ALTER TABLE quest_end_scripts CHANGE COLUMN datalong3 buddy_entry MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE quest_end_scripts CHANGE COLUMN datalong4 search_radius MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
UPDATE quest_end_scripts SET temp=0;
/* Chat*/
UPDATE quest_end_scripts SET temp=temp | 0x04 WHERE command=0 AND (data_flags & 0x02) > 0; -- target self
UPDATE quest_end_scripts SET temp=temp | 0x01 WHERE command=0 AND (data_flags & 0x04) > 0; -- buddy as target
UPDATE quest_end_scripts SET temp=temp | 0x10 WHERE command=0 AND (data_flags & 0x01) > 0; -- will produce error
-- Note that old flag 0x01 // flag_target_player_as_source 0x01 could not be converted automatically, need to check every script
/* Emote*/
UPDATE quest_end_scripts SET temp=temp | 0x02 WHERE command=1 AND (data_flags & 0x01 > 0) AND buddy_entry = 0; -- reverse order if no buddy defined
/*Summon */
UPDATE quest_end_scripts SET temp=temp | 0x08 WHERE command=10 AND (data_flags & 0x01 > 0); -- Summon as active
/* Remove Aura */
UPDATE quest_end_scripts SET temp=0x02 WHERE command=14 AND datalong2=1;
UPDATE quest_end_scripts SET datalong2=0 WHERE command=14;
/* Cast */
UPDATE quest_end_scripts SET temp=temp | 0x08 WHERE command=15 AND (datalong2 & 0x04 > 0); -- cast triggered
UPDATE quest_end_scripts SET temp=temp | 0x04 WHERE command=15 AND datalong2=0x01; -- s->t
UPDATE quest_end_scripts SET temp=temp | 0x06 WHERE command=15 AND datalong2=0x02; -- t->t
UPDATE quest_end_scripts SET temp=temp | 0x02 WHERE command=15 AND datalong2=0x03; -- t->s
UPDATE quest_end_scripts SET datalong2=0 WHERE command=15;
/* change faction */
UPDATE quest_end_scripts SET datalong2=data_flags WHERE command=22;
/* morph/ mount */
UPDATE quest_end_scripts SET temp=temp | 0x08 WHERE command IN (23, 24) AND (data_flags & 0x01 > 0); -- Summon as active
/* attack start */
UPDATE quest_end_scripts SET temp=temp | 0x03 WHERE command=26 AND data_flags=0x02; -- b->s
UPDATE quest_end_scripts SET temp=temp | 0x01 WHERE command=26 AND data_flags=0x04 AND buddy_entry!=0; -- s->b/t
UPDATE quest_end_scripts SET temp=temp | 0x14 WHERE command=26 AND data_flags=0x06 AND buddy_entry!=0; -- s->s -- Throw error, this would be unreasonable if buddy defined
UPDATE quest_end_scripts SET temp=temp | 0x04 WHERE command=26 AND data_flags=0x06 AND buddy_entry=0; -- s->s
/* stand state */
UPDATE quest_end_scripts SET temp=temp | 0x02 WHERE command=28 AND (data_flags & 0x01 > 0) AND buddy_entry=0;
/* change npc flag */
UPDATE quest_end_scripts SET datalong2=data_flags WHERE command=29;
UPDATE quest_end_scripts SET data_flags=temp;
ALTER TABLE quest_end_scripts DROP COLUMN temp;

View file

@ -0,0 +1,50 @@
ALTER TABLE db_version CHANGE COLUMN required_11940_05_mangos_quest_end_scripts required_11940_06_mangos_quest_start_scripts bit;
ALTER TABLE quest_start_scripts ADD COLUMN temp MEDIUMINT(8) DEFAULT 0 AFTER command;
-- Move datalong4 -> 2, 3 -> 4, 2 -> 3 (right shift)
UPDATE quest_start_scripts SET temp=datalong4 WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
UPDATE quest_start_scripts SET datalong4=datalong3, datalong3=datalong2, datalong2=temp WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
ALTER TABLE quest_start_scripts CHANGE COLUMN datalong3 buddy_entry MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE quest_start_scripts CHANGE COLUMN datalong4 search_radius MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
UPDATE quest_start_scripts SET temp=0;
/* Chat*/
UPDATE quest_start_scripts SET temp=temp | 0x04 WHERE command=0 AND (data_flags & 0x02) > 0; -- target self
UPDATE quest_start_scripts SET temp=temp | 0x01 WHERE command=0 AND (data_flags & 0x04) > 0; -- buddy as target
UPDATE quest_start_scripts SET temp=temp | 0x10 WHERE command=0 AND (data_flags & 0x01) > 0; -- will produce error
-- Note that old flag 0x01 // flag_target_player_as_source 0x01 could not be converted automatically, need to check every script
/* Emote*/
UPDATE quest_start_scripts SET temp=temp | 0x02 WHERE command=1 AND (data_flags & 0x01 > 0) AND buddy_entry = 0; -- reverse order if no buddy defined
/*Summon */
UPDATE quest_start_scripts SET temp=temp | 0x08 WHERE command=10 AND (data_flags & 0x01 > 0); -- Summon as active
/* Remove Aura */
UPDATE quest_start_scripts SET temp=0x02 WHERE command=14 AND datalong2=1;
UPDATE quest_start_scripts SET datalong2=0 WHERE command=14;
/* Cast */
UPDATE quest_start_scripts SET temp=temp | 0x08 WHERE command=15 AND (datalong2 & 0x04 > 0); -- cast triggered
UPDATE quest_start_scripts SET temp=temp | 0x04 WHERE command=15 AND datalong2=0x01; -- s->t
UPDATE quest_start_scripts SET temp=temp | 0x06 WHERE command=15 AND datalong2=0x02; -- t->t
UPDATE quest_start_scripts SET temp=temp | 0x02 WHERE command=15 AND datalong2=0x03; -- t->s
UPDATE quest_start_scripts SET datalong2=0 WHERE command=15;
/* change faction */
UPDATE quest_start_scripts SET datalong2=data_flags WHERE command=22;
/* morph/ mount */
UPDATE quest_start_scripts SET temp=temp | 0x08 WHERE command IN (23, 24) AND (data_flags & 0x01 > 0); -- Summon as active
/* attack start */
UPDATE quest_start_scripts SET temp=temp | 0x03 WHERE command=26 AND data_flags=0x02; -- b->s
UPDATE quest_start_scripts SET temp=temp | 0x01 WHERE command=26 AND data_flags=0x04 AND buddy_entry!=0; -- s->b/t
UPDATE quest_start_scripts SET temp=temp | 0x14 WHERE command=26 AND data_flags=0x06 AND buddy_entry!=0; -- s->s -- Throw error, this would be unreasonable if buddy defined
UPDATE quest_start_scripts SET temp=temp | 0x04 WHERE command=26 AND data_flags=0x06 AND buddy_entry=0; -- s->s
/* stand state */
UPDATE quest_start_scripts SET temp=temp | 0x02 WHERE command=28 AND (data_flags & 0x01 > 0) AND buddy_entry=0;
/* change npc flag */
UPDATE quest_start_scripts SET datalong2=data_flags WHERE command=29;
UPDATE quest_start_scripts SET data_flags=temp;
ALTER TABLE quest_start_scripts DROP COLUMN temp;

View file

@ -0,0 +1,50 @@
ALTER TABLE db_version CHANGE COLUMN required_11940_06_mangos_quest_start_scripts required_11940_07_mangos_spell_scripts bit;
ALTER TABLE spell_scripts ADD COLUMN temp MEDIUMINT(8) DEFAULT 0 AFTER command;
-- Move datalong4 -> 2, 3 -> 4, 2 -> 3 (right shift)
UPDATE spell_scripts SET temp=datalong4 WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
UPDATE spell_scripts SET datalong4=datalong3, datalong3=datalong2, datalong2=temp WHERE command IN (0, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
ALTER TABLE spell_scripts CHANGE COLUMN datalong3 buddy_entry MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE spell_scripts CHANGE COLUMN datalong4 search_radius MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0';
UPDATE spell_scripts SET temp=0;
/* Chat*/
UPDATE spell_scripts SET temp=temp | 0x04 WHERE command=0 AND (data_flags & 0x02) > 0; -- target self
UPDATE spell_scripts SET temp=temp | 0x01 WHERE command=0 AND (data_flags & 0x04) > 0; -- buddy as target
UPDATE spell_scripts SET temp=temp | 0x10 WHERE command=0 AND (data_flags & 0x01) > 0; -- will produce error
-- Note that old flag 0x01 // flag_target_player_as_source 0x01 could not be converted automatically, need to check every script
/* Emote*/
UPDATE spell_scripts SET temp=temp | 0x02 WHERE command=1 AND (data_flags & 0x01 > 0) AND buddy_entry = 0; -- reverse order if no buddy defined
/*Summon */
UPDATE spell_scripts SET temp=temp | 0x08 WHERE command=10 AND (data_flags & 0x01 > 0); -- Summon as active
/* Remove Aura */
UPDATE spell_scripts SET temp=0x02 WHERE command=14 AND datalong2=1;
UPDATE spell_scripts SET datalong2=0 WHERE command=14;
/* Cast */
UPDATE spell_scripts SET temp=temp | 0x08 WHERE command=15 AND (datalong2 & 0x04 > 0); -- cast triggered
UPDATE spell_scripts SET temp=temp | 0x04 WHERE command=15 AND datalong2=0x01; -- s->t
UPDATE spell_scripts SET temp=temp | 0x06 WHERE command=15 AND datalong2=0x02; -- t->t
UPDATE spell_scripts SET temp=temp | 0x02 WHERE command=15 AND datalong2=0x03; -- t->s
UPDATE spell_scripts SET datalong2=0 WHERE command=15;
/* change faction */
UPDATE spell_scripts SET datalong2=data_flags WHERE command=22;
/* morph/ mount */
UPDATE spell_scripts SET temp=temp | 0x08 WHERE command IN (23, 24) AND (data_flags & 0x01 > 0); -- Summon as active
/* attack start */
UPDATE spell_scripts SET temp=temp | 0x03 WHERE command=26 AND data_flags=0x02; -- b->s
UPDATE spell_scripts SET temp=temp | 0x01 WHERE command=26 AND data_flags=0x04 AND buddy_entry!=0; -- s->b/t
UPDATE spell_scripts SET temp=temp | 0x14 WHERE command=26 AND data_flags=0x06 AND buddy_entry!=0; -- s->s -- Throw error, this would be unreasonable if buddy defined
UPDATE spell_scripts SET temp=temp | 0x04 WHERE command=26 AND data_flags=0x06 AND buddy_entry=0; -- s->s
/* stand state */
UPDATE spell_scripts SET temp=temp | 0x02 WHERE command=28 AND (data_flags & 0x01 > 0) AND buddy_entry=0;
/* change npc flag */
UPDATE spell_scripts SET datalong2=data_flags WHERE command=29;
UPDATE spell_scripts SET data_flags=temp;
ALTER TABLE spell_scripts DROP COLUMN temp;

File diff suppressed because it is too large Load diff

View file

@ -215,7 +215,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
PlayerList const& GetPlayers() const { return m_mapRefManager; }
//per-map script storage
void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target);
void ScriptsStart(ScriptMapMapName const& scripts, uint32 id, Object* source, Object* target);
void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target);
// must called with AddToWorld

View file

@ -8534,7 +8534,7 @@ void ObjectMgr::LoadGossipMenu(std::set<uint32>& gossipScriptSet)
// Check script-id
if (gMenu.script_id)
{
if (sGossipScripts.find(gMenu.script_id) == sGossipScripts.end())
if (sGossipScripts.second.find(gMenu.script_id) == sGossipScripts.second.end())
{
sLog.outErrorDb("Table gossip_menu for menu %u, text-id %u have script_id %u that does not exist in `gossip_scripts`, ignoring", gMenu.entry, gMenu.text_id, gMenu.script_id);
continue;
@ -8743,7 +8743,7 @@ void ObjectMgr::LoadGossipMenuItems(std::set<uint32>& gossipScriptSet)
if (gMenuItem.action_script_id)
{
if (sGossipScripts.find(gMenuItem.action_script_id) == sGossipScripts.end())
if (sGossipScripts.second.find(gMenuItem.action_script_id) == sGossipScripts.second.end())
{
sLog.outErrorDb("Table gossip_menu_option for menu %u, id %u have action_script_id %u that does not exist in `gossip_scripts`, ignoring", gMenuItem.menu_id, gMenuItem.id, gMenuItem.action_script_id);
continue;
@ -8780,7 +8780,7 @@ void ObjectMgr::LoadGossipMenus()
{
// Check which script-ids in gossip_scripts are not used
std::set<uint32> gossipScriptSet;
for (ScriptMapMap::const_iterator itr = sGossipScripts.begin(); itr != sGossipScripts.end(); ++itr)
for (ScriptMapMap::const_iterator itr = sGossipScripts.second.begin(); itr != sGossipScripts.second.end(); ++itr)
gossipScriptSet.insert(itr->first);
// Load gossip_menu and gossip_menu_option data

File diff suppressed because it is too large Load diff

View file

@ -40,73 +40,65 @@ class SpellCastTargets;
class Unit;
class WorldObject;
enum eScriptCommand
enum ScriptCommand // resSource, resTarget are the resulting Source/ Target after buddy search is done
{
SCRIPT_COMMAND_TALK = 0, // source = WorldObject, target = any/none, datalong (see enum ChatType for supported CHAT_TYPE_'s)
// datalong2 = creature entry (searching for a buddy, closest to source), datalong3 = creature search radius, datalong4 = language
// 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. dataint2-4 optional for random selected text.
SCRIPT_COMMAND_EMOTE = 1, // source = Unit (or WorldObject when creature entry defined), target = Unit (or none)
// datalong = emote_id
// datalong2 = creature entry (searching for a buddy, closest to source), datalong3 = creature search radius
// data_flags = flag_target_as_source = 0x01
SCRIPT_COMMAND_FIELD_SET = 2, // source = any, datalong = field_id, datalong2 = value
SCRIPT_COMMAND_MOVE_TO = 3, // source = Creature, datalong2 = time, x/y/z
SCRIPT_COMMAND_FLAG_SET = 4, // source = any, datalong = field_id, datalong2 = bitmask
SCRIPT_COMMAND_FLAG_REMOVE = 5, // source = any, datalong = field_id, datalong2 = bitmask
SCRIPT_COMMAND_TELEPORT_TO = 6, // source or target with Player, datalong = map_id, x/y/z
SCRIPT_COMMAND_QUEST_EXPLORED = 7, // one from source or target must be Player, another GO/Creature, datalong=quest_id, datalong2=distance or 0
SCRIPT_COMMAND_KILL_CREDIT = 8, // source or target with Player, datalong = creature entry, datalong2 = bool (0=personal credit, 1=group credit)
SCRIPT_COMMAND_RESPAWN_GAMEOBJECT = 9, // source = any (summoner), datalong=db_guid, datalong2=despawn_delay
SCRIPT_COMMAND_TEMP_SUMMON_CREATURE = 10, // source = any (summoner), datalong=creature entry, datalong2=despawn_delay
SCRIPT_COMMAND_OPEN_DOOR = 11, // source = unit, datalong=db_guid, datalong2=reset_delay
SCRIPT_COMMAND_CLOSE_DOOR = 12, // source = unit, datalong=db_guid, datalong2=reset_delay
SCRIPT_COMMAND_TALK = 0, // resSource = WorldObject, resTarget = Unit/none
// datalong1 (see enum ChatType for supported CHAT_TYPE_'s), datalong2 = language
// dataint = text entry from db_script_string -table. dataint2-4 optional for random selected texts.
SCRIPT_COMMAND_EMOTE = 1, // resSource = Unit, resTarget = Unit/none
// datalong1 = emote_id
SCRIPT_COMMAND_FIELD_SET = 2, // source = any, datalong3 = field_id, datalong2 = value
SCRIPT_COMMAND_MOVE_TO = 3, // resSource = Creature, datalong2 = time, x/y/z
SCRIPT_COMMAND_FLAG_SET = 4, // source = any, datalong3 = field_id, datalong2 = bitmask
SCRIPT_COMMAND_FLAG_REMOVE = 5, // source = any, datalong3 = field_id, datalong2 = bitmask
SCRIPT_COMMAND_TELEPORT_TO = 6, // source or target with Player, datalong2 = map_id, x/y/z
SCRIPT_COMMAND_QUEST_EXPLORED = 7, // one from source or target must be Player, another GO/Creature, datalong3=quest_id, datalong2=distance or 0
SCRIPT_COMMAND_KILL_CREDIT = 8, // source or target with Player, datalong3 = creature entry, datalong2 = bool (0=personal credit, 1=group credit)
SCRIPT_COMMAND_RESPAWN_GAMEOBJECT = 9, // source = any, datalong=db_guid, datalong2=despawn_delay
SCRIPT_COMMAND_TEMP_SUMMON_CREATURE = 10, // source = any, datalong=creature entry, datalong2=despawn_delay
// data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL = summon active
SCRIPT_COMMAND_OPEN_DOOR = 11, // datalong=db_guid (or not provided), datalong2=reset_delay
SCRIPT_COMMAND_CLOSE_DOOR = 12, // datalong=db_guid (or not provided), datalong2=reset_delay
SCRIPT_COMMAND_ACTIVATE_OBJECT = 13, // source = unit, target=GO
SCRIPT_COMMAND_REMOVE_AURA = 14, // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id
SCRIPT_COMMAND_CAST_SPELL = 15, // source/target cast spell at target/source
// datalong2: 0: s->t 1: s->s 2: t->t 3: t->s (this values in 2 bits), and 0x4 mask for cast triggered can be added to
SCRIPT_COMMAND_PLAY_SOUND = 16, // source = any object, target=any/player, datalong (sound_id), datalong2 (bitmask: 0/1=anyone/target, 0/2=with distance dependent, so 1|2 = 3 is target with distance dependent)
SCRIPT_COMMAND_CREATE_ITEM = 17, // source or target must be player, datalong = item entry, datalong2 = amount
SCRIPT_COMMAND_DESPAWN_SELF = 18, // source or target must be creature, datalong = despawn delay
SCRIPT_COMMAND_REMOVE_AURA = 14, // resSource = Unit, datalong = spell_id
SCRIPT_COMMAND_CAST_SPELL = 15, // resSource = Unit, cast spell at resTarget = Unit
// datalong=spellid
// data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL = cast triggered
SCRIPT_COMMAND_PLAY_SOUND = 16, // resSource = WorldObject, target=any/player, datalong (sound_id), datalong2 (bitmask: 0/1=anyone/target, 0/2=with distance dependent, so 1|2 = 3 is target with distance dependent)
SCRIPT_COMMAND_CREATE_ITEM = 17, // source or target must be player, datalong3 = item entry, datalong2 = amount
SCRIPT_COMMAND_DESPAWN_SELF = 18, // resSource = Creature, datalong = despawn delay
SCRIPT_COMMAND_PLAY_MOVIE = 19, // target can only be a player, datalog = movie id
SCRIPT_COMMAND_MOVEMENT = 20, // source or target must be creature. datalong = MovementType (0:idle, 1:random or 2:waypoint)
// datalong2 = creature entry (searching for a buddy, closest to source), datalong3 = creature search radius
SCRIPT_COMMAND_SET_ACTIVEOBJECT = 21, // source=any, target=creature
SCRIPT_COMMAND_MOVEMENT = 20, // resSource = Creature. datalong = MovementType (0:idle, 1:random or 2:waypoint)
SCRIPT_COMMAND_SET_ACTIVEOBJECT = 21, // resSource = Creature
// datalong=bool 0=off, 1=on
// datalong2=creature entry, datalong3=search radius
SCRIPT_COMMAND_SET_FACTION = 22, // source=any, target=creature
// datalong=factionId,
// datalong2=creature entry, datalong3=search radius
SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL = 23, // source=any, target=creature
// datalong=creature entry/modelid (depend on data_flags)
// datalong2=creature entry, datalong3=search radius
// dataflags= 0x01 to use datalong value as modelid explicit
SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL = 24, // source=any, target=creature
// datalong=creature entry/modelid (depend on data_flags)
// datalong2=creature entry, datalong3=search radius
// dataflags= 0x01 to use datalong value as modelid explicit
SCRIPT_COMMAND_SET_RUN = 25, // source=any, target=creature
SCRIPT_COMMAND_SET_FACTION = 22, // resSource = Creature
// datalong=factionId, datalong2=faction_flags
SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL = 23, // resSource = Creature, datalong=creature entry/modelid
// data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL = use datalong value as modelid explicit
SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL = 24, // resSource = Creature, datalong=creature entry/modelid
// data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL = use datalong value as modelid explicit
SCRIPT_COMMAND_SET_RUN = 25, // resSource = Creature
// datalong= bool 0=off, 1=on
// datalong2=creature entry, datalong3=search radius
SCRIPT_COMMAND_ATTACK_START = 26, // source = Creature (or WorldObject when creature entry are defined), target = Player
// datalong2 = creature entry (searching for a buddy, closest to source), datalong3 = creature search radius
SCRIPT_COMMAND_GO_LOCK_STATE = 27, // source or target must be WorldObject
SCRIPT_COMMAND_ATTACK_START = 26, // resSource = Creature, resTarget = Unit
SCRIPT_COMMAND_GO_LOCK_STATE = 27, // resSource = GameObject
// datalong= 1=lock, 2=unlock, 4=set not-interactable, 8=set interactable
// datalong2= go entry, datalong3= go search radius
SCRIPT_COMMAND_STAND_STATE = 28, // source = Unit (or WorldObject when creature entry defined), target = Unit (or none)
SCRIPT_COMMAND_STAND_STATE = 28, // resSource = Creature
// datalong = stand state (enum UnitStandStateType)
// datalong2 = creature entry (searching for a buddy, closest to source), datalong3 = creature search radius
// data_flags = flag_target_as_source = 0x01
SCRIPT_COMMAND_MODIFY_NPC_FLAGS = 29, // source=worldobject or target=worldobject (datalong1==0), else creature
SCRIPT_COMMAND_MODIFY_NPC_FLAGS = 29, // resSource = Creature
// datalong=NPCFlags
// datalong1=creature entry, datalong2=search radius
// data_flags = 0x01=add, 0x02=remove
// datalong2:0x00=toggle, 0x01=add, 0x02=remove
};
#define MAX_TEXT_ID 4 // used for SCRIPT_COMMAND_TALK
enum ScriptInfoDataFlags
{ // default: s/b -> t
SCRIPT_FLAG_BUDDY_AS_TARGET = 0x01, // s -> b
SCRIPT_FLAG_REVERSE_DIRECTION = 0x02, // t* -> s* (* result after previous flag is evaluated)
SCRIPT_FLAG_SOURCE_TARGETS_SELF = 0x04, // s* -> s* (* result after previous flag is evaluated)
SCRIPT_FLAG_COMMAND_ADDITIONAL = 0x08, // command dependend
};
struct ScriptInfo
{
uint32 id;
@ -118,20 +110,13 @@ struct ScriptInfo
struct // SCRIPT_COMMAND_TALK (0)
{
uint32 chatType; // datalong
uint32 creatureEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 language; // datalong4
uint32 flags; // data_flags
int32 textId[MAX_TEXT_ID]; // dataint to dataint4
uint32 language; // datalong2
} talk;
struct // SCRIPT_COMMAND_EMOTE (1)
{
uint32 emoteId; // datalong
uint32 creatureEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 unused1; // datalong4
uint32 flags; // data_flags
uint32 unused1; // datalong2
} emote;
struct // SCRIPT_COMMAND_FIELD_SET (2)
@ -161,6 +146,7 @@ struct ScriptInfo
struct // SCRIPT_COMMAND_TELEPORT_TO (6)
{
uint32 mapId; // datalong
uint32 empty; // datalong2
} teleportTo;
struct // SCRIPT_COMMAND_QUEST_EXPLORED (7)
@ -178,42 +164,38 @@ struct ScriptInfo
struct // SCRIPT_COMMAND_RESPAWN_GAMEOBJECT (9)
{
uint32 goGuid; // datalong
int32 despawnDelay; // datalong2
uint32 despawnDelay; // datalong2
} respawnGo;
struct // SCRIPT_COMMAND_TEMP_SUMMON_CREATURE (10)
{
uint32 creatureEntry; // datalong
uint32 despawnDelay; // datalong2
uint32 unused1; // datalong3
uint32 unused2; // datalong4
uint32 flags; // data_flags
} summonCreature;
struct // SCRIPT_COMMAND_OPEN_DOOR (11)
{
uint32 goGuid; // datalong
int32 resetDelay; // datalong2
} openDoor;
// SCRIPT_COMMAND_OPEN_DOOR (11)
struct // SCRIPT_COMMAND_CLOSE_DOOR (12)
{
uint32 goGuid; // datalong
int32 resetDelay; // datalong2
} closeDoor;
uint32 resetDelay; // datalong2
} changeDoor;
// SCRIPT_COMMAND_ACTIVATE_OBJECT (13)
struct // SCRIPT_COMMAND_ACTIVATE_OBJECT (13)
{
uint32 empty1; // datalong
uint32 empty2; // datalong;
} activateObject;
struct // SCRIPT_COMMAND_REMOVE_AURA (14)
{
uint32 spellId; // datalong
uint32 isSourceTarget; // datalong2
uint32 empty; // datalong2
} removeAura;
struct // SCRIPT_COMMAND_CAST_SPELL (15)
{
uint32 spellId; // datalong
uint32 flags; // datalong2
uint32 empty; // datalong2
} castSpell;
struct // SCRIPT_COMMAND_PLAY_SOUND (16)
@ -231,101 +213,88 @@ struct ScriptInfo
struct // SCRIPT_COMMAND_DESPAWN_SELF (18)
{
uint32 despawnDelay; // datalong
uint32 empty; // datalong2
} despawn;
struct // SCRIPT_COMMAND_PLAY_MOVIE (19)
{
uint32 movieId; // datalong
uint32 empty; // datalong2
} playMovie;
struct // SCRIPT_COMMAND_MOVEMENT (20)
{
uint32 movementType; // datalong
uint32 creatureEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 empty; // datalong2
} movement;
struct // SCRIPT_COMMAND_SET_ACTIVEOBJECT (21)
{
uint32 activate; // datalong
uint32 creatureEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 empty; // datalong2
} activeObject;
struct // SCRIPT_COMMAND_SET_FACTION (22)
{
uint32 factionId; // datalong
uint32 creatureEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 empty1; // datalong4
uint32 flags; // data_flags
uint32 flags; // datalong2
} faction;
struct // SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL (23)
{
uint32 creatureOrModelEntry; // datalong
uint32 creatureEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 empty1; // datalong4
uint32 flags; // data_flags
uint32 empty1; // datalong2
} morph;
struct // SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL (24)
{
uint32 creatureOrModelEntry; // datalong
uint32 creatureEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 empty1; // datalong4
uint32 flags; // data_flags
uint32 empty1; // datalong2
} mount;
struct // SCRIPT_COMMAND_SET_RUN (25)
{
uint32 run; // datalong
uint32 creatureEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 empty; // datalong2
} run;
struct // SCRIPT_COMMAND_ATTACK_START (26)
{
uint32 empty1; // datalong
uint32 creatureEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 empty2; // datalong4
uint32 flags; // data_flags
uint32 empty2; // datalong2
} attack;
struct // SCRIPT_COMMAND_GO_LOCK_STATE (27)
{
uint32 lockState; // datalong
uint32 goEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 empty; // datalong
} goLockState;
struct // SCRIPT_COMMAND_STAND_STATE (28)
{
uint32 stand_state; // datalong
uint32 creatureEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 unused1; // datalong4
uint32 flags; // data_flags
uint32 unused1; // datalong2
} standState;
struct // SCRIPT_COMMAND_MODIFY_NPC_FLAGS (29)
{
uint32 flag; // datalong
uint32 creatureEntry; // datalong2
uint32 searchRadius; // datalong3
uint32 empty1; // datalong4
uint32 data_flags; // data_flags
uint32 change_flag; // datalong2
} npcFlag;
struct
{
uint32 data[9];
uint32 data[2];
} raw;
};
// Buddy system (entry can be npc or go entry, depending on command)
uint32 buddyEntry; // datalong3 -> buddy_entry
uint32 searchRadius; // datalong4 -> search_radius
uint8 data_flags; // data_flags
int32 textId[MAX_TEXT_ID]; // dataint to dataint4
float x;
float y;
float z;
@ -334,34 +303,85 @@ struct ScriptInfo
// helpers
uint32 GetGOGuid() const
{
switch(command)
switch (command)
{
case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT: return respawnGo.goGuid;
case SCRIPT_COMMAND_OPEN_DOOR: return openDoor.goGuid;
case SCRIPT_COMMAND_CLOSE_DOOR: return closeDoor.goGuid;
default: return 0;
case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT:
return respawnGo.goGuid;
case SCRIPT_COMMAND_OPEN_DOOR:
case SCRIPT_COMMAND_CLOSE_DOOR:
return changeDoor.goGuid;
default:
return 0;
}
}
bool IsCreatureBuddy() const
{
switch (command)
{
case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT:
case SCRIPT_COMMAND_OPEN_DOOR:
case SCRIPT_COMMAND_CLOSE_DOOR:
case SCRIPT_COMMAND_ACTIVATE_OBJECT:
case SCRIPT_COMMAND_GO_LOCK_STATE:
return false;
default:
return true;
}
}
bool HasAdditionalScriptFlag() const
{
switch (command)
{
case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE:
case SCRIPT_COMMAND_CAST_SPELL:
case SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL:
case SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL:
return true;
default:
return false;
}
}
};
struct ScriptAction
class ScriptAction
{
ObjectGuid sourceGuid;
ObjectGuid targetGuid;
ObjectGuid ownerGuid; // owner of source if source is item
ScriptInfo const* script; // pointer to static script data
public:
ScriptAction(const char* _table, Map* _map, ObjectGuid _sourceGuid, ObjectGuid _targetGuid, ObjectGuid _ownerGuid, ScriptInfo const* _script) :
m_table(_table), m_map(_map), m_sourceGuid(_sourceGuid), m_targetGuid(_targetGuid), m_ownerGuid(_ownerGuid), m_script(_script)
{}
void HandleScriptStep();
private:
ObjectGuid m_sourceGuid;
ObjectGuid m_targetGuid;
ObjectGuid m_ownerGuid; // owner of source if source is item
const char* m_table; // of which table the script was started
ScriptInfo const* m_script; // pointer to static script data
Map* m_map; // Map on which the action will be executed
// Helper functions
bool GetScriptCommandObject(const ObjectGuid guid, bool includeItem, Object*& resultObject);
bool GetScriptProcessTargets(WorldObject* pOrigSource, WorldObject* pOrigTarget, WorldObject*& pFinalSource, WorldObject*& pFinalTarget);
bool LogIfNotCreature(WorldObject* pWorldObject);
bool LogIfNotUnit(WorldObject* pWorldObject);
bool LogIfNotGameObject(WorldObject* pWorldObject);
Player* GetPlayerTargetOrSourceAndLog(WorldObject* pSource, WorldObject* pTarget);
};
typedef std::multimap<uint32 /*delay*/, ScriptInfo> ScriptMap;
typedef std::map<uint32 /*id*/, ScriptMap > ScriptMapMap;
typedef std::pair<const char*, ScriptMapMap> ScriptMapMapName;
extern ScriptMapMap sQuestEndScripts;
extern ScriptMapMap sQuestStartScripts;
extern ScriptMapMap sSpellScripts;
extern ScriptMapMap sGameObjectScripts;
extern ScriptMapMap sEventScripts;
extern ScriptMapMap sGossipScripts;
extern ScriptMapMap sCreatureMovementScripts;
extern ScriptMapMapName sQuestEndScripts;
extern ScriptMapMapName sQuestStartScripts;
extern ScriptMapMapName sSpellScripts;
extern ScriptMapMapName sGameObjectScripts;
extern ScriptMapMapName sEventScripts;
extern ScriptMapMapName sGossipScripts;
extern ScriptMapMapName sCreatureMovementScripts;
enum ScriptLoadResult
{
@ -432,8 +452,8 @@ class ScriptMgr
bool OnAuraDummy(Aura const* pAura, bool apply);
private:
void LoadScripts(ScriptMapMap& scripts, const char* tablename);
void CheckScriptTexts(ScriptMapMap const& scripts, std::set<int32>& ids);
void LoadScripts(ScriptMapMapName& scripts, const char* tablename);
void CheckScriptTexts(ScriptMapMapName const& scripts, std::set<int32>& ids);
template<class T>
void GetScriptHookPtr(T& ptr, const char* name)

View file

@ -8164,6 +8164,10 @@ static ScriptInfo generateActivateCommand()
{
ScriptInfo si;
si.command = SCRIPT_COMMAND_ACTIVATE_OBJECT;
si.id = 0;
si.buddyEntry = 0;
si.searchRadius = 0;
si.data_flags = 0x00;
return si;
}

View file

@ -59,7 +59,7 @@ void WaypointManager::Load()
std::set<uint32> movementScriptSet;
for(ScriptMapMap::const_iterator itr = sCreatureMovementScripts.begin(); itr != sCreatureMovementScripts.end(); ++itr)
for(ScriptMapMap::const_iterator itr = sCreatureMovementScripts.second.begin(); itr != sCreatureMovementScripts.second.end(); ++itr)
movementScriptSet.insert(itr->first);
// creature_movement
@ -162,7 +162,7 @@ void WaypointManager::Load()
if (node.script_id)
{
if (sCreatureMovementScripts.find(node.script_id) == sCreatureMovementScripts.end())
if (sCreatureMovementScripts.second.find(node.script_id) == sCreatureMovementScripts.second.end())
{
sLog.outErrorDb("Table creature_movement for id %u, point %u have script_id %u that does not exist in `creature_movement_scripts`, ignoring", id, point, node.script_id);
continue;
@ -327,7 +327,7 @@ void WaypointManager::Load()
if (node.script_id)
{
if (sCreatureMovementScripts.find(node.script_id) == sCreatureMovementScripts.end())
if (sCreatureMovementScripts.second.find(node.script_id) == sCreatureMovementScripts.second.end())
{
sLog.outErrorDb("Table creature_movement_template for entry %u, point %u have script_id %u that does not exist in `creature_movement_scripts`, ignoring", entry, point, node.script_id);
continue;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11939"
#define REVISION_NR "11940"
#endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_11785_02_characters_instance"
#define REVISION_DB_MANGOS "required_11926_01_mangos_creature_template"
#define REVISION_DB_MANGOS "required_11940_07_mangos_spell_scripts"
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
#endif // __REVISION_SQL_H__