Script and server code query updates for bots_updater

This commit is contained in:
Uleat 2015-10-09 21:34:31 -04:00
parent bcf2a5c852
commit ecd695ff9b
14 changed files with 1722 additions and 803 deletions

View File

@ -349,7 +349,7 @@ bool Database::DeleteCharacter(char *name) {
query = StringFormat("DELETE FROM `character_leadership_abilities` WHERE `id` = %u", charid); QueryDatabase(query);
query = StringFormat("DELETE FROM `character_alt_currency` WHERE `char_id` = '%d'", charid); QueryDatabase(query);
#ifdef BOTS
query = StringFormat("DELETE FROM `guild_members` WHERE `char_id` = '%d' AND GetMobTypeById(%i) = 'C'", charid);
query = StringFormat("DELETE FROM `guild_members` WHERE `char_id` = '%d' AND GetMobTypeById(%i) = 'C'", charid); // note: only use of GetMobTypeById()
#else
query = StringFormat("DELETE FROM `guild_members` WHERE `char_id` = '%d'", charid);
#endif

View File

@ -209,7 +209,6 @@ public:
/* Database Conversions 'database_conversions.cpp' */
bool CheckDatabaseConversions();
bool CheckDatabaseConvertBotsPostPPDeblob();
bool CheckDatabaseConvertCorpseDeblob();
bool CheckDatabaseConvertPPDeblob();

View File

@ -470,7 +470,6 @@ static inline void loadbar(unsigned int x, unsigned int n, unsigned int w = 50)
bool Database::CheckDatabaseConversions() {
CheckDatabaseConvertPPDeblob();
CheckDatabaseConvertBotsPostPPDeblob();
CheckDatabaseConvertCorpseDeblob();
/* Fetch Automatic Upgrade Script */
@ -1491,163 +1490,6 @@ bool Database::CheckDatabaseConvertPPDeblob(){
return true;
}
bool Database::CheckDatabaseConvertBotsPostPPDeblob(){
#ifdef BOTS
int runbotsconvert = 0;
/* Check For Legacy Bot References */
std::string rquery = StringFormat("SHOW CREATE VIEW `vwBotCharacterMobs`");
auto results = QueryDatabase(rquery);
if (results.RowCount() == 1){
auto row = results.begin();
std::string table_check = row[1];
if (table_check.find("character_data") == -1){
runbotsconvert = 1;
printf("\n\n::: Legacy Bot Views and Function Detected... \n");
printf("----------------------------------------------------------\n\n");
printf(" Database currently has bot view/function linkage to obselete \n");
printf(" table references and will now be converted...\n\n");
printf(" It is recommended that you backup your database \n");
printf(" before continuing the automatic conversion process...\n\n");
printf("----------------------------------------------------------\n\n");
std::cout << "Press ENTER to continue....." << std::endl << std::endl;
std::cin.ignore(1);
}
}
if (runbotsconvert == 1){
printf("Running bot views/function database conversion... \n");
/* Update view `vwbotcharactermobs` */
rquery = StringFormat("DROP VIEW `vwBotCharacterMobs`;");
results = QueryDatabase(rquery);
rquery = StringFormat(
"CREATE VIEW `vwBotCharacterMobs` AS\n"
"SELECT _utf8'C' AS mobtype,\n" // Natedog: '_utf8'
"c.`id`,\n"
"c.`name`,\n"
"c.`class`,\n"
"c.`level`,\n"
"c.`last_login`,\n"
"c.`zone_id`\n"
"FROM `character_data` AS c\n"
"UNION ALL\n"
"SELECT _utf8'B' AS mobtype,\n" // Natedog: '_utf8'
"b.`BotID` AS id,\n"
"b.`Name` AS name,\n"
"b.`Class` AS class,\n"
"b.`BotLevel` AS level,\n"
"0 AS timelaston,\n"
"0 AS zoneid\n"
"FROM bots AS b;"
);
results = QueryDatabase(rquery);
/* Update function `GetMobType` */
rquery = StringFormat("DROP FUNCTION IF EXISTS `GetMobType`;");
results = QueryDatabase(rquery);
rquery = StringFormat(
"CREATE FUNCTION `GetMobType` (mobname VARCHAR(64)) RETURNS CHAR(1)\n"
"BEGIN\n"
" DECLARE Result CHAR(1);\n"
"\n"
" SET Result = NULL;\n"
"\n"
" IF (SELECT COUNT(*) FROM `character_data` WHERE `name` = mobname) > 0 THEN\n"
" SET Result = 'C';\n"
" ELSEIF (SELECT COUNT(*) FROM `bots` WHERE `Name` = mobname) > 0 THEN\n"
" SET Result = 'B';\n"
" END IF;\n "
"\n"
" RETURN Result;\n"
"END"
);
results = QueryDatabase(rquery);
/* Update view `vwgroups` */
rquery = StringFormat("DROP VIEW IF EXISTS `vwGroups`;");
results = QueryDatabase(rquery);
rquery = StringFormat(
"CREATE VIEW `vwGroups` AS\n"
"SELECT g.`groupid` AS groupid,\n"
"GetMobType(g.`name`) AS mobtype,\n"
"g.`name` AS name,\n"
"g.`charid` AS mobid,\n"
"IFNULL(c.`level`, b.`BotLevel`) AS level\n"
"FROM `group_id` AS g\n"
"LEFT JOIN `character_data` AS c ON g.`name` = c.`name`\n"
"LEFT JOIN `bots` AS b ON g.`name` = b.`Name`;"
);
results = QueryDatabase(rquery);
/* Update view `vwbotgroups` */
rquery = StringFormat("DROP VIEW IF EXISTS `vwBotGroups`;");
results = QueryDatabase(rquery);
rquery = StringFormat(
"CREATE VIEW `vwBotGroups` AS\n"
"SELECT g.`BotGroupId`,\n"
"g.`BotGroupName`,\n"
"g.`BotGroupLeaderBotId`,\n"
"b.`Name` AS BotGroupLeaderName,\n"
"b.`BotOwnerCharacterId`,\n"
"c.`name` AS BotOwnerCharacterName\n"
"FROM `botgroup` AS g\n"
"JOIN `bots` AS b ON g.`BotGroupLeaderBotId` = b.`BotID`\n"
"JOIN `character_data` AS c ON b.`BotOwnerCharacterID` = c.`id`\n"
"ORDER BY b.`BotOwnerCharacterId`, g.`BotGroupName`;"
);
results = QueryDatabase(rquery);
/* Update view `vwguildmembers` */
rquery = StringFormat("DROP VIEW IF EXISTS `vwGuildMembers`;");
results = QueryDatabase(rquery);
rquery = StringFormat(
"CREATE VIEW `vwGuildMembers` AS\n"
"SELECT 'C' AS mobtype,\n"
"cm.`char_id`,\n"
"cm.`guild_id`,\n"
"cm.`rank`,\n"
"cm.`tribute_enable`,\n"
"cm.`total_tribute`,\n"
"cm.`last_tribute`,\n"
"cm.`banker`,\n"
"cm.`public_note`,\n"
"cm.`alt`\n"
"FROM `guild_members` AS cm\n"
"UNION ALL\n"
"SELECT 'B' AS mobtype,\n"
"bm.`char_id`,\n"
"bm.`guild_id`,\n"
"bm.`rank`,\n"
"bm.`tribute_enable`,\n"
"bm.`total_tribute`,\n"
"bm.`last_tribute`,\n"
"bm.`banker`,\n"
"bm.`public_note`,\n"
"bm.`alt`\n"
"FROM `botguildmembers` AS bm;"
);
results = QueryDatabase(rquery);
}
if (runbotsconvert == 1){
printf("\n\nBot views/function conversion complete, continuing world bootup...\n");
}
#endif
return true;
}
bool Database::CheckDatabaseConvertCorpseDeblob(){
Convert::DBPlayerCorpse_Struct_temp* dbpc;
Convert::classic_db_temp::DBPlayerCorpse_Struct_temp* dbpc_c;

View File

@ -867,16 +867,16 @@ bool BaseGuildManager::QueryWithLogging(std::string query, const char *errmsg) {
//factored out so I dont have to copy this crap.
#ifdef BOTS
#define GuildMemberBaseQuery \
"SELECT c.id,c.name,c.class,c.level,c.last_login,c.zone_id," \
" g.guild_id,g.rank,g.tribute_enable,g.total_tribute,g.last_tribute," \
" g.banker,g.public_note,g.alt" \
" FROM vwBotCharacterMobs AS c LEFT JOIN vwGuildMembers AS g ON c.id=g.char_id AND c.mobtype = g.mobtype "
"SELECT c.`id`, c.`name`, c.`class`, c.`level`, c.`last_login`, c.`zone_id`," \
" g.`guild_id`, g.`rank`, g.`tribute_enable`, g.`total_tribute`, g.`last_tribute`," \
" g.`banker`, g.`public_note`, g.`alt`" \
" FROM `vw_bot_character_mobs` AS c LEFT JOIN `vw_guild_members` AS g ON c.`id` = g.`char_id` AND c.`mob_type` = g.`mob_type` "
#else
#define GuildMemberBaseQuery \
"SELECT c.id,c.name,c.class,c.level,c.last_login,c.zone_id," \
" g.guild_id,g.rank,g.tribute_enable,g.total_tribute,g.last_tribute," \
" g.banker,g.public_note,g.alt " \
" FROM `character_data` AS c LEFT JOIN guild_members AS g ON c.id=g.char_id "
"SELECT c.`id`, c.`name`, c.`class`, c.`level`, c.`last_login`, c.`zone_id`," \
" g.`guild_id`, g.`rank`, g.`tribute_enable`, g.`total_tribute`, g.`last_tribute`," \
" g.`banker`, g.`public_note`, g.`alt` " \
" FROM `character_data` AS c LEFT JOIN `guild_members` AS g ON c.`id` = g.`char_id` "
#endif
static void ProcessGuildMember(MySQLRequestRow row, CharGuildInfo &into) {
//fields from `characer_`

View File

@ -502,16 +502,16 @@ RULE_CATEGORY_END()
#ifdef BOTS
RULE_CATEGORY(Bots)
RULE_REAL(Bots, BotManaRegen, 2.0) // Adjust mana regen for bots, 1 is fast and higher numbers slow it down 3 is about the same as players.
RULE_BOOL(Bots, BotFinishBuffing, false) // Allow for buffs to complete even if the bot caster is out of mana. Only affects buffing out of combat.
RULE_INT(Bots, CreateBotCount, 150) // Number of bots that each account can create
RULE_INT(Bots, SpawnBotCount, 71) // Number of bots a character can have spawned at one time, You + 71 bots is a 12 group raid
RULE_BOOL(Bots, BotQuest, false) // Optional quest method to manage bot spawn limits using the quest_globals name bot_spawn_limit, see: /bazaar/Aediles_Thrall.pl
RULE_BOOL(Bots, BotGroupBuffing, false) // Bots will cast single target buffs as group buffs, default is false for single. Does not make single target buffs work for MGB.
RULE_BOOL(Bots, BotSpellQuest, false) // Anita Thrall's (Anita_Thrall.pl) Bot Spell Scriber quests.
RULE_INT(Bots, BotAAExpansion, 8) // Bots get AAs through this expansion
RULE_INT(Bots, AAExpansion, 8) // Bots get AAs through this expansion
RULE_INT(Bots, CreationLimit, 150) // Number of bots that each account can create
RULE_BOOL(Bots, FinishBuffing, false) // Allow for buffs to complete even if the bot caster is out of mana. Only affects buffing out of combat.
RULE_BOOL(Bots, GroupBuffing, false) // Bots will cast single target buffs as group buffs, default is false for single. Does not make single target buffs work for MGB.
RULE_REAL(Bots, ManaRegen, 2.0) // Adjust mana regen for bots, 1 is fast and higher numbers slow it down 3 is about the same as players.
RULE_BOOL(Bots, QuestableSpawnLimit, false) // Optional quest method to manage bot spawn limits using the quest_globals name bot_spawn_limit, see: /bazaar/Aediles_Thrall.pl
RULE_BOOL(Bots, QuestableSpells, false) // Anita Thrall's (Anita_Thrall.pl) Bot Spell Scriber quests.
RULE_INT(Bots, SpawnLimit, 71) // Number of bots a character can have spawned at one time, You + 71 bots is a 12 group raid
RULE_BOOL(Bots, BotGroupXP, false) // Determines whether client gets xp for bots outside their group.
RULE_BOOL(Bots, BotBardUseOutOfCombatSongs, true) // Determines whether bard bots use additional out of combat songs.
RULE_BOOL(Bots, BotBardUseOutOfCombatSongs, true) // Determines whether bard bots use additional out of combat songs (optional script)
RULE_BOOL(Bots, BotLevelsWithOwner, false) // Auto-updates spawned bots as owner levels/de-levels (false is original behavior)
RULE_BOOL(Bots, BotCharacterLevelEnabled, false) // Enables required level to spawn bots
RULE_INT(Bots, BotCharacterLevel, 0) // 0 as default (if level > this value you can spawn bots if BotCharacterLevelEnabled is true)

View File

@ -2007,24 +2007,21 @@ void SharedDatabase::SaveCharacterInspectMessage(uint32 character_id, const Insp
auto results = QueryDatabase(query);
}
void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message) {
std::string query = StringFormat("SELECT BotInspectMessage FROM bots WHERE BotID = %i", botid);
#ifdef BOTS
void SharedDatabase::GetBotInspectMessage(uint32 bot_id, InspectMessage_Struct* message)
{
std::string query = StringFormat("SELECT `inspect_message` FROM `bot_inspect_messages` WHERE `bot_id` = %i LIMIT 1", bot_id);
auto results = QueryDatabase(query);
if (!results.Success()) {
return;
}
if (results.RowCount() != 1)
return;
auto row = results.begin();
memset(message, '\0', sizeof(InspectMessage_Struct));
for (auto row = results.begin(); row != results.end(); ++row) {
memcpy(message, row[0], sizeof(InspectMessage_Struct));
}
}
void SharedDatabase::SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message) {
std::string msg = EscapeString(message->text);
std::string query = StringFormat("UPDATE bots SET BotInspectMessage = '%s' WHERE BotID = %i", msg.c_str(), botid);
QueryDatabase(query);
void SharedDatabase::SetBotInspectMessage(uint32 bot_id, const InspectMessage_Struct* message)
{
std::string query = StringFormat("REPLACE INTO `bot_inspect_messages` (bot_id, inspect_message) VALUES (%u, '%s')", bot_id, EscapeString(message->text).c_str());
auto results = QueryDatabase(query);
}
#endif

View File

@ -51,8 +51,6 @@ class SharedDatabase : public Database
int32 DeleteStalePlayerCorpses();
void LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message);
void SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message);
void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message);
void SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message);
bool GetCommandSettings(std::map<std::string, uint8> &commands);
uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID);
@ -128,6 +126,11 @@ class SharedDatabase : public Database
void LoadBaseData(void *data, int max_level);
const BaseDataStruct* GetBaseData(int lvl, int cl);
#ifdef BOTS
void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message);
void SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message);
#endif
protected:
std::unique_ptr<EQEmu::MemoryMappedFile> skill_caps_mmf;

