Fix pet instrument mod issue

This commit is contained in:
Michael Cook (mackal) 2015-05-23 17:14:08 -04:00
parent 8aadc36320
commit 00721f4a96
5 changed files with 75 additions and 67 deletions

View File

@ -30,7 +30,7 @@
Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
*/ */
#define CURRENT_BINARY_DATABASE_VERSION 9079 #define CURRENT_BINARY_DATABASE_VERSION 9080
#define COMPILE_DATE __DATE__ #define COMPILE_DATE __DATE__
#define COMPILE_TIME __TIME__ #define COMPILE_TIME __TIME__
#ifndef WIN32 #ifndef WIN32

View File

@ -333,6 +333,7 @@
9077|2015_02_12_zone_gravity.sql|SHOW COLUMNS FROM `zone` LIKE 'gravity'|empty| 9077|2015_02_12_zone_gravity.sql|SHOW COLUMNS FROM `zone` LIKE 'gravity'|empty|
9078|2015_05_20_BuffInstrumentMod.sql|SHOW COLUMNS FROM `character_buffs` LIKE 'instrument_mod'|empty| 9078|2015_05_20_BuffInstrumentMod.sql|SHOW COLUMNS FROM `character_buffs` LIKE 'instrument_mod'|empty|
9079|2015_05_23_BuffDurations.sql|SHOW COLUMNS FROM `character_buffs` LIKE 'ticsremaining'|contains|unsigned| 9079|2015_05_23_BuffDurations.sql|SHOW COLUMNS FROM `character_buffs` LIKE 'ticsremaining'|contains|unsigned|
9080|2015_05_23_PetBuffInstrumentMod.sql|SHOW COLUMNS FROM `character_pet_buffs` LIKE 'instrument_mod'|empty|
# Upgrade conditions: # Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not # This won't be needed after this system is implemented, but it is used database that are not

View File

@ -0,0 +1 @@
ALTER TABLE `character_pet_buffs` ADD COLUMN `instrument_mod` tinyint UNSIGNED DEFAULT 10 NOT NULL;

View File

