diff --git a/common/version.h b/common/version.h index 88f986807..bda89dd8c 100644 --- a/common/version.h +++ b/common/version.h @@ -32,7 +32,7 @@ #define CURRENT_BINARY_DATABASE_VERSION 9105 #ifdef BOTS - #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9008 + #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9009 #else #define CURRENT_BINARY_BOTS_DATABASE_VERSION 0 // must be 0 #endif diff --git a/utils/sql/git/bots/bots_db_update_manifest.txt b/utils/sql/git/bots/bots_db_update_manifest.txt index 3122545a0..d63c142c8 100644 --- a/utils/sql/git/bots/bots_db_update_manifest.txt +++ b/utils/sql/git/bots/bots_db_update_manifest.txt @@ -7,6 +7,7 @@ 9006|2016_04_12_bots_inventory_window.sql|SELECT `bot_command` FROM `bot_command_settings` WHERE `bot_command` LIKE 'inventorywindow'|empty| 9007|2016_06_23_bots_camel_case_name_rule.sql|SELECT * FROM `rule_values` WHERE `rule_name` LIKE 'Bots:AllowCamelCaseNames'|empty| 9008|2016_06_28_bots_inventory_charges_update.sql|SELECT * FROM `information_schema`.`COLUMNS` isc WHERE isc.`TABLE_SCHEMA` = DATABASE() AND isc.`TABLE_NAME` = 'bot_inventories' AND isc.`COLUMN_NAME` = 'inst_charges' AND isc.`DATA_TYPE` = 'tinyint'|not_empty| +9009|2017_02_15_bots_bot_spells_entries.sql|SELECT `id` FROM `npc_spells_entries` WHERE `npc_spells_id` >= 701 AND `npc_spells_id` <= 712|not_empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not diff --git a/utils/sql/git/bots/required/2017_02_15_bots_bot_spells_entries.sql b/utils/sql/git/bots/required/2017_02_15_bots_bot_spells_entries.sql new file mode 100644 index 000000000..c7d5087e6 --- /dev/null +++ b/utils/sql/git/bots/required/2017_02_15_bots_bot_spells_entries.sql @@ -0,0 +1,29 @@ +-- Delete any existing `bots_spells_entries` table +DROP TABLE IF EXISTS `bots_spells_entries`; + +-- Create new bot spells entries table (new table does not have spells_id_spellid constraint) +CREATE TABLE `bot_spells_entries` ( + `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `npc_spells_id` INT(11) NOT NULL DEFAULT '0', + `spellid` SMALLINT(5) NOT NULL DEFAULT '0', + `type` INT(10) UNSIGNED NOT NULL DEFAULT '0', + `minlevel` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0', + `maxlevel` TINYINT(3) UNSIGNED NOT NULL DEFAULT '255', + `manacost` SMALLINT(5) NOT NULL DEFAULT '-1', + `recast_delay` INT(11) NOT NULL DEFAULT '-1', + `priority` SMALLINT(5) NOT NULL DEFAULT '0', + `resist_adjust` INT(11) NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) +COLLATE='latin1_swedish_ci' +ENGINE=InnoDB +AUTO_INCREMENT=1 +; + +-- Copy bots spells into new table +INSERT INTO `bot_spells_entries` (`npc_spells_id`, `spellid`, `type`, `minlevel`, `maxlevel`, `manacost`, `recast_delay`, `priority`, `resist_adjust`) +SELECT `npc_spells_id`, `spellid`, `type`, `minlevel`, `maxlevel`, `manacost`, `recast_delay`, `priority`, `resist_adjust` +FROM `npc_spells_entries` WHERE `npc_spells_id` >= '701' AND `npc_spells_id` <= '712'; + +-- Delete bot spells from old table +DELETE FROM `npc_spells_entries` WHERE `npc_spells_id` >= '701' AND `npc_spells_id` <= '712'; diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 896709fc8..294247d59 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -2608,8 +2608,13 @@ DBnpcspells_Struct* ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) { query = StringFormat("SELECT spellid, type, minlevel, maxlevel, " "manacost, recast_delay, priority, resist_adjust " +#ifdef BOTS + "FROM %s " + "WHERE npc_spells_id=%d ORDER BY minlevel", (iDBSpellsID >= 701 && iDBSpellsID <= 712 ? "bot_spells_entries" : "npc_spells_entries"), iDBSpellsID); +#else "FROM npc_spells_entries " - "WHERE npc_spells_id=%d ORDER BY minlevel", iDBSpellsID); + "WHERE npc_spells_id=%d ORDER BY minlevel", iDBSpellsID); +#endif results = QueryDatabase(query); if (!results.Success())