Migrated bot spell casting chance data to the database

This commit is contained in:
Uleat 2017-02-23 19:16:36 -05:00
parent ce3fc0f2c3
commit 4e8a03f7b4
9 changed files with 11341 additions and 2947 deletions

View File

@ -1,5 +1,20 @@
EQEMu Changelog (Started on Sept 24, 2003 15:50)
-------------------------------------------------------
== 02/23/2017 ==
Uleat: Moved bot spell casting chance values into database - this will allow admins to tailor their bots without having to rebuild server code
- Each entry uses a 4-dimensional identifier: [spell type index][class index][stance index][conditional index]
- [spell type index] is not the SpellType_## bit value..use SpellType_##Index instead
- [class index] values of 0-15 are valid and determined by subtracting 1 from the actual class value
- [stance index] is a direct correlation (0-6)
- the [conditional index] is currently predicated on 2 compounded boolean states:
- not primary healer/not primary slower: 0
- primary healer/not primary slower: 1
- not primary healer/ primary slower: 2
- primary healer/primary slower: 3
- Valid `value` entries are 0-100..though, the field accepts up to 255... Anything above 100 is clamped to 100 upon loading, however
- Not all conditions are currently coded and changing a field may not produce any results
- The 'default' database values will be changed and tweaked as bot spell code modifications occur
== 02/20/2017 ==
Uleat: Reworked bard bot spell twisting and updated their spell (song) list
Uleat: Added ability to shift to pre-combat song buffing by selecting a non-pet npc target, eliminating the need to mix all bard buff songs together

View File

@ -32,7 +32,7 @@
#define CURRENT_BINARY_DATABASE_VERSION 9105
#ifdef BOTS
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9010
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9011
#else
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 0 // must be 0
#endif

View File

@ -9,6 +9,7 @@
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|
9010|2017_02_20_bots_bard_spell_update.sql|SELECT * FROM `bot_spells_entries` WHERE `npc_spells_id` = 711 AND (`type` & 0xFFFF0000) = 0xFFFF0000|empty|
9011|2017_02_23_bots_spell_casting_chances.sql|SHOW TABLES LIKE 'bot_spell_casting_chances'|empty|
# Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not

File diff suppressed because it is too large Load Diff

View File

@ -132,6 +132,9 @@ enum SpellTypeIndex {
MaxSpellTypes
};
enum BotCastingChanceConditional : uint8 { nHS = 0, pH, pS, pHS, cntHS }; // negative Healer/Slower, positive Healer, postive Slower, positive Healer/Slower
class Bot : public NPC {
friend class Mob;
public:

View File

@ -82,6 +82,50 @@ bool BotDatabase::LoadBotCommandSettings(std::map<std::string, std::pair<uint8,
return true;
}
static uint8 spell_casting_chances[MaxSpellTypes][PLAYER_CLASS_COUNT][MaxStances][cntHS];
bool BotDatabase::LoadBotSpellCastingChances()
{
memset(spell_casting_chances, 0, sizeof(spell_casting_chances));
query =
"SELECT"
" `spell_type_index`,"
" `class_index`,"
" `stance_index`,"
" `conditional_index`,"
" `value` "
"FROM"
" `bot_spell_casting_chances` "
"WHERE"
" `value` != '0'";
auto results = QueryDatabase(query);
if (!results.Success())
return false;
for (auto row = results.begin(); row != results.end(); ++row) {
uint8 spell_type_index = atoi(row[0]);
if (spell_type_index >= MaxSpellTypes)
continue;
uint8 class_index = atoi(row[1]);
if (class_index >= PLAYER_CLASS_COUNT)
continue;
uint8 stance_index = atoi(row[2]);
if (stance_index >= MaxStances)
continue;
uint8 conditional_index = atoi(row[3]);
if (conditional_index >= cntHS)
continue;
uint8 value = atoi(row[4]);
if (value > 100)
value = 100;
spell_casting_chances[spell_type_index][class_index][stance_index][conditional_index] = value;
}
return true;
}
/* Bot functions */
bool BotDatabase::QueryNameAvailablity(const std::string& bot_name, bool& available_flag)
@ -2711,6 +2755,19 @@ bool BotDatabase::DeleteAllHealRotations(const uint32 owner_id)
/* Bot miscellaneous functions */
uint8 BotDatabase::GetSpellCastingChance(uint8 spell_type_index, uint8 class_index, uint8 stance_index, uint8 conditional_index)
{
if (spell_type_index >= MaxSpellTypes)
return 0;
if (class_index >= PLAYER_CLASS_COUNT)
return 0;
if (stance_index >= MaxStances)
return 0;
if (conditional_index >= cntHS)
return 0;
return spell_casting_chances[spell_type_index][class_index][stance_index][conditional_index];
}
/* fail::Bot functions */

View File

@ -50,6 +50,7 @@ public:
bool Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port);
bool LoadBotCommandSettings(std::map<std::string, std::pair<uint8, std::vector<std::string>>> &bot_command_settings);
bool LoadBotSpellCastingChances();
/* Bot functions */
@ -183,6 +184,7 @@ public:
bool DeleteAllHealRotations(const uint32 owner_id);
/* Bot miscellaneous functions */
uint8 GetSpellCastingChance(uint8 spell_type_index, uint8 class_index, uint8 stance_index, uint8 conditional_index);
class fail {

File diff suppressed because it is too large Load Diff

View File

@ -369,6 +369,10 @@ int main(int argc, char** argv) {
Log.Out(Logs::General, Logs::Error, "Bot command loading FAILED");
else
Log.Out(Logs::General, Logs::Zone_Server, "%d bot commands loaded", botretval);
Log.Out(Logs::General, Logs::Zone_Server, "Loading bot spell casting chances");
if (!botdb.LoadBotSpellCastingChances())
Log.Out(Logs::General, Logs::Error, "Bot spell casting chances loading FAILED");
#endif
if(RuleB(TaskSystem, EnableTaskSystem)) {