View File

@ -1,4 +1,4 @@
9000|2015_09_30_bots.sql|SHOW TABLES LIKE 'bot%'|empty|
9000|2015_09_30_bots.sql|SHOW TABLES LIKE 'bot_data'|empty|
# Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not

View File

@ -0,0 +1,88 @@
-- 'drop_bots (pre-update script)' sql script file
-- current as of 10/09/2015
--
-- Note: This file will remove bot schema loaded by 'load_bots' sql scripts.
-- There may still be remnants of bot activity in tables `guild_members` and
-- `group_id`. If these entries are causing issues, you may need to manually
-- remove them.
SELECT "dropping views...";
DROP VIEW IF EXISTS `vwGuildMembers`;
DROP VIEW IF EXISTS `vwGroups`;
DROP VIEW IF EXISTS `vwBotGroups`;
DROP VIEW IF EXISTS `vwBotCharacterMobs`;
SELECT "dropping functions...";
DROP FUNCTION IF EXISTS `GetMobTypeByName`;
DROP FUNCTION IF EXISTS `GetMobTypeByID`;
DROP FUNCTION IF EXISTS `GetMobType`;
SELECT "dropping tables...";
DROP TABLE IF EXISTS `botguildmembers`;
DROP TABLE IF EXISTS `botgroupmembers`;
DROP TABLE IF EXISTS `botgroup`;
DROP TABLE IF EXISTS `botgroups`; -- this table is not a part of 'load_bots.sql'
DROP TABLE IF EXISTS `botpetinventory`;
DROP TABLE IF EXISTS `botpetbuffs`;
DROP TABLE IF EXISTS `botpets`;
DROP TABLE IF EXISTS `botinventory`;
DROP TABLE IF EXISTS `botbuffs`;
DROP TABLE IF EXISTS `bottimers`;
DROP TABLE IF EXISTS `botstances`;
DROP TABLE IF EXISTS `bots`;
DROP PROCEDURE IF EXISTS `DropBotsSchema`;
DELIMITER $$
CREATE PROCEDURE `DropBotsSchema` ()
BEGIN
SELECT "deleting rules...";
DELETE FROM `rule_values` WHERE `rule_name` LIKE 'Bots%';
SELECT "deleting command...";
DELETE FROM `commands` WHERE `command` LIKE 'bot';
SELECT "restoring keys...";
IF ((SELECT COUNT(*) FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'group_id' AND `CONSTRAINT_NAME` = 'PRIMARY') > 0) THEN
-- IF ((SHOW KEYS IN `group_id` WHERE `Key_name` LIKE 'PRIMARY') != '') THEN
ALTER TABLE `group_id` DROP PRIMARY KEY;
END IF;
ALTER TABLE `group_id` ADD PRIMARY KEY (`groupid`, `charid`, `ismerc`);
IF ((SELECT COUNT(*) FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'guild_members' AND `CONSTRAINT_NAME` = 'PRIMARY') > 0) THEN
-- IF ((SHOW KEYS IN `guild_members` WHERE `Key_name` LIKE 'PRIMARY') != '') THEN
ALTER TABLE `guild_members` DROP PRIMARY KEY;
END IF;
ALTER TABLE `guild_members` ADD PRIMARY KEY (`char_id`);
SELECT "de-activating spawns...";
UPDATE `spawn2` SET `enabled` = 0 WHERE `id` IN (59297,59298);
SELECT "clearing database version...";
IF ((SELECT COUNT(*) FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'db_version' AND `COLUMN_NAME` = 'bots_version') > 0) THEN
-- IF ((SHOW COLUMNS FROM `db_version` LIKE 'bots_version') != '') THEN
UPDATE `db_version`
SET `bots_version` = 0;
END IF;
END$$
DELIMITER ;
CALL `DropBotsSchema`();
SELECT "dropping procedure...";
DROP PROCEDURE IF EXISTS `DropBotsSchema`;
-- End of File