@ -426,7 +426,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower,
entity_list.AddNPC(npc, true, true); entity_list.AddNPC(npc, true, true);
SetPetID(npc->GetID()); SetPetID(npc->GetID());
// We need to handle PetType 5 (petHatelist), add the current target to the hatelist of the pet // We need to handle PetType 5 (petHatelist), add the current target to the hatelist of the pet
if (record.petcontrol == petTargetLock) if (record.petcontrol == petTargetLock)
{ {
@ -588,6 +588,7 @@ void NPC::SetPetState(SpellBuff_Struct *pet_buffs, uint32 *items) {
buffs[i].casterid = 0; buffs[i].casterid = 0;
buffs[i].counters = pet_buffs[i].counters; buffs[i].counters = pet_buffs[i].counters;
buffs[i].numhits = spells[pet_buffs[i].spellid].numhits; buffs[i].numhits = spells[pet_buffs[i].spellid].numhits;
buffs[i].instrument_mod = pet_buffs[i].bard_modifier;
} }
else { else {
buffs[i].spellid = SPELL_UNKNOWN; buffs[i].spellid = SPELL_UNKNOWN;

View File

@ -3127,16 +3127,16 @@ void ZoneDatabase::SavePetInfo(Client *client)
if (query.length() == 0) if (query.length() == 0)
query = StringFormat("INSERT INTO `character_pet_buffs` " query = StringFormat("INSERT INTO `character_pet_buffs` "
"(`char_id`, `pet`, `slot`, `spell_id`, `caster_level`, " "(`char_id`, `pet`, `slot`, `spell_id`, `caster_level`, "
"`ticsremaining`, `counters`) " "`ticsremaining`, `counters`, `instrument_mod`) "
"VALUES (%u, %u, %u, %u, %u, %d, %d)", "VALUES (%u, %u, %u, %u, %u, %d, %d, %u)",
client->CharacterID(), pet, index, petinfo->Buffs[index].spellid, client->CharacterID(), pet, index, petinfo->Buffs[index].spellid,
petinfo->Buffs[index].level, petinfo->Buffs[index].duration, petinfo->Buffs[index].level, petinfo->Buffs[index].duration,
petinfo->Buffs[index].counters); petinfo->Buffs[index].counters, petinfo->Buffs[index].bard_modifier);
else else
query += StringFormat(", (%u, %u, %u, %u, %u, %d, %d)", query += StringFormat(", (%u, %u, %u, %u, %u, %d, %d, %u)",
client->CharacterID(), pet, index, petinfo->Buffs[index].spellid, client->CharacterID(), pet, index, petinfo->Buffs[index].spellid,
petinfo->Buffs[index].level, petinfo->Buffs[index].duration, petinfo->Buffs[index].level, petinfo->Buffs[index].duration,
petinfo->Buffs[index].counters); petinfo->Buffs[index].counters, petinfo->Buffs[index].bard_modifier);
} }
database.QueryDatabase(query); database.QueryDatabase(query);
query.clear(); query.clear();
@ -3174,7 +3174,8 @@ void ZoneDatabase::UpdateItemRecastTimestamps(uint32 char_id, uint32 recast_type
QueryDatabase(query); QueryDatabase(query);
} }
void ZoneDatabase::LoadPetInfo(Client *client) { void ZoneDatabase::LoadPetInfo(Client *client)
{
// Load current pet and suspended pet // Load current pet and suspended pet
PetInfo *petinfo = client->GetPetInfo(0); PetInfo *petinfo = client->GetPetInfo(0);
@ -3183,17 +3184,18 @@ void ZoneDatabase::LoadPetInfo(Client *client) {
memset(petinfo, 0, sizeof(PetInfo)); memset(petinfo, 0, sizeof(PetInfo));
memset(suspended, 0, sizeof(PetInfo)); memset(suspended, 0, sizeof(PetInfo));
std::string query = StringFormat("SELECT `pet`, `petname`, `petpower`, `spell_id`, " std::string query = StringFormat("SELECT `pet`, `petname`, `petpower`, `spell_id`, "
"`hp`, `mana`, `size` FROM `character_pet_info` " "`hp`, `mana`, `size` FROM `character_pet_info` "
"WHERE `char_id` = %u", client->CharacterID()); "WHERE `char_id` = %u",
auto results = database.QueryDatabase(query); client->CharacterID());
if(!results.Success()) { auto results = database.QueryDatabase(query);
if (!results.Success()) {
return; return;
} }
PetInfo *pi; PetInfo *pi;
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
uint16 pet = atoi(row[0]); uint16 pet = atoi(row[0]);
if (pet == 0) if (pet == 0)
pi = petinfo; pi = petinfo;
@ -3202,7 +3204,7 @@ void ZoneDatabase::LoadPetInfo(Client *client) {
else else
continue; continue;
strncpy(pi->Name,row[1],64); strncpy(pi->Name, row[1], 64);
pi->petpower = atoi(row[2]); pi->petpower = atoi(row[2]);
pi->SpellID = atoi(row[3]); pi->SpellID = atoi(row[3]);
pi->HP = atoul(row[4]); pi->HP = atoul(row[4]);
@ -3210,56 +3212,60 @@ void ZoneDatabase::LoadPetInfo(Client *client) {
pi->size = atof(row[6]); pi->size = atof(row[6]);
} }
query = StringFormat("SELECT `pet`, `slot`, `spell_id`, `caster_level`, `castername`, " query = StringFormat("SELECT `pet`, `slot`, `spell_id`, `caster_level`, `castername`, "
"`ticsremaining`, `counters` FROM `character_pet_buffs` " "`ticsremaining`, `counters`, `instrument_mod` FROM `character_pet_buffs` "
"WHERE `char_id` = %u", client->CharacterID()); "WHERE `char_id` = %u",
results = QueryDatabase(query); client->CharacterID());
if (!results.Success()) { results = QueryDatabase(query);
return; if (!results.Success()) {
}
for (auto row = results.begin(); row != results.end(); ++row) {
uint16 pet = atoi(row[0]);
if (pet == 0)
pi = petinfo;
else if (pet == 1)
pi = suspended;
else
continue;
uint32 slot_id = atoul(row[1]);
if(slot_id >= RuleI(Spells, MaxTotalSlotsPET))
continue;
uint32 spell_id = atoul(row[2]);
if(!IsValidSpell(spell_id))
continue;
uint32 caster_level = atoi(row[3]);
int caster_id = 0;
// The castername field is currently unused
int32 ticsremaining = atoi(row[5]);
uint32 counters = atoul(row[6]);
pi->Buffs[slot_id].spellid = spell_id;
pi->Buffs[slot_id].level = caster_level;
pi->Buffs[slot_id].player_id = caster_id;
pi->Buffs[slot_id].slotid = 2; // Always 2 in buffs struct for real buffs
pi->Buffs[slot_id].duration = ticsremaining;
pi->Buffs[slot_id].counters = counters;
}
query = StringFormat("SELECT `pet`, `slot`, `item_id` "
"FROM `character_pet_inventory` "
"WHERE `char_id`=%u",client->CharacterID());
results = database.QueryDatabase(query);
if (!results.Success()) {
return; return;
} }
for(auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
uint16 pet = atoi(row[0]); uint16 pet = atoi(row[0]);
if (pet == 0)
pi = petinfo;
else if (pet == 1)
pi = suspended;
else
continue;
uint32 slot_id = atoul(row[1]);
if (slot_id >= RuleI(Spells, MaxTotalSlotsPET))
continue;
uint32 spell_id = atoul(row[2]);
if (!IsValidSpell(spell_id))
continue;
uint32 caster_level = atoi(row[3]);
int caster_id = 0;
// The castername field is currently unused
int32 ticsremaining = atoi(row[5]);
uint32 counters = atoul(row[6]);
uint8 bard_mod = atoul(row[7]);
pi->Buffs[slot_id].spellid = spell_id;
pi->Buffs[slot_id].level = caster_level;
pi->Buffs[slot_id].player_id = caster_id;
pi->Buffs[slot_id].slotid = 2; // Always 2 in buffs struct for real buffs
pi->Buffs[slot_id].duration = ticsremaining;
pi->Buffs[slot_id].counters = counters;
pi->Buffs[slot_id].bard_modifier = bard_mod;
}
query = StringFormat("SELECT `pet`, `slot`, `item_id` "
"FROM `character_pet_inventory` "
"WHERE `char_id`=%u",
client->CharacterID());
results = database.QueryDatabase(query);
if (!results.Success()) {
return;
}
for (auto row = results.begin(); row != results.end(); ++row) {
uint16 pet = atoi(row[0]);
if (pet == 0) if (pet == 0)
pi = petinfo; pi = petinfo;
else if (pet == 1) else if (pet == 1)
@ -3269,11 +3275,10 @@ void ZoneDatabase::LoadPetInfo(Client *client) {
int slot = atoi(row[1]); int slot = atoi(row[1]);
if (slot < EmuConstants::EQUIPMENT_BEGIN || slot > EmuConstants::EQUIPMENT_END) if (slot < EmuConstants::EQUIPMENT_BEGIN || slot > EmuConstants::EQUIPMENT_END)
continue; continue;
pi->Items[slot] = atoul(row[2]);
}
pi->Items[slot] = atoul(row[2]);
}
} }
bool ZoneDatabase::GetFactionData(FactionMods* fm, uint32 class_mod, uint32 race_mod, uint32 deity_mod, int32 faction_id) { bool ZoneDatabase::GetFactionData(FactionMods* fm, uint32 class_mod, uint32 race_mod, uint32 deity_mod, int32 faction_id) {