diff --git a/changelog.txt b/changelog.txt index 5a91b9e74..034dbc03f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,10 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 03/18/2013 == +Bad_Captain: Fixed zone crash due to merc focus effects & tribute. +Bad_Captain: Fixed merc aggro issues when client in melee range & spell recast timers. +Bad_Captain: Added melee DPS spells/disciplines & support. + == 03/15/2013 == Derision: RoF: Added ENCODE for Resurrect_struct (Accepting a rez should now work). Derision: Fixed a couple of memory leaks in Rez code. diff --git a/utils/sql/git/optional/2013_03_18_Merc_Spells.sql b/utils/sql/git/optional/2013_03_18_Merc_Spells.sql new file mode 100644 index 000000000..bf3b51076 --- /dev/null +++ b/utils/sql/git/optional/2013_03_18_Merc_Spells.sql @@ -0,0 +1,92 @@ +REPLACE INTO merc_spell_list_entries (merc_spell_list_id, spell_id, spell_type, stance_id, minlevel, maxlevel, slot, procChance) VALUES + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23181, 16, 0, 1, 9, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23182, 16, 0, 10, 19, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23183, 16, 0, 20, 24, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23184, 16, 0, 25, 29, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23185, 16, 0, 30, 34, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23186, 16, 0, 35, 39, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23187, 16, 0, 40, 44, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23188, 16, 0, 45, 49, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23189, 16, 0, 50, 54, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23190, 16, 0, 55, 59, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23191, 16, 0, 60, 64, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23192, 16, 0, 65, 69, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23193, 16, 0, 70, 74, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23194, 16, 0, 75, 79, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23195, 16, 0, 80, 80, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23196, 16, 0, 81, 81, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23197, 16, 0, 82, 82, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23198, 16, 0, 83, 83, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23199, 16, 0, 84, 84, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 23200, 16, 0, 85, 95, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), 37747, 16, 0, 96, 255, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Hide' ORDER BY id DESC LIMIT 1), 8, 0, 1, 255, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Sneak Attack' ORDER BY id DESC LIMIT 1), 1024, 0, 20, 51, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Thief\'s Vengeance' ORDER BY id DESC LIMIT 1), 1024, 0, 52, 62, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Assassin\'s Strike' ORDER BY id DESC LIMIT 1), 1024, 0, 63, 64, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Kyv Strike' ORDER BY id DESC LIMIT 1), 1024, 0, 65, 68, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Thief\'s eyes' ORDER BY id DESC LIMIT 1), 1024, 0, 68, 255, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerfall' ORDER BY id DESC LIMIT 1), 1024, 0, 69, 69, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Razorarc' ORDER BY id DESC LIMIT 1), 1024, 0, 70, 79, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Swiftblade' ORDER BY id DESC LIMIT 1), 1024, 0, 80, 84, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Swiftblade Rk. II' ORDER BY id DESC LIMIT 1), 1024, 0, 80, 84, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Swiftblade Rk. III' ORDER BY id DESC LIMIT 1), 1024, 0, 80, 84, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerlunge' ORDER BY id DESC LIMIT 1), 1024, 0, 85, 89, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerlunge Rk. II' ORDER BY id DESC LIMIT 1), 1024, 0, 85, 89, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerlunge Rk. III' ORDER BY id DESC LIMIT 1), 1024, 0, 85, 89, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerswipe' ORDER BY id DESC LIMIT 1), 1024, 0, 90, 94, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerswipe Rk. II' ORDER BY id DESC LIMIT 1), 1024, 0, 90, 94, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerswipe Rk. III' ORDER BY id DESC LIMIT 1), 1024, 0, 90, 94, 1, 0 ); + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerstrike' ORDER BY id DESC LIMIT 1), 1024, 0, 95, 99, 1, 0 ), + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerstrike Rk. II' ORDER BY id DESC LIMIT 1), 1024, 0, 95, 9, 1, 0 ), + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerstrike Rk. III' ORDER BY id DESC LIMIT 1), 1024, 0, 95, 9, 1, 0 ), + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerthrust' ORDER BY id DESC LIMIT 1), 1024, 0, 100, 255, 1, 0 ), + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerthrust Rk. II' ORDER BY id DESC LIMIT 1), 1024, 0, 100, 255, 1, 0 ), + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 1), (SELECT id FROM spells_new WHERE name = 'Daggerthrust Rk. III' ORDER BY id DESC LIMIT 1), 1024, 0, 100, 255, 1, 0 ), + + +REPLACE INTO merc_spell_list_entries (merc_spell_list_id, spell_id, spell_type, stance_id, minlevel, maxlevel, slot, procChance) VALUES + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23181, 16, 0, 1, 9, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23182, 16, 0, 10, 19, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23183, 16, 0, 20, 24, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23184, 16, 0, 25, 29, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23185, 16, 0, 30, 34, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23186, 16, 0, 35, 39, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23187, 16, 0, 40, 44, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23188, 16, 0, 45, 49, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23189, 16, 0, 50, 54, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23190, 16, 0, 55, 59, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23191, 16, 0, 60, 64, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23192, 16, 0, 65, 69, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23193, 16, 0, 70, 74, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23194, 16, 0, 75, 79, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23195, 16, 0, 80, 80, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23196, 16, 0, 81, 81, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23197, 16, 0, 82, 82, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23198, 16, 0, 83, 83, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23199, 16, 0, 84, 84, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 23200, 16, 0, 85, 95, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), 37747, 16, 0, 96, 255, 1, 0 ), -- Strike of Impaired Vision + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Hide' ORDER BY id DESC LIMIT 1), 8, 0, 1, 255, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Sneak Attack' ORDER BY id DESC LIMIT 1), 1024, 0, 20, 51, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Thief\'s Vengeance' ORDER BY id DESC LIMIT 1), 1024, 0, 52, 62, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Assassin\'s Strike' ORDER BY id DESC LIMIT 1), 1024, 0, 63, 64, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Ancient: Chaos Strike' ORDER BY id DESC LIMIT 1), 1024, 0, 65, 68, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Thief\'s eyes' ORDER BY id DESC LIMIT 1), 1024, 0, 68, 255, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerfall' ORDER BY id DESC LIMIT 1), 1024, 0, 69, 69, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Razorarc' ORDER BY id DESC LIMIT 1), 1024, 0, 70, 79, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Swiftblade' ORDER BY id DESC LIMIT 1), 1024, 0, 80, 84, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Swiftblade Rk. II' ORDER BY id DESC LIMIT 1), 1024, 0, 80, 84, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Swiftblade Rk. III' ORDER BY id DESC LIMIT 1), 1024, 0, 80, 84, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerlunge' ORDER BY id DESC LIMIT 1), 1024, 0, 85, 89, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerlunge Rk. II' ORDER BY id DESC LIMIT 1), 1024, 0, 85, 89, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerlunge Rk. III' ORDER BY id DESC LIMIT 1), 1024, 0, 85, 89, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerswipe' ORDER BY id DESC LIMIT 1), 1024, 0, 90, 94, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerswipe Rk. II' ORDER BY id DESC LIMIT 1), 1024, 0, 90, 94, 1, 0 ), + ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerswipe Rk. III' ORDER BY id DESC LIMIT 1), 1024, 0, 90, 94, 1, 0 ); + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerstrike' ORDER BY id DESC LIMIT 1), 1024, 0, 95, 99, 1, 0 ), + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerstrike Rk. II' ORDER BY id DESC LIMIT 1), 1024, 0, 95, 99, 1, 0 ), + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerstrike Rk. III' ORDER BY id DESC LIMIT 1), 1024, 0, 95, 99, 1, 0 ), + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerthrust' ORDER BY id DESC LIMIT 1), 1024, 0, 100, 255, 1, 0 ), + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerthrust Rk. II' ORDER BY id DESC LIMIT 1), 1024, 0, 100, 255, 1, 0 ), + -- ((SELECT merc_spell_list_id FROM merc_spell_lists WHERE class_id = 9 AND proficiency_id = 2), (SELECT id FROM spells_new WHERE name = 'Daggerthrust Rk. III' ORDER BY id DESC LIMIT 1), 1024, 0, 100, 255, 1, 0 ); diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index 28ac0bccb..25a0bc197 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -258,8 +258,8 @@ Mob *HateList::GetTop(Mob *center) int32 hate = -1; if (RuleB(Aggro,SmartAggroList)){ - Mob* topClientInRange = NULL; - int32 hateClientInRange = -1; + Mob* topClientTypeInRange = NULL; + int32 hateClientTypeInRange = -1; int skipped_count = 0; LinkedListIterator iterator(list); @@ -313,9 +313,9 @@ Mob *HateList::GetTop(Mob *center) if(center->CombatRange(cur->ent)){ aggroMod += RuleI(Aggro, MeleeRangeAggroMod); - if(currentHate > hateClientInRange || cur->bFrenzy){ - hateClientInRange = currentHate; - topClientInRange = cur->ent; + if(currentHate > hateClientTypeInRange || cur->bFrenzy){ + hateClientTypeInRange = currentHate; + topClientTypeInRange = cur->ent; } } } @@ -351,18 +351,26 @@ Mob *HateList::GetTop(Mob *center) iterator.Advance(); } - if(topClientInRange != NULL && top != NULL) { + if(topClientTypeInRange != NULL && top != NULL) { bool isTopClientType = top->IsClient(); #ifdef BOTS if(!isTopClientType) { if(top->IsBot()) { isTopClientType = true; - topClientInRange = top; + topClientTypeInRange = top; } } #endif //BOTS + + if(!isTopClientType) { + if(top->IsMerc()) { + isTopClientType = true; + topClientTypeInRange = top; + } + } + if(!isTopClientType) - return topClientInRange; + return topClientTypeInRange; return top; } diff --git a/zone/merc.cpp b/zone/merc.cpp index 4d3b2881b..67199c251 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -351,13 +351,6 @@ void Merc::CalcItemBonuses(StatBonuses* newbon) { AddItemBonuses(inst, newbon); }*/ - //tribute items - /*for (i = 0; i < MAX_PLAYER_TRIBUTES; i++) { - const ItemInst* inst = m_inv[TRIBUTE_SLOT_START + i]; - if(inst == 0) - continue; - AddItemBonuses(inst, newbon, false, true); - }*/ // Caps if(newbon->HPRegen > CalcHPRegenCap()) newbon->HPRegen = CalcHPRegenCap(); @@ -1866,10 +1859,6 @@ void Merc::AI_Process() { //TODO: Implement passive stances. //if(GetStance() != MercStancePassive) { if(!AI_IdleCastCheck() && !IsCasting()) { - if(GetClass() == MELEEDPS && !hidden) { - TryHide(); - } - if(GetArchetype() == ARCHETYPE_CASTER) { MercMeditate(true); } @@ -2028,7 +2017,9 @@ bool Merc::AI_IdleCastCheck() { result = true; break; case MELEEDPS: - failedToCast = true; + if(!entity_list.Merc_AICheckCloseBeneficialSpells(this, 100, MercAISpellRange, SpellType_Buff)) { + failedToCast = true; + } break; case CASTERDPS: failedToCast = true; @@ -2146,7 +2137,6 @@ bool Merc::AIDoSpellCast(uint16 spellid, Mob* tar, int32 mana_cost, uint32* oDon } else { //handle spell recast and recast timers SetSpellTimeCanCast(mercSpell.spellid, spells[spellid].recast_time); - //mercSpell.time_cancast = Timer::GetCurrentTime() + spells[spellid].recast_time; if(spells[spellid].EndurTimerIndex > 0) { SetSpellRecastTimer(spells[spellid].EndurTimerIndex, spellid, spells[spellid].recast_time); @@ -2321,7 +2311,7 @@ bool Merc::AICastSpell(int8 iChance, int32 iSpellTypes) { } case SpellType_Buff: { - if(GetManaRatio() < 50) { + if(GetClass() == HEALER && GetManaRatio() < 50) { return false; //mercs buff when Mana > 50% } @@ -2331,52 +2321,87 @@ bool Merc::AICastSpell(int8 iChance, int32 iSpellTypes) { MercSpell selectedMercSpell = *itr; if(!((spells[selectedMercSpell.spellid].targettype == ST_Target || spells[selectedMercSpell.spellid].targettype == ST_Pet || - spells[selectedMercSpell.spellid].targettype == ST_Group || spells[selectedMercSpell.spellid].targettype == ST_GroupTeleport ))) { + spells[selectedMercSpell.spellid].targettype == ST_Group || spells[selectedMercSpell.spellid].targettype == ST_GroupTeleport || + spells[selectedMercSpell.spellid].targettype == ST_Self))) { continue; } - for( int i = 0; i < MAX_GROUP_MEMBERS; i++) { - if(g->members[i]) { - int32 oDontDoAgainBefore; - Mob* tar = g->members[i]; + if(spells[selectedMercSpell.spellid].targettype == ST_Self) { + if( !this->IsImmuneToSpell(selectedMercSpell.spellid, this) + && (this->CanBuffStack(selectedMercSpell.spellid, mercLevel, true) >= 0)) { - if( !tar->IsImmuneToSpell(selectedMercSpell.spellid, this) - && (tar->CanBuffStack(selectedMercSpell.spellid, mercLevel, true) >= 0)) { - - if( tar->GetArchetype() == ARCHETYPE_MELEE && IsEffectInSpell(selectedMercSpell.spellid, SE_IncreaseSpellHaste)) { - continue; - } - - uint32 TempDontBuffMeBeforeTime = tar->DontBuffMeBefore(); - - if(AIDoSpellCast(selectedMercSpell.spellid, tar, -1, &TempDontBuffMeBeforeTime)) { - if(TempDontBuffMeBeforeTime != tar->DontBuffMeBefore()) - tar->SetDontBuffMeBefore(TempDontBuffMeBeforeTime); - - castedSpell = true; - } + if( this->GetArchetype() == ARCHETYPE_MELEE && IsEffectInSpell(selectedMercSpell.spellid, SE_IncreaseSpellHaste)) { + continue; } - if(!castedSpell && tar->GetPet()) { + uint32 TempDontBuffMeBeforeTime = this->DontBuffMeBefore(); - //don't cast group spells on pets - if(IsGroupSpell(selectedMercSpell.spellid) - || spells[selectedMercSpell.spellid].targettype == ST_Group - || spells[selectedMercSpell.spellid].targettype == ST_GroupTeleport ) { - continue; + if(selectedMercSpell.spellid > 0) { + if(isDiscipline) { + castedSpell = UseDiscipline(selectedMercSpell.spellid, GetID()); } + else { + castedSpell = AIDoSpellCast(selectedMercSpell.spellid, this, -1, &TempDontBuffMeBeforeTime); - if(!tar->GetPet()->IsImmuneToSpell(selectedMercSpell.spellid, this) - && (tar->GetPet()->CanBuffStack(selectedMercSpell.spellid, mercLevel, true) >= 0)) { + if(TempDontBuffMeBeforeTime != this->DontBuffMeBefore()) + this->SetDontBuffMeBefore(TempDontBuffMeBeforeTime); + } + } + } + } + else { + for( int i = 0; i < MAX_GROUP_MEMBERS; i++) { + if(g->members[i]) { + int32 oDontDoAgainBefore; + Mob* tar = g->members[i]; + + if( !tar->IsImmuneToSpell(selectedMercSpell.spellid, this) + && (tar->CanBuffStack(selectedMercSpell.spellid, mercLevel, true) >= 0)) { + + if( tar->GetArchetype() == ARCHETYPE_MELEE && IsEffectInSpell(selectedMercSpell.spellid, SE_IncreaseSpellHaste)) { + continue; + } uint32 TempDontBuffMeBeforeTime = tar->DontBuffMeBefore(); - if(AIDoSpellCast(selectedMercSpell.spellid, tar->GetPet(), -1, &TempDontBuffMeBeforeTime)) { - if(TempDontBuffMeBeforeTime != tar->DontBuffMeBefore()) { - tar->SetDontBuffMeBefore(TempDontBuffMeBeforeTime); + if(selectedMercSpell.spellid > 0) { + if(isDiscipline) { + castedSpell = UseDiscipline(selectedMercSpell.spellid, GetID()); } + else { + castedSpell = AIDoSpellCast(selectedMercSpell.spellid, this, -1, &TempDontBuffMeBeforeTime); - castedSpell = true; + if(TempDontBuffMeBeforeTime != this->DontBuffMeBefore()) + this->SetDontBuffMeBefore(TempDontBuffMeBeforeTime); + } + } + } + + if(!castedSpell && tar->GetPet()) { + + //don't cast group spells on pets + if(IsGroupSpell(selectedMercSpell.spellid) + || spells[selectedMercSpell.spellid].targettype == ST_Group + || spells[selectedMercSpell.spellid].targettype == ST_GroupTeleport ) { + continue; + } + + if(!tar->GetPet()->IsImmuneToSpell(selectedMercSpell.spellid, this) + && (tar->GetPet()->CanBuffStack(selectedMercSpell.spellid, mercLevel, true) >= 0)) { + + uint32 TempDontBuffMeBeforeTime = tar->DontBuffMeBefore(); + + if(selectedMercSpell.spellid > 0) { + if(isDiscipline) { + castedSpell = UseDiscipline(selectedMercSpell.spellid, GetID()); + } + else { + castedSpell = AIDoSpellCast(selectedMercSpell.spellid, this, -1, &TempDontBuffMeBeforeTime); + + if(TempDontBuffMeBeforeTime != this->DontBuffMeBefore()) + this->SetDontBuffMeBefore(TempDontBuffMeBeforeTime); + } + } } } } @@ -2450,6 +2475,37 @@ bool Merc::AICastSpell(int8 iChance, int32 iSpellTypes) { break; } case SpellType_InCombatBuff: { + std::list buffSpellList = GetMercSpellsBySpellType(this, SpellType_InCombatBuff); + Mob* tar = this; + + for(std::list::iterator itr = buffSpellList.begin(); itr != buffSpellList.end(); itr++) { + MercSpell selectedMercSpell = *itr; + + if(!(spells[selectedMercSpell.spellid].targettype == ST_Self)) { + continue; + } + + if(spells[selectedMercSpell.spellid].skill == BACKSTAB && spells[selectedMercSpell.spellid].targettype == ST_Self) { + if(!hidden) { + continue; + } + } + + if( !tar->IsImmuneToSpell(selectedMercSpell.spellid, this) + && (tar->CanBuffStack(selectedMercSpell.spellid, mercLevel, true) >= 0)) { + + uint32 TempDontBuffMeBeforeTime = tar->DontBuffMeBefore(); + + if(selectedMercSpell.spellid > 0) { + if(isDiscipline) { + castedSpell = UseDiscipline(selectedMercSpell.spellid, GetID()); + } + else { + castedSpell = AIDoSpellCast(selectedMercSpell.spellid, this, -1); + } + } + } + } break; } case SpellType_Cure: { @@ -2724,42 +2780,6 @@ int16 Merc::GetFocusEffect(focusType type, uint16 spell_id) { } } - //Tribute Focus - for(int x = TRIBUTE_SLOT_START; x < (TRIBUTE_SLOT_START + MAX_PLAYER_TRIBUTES); ++x) - { - TempItem = NULL; - if (equipment[x] == 0) - continue; - TempItem = database.GetItem(equipment[x]); - if (TempItem && TempItem->Focus.Effect > 0 && TempItem->Focus.Effect != SPELL_UNKNOWN) { - if(rand_effectiveness) { - focus_max = CalcFocusEffect(type, TempItem->Focus.Effect, spell_id, true); - if (focus_max > 0 && focus_max_real >= 0 && focus_max > focus_max_real) { - focus_max_real = focus_max; - UsedItem = TempItem; - UsedFocusID = TempItem->Focus.Effect; - } else if (focus_max < 0 && focus_max < focus_max_real) { - focus_max_real = focus_max; - UsedItem = TempItem; - UsedFocusID = TempItem->Focus.Effect; - } - } - else { - Total = CalcFocusEffect(type, TempItem->Focus.Effect, spell_id); - if (Total > 0 && realTotal >= 0 && Total > realTotal) { - realTotal = Total; - UsedItem = TempItem; - UsedFocusID = TempItem->Focus.Effect; - } - else if (Total < 0 && Total < realTotal) { - realTotal = Total; - UsedItem = TempItem; - UsedFocusID = TempItem->Focus.Effect; - } - } - } - } - if(UsedItem && rand_effectiveness && focus_max_real != 0) realTotal = CalcFocusEffect(type, UsedFocusID, spell_id); @@ -3166,6 +3186,7 @@ int8 Merc::GetChanceToCastBySpellType(int16 spellType) { break; } case MELEEDPS:{ + chance = 50; break; } case CASTERDPS:{ @@ -3204,9 +3225,11 @@ int8 Merc::GetChanceToCastBySpellType(int16 spellType) { bool Merc::CheckStance(int16 stance) { + //checks of current stance matches stances listed as valid for spell in database + //stance = 0 for all stances, stance # for only that stance & -stance# for all but that stance if(stance == 0 || (stance > 0 && stance == GetStance()) - || (stance < 0 && abs(stance) == GetStance())) { + || (stance < 0 && abs(stance) != GetStance())) { return true; } @@ -3301,7 +3324,7 @@ MercSpell Merc::GetMercSpellBySpellID(Merc* caster, uint16 spellid) { continue; } - if((mercSpellList[i].spellid = spellid) + if((mercSpellList[i].spellid == spellid) && caster->CheckStance(mercSpellList[i].stance)) { result.spellid = mercSpellList[i].spellid; result.stance = mercSpellList[i].stance; @@ -4296,15 +4319,20 @@ bool Merc::UseDiscipline(int32 spell_id, int32 target) { return(false); } - //can we use the spell? const SPDat_Spell_Struct &spell = spells[spell_id]; - int8 level_to_use = spell.classes[GetClass() - 1]; - if(level_to_use == 255) { - return(false); - } - if(level_to_use > GetLevel()) { - return(false); + if(spell.recast_time > 0) + { + if(CheckDisciplineRecastTimers(this, spell_id, spells[spell_id].EndurTimerIndex)) { + if(spells[spell_id].EndurTimerIndex > 0) { + SetDisciplineRecastTimer(spells[spell_id].EndurTimerIndex, spell_id, spell.recast_time); + } + + SetSpellTimeCanCast(spell_id, spells[spell_id].recast_time); + } + else { + return(false); + } } if(GetEndurance() > spell.EndurCost) { @@ -4314,18 +4342,6 @@ bool Merc::UseDiscipline(int32 spell_id, int32 target) { return(false); } - if(spell.recast_time > 0) - { - if(CheckDisciplineRecastTimers(this, spells[spell_id].EndurTimerIndex)) { - if(spells[spell_id].EndurTimerIndex > 0) { - SetDisciplineRecastTimer(spells[spell_id].EndurTimerIndex, spell_id, spell.recast_time); - } - } - else { - return(false); - } - } - if(IsCasting()) InterruptSpell(); @@ -4398,13 +4414,14 @@ int32 Merc::GetDisciplineRemainingTime(Merc *caster, uint16 timer_id) { return result; } -bool Merc::CheckDisciplineRecastTimers(Merc *caster, uint16 spell_id) { +bool Merc::CheckDisciplineRecastTimers(Merc *caster, uint16 spell_id, uint16 timer_id) { if(caster) { MercSpell mercSpell = GetMercSpellBySpellID(caster, spell_id); if(mercSpell.spellid > 0 && mercSpell.time_cancast < Timer::GetCurrentTime()) { //checks spell recast - if(GetDisciplineRecastTimer(caster, spells[spell_id].EndurTimerIndex) < Timer::GetCurrentTime()) { //checks for spells on the same timer - return true; //can cast spell + if(timer_id > 0 && !(GetDisciplineRecastTimer(caster, timer_id) < Timer::GetCurrentTime())) { //checks for spells on the same timer + return false; //can't cast spell } + return true; } } return false; @@ -5376,7 +5393,7 @@ bool Client::CheckCanHireMerc(Mob* merchant, uint32 template_id) { //check for sufficient funds if(RuleB(Mercs, ChargeMercPurchaseCost)) { uint32 cost = Merc::CalcPurchaseCost(template_id, GetLevel()) * 100; // Cost is in gold - if(!HasMoney(cost)) { + if(cost > 0 && !HasMoney(cost)) { SendMercMerchantResponsePacket(1); result = false; } @@ -5414,7 +5431,7 @@ bool Client::CheckCanRetainMerc(uint32 upkeep) { //check for sufficient funds if(RuleB(Mercs, ChargeMercPurchaseCost)) { if(merc) { - if(!HasMoney(upkeep * 100)) { + if(upkeep > 0 && !HasMoney(upkeep * 100)) { SendMercMerchantResponsePacket(1); result = false; } diff --git a/zone/merc.h b/zone/merc.h index faf19eec3..b76bb566d 100644 --- a/zone/merc.h +++ b/zone/merc.h @@ -90,7 +90,7 @@ public: static int32 GetSpellRecastTimer(Merc *caster, uint16 timer_id); static bool CheckSpellRecastTimers(Merc *caster, uint16 spellid); static int32 GetDisciplineRecastTimer(Merc *caster, uint16 timer_id); - static bool CheckDisciplineRecastTimers(Merc *caster, uint16 spellid); + static bool CheckDisciplineRecastTimers(Merc *caster, uint16 spell_id, uint16 timer_id); static int32 GetDisciplineRemainingTime(Merc *caster, uint16 timer_id); static std::list GetMercSpellsForSpellEffect(Merc* caster, int spellEffect); static std::list GetMercSpellsForSpellEffectAndTargetType(Merc* caster, int spellEffect, SpellTargetType targetType);