View File

@ -1,41 +1,100 @@
-- 'drop_bots' sql script file
-- current as of 10/15/2014
-- current as of 10/09/2015
--
-- Note: This file will revert all changes made by either 'load_bots' sql file.
-- Note: This file will remove bot schema loaded by 'load_bots' sql scripts.
-- There may still be remnants of bot activity in tables `guild_members` and
-- `group_id`. If these entries are causing issues, you may need to manually
-- remove them.
--
-- If this script fails due to a 'SQL Error (1068): Multiple primary key defined'
-- error, run this query: ALTER TABLE `guild_members` DROP PRIMARY KEY;
-- and it should remove the key so this script will process in its entirety.
ALTER TABLE `guild_members` ADD PRIMARY KEY (`char_id`);
ALTER TABLE `group_id` DROP PRIMARY KEY, ADD PRIMARY KEY (`groupid`, `charid`, `ismerc`);
SELECT "dropping views...";
DROP VIEW IF EXISTS `vw_guild_members`;
DROP VIEW IF EXISTS `vw_groups`;
DROP VIEW IF EXISTS `vw_bot_groups`;
DROP VIEW IF EXISTS `vw_bot_character_mobs`;
UPDATE `spawn2` SET `enabled` = 0 WHERE `id` IN (59297,59298);
DELETE FROM `commands` WHERE `command` = 'bot';
DELETE FROM `rule_values` WHERE `rule_name` LIKE 'Bots%';
DROP VIEW IF EXISTS `vwBotCharacterMobs`;
DROP VIEW IF EXISTS `vwBotGroups`;
DROP VIEW IF EXISTS `vwGroups`;
DROP VIEW IF EXISTS `vwGuildMembers`;
SELECT "dropping functions...";
DROP FUNCTION IF EXISTS `GetMobTypeByName`;
DROP FUNCTION IF EXISTS `GetMobTypeByID`;
DROP FUNCTION IF EXISTS `GetMobType`;
DROP TABLE IF EXISTS `botguildmembers`;
DROP TABLE IF EXISTS `botgroupmembers`;
-- this table is not a part of 'load_bots.sql'
DROP TABLE IF EXISTS `botgroups`;
DROP TABLE IF EXISTS `botgroup`;
DROP TABLE IF EXISTS `botpetinventory`;
DROP TABLE IF EXISTS `botpetbuffs`;
DROP TABLE IF EXISTS `botpets`;
DROP TABLE IF EXISTS `botinventory`;
DROP TABLE IF EXISTS `botbuffs`;
DROP TABLE IF EXISTS `bottimers`;
DROP TABLE IF EXISTS `botstances`;
DROP TABLE IF EXISTS `bots`;
SELECT "dropping tables...";
DROP TABLE IF EXISTS `botguildmembers_old`;
DROP TABLE IF EXISTS `botgroupmembers_old`;
DROP TABLE IF EXISTS `botgroup_old`;
DROP TABLE IF EXISTS `botpetinventory_old`;
DROP TABLE IF EXISTS `botpetbuffs_old`;
DROP TABLE IF EXISTS `botpets_old`;
DROP TABLE IF EXISTS `botinventory_old`;
DROP TABLE IF EXISTS `botbuffs_old`;
DROP TABLE IF EXISTS `bottimers_old`;
DROP TABLE IF EXISTS `botstances_old`;
DROP TABLE IF EXISTS `bots_old`;
DROP TABLE IF EXISTS `bot_guild_members`;
DROP TABLE IF EXISTS `bot_group_members`;
DROP TABLE IF EXISTS `bot_groups`;
DROP TABLE IF EXISTS `bot_pet_inventories`;
DROP TABLE IF EXISTS `bot_pet_buffs`;
DROP TABLE IF EXISTS `bot_pets`;
DROP TABLE IF EXISTS `bot_inventories`;
DROP TABLE IF EXISTS `bot_buffs`;
DROP TABLE IF EXISTS `bot_timers`;
DROP TABLE IF EXISTS `bot_stances`;
DROP TABLE IF EXISTS `bot_inspect_messages`;
DROP TABLE IF EXISTS `bot_data`;
DROP PROCEDURE IF EXISTS `DropBotsSchema`;
DELIMITER $$
CREATE PROCEDURE `DropBotsSchema` ()
BEGIN
SELECT "deleting rules...";
DELETE FROM `rule_values` WHERE `rule_name` LIKE 'Bots%';
SELECT "deleting command...";
DELETE FROM `commands` WHERE `command` LIKE 'bot';
SELECT "restoring keys...";
IF ((SELECT COUNT(*) FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'group_id' AND `CONSTRAINT_NAME` = 'PRIMARY') > 0) THEN
-- IF ((SHOW KEYS IN `group_id` WHERE `Key_name` LIKE 'PRIMARY') != '') THEN
ALTER TABLE `group_id` DROP PRIMARY KEY;
END IF;
ALTER TABLE `group_id` ADD PRIMARY KEY (`groupid`, `charid`, `ismerc`);
IF ((SELECT COUNT(*) FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'guild_members' AND `CONSTRAINT_NAME` = 'PRIMARY') > 0) THEN
-- IF ((SHOW KEYS IN `guild_members` WHERE `Key_name` LIKE 'PRIMARY') != '') THEN
ALTER TABLE `guild_members` DROP PRIMARY KEY;
END IF;
ALTER TABLE `guild_members` ADD PRIMARY KEY (`char_id`);
SELECT "de-activating spawns...";
UPDATE `spawn2` SET `enabled` = 0 WHERE `id` IN (59297,59298);
SELECT "clearing database version...";
IF ((SELECT COUNT(*) FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'db_version' AND `COLUMN_NAME` = 'bots_version') > 0) THEN
-- IF ((SHOW COLUMNS FROM `db_version` LIKE 'bots_version') != '') THEN
UPDATE `db_version`
SET `bots_version` = 0;
END IF;
END$$
DELIMITER ;
CALL `DropBotsSchema`();
SELECT "dropping procedure...";
DROP PROCEDURE IF EXISTS `DropBotsSchema`;
-- End of File

View File

@ -1,188 +1,618 @@
-- 'load_bots' sql script file
-- current as of 10/15/2014
-- '2015_09_30_bots' sql script file
-- current as of 10/09/2015
--
-- Use this file on databases where the player profile blob has been converted.
--
-- Note: This file assumes a database free of bot remnants. If you have a prior
-- bot installation and wish to reload the default schema and entries, then
-- source 'drop_bots.sql' before sourcing this file.
-- Use eqemu_update.pl to administer this script
ALTER TABLE `guild_members` DROP PRIMARY KEY;
ALTER TABLE `group_id` DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(`groupid`, `charid`, `name`, `ismerc`);
-- Clean-up
DROP VIEW IF EXISTS `vwBotCharacterMobs`;
DROP VIEW IF EXISTS `vwBotGroups`;
DROP VIEW IF EXISTS `vwGroups`;
DROP VIEW IF EXISTS `vwGuildMembers`;
DROP VIEW IF EXISTS `vw_bot_character_mobs`;
DROP VIEW IF EXISTS `vw_bot_groups`;
DROP VIEW IF EXISTS `vw_groups`;
DROP VIEW IF EXISTS `vw_guild_members`;
DROP FUNCTION IF EXISTS `GetMobType`;
DROP FUNCTION IF EXISTS `GetMobTypeByName`;
DROP FUNCTION IF EXISTS `GetMobTypeByID`;
DROP PROCEDURE IF EXISTS `LoadBotsSchema`;
DELIMITER $$
CREATE PROCEDURE `LoadBotsSchema` ()
BEGIN
-- Activate
UPDATE `spawn2` SET `enabled` = 1 WHERE `id` IN (59297,59298);
-- old command kept for reference (`commands` now only has 2 columns - `command` and `access`)
-- INSERT INTO `commands` VALUES ('bot', '0', 'Type \"#bot help\" to the see the list of available commands for bots.');
-- Alter
IF ((SELECT COUNT(*) FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'guild_members' AND `CONSTRAINT_NAME` = 'PRIMARY') > 0) THEN
-- IF ((SHOW KEYS IN `guild_members` WHERE `Key_name` LIKE 'PRIMARY') != '') THEN
ALTER TABLE `guild_members` DROP PRIMARY KEY;
END IF;
IF ((SELECT COUNT(*) FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'group_id' AND `CONSTRAINT_NAME` = 'PRIMARY') > 0) THEN
-- IF ((SHOW KEYS IN `group_id` WHERE `Key_name` LIKE 'PRIMARY') != '') THEN
ALTER TABLE `group_id` DROP PRIMARY KEY;
END IF;
ALTER TABLE `group_id` ADD PRIMARY KEY USING BTREE(`groupid`, `charid`, `name`, `ismerc`);
--
-- From original bots.sql (for reference)
-- ALTER TABLE `group_id` DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(`groupid`, `charid`, `name`);
-- ALTER TABLE `guild_members` DROP PRIMARY KEY;
-- ALTER TABLE `group_id` ADD UNIQUE INDEX `U_group_id_1`(`name`);
-- ALTER TABLE `group_leaders` ADD UNIQUE INDEX `U_group_leaders_1`(`leadername`);
-- Commands
IF ((SELECT COUNT(`command`) FROM `commands` WHERE `command` LIKE 'bot') = 0) THEN
INSERT INTO `commands` VALUES ('bot', '0');
END IF;
INSERT INTO `rule_values` VALUES
('1', 'Bots:BotAAExpansion', '8', 'The expansion through which bots will obtain AAs'),
('1', 'Bots:BotFinishBuffing', 'false', 'Allow for buffs to complete even if the bot caster is out of mana. Only affects buffing out of combat.'),
('1', 'Bots:BotGroupBuffing', 'false', 'Bots will cast single target buffs as group buffs, default is false for single. Does not make single target buffs work for MGB.'),
('1', 'Bots:BotManaRegen', '3.0', 'Adjust mana regen for bots, 1 is fast and higher numbers slow it down 3 is about the same as players.'),
('1', 'Bots:BotQuest', 'false', 'Optional quest method to manage bot spawn limits using the quest_globals name bot_spawn_limit, see: /bazaar/Aediles_Thrall.pl'),
('1', 'Bots:BotSpellQuest', 'false', 'Anita Thrall\'s (Anita_Thrall.pl) Bot Spell Scriber quests.'),
('1', 'Bots:CreateBotCount', '150', 'Number of bots that each account can create'),
('1', 'Bots:SpawnBotCount', '71', 'Number of bots a character can have spawned at one time, You + 71 bots is a 12 group raid');
CREATE TABLE `bots` (
`BotID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`BotOwnerCharacterID` INT(10) UNSIGNED NOT NULL,
`BotSpellsID` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`Name` VARCHAR(64) NOT NULL,
`LastName` VARCHAR(32) DEFAULT NULL,
`BotLevel` TINYINT(2) UNSIGNED NOT NULL DEFAULT '0',
`Race` SMALLINT(5) NOT NULL DEFAULT '0',
`Class` TINYINT(2) NOT NULL DEFAULT '0',
`Gender` TINYINT(2) NOT NULL DEFAULT '0',
`Size` FLOAT NOT NULL DEFAULT '0',
`Face` INT(10) NOT NULL DEFAULT '1',
`LuclinHairStyle` INT(10) NOT NULL DEFAULT '1',
`LuclinHairColor` INT(10) NOT NULL DEFAULT '1',
`LuclinEyeColor` INT(10) NOT NULL DEFAULT '1',
`LuclinEyeColor2` INT(10) NOT NULL DEFAULT '1',
`LuclinBeardColor` INT(10) NOT NULL DEFAULT '1',
`LuclinBeard` INT(10) NOT NULL DEFAULT '0',
`DrakkinHeritage` INT(10) NOT NULL DEFAULT '0',
`DrakkinTattoo` INT(10) NOT NULL DEFAULT '0',
`DrakkinDetails` INT(10) NOT NULL DEFAULT '0',
`HP` INTEGER NOT NULL DEFAULT '0',
`Mana` INTEGER NOT NULL DEFAULT '0',
`MR` SMALLINT(5) NOT NULL DEFAULT '0',
`CR` SMALLINT(5) NOT NULL DEFAULT '0',
`DR` SMALLINT(5) NOT NULL DEFAULT '0',
`FR` SMALLINT(5) NOT NULL DEFAULT '0',
`PR` SMALLINT(5) NOT NULL DEFAULT '0',
`Corrup` SMALLINT(5) NOT NULL DEFAULT '0',
`AC` SMALLINT(5) NOT NULL DEFAULT '0',
`STR` MEDIUMINT(8) NOT NULL DEFAULT '75',
`STA` MEDIUMINT(8) NOT NULL DEFAULT '75',
`DEX` MEDIUMINT(8) NOT NULL DEFAULT '75',
`AGI` MEDIUMINT(8) NOT NULL DEFAULT '75',
`_INT` MEDIUMINT(8) NOT NULL DEFAULT '80',
`WIS` MEDIUMINT(8) NOT NULL DEFAULT '75',
`CHA` MEDIUMINT(8) NOT NULL DEFAULT '75',
`ATK` MEDIUMINT(9) NOT NULL DEFAULT '0',
`BotCreateDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`LastSpawnDate` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`TotalPlayTime` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`LastZoneId` SMALLINT(6) NOT NULL DEFAULT '0',
`BotInspectMessage` VARCHAR(256) NOT NULL DEFAULT '',
PRIMARY KEY (`BotID`)
-- Rules
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotAAExpansion') > 0) THEN
UPDATE `rule_values` SET `rule_name` = 'Bots:AAExpansion' WHERE `rule_name` LIKE 'Bots:BotAAExpansion';
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:AAExpansion') = 0) THEN
INSERT INTO `rule_values` VALUES ('1', 'Bots:AAExpansion', '8', 'The expansion through which bots will obtain AAs');
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:CreateBotCount') > 0) THEN
UPDATE `rule_values` SET `rule_name` = 'Bots:CreationLimit' WHERE `rule_name` LIKE 'Bots:CreateBotCount';
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:CreationLimit') = 0) THEN
INSERT INTO `rule_values` VALUES ('1', 'Bots:CreationLimit', '150', 'Number of bots that each account can create');
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotFinishBuffing') > 0) THEN
UPDATE `rule_values` SET `rule_name` = 'Bots:FinishBuffing' WHERE `rule_name` LIKE 'Bots:BotFinishBuffing';
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:FinishBuffing') = 0) THEN
INSERT INTO `rule_values` VALUES ('1', 'Bots:FinishBuffing', 'false', 'Allow for buffs to complete even if the bot caster is out of mana. Only affects buffing out of combat.');
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotGroupBuffing') > 0) THEN
UPDATE `rule_values` SET `rule_name` = 'Bots:GroupBuffing' WHERE `rule_name` LIKE 'Bots:BotGroupBuffing';
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:GroupBuffing') = 0) THEN
INSERT INTO `rule_values` VALUES ('1', 'Bots:GroupBuffing', 'false', 'Bots will cast single target buffs as group buffs, default is false for single. Does not make single target buffs work for MGB.');
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotManaRegen') > 0) THEN
UPDATE `rule_values` SET `rule_name` = 'Bots:ManaRegen' WHERE `rule_name` LIKE 'Bots:BotManaRegen';
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:ManaRegen') = 0) THEN
INSERT INTO `rule_values` VALUES ('1', 'Bots:ManaRegen', '3.0', 'Adjust mana regen for bots, 1 is fast and higher numbers slow it down 3 is about the same as players.');
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotQuest') > 0) THEN
UPDATE `rule_values` SET `rule_name` = 'Bots:QuestableSpawnLimit' WHERE `rule_name` LIKE 'Bots:BotQuest';
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:QuestableSpawnLimit') = 0) THEN
INSERT INTO `rule_values` VALUES ('1', 'Bots:QuestableSpawnLimit', 'false', 'Optional quest method to manage bot spawn limits using the quest_globals name bot_spawn_limit, see: /bazaar/Aediles_Thrall.pl');
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotSpellQuest') > 0) THEN
UPDATE `rule_values` SET `rule_name` = 'Bots:QuestableSpells' WHERE `rule_name` LIKE 'Bots:BotSpellQuest';
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:QuestableSpells') = 0) THEN
INSERT INTO `rule_values` VALUES ('1', 'Bots:QuestableSpells', 'false', 'Anita Thrall\'s (Anita_Thrall.pl) Bot Spell Scriber quests.');
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:SpawnBotCount') > 0) THEN
UPDATE `rule_values` SET `rule_name` = 'Bots:SpawnLimit' WHERE `rule_name` LIKE 'Bots:SpawnBotCount';
END IF;
IF ((SELECT COUNT(`rule_name`) FROM `rule_values` WHERE `rule_name` LIKE 'Bots:SpawnLimit') = 0) THEN
INSERT INTO `rule_values` VALUES ('1', 'Bots:SpawnLimit', '71', 'Number of bots a character can have spawned at one time, You + 71 bots is a 12 group raid');
END IF;
-- Tables
CREATE TABLE `bot_data` (
`bot_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`owner_id` INT(11) UNSIGNED NOT NULL,
`spells_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`name` VARCHAR(64) NOT NULL DEFAULT '',
`last_name` VARCHAR(64) NOT NULL DEFAULT '', -- Change unused (64) from (32)
`title` VARCHAR(32) NOT NULL DEFAULT '', -- Unused
`suffix` VARCHAR(32) NOT NULL DEFAULT '', -- Unused
`zone_id` SMALLINT(6) NOT NULL DEFAULT '0',
`gender` TINYINT(2) NOT NULL DEFAULT '0',
`race` SMALLINT(5) NOT NULL DEFAULT '0',
`class` TINYINT(2) NOT NULL DEFAULT '0',
`level` TINYINT(2) UNSIGNED NOT NULL DEFAULT '0',
`deity` INT(11) UNSIGNED NOT NULL DEFAULT '0', -- Unused
`creation_day` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_spawn` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`time_spawned` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`size` FLOAT NOT NULL DEFAULT '0',
`face` INT(10) NOT NULL DEFAULT '1',
`hair_color` INT(10) NOT NULL DEFAULT '1',
`hair_style` INT(10) NOT NULL DEFAULT '1',
`beard` INT(10) NOT NULL DEFAULT '0',
`beard_color` INT(10) NOT NULL DEFAULT '1',
`eye_color_1` INT(10) NOT NULL DEFAULT '1',
`eye_color_2` INT(10) NOT NULL DEFAULT '1',
`drakkin_heritage` INT(10) NOT NULL DEFAULT '0',
`drakkin_tattoo` INT(10) NOT NULL DEFAULT '0',
`drakkin_details` INT(10) NOT NULL DEFAULT '0',
`ac` SMALLINT(5) NOT NULL DEFAULT '0',
`atk` MEDIUMINT(9) NOT NULL DEFAULT '0',
`hp` INTEGER NOT NULL DEFAULT '0',
`mana` INTEGER NOT NULL DEFAULT '0',
`str` MEDIUMINT(8) NOT NULL DEFAULT '75',
`sta` MEDIUMINT(8) NOT NULL DEFAULT '75',
`cha` MEDIUMINT(8) NOT NULL DEFAULT '75',
`dex` MEDIUMINT(8) NOT NULL DEFAULT '75',
`int` MEDIUMINT(8) NOT NULL DEFAULT '75',
`agi` MEDIUMINT(8) NOT NULL DEFAULT '75',
`wis` MEDIUMINT(8) NOT NULL DEFAULT '75',
`fire` SMALLINT(5) NOT NULL DEFAULT '0',
`cold` SMALLINT(5) NOT NULL DEFAULT '0',
`magic` SMALLINT(5) NOT NULL DEFAULT '0',
`poison` SMALLINT(5) NOT NULL DEFAULT '0',
`disease` SMALLINT(5) NOT NULL DEFAULT '0',
`corruption` SMALLINT(5) NOT NULL DEFAULT '0',
`show_helm` INT(11) UNSIGNED NOT NULL DEFAULT '0', -- Unused
PRIMARY KEY (`bot_id`)
) ENGINE=InnoDB;
CREATE TABLE `bot_inspect_messages` (
`bot_id` INT(11) UNSIGNED NOT NULL,
`inspect_message` VARCHAR(256) NOT NULL DEFAULT '',
PRIMARY KEY (`bot_id`),
INDEX `bot_id` (`bot_id`)
) ENGINE=InnoDB;
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'bots') > 0) THEN
-- IF ((SHOW TABLES LIKE 'bots') != '') THEN
INSERT INTO `bot_data` (
`bot_id`,
`owner_id`,
`spells_id`,
`name`,
`last_name`,
`zone_id`,
`gender`,
`race`,
`class`,
`level`,
`creation_day`,
`last_spawn`,
`time_spawned`,
`size`,
`face`,
`hair_color`,
`hair_style`,
`beard`,
`beard_color`,
`eye_color_1`,
`eye_color_2`,
`drakkin_heritage`,
`drakkin_tattoo`,
`drakkin_details`,
`ac`,
`atk`,
`hp`,
`mana`,
`str`,
`sta`,
`cha`,
`dex`,
`int`,
`agi`,
`wis`,
`fire`,
`cold`,
`magic`,
`poison`,
`disease`,
`corruption`
)
SELECT
`BotID`,
`BotOwnerCharacterID`,
`BotSpellsID`,
`Name`,
`LastName`,
`LastZoneId`,
`Gender`,
`Race`,
`Class`,
`BotLevel`,
`BotCreateDate`,
`LastSpawnDate`,
`TotalPlayTime`,
`Size`,
`Face`,
`LuclinHairColor`,
`LuclinHairStyle`,
`LuclinBeard`,
`LuclinBeardColor`,
`LuclinEyeColor`,
`LuclinEyeColor2`,
`DrakkinHeritage`,
`DrakkinTattoo`,
`DrakkinDetails`,
`AC`,
`ATK`,
`HP`,
`Mana`,
`STR`,
`STA`,
`CHA`,
`DEX`,
`_INT`,
`AGI`,
`WIS`,
`FR`,
`CR`,
`MR`,
`PR`,
`DR`,
`Corrup`
FROM `bots`;
CREATE TABLE `botstances` (
`BotID` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`StanceID` TINYINT UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`BotID`),
CONSTRAINT `FK_botstances_1` FOREIGN KEY (`BotID`) REFERENCES `bots` (`BotID`)
INSERT INTO `bot_inspect_messages` (
`bot_id`,
`inspect_message`
)
SELECT
`BotID`,
`BotInspectMessage`
FROM `bots`;
RENAME TABLE `bots` TO `bots_old`;
END IF;
CREATE TABLE `bot_stances` (
`bot_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`stance_id` TINYINT UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`bot_id`),
CONSTRAINT `FK_bot_stances_1` FOREIGN KEY (`bot_id`) REFERENCES `bot_data` (`bot_id`)
);
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botstances') > 0) THEN
-- IF ((SHOW TABLES LIKE 'botstances') != '') THEN
INSERT INTO `bot_stances` (
`bot_id`,
`stance_id`
)
SELECT
`BotID`,
`StanceID`
FROM `botstances`;
CREATE TABLE `bottimers` (
`BotID` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`TimerID` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`Value` INT(10) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`BotID`),
CONSTRAINT `FK_bottimers_1` FOREIGN KEY (`BotID`) REFERENCES `bots` (`BotID`)
RENAME TABLE `botstances` TO `botstances_old`;
END IF;
CREATE TABLE `bot_timers` (
`bot_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`timer_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`timer_value` INT(11) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`bot_id`),
CONSTRAINT `FK_bot_timers_1` FOREIGN KEY (`bot_id`) REFERENCES `bot_data` (`bot_id`)
);
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'bottimers') > 0) THEN
-- IF ((SHOW TABLES LIKE 'bottimers') != '') THEN
INSERT INTO `bot_timers` (
`bot_id`,
`timer_id`,
`timer_value`
)
SELECT
`BotID`,
`TimerID`,
`Value`
FROM `bottimers`;
CREATE TABLE `botbuffs` (
`BotBuffId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`BotId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`SpellId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`CasterLevel` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`DurationFormula` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`TicsRemaining` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`PoisonCounters` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`DiseaseCounters` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`CurseCounters` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`CorruptionCounters` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`HitCount` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`MeleeRune` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`MagicRune` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`DeathSaveSuccessChance` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`CasterAARank` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`Persistent` TINYINT(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`BotBuffId`),
KEY `FK_botbuff_1` (`BotId`),
CONSTRAINT `FK_botbuff_1` FOREIGN KEY (`BotId`) REFERENCES `bots` (`BotID`)
RENAME TABLE `bottimers` TO `bottimers_old`;
END IF;
CREATE TABLE `bot_buffs` (
`buffs_index` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`bot_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`spell_id` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`caster_level` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
`duration_formula` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`tics_remaining` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`poison_counters` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`disease_counters` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`curse_counters` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`corruption_counters` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`numhits` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`melee_rune` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`magic_rune` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`dot_rune` INT(10) UNSIGNED NOT NULL DEFAULT '0', -- Fix
`persistent` TINYINT(1) NOT NULL DEFAULT '0',
`caston_x` INT(10) NOT NULL DEFAULT '0', -- Fix
`caston_y` INT(10) NOT NULL DEFAULT '0', -- Fix
`caston_z` INT(10) NOT NULL DEFAULT '0', -- Fix
`extra_di_chance` INT(10) UNSIGNED NOT NULL DEFAULT '0', -- Fix
`instrument_mod` INT(10) NOT NULL DEFAULT '10', -- Unused
PRIMARY KEY (`buffs_index`),
KEY `FK_bot_buffs_1` (`bot_id`),
CONSTRAINT `FK_bot_buffs_1` FOREIGN KEY (`bot_id`) REFERENCES `bot_data` (`bot_id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botbuffs') > 0) THEN
-- IF ((SHOW TABLES LIKE 'botbuffs') != '') THEN
INSERT INTO `bot_buffs` (
`buffs_index`,
`bot_id`,
`spell_id`,
`caster_level`,
`duration_formula`,
`tics_remaining`,
`poison_counters`,
`disease_counters`,
`curse_counters`,
`corruption_counters`,
`numhits`,
`melee_rune`,
`magic_rune`,
`persistent`
)
SELECT
`BotBuffId`,
`BotId`,
`SpellId`,
`CasterLevel`,
`DurationFormula`,
`TicsRemaining`,
`PoisonCounters`,
`DiseaseCounters`,
`CurseCounters`,
`CorruptionCounters`,
`HitCount`,
`MeleeRune`,
`MagicRune`,
`Persistent`
FROM `botbuffs`;
CREATE TABLE `botinventory` (
`BotInventoryID` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`BotID` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`SlotID` INTEGER SIGNED NOT NULL DEFAULT '0',
`ItemID` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`charges` TINYINT(3) UNSIGNED DEFAULT 0,
`color` INTEGER UNSIGNED NOT NULL DEFAULT 0,
`augslot1` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT 0,
`augslot2` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT 0,
`augslot3` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT 0,
`augslot4` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT 0,
`augslot5` MEDIUMINT(7) UNSIGNED DEFAULT 0,
`instnodrop` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`BotInventoryID`),
KEY `FK_botinventory_1` (`BotID`),
CONSTRAINT `FK_botinventory_1` FOREIGN KEY (`BotID`) REFERENCES `bots` (`BotID`)
IF ((SELECT COUNT(*) FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botbuffs' AND `COLUMN_NAME` = 'dot_rune') > 0) THEN
-- IF ((SHOW COLUMNS FROM `botbuffs` LIKE 'dot_rune') != '') THEN
UPDATE `bot_buffs`
SET `dot_rune` = `botbuffs`.`dot_rune`
WHERE `buffs_index` = `botbuffs`.`BotBuffId` AND `bot_id` = `botbuffs`.`BotID`;
END IF;
IF ((SELECT COUNT(*) FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botbuffs' AND `COLUMN_NAME` = 'caston_x') > 0) THEN
-- IF ((SHOW COLUMNS FROM `botbuffs` LIKE 'caston_x') != '') THEN
UPDATE `bot_buffs`
SET `caston_x` = `botbuffs`.`caston_x`
WHERE `buffs_index` = `botbuffs`.`BotBuffId` AND `bot_id` = `botbuffs`.`BotID`;
END IF;
IF ((SELECT COUNT(*) FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botbuffs' AND `COLUMN_NAME` = 'caston_y') > 0) THEN
-- IF ((SHOW COLUMNS FROM `botbuffs` LIKE 'caston_y') != '') THEN
UPDATE `bot_buffs`
SET `caston_y` = `botbuffs`.`caston_y`
WHERE `buffs_index` = `botbuffs`.`BotBuffId` AND `bot_id` = `botbuffs`.`BotID`;
END IF;
IF ((SELECT COUNT(*) FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botbuffs' AND `COLUMN_NAME` = 'caston_z') > 0) THEN
-- IF ((SHOW COLUMNS FROM `botbuffs` LIKE 'caston_z') != '') THEN
UPDATE `bot_buffs`
SET `caston_z` = `botbuffs`.`caston_z`
WHERE `buffs_index` = `botbuffs`.`BotBuffId` AND `bot_id` = `botbuffs`.`BotID`;
END IF;
IF ((SELECT COUNT(*) FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botbuffs' AND `COLUMN_NAME` = 'ExtraDIChance') > 0) THEN
-- IF ((SHOW COLUMNS FROM `botbuffs` LIKE 'ExtraDIChance') != '') THEN
UPDATE `bot_buffs`
SET `extra_di_chance` = `botbuffs`.`ExtraDIChance`
WHERE `buffs_index` = `botbuffs`.`BotBuffId` AND `bot_id` = `botbuffs`.`BotID`;
END IF;
RENAME TABLE `botbuffs` TO `botbuffs_old`;
END IF;
CREATE TABLE `bot_inventories` (
`inventories_index` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`bot_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`slot_id` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`item_id` INT(11) UNSIGNED NULL DEFAULT '0',
`inst_charges` TINYINT(3) UNSIGNED DEFAULT 0,
`inst_color` INT(11) UNSIGNED NOT NULL DEFAULT '0',
`inst_no_drop` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
`inst_custom_data` TEXT NULL, -- Unused
`ornament_icon` INT(11) UNSIGNED NOT NULL DEFAULT '0', -- Unused
`ornament_id_file` INT(11) UNSIGNED NOT NULL DEFAULT '0', -- Unused
`ornament_hero_model` INT(11) NOT NULL DEFAULT '0', -- Unused
`augment_1` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augment_2` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augment_3` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augment_4` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augment_5` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0',
`augment_6` MEDIUMINT(7) UNSIGNED NOT NULL DEFAULT '0', -- Unused
PRIMARY KEY (`inventories_index`),
KEY `FK_bot_inventories_1` (`bot_id`),
CONSTRAINT `FK_bot_inventories_1` FOREIGN KEY (`bot_id`) REFERENCES `bot_data` (`bot_id`)
) ENGINE=InnoDB;
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botinventory') > 0) THEN
-- IF ((SHOW TABLES LIKE 'botinventory') != '') THEN
INSERT INTO `bot_inventories` (
`inventories_index`,
`bot_id`,
`slot_id`,
`item_id`,
`inst_charges`,
`inst_color`,
`inst_no_drop`,
`augment_1`,
`augment_2`,
`augment_3`,
`augment_4`,
`augment_5`
)
SELECT
`BotInventoryID`,
`BotID`,
`SlotID`,
`ItemID`,
`charges`,
`color`,
`instnodrop`,
`augslot1`,
`augslot2`,
`augslot3`,
`augslot4`,
`augslot5`
FROM `botinventory`;
CREATE TABLE `botpets` (
`BotPetsId` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`PetId` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`BotId` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`Name` VARCHAR(64) NULL,
`Mana` INTEGER NOT NULL DEFAULT '0',
`HitPoints` INTEGER NOT NULL DEFAULT '0',
PRIMARY KEY (`BotPetsId`),
KEY `FK_botpets_1` (`BotId`),
CONSTRAINT `FK_botpets_1` FOREIGN KEY (`BotId`) REFERENCES `bots` (`BotID`),
CONSTRAINT `U_botpets_1` UNIQUE (`BotId`)
IF ((SELECT COUNT(*) FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botinventory' AND `COLUMN_NAME` = 'augslot6') > 0) THEN
-- IF ((SHOW COLUMNS FROM `botinventory` LIKE 'augslot6') != '') THEN
UPDATE `bot_inventories`
SET `augment_6` = `botinventory`.`augslot6`
WHERE `inventories_index` = `botinventory`.`BotInventoryID` AND `bot_id` = `botinventory`.`BotID`;
END IF;
RENAME TABLE `botinventory` TO `botinventory_old`;
END IF;
CREATE TABLE `bot_pets` (
`pets_index` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`pet_id` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`bot_id` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`name` VARCHAR(64) NULL,
`mana` INTEGER NOT NULL DEFAULT '0',
`hp` INTEGER NOT NULL DEFAULT '0',
PRIMARY KEY (`pets_index`),
KEY `FK_bot_pets_1` (`bot_id`),
CONSTRAINT `FK_bot_pets_1` FOREIGN KEY (`bot_id`) REFERENCES `bot_data` (`bot_id`),
CONSTRAINT `U_bot_pets_1` UNIQUE (`bot_id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botpets') > 0) THEN
-- IF ((SHOW TABLES LIKE 'botpets') != '') THEN
INSERT INTO `bot_pets` (
`pets_index`,
`pet_id`,
`bot_id`,
`name`,
`mana`,
`hp`
)
SELECT
`BotPetsId`,
`PetId`,
`BotId`,
`Name`,
`Mana`,
`HitPoints`
FROM `botpets`;
CREATE TABLE `botpetbuffs` (
`BotPetBuffId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`BotPetsId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`SpellId` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`CasterLevel` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`Duration` INT(11) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`BotPetBuffId`),
KEY `FK_botpetbuffs_1` (`BotPetsId`),
CONSTRAINT `FK_botpetbuffs_1` FOREIGN KEY (`BotPetsId`) REFERENCES `botpets` (`BotPetsID`)
RENAME TABLE `botpets` TO `botpets_old`;
END IF;
CREATE TABLE `bot_pet_buffs` (
`pet_buffs_index` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`pets_index` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`spell_id` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`caster_level` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`duration` INT(11) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`pet_buffs_index`),
KEY `FK_bot_pet_buffs_1` (`pets_index`),
CONSTRAINT `FK_bot_pet_buffs_1` FOREIGN KEY (`pets_index`) REFERENCES `bot_pets` (`pets_index`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botpetbuffs') > 0) THEN
-- IF ((SHOW TABLES LIKE 'botpetbuffs') != '') THEN
INSERT INTO `bot_pet_buffs` (
`pet_buffs_index`,
`pets_index`,
`spell_id`,
`caster_level`,
`duration`
)
SELECT
`BotPetBuffId`,
`BotPetsId`,
`SpellId`,
`CasterLevel`,
`Duration`
FROM `botpetbuffs`;
CREATE TABLE `botpetinventory` (
`BotPetInventoryId` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`BotPetsId` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`ItemId` INTEGER UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`BotPetInventoryId`),
KEY `FK_botpetinventory_1` (`BotPetsId`),
CONSTRAINT `FK_botpetinventory_1` FOREIGN KEY (`BotPetsId`) REFERENCES `botpets` (`BotPetsID`)
RENAME TABLE `botpetbuffs` TO `botpetbuffs_old`;
END IF;
CREATE TABLE `bot_pet_inventories` (
`pet_inventories_index` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`pets_index` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`item_id` INTEGER UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`pet_inventories_index`),
KEY `FK_bot_pet_inventories_1` (`pets_index`),
CONSTRAINT `FK_bot_pet_inventories_1` FOREIGN KEY (`pets_index`) REFERENCES `bot_pets` (`pets_index`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botpetinventory') > 0) THEN
-- IF ((SHOW TABLES LIKE 'botpetinventory') != '') THEN
INSERT INTO `bot_pet_inventories` (
`pet_inventories_index`,
`pets_index`,
`item_id`
)
SELECT
`BotPetInventoryId`,
`BotPetsId`,
`ItemId`
FROM `botpetinventory`;
CREATE TABLE `botgroup` (
`BotGroupId` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`BotGroupLeaderBotId` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`BotGroupName` VARCHAR(64) NOT NULL,
PRIMARY KEY (`BotGroupId`),
KEY `FK_botgroup_1` (`BotGroupLeaderBotId`),
CONSTRAINT `FK_botgroup_1` FOREIGN KEY (`BotGroupLeaderBotId`) REFERENCES `bots` (`BotID`)
RENAME TABLE `botpetinventory` TO `botpetinventory_old`;
END IF;
CREATE TABLE `bot_groups` (
`groups_index` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`group_leader_id` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`group_name` VARCHAR(64) NOT NULL,
PRIMARY KEY (`groups_index`),
KEY `FK_bot_groups_1` (`group_leader_id`),
CONSTRAINT `FK_bot_groups_1` FOREIGN KEY (`group_leader_id`) REFERENCES `bot_data` (`bot_id`)
) ENGINE=InnoDB;
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botgroup') > 0) THEN
-- IF ((SHOW TABLES LIKE 'botgroup') != '') THEN
INSERT INTO `bot_groups` (
`groups_index`,
`group_leader_id`,
`group_name`
)
SELECT
`BotGroupId`,
`BotGroupLeaderBotId`,
`BotGroupName`
FROM `botgroup`;
CREATE TABLE `botgroupmembers` (
`BotGroupMemberId` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`BotGroupId` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`BotId` INTEGER UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`BotGroupMemberId`),
KEY `FK_botgroupmembers_1` (`BotGroupId`),
CONSTRAINT `FK_botgroupmembers_1` FOREIGN KEY (`BotGroupId`) REFERENCES `botgroup` (`BotGroupId`),
KEY `FK_botgroupmembers_2` (`BotId`),
CONSTRAINT `FK_botgroupmembers_2` FOREIGN KEY (`BotId`) REFERENCES `bots` (`BotID`)
RENAME TABLE `botgroup` TO `botgroup_old`;
END IF;
CREATE TABLE `bot_group_members` (
`group_members_index` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`groups_index` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`bot_id` INTEGER UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`group_members_index`),
KEY `FK_bot_group_members_1` (`groups_index`),
CONSTRAINT `FK_bot_group_members_1` FOREIGN KEY (`groups_index`) REFERENCES `bot_groups` (`groups_index`),
KEY `FK_bot_group_members_2` (`bot_id`),
CONSTRAINT `FK_bot_group_members_2` FOREIGN KEY (`bot_id`) REFERENCES `bot_data` (`bot_id`)
) ENGINE=InnoDB;
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botgroupmembers') > 0) THEN
-- IF ((SHOW TABLES LIKE 'botgroupmembers') != '') THEN
INSERT INTO `bot_group_members` (
`group_members_index`,
`groups_index`,
`bot_id`
)
SELECT
`BotGroupMemberId`,
`BotGroupId`,
`BotId`
FROM `botgroupmembers`;
CREATE TABLE `botguildmembers` (
`char_id` INT(11) NOT NULL DEFAULT '0',
RENAME TABLE `botgroupmembers` TO `botgroupmembers_old`;
END IF;
CREATE TABLE `bot_guild_members` (
`bot_id` INT(11) NOT NULL DEFAULT '0',
`guild_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
`rank` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
`tribute_enable` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
@ -191,30 +621,104 @@ CREATE TABLE `botguildmembers` (
`banker` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
`public_note` TEXT NULL,
`alt` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`char_id`)
PRIMARY KEY (`bot_id`)
) ENGINE=InnoDB;
IF ((SELECT COUNT(*) FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = DATABASE() AND `TABLE_NAME` = 'botguildmembers') > 0) THEN
-- IF ((SHOW TABLES LIKE 'botguildmembers') != '') THEN
INSERT INTO `bot_guild_members` (
`bot_id`,
`guild_id`,
`rank`,
`tribute_enable`,
`total_tribute`,
`last_tribute`,
`banker`,
`public_note`,
`alt`
)
SELECT
`char_id`,
`guild_id`,
`rank`,
`tribute_enable`,
`total_tribute`,
`last_tribute`,
`banker`,
`public_note`,
`alt`
FROM `botguildmembers`;
RENAME TABLE `botguildmembers` TO `botguildmembers_old`;
END IF;
END$$
DELIMITER ;
CALL `LoadBotsSchema`();
DROP PROCEDURE IF EXISTS `LoadBotsSchema`;
-- Functions
DELIMITER $$
CREATE FUNCTION `GetMobType` (mobname VARCHAR(64)) RETURNS CHAR(1)
-- (no code references)
CREATE FUNCTION `GetMobType` (mob_name VARCHAR(64)) RETURNS CHAR(1)
BEGIN
DECLARE Result CHAR(1);
SET Result = NULL;
IF (SELECT COUNT(*) FROM `character_data` WHERE `name` = mobname) > 0 THEN
IF ((SELECT COUNT(*) FROM `character_data` WHERE `name` = mob_name) > 0) THEN
SET Result = 'C';
ELSEIF (SELECT COUNT(*) FROM `bots` WHERE `Name` = mobname) > 0 THEN
ELSEIF ((SELECT COUNT(*) FROM `bot_data` WHERE `name` = mob_name) > 0) THEN
SET Result = 'B';
END IF;
RETURN Result;
END$$
-- (one code reference in /common/database.cpp)
CREATE FUNCTION `GetMobTypeById` (mob_id INTEGER UNSIGNED) RETURNS CHAR(1)
BEGIN
DECLARE Result CHAR(1);
SET Result = NULL;
IF ((select `id` from `character_data` where `id` = mob_id) > 0) THEN
SET Result = 'C';
ELSEIF ((select `bot_id` from `bot_data` where `bot_id` = mob_id) > 0) THEN
SET Result = 'B';
END IF;
RETURN Result;
END$$
-- (for reference only)
-- CREATE FUNCTION `GetMobTypeByName` (mob_name VARCHAR(64)) RETURNS CHAR(1)
-- BEGIN
-- DECLARE Result CHAR(1);
--
-- SET Result = NULL;
--
-- IF (select `id` from `character_data` where `name` = mob_name) > 0 THEN
-- SET Result = 'C';
-- ELSEIF (select `bot_id` from `bot_data` where `name` = mob_name) > 0 THEN
-- SET Result = 'B';
-- END IF;
--
-- RETURN Result;
-- END $$
DELIMITER ;
CREATE VIEW `vwBotCharacterMobs` AS
SELECT _utf8'C' AS mobtype,
-- Views
CREATE VIEW `vw_bot_character_mobs` AS
SELECT
_utf8'C' AS mob_type,
c.`id`,
c.`name`,
c.`class`,
@ -223,39 +727,42 @@ c.`last_login`,
c.`zone_id`
FROM `character_data` AS c
UNION ALL
SELECT _utf8'B' AS mobtype,
b.`BotID` AS id,
b.`Name` AS name,
b.`Class` AS class,
b.`BotLevel` AS level,
0 AS timelaston,
0 AS zoneid
FROM bots AS b;
SELECT _utf8'B' AS mob_type,
b.`bot_id` AS id,
b.`name`,
b.`class`,
b.`level`,
b.`last_spawn` AS last_login,
b.`zone_id`
FROM `bot_data` AS b;
CREATE VIEW `vwGroups` AS
SELECT g.`groupid` AS groupid,
GetMobType(g.`name`) AS mobtype,
CREATE VIEW `vw_bot_groups` AS
SELECT
g.`groups_index`,
g.`group_name`,
g.`group_leader_id`,
b.`name` AS group_leader_name,
b.`owner_id`,
c.`name` AS owner_name
FROM `bot_groups` AS g
JOIN `bot_data` AS b ON g.`group_leader_id` = b.`bot_id`
JOIN `character_data` AS c ON b.`owner_id` = c.`id`
ORDER BY b.`owner_id`, g.`group_name`;
CREATE VIEW `vw_groups` AS
SELECT
g.`groupid` AS group_id,
GetMobType(g.`name`) AS mob_type,
g.`name` AS name,
g.`charid` AS mobid,
IFNULL(c.`level`, b.`BotLevel`) AS level
g.`charid` AS mob_id,
IFNULL(c.`level`, b.`level`) AS level
FROM `group_id` AS g
LEFT JOIN `character_data` AS c ON g.`name` = c.`name`
LEFT JOIN `bots` AS b ON g.`name` = b.`Name`;
LEFT JOIN `bot_data` AS b ON g.`name` = b.`name`;
CREATE VIEW `vwBotGroups` AS
SELECT g.`BotGroupId`,
g.`BotGroupName`,
g.`BotGroupLeaderBotId`,
b.`Name` AS BotGroupLeaderName,
b.`BotOwnerCharacterId`,
c.`name` AS BotOwnerCharacterName
FROM `botgroup` AS g
JOIN `bots` AS b ON g.`BotGroupLeaderBotId` = b.`BotID`
JOIN `character_data` AS c ON b.`BotOwnerCharacterID` = c.`id`
ORDER BY b.`BotOwnerCharacterId`, g.`BotGroupName`;
CREATE VIEW `vwGuildMembers` AS
SELECT 'C' AS mobtype,
CREATE VIEW `vw_guild_members` AS
SELECT
'C' AS mob_type,
cm.`char_id`,
cm.`guild_id`,
cm.`rank`,
@ -267,8 +774,9 @@ cm.`public_note`,
cm.`alt`
FROM `guild_members` AS cm
UNION ALL
SELECT 'B' AS mobtype,
bm.`char_id`,
SELECT
'B' AS mob_type,
bm.`bot_id` AS char_id,
bm.`guild_id`,
bm.`rank`,
bm.`tribute_enable`,
@ -277,4 +785,7 @@ bm.`last_tribute`,
bm.`banker`,
bm.`public_note`,
bm.`alt`
FROM `botguildmembers` AS bm;
FROM `bot_guild_members` AS bm;
-- End of File

File diff suppressed because it is too large Load Diff

View File

@ -883,7 +883,7 @@ bool Bot::AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgain
int32 hasMana = GetMana();
// Allow bots to cast buff spells even if they are out of mana
if(RuleB(Bots, BotFinishBuffing)) {
if(RuleB(Bots, FinishBuffing)) {
if(manaCost > hasMana) {
// Let's have the bots complete the buff time process
if(AIspells[i].type & SpellType_Buff) {

View File

@ -2041,23 +2041,23 @@ void QuestManager::popup(const char *title, const char *text, uint32 popupid, ui
#ifdef BOTS
int QuestManager::createbotcount() {
return RuleI(Bots, CreateBotCount);
return RuleI(Bots, CreationLimit);
}
int QuestManager::spawnbotcount() {
return RuleI(Bots, SpawnBotCount);
return RuleI(Bots, SpawnLimit);
}
bool QuestManager::botquest()
{
return RuleB(Bots, BotQuest);
return RuleB(Bots, QuestableSpawnLimit);
}
bool QuestManager::createBot(const char *name, const char *lastname, uint8 level, uint16 race, uint8 botclass, uint8 gender)
{
QuestManagerCurrentQuestVars();
std::string TempErrorMessage;
uint32 MaxBotCreate = RuleI(Bots, CreateBotCount);
uint32 MaxBotCreate = RuleI(Bots, CreationLimit);
if (initiator && initiator->IsClient())
{