From f12090d109a1cc73b410c203150b439b687f6ad3 Mon Sep 17 00:00:00 2001 From: Aeadoin <109764533+Aeadoin@users.noreply.github.com> Date: Fri, 16 Dec 2022 17:21:37 -0500 Subject: [PATCH] [Bots] Cleanup various Bot Spell Focus methods (#2649) * [Bots] Cleanup GetFocusEffect & GetActSpellDamage * Remove unused CalcBotFocusEffect * Cleanup unneeded derived class methods * compile error --- zone/bot.cpp | 967 +---------------------------------------- zone/bot.h | 6 +- zone/bot_command.cpp | 2 +- zone/client.h | 2 - zone/effects.cpp | 10 +- zone/inventory.cpp | 24 +- zone/lua_bot.cpp | 8 +- zone/mob.h | 4 +- zone/npc.h | 4 +- zone/perl_bot.cpp | 12 +- zone/pets.cpp | 2 +- zone/spell_effects.cpp | 68 +-- 12 files changed, 87 insertions(+), 1022 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 51f0fb05c..c58225ee4 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -5457,836 +5457,6 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b return false; } -int32 Bot::CalcBotAAFocus(focusType type, uint32 aa_ID, uint32 points, uint16 spell_id) -{ - const SPDat_Spell_Struct &spell = spells[spell_id]; - int32 value = 0; - int lvlModifier = 100; - int spell_level = 0; - int lvldiff = 0; - bool LimitSpellSkill = false; - bool SpellSkill_Found = false; - uint32 effect = 0; - int32 base_value = 0; - int32 limit_value = 0; - uint32 slot = 0; - bool LimitFound = false; - int FocusCount = 0; - - auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa_ID, points); - auto ability = ability_rank.first; - auto rank = ability_rank.second; - - if(!ability) { - return 0; - } - - for(auto &eff : rank->effects) { - effect = eff.effect_id; - base_value = eff.base_value; - limit_value = eff.limit_value; - slot = eff.slot; - - //AA Foci's can contain multiple focus effects within the same AA. - //To handle this we will not automatically return zero if a limit is found. - //Instead if limit is found and multiple effects, we will reset the limit check - //when the next valid focus effect is found. - if (IsFocusEffect(0, 0, true,effect) || (effect == SE_TriggerOnCast)) { - FocusCount++; - //If limit found on prior check next, else end loop. - if (FocusCount > 1) { - if (LimitFound) { - value = 0; - LimitFound = false; - } - else - break; - } - } - - - switch (effect) { - case SE_Blank: - break; - case SE_LimitResist: - if(base_value) { - if(spell.resist_type != base_value) - LimitFound = true; - } - break; - case SE_LimitInstant: - if(spell.buff_duration) - LimitFound = true; - break; - case SE_LimitMaxLevel: - spell_level = spell.classes[(GetClass() % 17) - 1]; - lvldiff = spell_level - base_value; - //every level over cap reduces the effect by base2 percent unless from a clicky when ItemCastsUseFocus is true - if(lvldiff > 0 && (spell_level <= RuleI(Character, MaxLevel) || RuleB(Character, ItemCastsUseFocus) == false)) { - if(limit_value > 0) { - lvlModifier -= (limit_value * lvldiff); - if(lvlModifier < 1) - LimitFound = true; - } - else - LimitFound = true; - } - break; - case SE_LimitMinLevel: - if((spell.classes[(GetClass() % 17) - 1]) < base_value) - LimitFound = true; - break; - case SE_LimitCastTimeMin: - if (spell.cast_time < base_value) - LimitFound = true; - break; - case SE_LimitSpell: - if(base_value < 0) { - if (spell_id == (base_value*-1)) - LimitFound = true; - } else { - if (spell_id != base_value) - LimitFound = true; - } - break; - case SE_LimitMinDur: - if (base_value > CalcBuffDuration_formula(GetLevel(), spell.buff_duration_formula, spell.buff_duration)) - LimitFound = true; - break; - case SE_LimitEffect: - if(base_value < 0) { - if(IsEffectInSpell(spell_id,(base_value*-1))) - LimitFound = true; - } else { - if(!IsEffectInSpell(spell_id,base_value)) - LimitFound = true; - } - break; - case SE_LimitSpellType: - switch(base_value) { - case 0: - if (!IsDetrimentalSpell(spell_id)) - LimitFound = true; - break; - case 1: - if (!IsBeneficialSpell(spell_id)) - LimitFound = true; - break; - } - break; - - case SE_LimitManaMin: - if(spell.mana < base_value) - LimitFound = true; - break; - case SE_LimitTarget: - if(base_value < 0) { - if(-base_value == spell.target_type) - LimitFound = true; - } else { - if(base_value != spell.target_type) - LimitFound = true; - } - break; - case SE_LimitCombatSkills: - if((base_value == 1 && !IsDiscipline(spell_id)) || (base_value == 0 && IsDiscipline(spell_id))) - LimitFound = true; - break; - case SE_LimitSpellGroup: - if((base_value > 0 && base_value != spell.spell_group) || (base_value < 0 && base_value == spell.spell_group)) - LimitFound = true; - break; - case SE_LimitCastingSkill: - LimitSpellSkill = true; - if(base_value == spell.skill) - SpellSkill_Found = true; - break; - case SE_LimitClass: - //Do not use this limit more then once per spell. If multiple class, treat value like items would. - if (!PassLimitClass(base_value, GetClass())) - LimitFound = true; - break; - //Handle Focus Effects - case SE_ImprovedDamage: - if (type == focusImprovedDamage && base_value > value) - value = base_value; - break; - case SE_ImprovedDamage2: - if (type == focusImprovedDamage2 && base_value > value) - value = base_value; - break; - case SE_ImprovedHeal: - if (type == focusImprovedHeal && base_value > value) - value = base_value; - break; - case SE_ReduceManaCost: - if (type == focusManaCost) - value = base_value; - break; - case SE_IncreaseSpellHaste: - if (type == focusSpellHaste && base_value > value) - value = base_value; - break; - case SE_IncreaseSpellDuration: - if (type == focusSpellDuration && base_value > value) - value = base_value; - break; - case SE_SpellDurationIncByTic: - if (type == focusSpellDurByTic && base_value > value) - value = base_value; - break; - case SE_SwarmPetDuration: - if (type == focusSwarmPetDuration && base_value > value) - value = base_value; - break; - case SE_IncreaseRange: - if (type == focusRange && base_value > value) - value = base_value; - break; - case SE_ReduceReagentCost: - if (type == focusReagentCost && base_value > value) - value = base_value; - break; - case SE_PetPowerIncrease: - if (type == focusPetPower && base_value > value) - value = base_value; - break; - case SE_SpellResistReduction: - if (type == focusResistRate && base_value > value) - value = base_value; - break; - case SE_SpellHateMod: - if (type == focusSpellHateMod) { - if(value != 0) { - if(value > 0) { - if(base_value > value) - value = base_value; - } else { - if(base_value < value) - value = base_value; - } - } - else - value = base_value; - } - break; - - case SE_ReduceReuseTimer: { - if(type == focusReduceRecastTime) - value = (base_value / 1000); - break; - } - case SE_TriggerOnCast: { - if(type == focusTriggerOnCast) { - if(zone->random.Int(0, 100) <= base_value) - value = limit_value; - else { - value = 0; - LimitFound = true; - } - } - break; - } - case SE_FcSpellVulnerability: { - if(type == focusSpellVulnerability) - value = base_value; - break; - } - case SE_BlockNextSpellFocus: { - if(type == focusBlockNextSpell) { - if(zone->random.Int(1, 100) <= base_value) - value = 1; - } - break; - } - case SE_FcTwincast: { - if(type == focusTwincast) - value = base_value; - break; - } - //case SE_SympatheticProc: - //{ - // if(type == focusSympatheticProc) - // { - // float ProcChance, ProcBonus; - // int16 ProcRateMod = base1; //Baseline is 100 for most Sympathetic foci - // int32 cast_time = GetActSpellCasttime(spell_id, spells[spell_id].cast_time); - // GetSympatheticProcChances(ProcBonus, ProcChance, cast_time, ProcRateMod); - - // if(zone->random.Real(0, 1) <= ProcChance) - // value = focus_id; - - // else - // value = 0; - // } - // break; - //} - case SE_FcDamageAmt: { - if(type == focusFcDamageAmt) - value = base_value; - break; - } - case SE_FcDamageAmt2: { - if(type == focusFcDamageAmt2) - value = base_value; - break; - } - case SE_FcDamageAmtCrit: { - if(type == focusFcDamageAmtCrit) - value = base_value; - break; - } - case SE_FcDamageAmtIncoming: { - if(type == focusFcDamageAmtIncoming) - value = base_value; - break; - } - case SE_FcHealAmtIncoming: - if(type == focusFcHealAmtIncoming) - value = base_value; - break; - case SE_FcHealPctCritIncoming: - if (type == focusFcHealPctCritIncoming) - value = base_value; - break; - case SE_FcHealAmtCrit: - if(type == focusFcHealAmtCrit) - value = base_value; - break; - case SE_FcHealAmt: - if(type == focusFcHealAmt) - value = base_value; - break; - case SE_FcHealPctIncoming: - if(type == focusFcHealPctIncoming) - value = base_value; - break; - case SE_FcBaseEffects: { - if (type == focusFcBaseEffects) - value = base_value; - break; - } - case SE_FcDamagePctCrit: { - if(type == focusFcDamagePctCrit) - value = base_value; - break; - } - case SE_FcIncreaseNumHits: { - if(type == focusIncreaseNumHits) - value = base_value; - break; - } - - //Check for spell skill limits. - if ((LimitSpellSkill) && (!SpellSkill_Found)) - return 0; - } - } - - if (LimitFound) - return 0; - - return (value * lvlModifier / 100); -} - -int32 Bot::GetBotFocusEffect(focusType bottype, uint16 spell_id, bool from_buff_tic) { - if (IsBardSong(spell_id) && bottype != focusFcBaseEffects) - return 0; - - int32 realTotal = 0; - int32 realTotal2 = 0; - int32 realTotal3 = 0; - bool rand_effectiveness = false; - //Improved Healing, Damage & Mana Reduction are handled differently in that some are random percentages - //In these cases we need to find the most powerful effect, so that each piece of gear wont get its own chance - if(RuleB(Spells, LiveLikeFocusEffects) && (bottype == focusManaCost || bottype == focusImprovedHeal || bottype == focusImprovedDamage || bottype == focusImprovedDamage2 || bottype == focusResistRate)) - rand_effectiveness = true; - - //Check if item focus effect exists for the client. - if (itembonuses.FocusEffects[bottype]) { - const EQ::ItemData* TempItem = nullptr; - const EQ::ItemData* UsedItem = nullptr; - const EQ::ItemInstance* TempInst = nullptr; - uint16 UsedFocusID = 0; - int32 Total = 0; - int32 focus_max = 0; - int32 focus_max_real = 0; - //item focus - // are focus effects the same as bonus? (slotAmmo-excluded) - for (int x = EQ::invslot::EQUIPMENT_BEGIN; x <= EQ::invslot::EQUIPMENT_END; x++) { - TempItem = nullptr; - EQ::ItemInstance* ins = GetBotItem(x); - if (!ins) - continue; - - TempItem = ins->GetItem(); - if (TempItem && TempItem->Focus.Effect > 0 && TempItem->Focus.Effect != SPELL_UNKNOWN) { - if(rand_effectiveness) { - focus_max = CalcBotFocusEffect(bottype, TempItem->Focus.Effect, spell_id, true); - if ((focus_max > 0 && focus_max_real >= 0 && focus_max > focus_max_real) || (focus_max < 0 && focus_max < focus_max_real)) { - focus_max_real = focus_max; - UsedItem = TempItem; - UsedFocusID = TempItem->Focus.Effect; - } - } else { - Total = CalcBotFocusEffect(bottype, TempItem->Focus.Effect, spell_id); - if ((Total > 0 && realTotal >= 0 && Total > realTotal) || (Total < 0 && Total < realTotal)) { - realTotal = Total; - UsedItem = TempItem; - UsedFocusID = TempItem->Focus.Effect; - } - } - } - - for (int y = EQ::invaug::SOCKET_BEGIN; y <= EQ::invaug::SOCKET_END; ++y) { - EQ::ItemInstance *aug = nullptr; - aug = ins->GetAugment(y); - if(aug) { - const EQ::ItemData* TempItemAug = aug->GetItem(); - if (TempItemAug && TempItemAug->Focus.Effect > 0 && TempItemAug->Focus.Effect != SPELL_UNKNOWN) { - if(rand_effectiveness) { - focus_max = CalcBotFocusEffect(bottype, TempItemAug->Focus.Effect, spell_id, true); - if ((focus_max > 0 && focus_max_real >= 0 && focus_max > focus_max_real) || (focus_max < 0 && focus_max < focus_max_real)) { - focus_max_real = focus_max; - UsedItem = TempItem; - UsedFocusID = TempItemAug->Focus.Effect; - } - } else { - Total = CalcBotFocusEffect(bottype, TempItemAug->Focus.Effect, spell_id); - if ((Total > 0 && realTotal >= 0 && Total > realTotal) || (Total < 0 && Total < realTotal)) { - realTotal = Total; - UsedItem = TempItem; - UsedFocusID = TempItemAug->Focus.Effect; - } - } - } - } - } - } - - if(UsedItem && rand_effectiveness && focus_max_real != 0) - realTotal = CalcBotFocusEffect(bottype, UsedFocusID, spell_id); - } - - //Check if spell focus effect exists for the client. - if (spellbonuses.FocusEffects[bottype]) { - //Spell Focus - int32 Total2 = 0; - int32 focus_max2 = 0; - int32 focus_max_real2 = 0; - int buff_tracker = -1; - int buff_slot = 0; - uint32 focusspellid = 0; - uint32 focusspell_tracker = 0; - uint32 buff_max = GetMaxTotalSlots(); - for (buff_slot = 0; buff_slot < buff_max; buff_slot++) { - focusspellid = buffs[buff_slot].spellid; - if (focusspellid == 0 || focusspellid >= SPDAT_RECORDS) - continue; - - if(rand_effectiveness) { - focus_max2 = CalcBotFocusEffect(bottype, focusspellid, spell_id, true); - if ((focus_max2 > 0 && focus_max_real2 >= 0 && focus_max2 > focus_max_real2) || (focus_max2 < 0 && focus_max2 < focus_max_real2)) { - focus_max_real2 = focus_max2; - buff_tracker = buff_slot; - focusspell_tracker = focusspellid; - } - } else { - Total2 = CalcBotFocusEffect(bottype, focusspellid, spell_id); - if ((Total2 > 0 && realTotal2 >= 0 && Total2 > realTotal2) || (Total2 < 0 && Total2 < realTotal2)) { - realTotal2 = Total2; - buff_tracker = buff_slot; - focusspell_tracker = focusspellid; - } - } - } - - if(focusspell_tracker && rand_effectiveness && focus_max_real2 != 0) - realTotal2 = CalcBotFocusEffect(bottype, focusspell_tracker, spell_id); - - if (!from_buff_tic && buff_tracker >= 0 && buffs[buff_tracker].hit_number > 0) { - CheckNumHitsRemaining(NumHit::MatchingSpells, buff_tracker); - } - } - - // AA Focus - if (aabonuses.FocusEffects[bottype]) { - int32 Total3 = 0; - uint32 slots = 0; - uint32 aa_AA = 0; - uint32 aa_value = 0; - - for(auto &aa : aa_ranks) { - auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa.first, aa.second.first); - auto ability = ability_rank.first; - auto rank = ability_rank.second; - - if(!ability) { - continue; - } - - aa_AA = ability->id; - aa_value = aa.second.first; - if (aa_AA < 1 || aa_value < 1) - continue; - - Total3 = CalcBotAAFocus(bottype, aa_AA, aa_value, spell_id); - if (Total3 > 0 && realTotal3 >= 0 && Total3 > realTotal3) { - realTotal3 = Total3; - } - else if (Total3 < 0 && Total3 < realTotal3) { - realTotal3 = Total3; - } - } - } - - if(bottype == focusReagentCost && IsSummonPetSpell(spell_id) && GetAA(aaElementalPact)) - return 100; - - if(bottype == focusReagentCost && (IsEffectInSpell(spell_id, SE_SummonItem) || IsSacrificeSpell(spell_id))) - return 0; - - return (realTotal + realTotal2); -} - -int32 Bot::CalcBotFocusEffect(focusType bottype, uint16 focus_id, uint16 spell_id, bool best_focus) { - if(!IsValidSpell(focus_id) || !IsValidSpell(spell_id)) - return 0; - - const SPDat_Spell_Struct &focus_spell = spells[focus_id]; - const SPDat_Spell_Struct &spell = spells[spell_id]; - int32 value = 0; - int lvlModifier = 100; - int spell_level = 0; - int lvldiff = 0; - bool LimitSpellSkill = false; - bool SpellSkill_Found = false; - for (int i = 0; i < EFFECT_COUNT; i++) { - switch (focus_spell.effect_id[i]) { - case SE_Blank: - break; - case SE_LimitResist:{ - if(focus_spell.base_value[i]) { - if(spell.resist_type != focus_spell.base_value[i]) - return 0; - } - break; - } - case SE_LimitInstant: { - if(spell.buff_duration) - return 0; - break; - } - case SE_LimitMaxLevel:{ - if (IsNPC()) - break; - spell_level = spell.classes[(GetClass() % 17) - 1]; - lvldiff = (spell_level - focus_spell.base_value[i]); - if(lvldiff > 0 && (spell_level <= RuleI(Character, MaxLevel) || RuleB(Character, ItemCastsUseFocus) == false)) { - if(focus_spell.limit_value[i] > 0) { - lvlModifier -= (focus_spell.limit_value[i] * lvldiff); - if(lvlModifier < 1) - return 0; - } - else - return 0; - } - break; - } - case SE_LimitMinLevel: - if (IsNPC()) - break; - if (spell.classes[(GetClass() % 17) - 1] < focus_spell.base_value[i]) - return 0; - break; - - case SE_LimitCastTimeMin: - if (spells[spell_id].cast_time < (uint32)focus_spell.base_value[i]) - return 0; - break; - case SE_LimitSpell: - if(focus_spell.base_value[i] < 0) { - if (spell_id == (focus_spell.base_value[i] * -1)) - return 0; - } else { - if (spell_id != focus_spell.base_value[i]) - return 0; - } - break; - case SE_LimitMinDur: - if (focus_spell.base_value[i] > CalcBuffDuration_formula(GetLevel(), spell.buff_duration_formula, spell.buff_duration)) - return 0; - break; - case SE_LimitEffect: - if(focus_spell.base_value[i] < 0) { - if(IsEffectInSpell(spell_id,focus_spell.base_value[i])) - return 0; - } else { - if(focus_spell.base_value[i] == SE_SummonPet) { - if(!IsEffectInSpell(spell_id, SE_SummonPet) && !IsEffectInSpell(spell_id, SE_NecPet) && !IsEffectInSpell(spell_id, SE_SummonBSTPet)) { - return 0; - } - } else if(!IsEffectInSpell(spell_id,focus_spell.base_value[i])) - return 0; - } - break; - - - case SE_LimitSpellType: - switch(focus_spell.base_value[i]) { - case 0: - if (!IsDetrimentalSpell(spell_id)) - return 0; - break; - case 1: - if (!IsBeneficialSpell(spell_id)) - return 0; - break; - default: - LogInfo("[Bot::CalcBotFocusEffect] CalcFocusEffect: unknown limit spelltype [{}]", focus_spell.base_value[i]); - } - break; - - case SE_LimitManaMin: - if(spell.mana < focus_spell.base_value[i]) - return 0; - break; - case SE_LimitTarget: - if((focus_spell.base_value[i] < 0) && -focus_spell.base_value[i] == spell.target_type) - return 0; - else if (focus_spell.base_value[i] > 0 && focus_spell.base_value[i] != spell.target_type) - return 0; - break; - case SE_LimitCombatSkills: - if(focus_spell.base_value[i] == 1 && !IsDiscipline(spell_id)) - return 0; - else if(focus_spell.base_value[i] == 0 && IsDiscipline(spell_id)) - return 0; - break; - case SE_LimitSpellGroup: - if(focus_spell.base_value[i] > 0 && focus_spell.base_value[i] != spell.spell_group) - return 0; - else if(focus_spell.base_value[i] < 0 && focus_spell.base_value[i] == spell.spell_group) - return 0; - break; - case SE_LimitCastingSkill: - LimitSpellSkill = true; - if(focus_spell.base_value[i] == spell.skill) - SpellSkill_Found = true; - break; - case SE_LimitClass: - if (!PassLimitClass(focus_spell.base_value[i], GetClass())) - return 0; - break; - case SE_ImprovedDamage: - if (bottype == focusImprovedDamage) { - if(best_focus) { - if (focus_spell.limit_value[i] != 0) - value = focus_spell.limit_value[i]; - else - value = focus_spell.base_value[i]; - } - else if (focus_spell.limit_value[i] == 0 || focus_spell.base_value[i] == focus_spell.limit_value[i]) - value = focus_spell.base_value[i]; - else - value = zone->random.Int(focus_spell.base_value[i], focus_spell.limit_value[i]); - } - break; - case SE_ImprovedDamage2: - if (bottype == focusImprovedDamage2) { - if(best_focus) { - if (focus_spell.limit_value[i] != 0) - value = focus_spell.limit_value[i]; - else - value = focus_spell.base_value[i]; - } - else if (focus_spell.limit_value[i] == 0 || focus_spell.base_value[i] == focus_spell.limit_value[i]) - value = focus_spell.base_value[i]; - else - value = zone->random.Int(focus_spell.base_value[i], focus_spell.limit_value[i]); - } - break; - case SE_ImprovedHeal: - if (bottype == focusImprovedHeal) { - if(best_focus) { - if (focus_spell.limit_value[i] != 0) - value = focus_spell.limit_value[i]; - else - value = focus_spell.base_value[i]; - } - else if (focus_spell.limit_value[i] == 0 || focus_spell.base_value[i] == focus_spell.limit_value[i]) - value = focus_spell.base_value[i]; - else - value = zone->random.Int(focus_spell.base_value[i], focus_spell.limit_value[i]); - } - break; - case SE_ReduceManaCost: - if (bottype == focusManaCost) { - if(best_focus) { - if (focus_spell.limit_value[i] != 0) - value = focus_spell.limit_value[i]; - else - value = focus_spell.base_value[i]; - } - else if (focus_spell.limit_value[i] == 0 || focus_spell.base_value[i] == focus_spell.limit_value[i]) - value = focus_spell.base_value[i]; - else - value = zone->random.Int(focus_spell.base_value[i], focus_spell.limit_value[i]); - } - break; - case SE_IncreaseSpellHaste: - if (bottype == focusSpellHaste && focus_spell.base_value[i] > value) - value = focus_spell.base_value[i]; - break; - case SE_IncreaseSpellDuration: - if (bottype == focusSpellDuration && focus_spell.base_value[i] > value) - value = focus_spell.base_value[i]; - break; - case SE_SpellDurationIncByTic: - if (bottype == focusSpellDurByTic && focus_spell.base_value[i] > value) - value = focus_spell.base_value[i]; - break; - case SE_SwarmPetDuration: - if (bottype == focusSwarmPetDuration && focus_spell.base_value[i] > value) - value = focus_spell.base_value[i]; - break; - case SE_IncreaseRange: - if (bottype == focusRange && focus_spell.base_value[i] > value) - value = focus_spell.base_value[i]; - break; - case SE_ReduceReagentCost: - if (bottype == focusReagentCost && focus_spell.base_value[i] > value) - value = focus_spell.base_value[i]; - break; - case SE_PetPowerIncrease: - if (bottype == focusPetPower && focus_spell.base_value[i] > value) - value = focus_spell.base_value[i]; - break; - case SE_SpellResistReduction: - if (bottype == focusResistRate && focus_spell.base_value[i] > value) - value = focus_spell.base_value[i]; - break; - case SE_SpellHateMod: - if (bottype == focusSpellHateMod) { - if(value != 0) { - if(value > 0) { - if(focus_spell.base_value[i] > value) - value = focus_spell.base_value[i]; - } - else { - if(focus_spell.base_value[i] < value) - value = focus_spell.base_value[i]; - } - } else - value = focus_spell.base_value[i]; - } - break; - case SE_ReduceReuseTimer: { - if(bottype == focusReduceRecastTime) - value = (focus_spell.base_value[i] / 1000); - break; - } - case SE_TriggerOnCast: { - if(bottype == focusTriggerOnCast) { - if(zone->random.Int(0, 100) <= focus_spell.base_value[i]) - value = focus_spell.limit_value[i]; - else - value = 0; - } - break; - } - case SE_FcSpellVulnerability: { - if(bottype == focusSpellVulnerability) - value = focus_spell.base_value[i]; - break; - } - case SE_BlockNextSpellFocus: { - if(bottype == focusBlockNextSpell) { - if(zone->random.Int(1, 100) <= focus_spell.base_value[i]) - value = 1; - } - break; - } - case SE_FcTwincast: { - if(bottype == focusTwincast) - value = focus_spell.base_value[i]; - break; - } - case SE_SympatheticProc: { - if(bottype == focusSympatheticProc) { - float ProcChance = GetSympatheticProcChances(spell_id, focus_spell.base_value[i]); - if(zone->random.Real(0, 1) <= ProcChance) - value = focus_id; - else - value = 0; - } - break; - } - case SE_FcDamageAmt: { - if(bottype == focusFcDamageAmt) - value = focus_spell.base_value[i]; - break; - } - case SE_FcDamageAmt2: { - if(bottype == focusFcDamageAmt2) - value = focus_spell.base_value[i]; - break; - } - case SE_FcDamageAmtCrit: { - if(bottype == focusFcDamageAmtCrit) - value = focus_spell.base_value[i]; - break; - } - case SE_FcHealAmtIncoming: - if(bottype == focusFcHealAmtIncoming) - value = focus_spell.base_value[i]; - break; - case SE_FcHealPctCritIncoming: - if (bottype == focusFcHealPctCritIncoming) - value = focus_spell.base_value[i]; - break; - case SE_FcHealAmtCrit: - if(bottype == focusFcHealAmtCrit) - value = focus_spell.base_value[i]; - break; - case SE_FcHealAmt: - if(bottype == focusFcHealAmt) - value = focus_spell.base_value[i]; - break; - case SE_FcHealPctIncoming: - if(bottype == focusFcHealPctIncoming) - value = focus_spell.base_value[i]; - break; - case SE_FcBaseEffects: { - if (bottype == focusFcBaseEffects) - value = focus_spell.base_value[i]; - - break; - } - case SE_FcDamagePctCrit: { - if(bottype == focusFcDamagePctCrit) - value = focus_spell.base_value[i]; - - break; - } - case SE_FcIncreaseNumHits: { - if(bottype == focusIncreaseNumHits) - value = focus_spell.base_value[i]; - - break; - } - default: - LogSpellsModerate("[Bot::CalcBotFocusEffect] unknown effectid [{}]", focus_spell.effect_id[i]); - break; - } - } - //Check for spell skill limits. - if ((LimitSpellSkill) && (!SpellSkill_Found)) - return 0; - - return(value * lvlModifier / 100); -} - //proc chance includes proc bonus float Bot::GetProcChances(float ProcBonus, uint16 hand) { int mydex = GetDEX(); @@ -6933,14 +6103,14 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { int32 Bot::CheckAggroAmount(uint16 spellid) { int32 AggroAmount = Mob::CheckAggroAmount(spellid, nullptr); - int32 focusAggro = GetBotFocusEffect(focusSpellHateMod, spellid); + int64 focusAggro = GetFocusEffect(focusSpellHateMod, spellid); AggroAmount = (AggroAmount * (100 + focusAggro) / 100); return AggroAmount; } int32 Bot::CheckHealAggroAmount(uint16 spellid, Mob *target, uint32 heal_possible) { int32 AggroAmount = Mob::CheckHealAggroAmount(spellid, target, heal_possible); - int32 focusAggro = GetBotFocusEffect(focusSpellHateMod, spellid); + int64 focusAggro = GetFocusEffect(focusSpellHateMod, spellid); AggroAmount = (AggroAmount * (100 + focusAggro) / 100); return AggroAmount; } @@ -7209,116 +6379,11 @@ void Bot::SetAttackTimer() { } } -int64 Bot::GetActSpellDamage(uint16 spell_id, int64 value, Mob* target) { - if (spells[spell_id].target_type == ST_Self) - return value; - - bool Critical = false; - int32 base_value = value; - int chance = 0; - - // Need to scale HT damage differently after level 40! It no longer scales by the constant value in the spell file. It scales differently, instead of 10 more damage per level, it does 30 more damage per level. So we multiply the level minus 40 times 20 if they are over level 40. - if ((spell_id == SPELL_HARM_TOUCH || spell_id == SPELL_HARM_TOUCH2 || spell_id == SPELL_IMP_HARM_TOUCH ) && GetLevel() > 40) - value -= (GetLevel() - 40) * 20; - - //This adds the extra damage from the AA Unholy Touch, 450 per level to the AA Improved Harm TOuch. - if (spell_id == SPELL_IMP_HARM_TOUCH) //Improved Harm Touch - value -= GetAA(aaUnholyTouch) * 450; //Unholy Touch - - chance = RuleI(Spells, BaseCritChance); //Wizard base critical chance is 2% (Does not scale with level) - chance += itembonuses.CriticalSpellChance + spellbonuses.CriticalSpellChance + aabonuses.CriticalSpellChance; - chance += itembonuses.FrenziedDevastation + spellbonuses.FrenziedDevastation + aabonuses.FrenziedDevastation; - - //Crtical Hit Calculation pathway - if (chance > 0 || (GetClass() == WIZARD && GetLevel() >= RuleI(Spells, WizCritLevel))) { - - int32 ratio = RuleI(Spells, BaseCritRatio); //Critical modifier is applied from spell effects only. Keep at 100 for live like criticals. - - //Improved Harm Touch is a guaranteed crit if you have at least one level of SCF. - if (spell_id == SPELL_IMP_HARM_TOUCH && (GetAA(aaSpellCastingFury) > 0) && (GetAA(aaUnholyTouch) > 0)) - chance = 100; - - if (spells[spell_id].override_crit_chance > 0 && chance > spells[spell_id].override_crit_chance) - chance = spells[spell_id].override_crit_chance; - - if (zone->random.Roll(chance)) { - Critical = true; - ratio += itembonuses.SpellCritDmgIncrease + spellbonuses.SpellCritDmgIncrease + aabonuses.SpellCritDmgIncrease; - ratio += itembonuses.SpellCritDmgIncNoStack + spellbonuses.SpellCritDmgIncNoStack + aabonuses.SpellCritDmgIncNoStack; - } - - else if (GetClass() == WIZARD || (IsMerc() && GetClass() == CASTERDPS)) { - if ((GetLevel() >= RuleI(Spells, WizCritLevel)) && zone->random.Roll(RuleI(Spells, WizCritChance))) { - //Wizard innate critical chance is calculated seperately from spell effect and is not a set ratio. (20-70 is parse confirmed) - ratio += zone->random.Int(20,70); - Critical = true; - } - } - - if (GetClass() == WIZARD) - ratio += RuleI(Spells, WizCritRatio); //Default is zero - - if (Critical) { - - value = base_value*ratio/100; - - value += base_value*GetBotFocusEffect(focusImprovedDamage, spell_id)/100; - value += base_value*GetBotFocusEffect(focusImprovedDamage2, spell_id)/100; - - value += int(base_value*GetBotFocusEffect(focusFcDamagePctCrit, spell_id)/100)*ratio/100; - value += int(base_value*GetBotFocusEffect(focusFcAmplifyMod, spell_id) / 100)*ratio / 100; - - if (target) { - value += int(base_value*target->GetVulnerability(this, spell_id, 0)/100)*ratio/100; - value -= target->GetFcDamageAmtIncoming(this, spell_id); - } - - value -= GetBotFocusEffect(focusFcDamageAmtCrit, spell_id)*ratio/100; - - value -= GetBotFocusEffect(focusFcDamageAmt, spell_id); - value -= GetBotFocusEffect(focusFcDamageAmt2, spell_id); - value -= GetBotFocusEffect(focusFcAmplifyAmt, spell_id); - - if ((RuleB(Spells, IgnoreSpellDmgLvlRestriction) || spells[spell_id].classes[(GetClass() % 17) - 1] >= GetLevel() - 5) && !spells[spell_id].no_heal_damage_item_mod && itembonuses.SpellDmg) - value -= GetExtraSpellAmt(spell_id, itembonuses.SpellDmg, base_value) * ratio / 100; - - entity_list.MessageCloseString( - this, true, 100, Chat::SpellCrit, - OTHER_CRIT_BLAST, GetName(), itoa(-value)); - - return value; - } - } - //Non Crtical Hit Calculation pathway - value = base_value; - - value += base_value*GetBotFocusEffect(focusImprovedDamage, spell_id)/100; - value += base_value*GetBotFocusEffect(focusImprovedDamage2, spell_id)/100; - - value += base_value*GetBotFocusEffect(focusFcDamagePctCrit, spell_id)/100; - value += base_value*GetBotFocusEffect(focusFcAmplifyMod, spell_id)/100; - - if (target) { - value += base_value*target->GetVulnerability(this, spell_id, 0)/100; - value -= target->GetFcDamageAmtIncoming(this, spell_id); - } - - value -= GetBotFocusEffect(focusFcDamageAmtCrit, spell_id); - value -= GetBotFocusEffect(focusFcDamageAmt, spell_id); - value -= GetBotFocusEffect(focusFcDamageAmt2, spell_id); - value -= GetBotFocusEffect(focusFcAmplifyAmt, spell_id); - - if ((RuleB(Spells, IgnoreSpellDmgLvlRestriction) || spells[spell_id].classes[(GetClass() % 17) - 1] >= GetLevel() - 5) && !spells[spell_id].no_heal_damage_item_mod && itembonuses.SpellDmg) - value -= GetExtraSpellAmt(spell_id, itembonuses.SpellDmg, base_value); - - return value; -} - int64 Bot::GetActSpellHealing(uint16 spell_id, int64 value, Mob* target) { if (target == nullptr) target = this; - int32 base_value = value; + int64 base_value = value; int16 critical_chance = 0; int8 critical_modifier = 1; @@ -7351,8 +6416,8 @@ int64 Bot::GetActSpellHealing(uint16 spell_id, int64 value, Mob* target) { if (GetClass() == CLERIC) { value += int(base_value*RuleI(Spells, ClericInnateHealFocus) / 100); //confirmed on live parsing clerics get an innate 5 pct heal focus } - value += int(base_value*GetBotFocusEffect(focusImprovedHeal, spell_id) / 100); - value += int(base_value*GetBotFocusEffect(focusFcAmplifyMod, spell_id) / 100); + value += int(base_value*GetFocusEffect(focusImprovedHeal, spell_id) / 100); + value += int(base_value*GetFocusEffect(focusFcAmplifyMod, spell_id) / 100); // Instant Heals if (spells[spell_id].buff_duration < 1) { @@ -7364,7 +6429,7 @@ int64 Bot::GetActSpellHealing(uint16 spell_id, int64 value, Mob* target) { } */ - value += GetBotFocusEffect(focusFcHealAmtCrit, spell_id); //SPA 396 Add before critical + value += GetFocusEffect(focusFcHealAmtCrit, spell_id); //SPA 396 Add before critical //Using IgnoreSpellDmgLvlRestriction to also allow healing to scale if ((RuleB(Spells, IgnoreSpellDmgLvlRestriction) || spells[spell_id].classes[(GetClass() % 17) - 1] >= GetLevel() - 5) && !spells[spell_id].no_heal_damage_item_mod && itembonuses.HealAmt) { @@ -7380,14 +6445,9 @@ int64 Bot::GetActSpellHealing(uint16 spell_id, int64 value, Mob* target) { */ value *= critical_modifier; - value += GetBotFocusEffect(focusFcHealAmt, spell_id); //SPA 392 Add after critical - value += GetBotFocusEffect(focusFcAmplifyAmt, spell_id); //SPA 508 ? Add after critical + value += GetFocusEffect(focusFcHealAmt, spell_id); //SPA 392 Add after critical + value += GetFocusEffect(focusFcAmplifyAmt, spell_id); //SPA 508 ? Add after critical - /* - if (target) { - value += target->GetBotFocusEffect(focusFcHealAmtIncoming, spell_id, this); //SPA 394 Add after critical - } - */ if (critical_modifier > 1) { entity_list.MessageCloseString( @@ -7422,7 +6482,7 @@ int64 Bot::GetActSpellHealing(uint16 spell_id, int64 value, Mob* target) { } int32 Bot::GetActSpellCasttime(uint16 spell_id, int32 casttime) { - int32 cast_reducer = GetBotFocusEffect(focusSpellHaste, spell_id); + int64 cast_reducer = GetFocusEffect(focusSpellHaste, spell_id); auto min_cap = casttime / 2; uint8 botlevel = GetLevel(); uint8 botclass = GetClass(); @@ -7558,7 +6618,7 @@ int32 Bot::GetActSpellCost(uint16 spell_id, int32 cost) { } } - int32 focus_redux = GetBotFocusEffect(focusManaCost, spell_id); + int64 focus_redux = GetFocusEffect(focusManaCost, spell_id); if(focus_redux > 0) PercentManaReduction += zone->random.Real(1, (double)focus_redux); @@ -7585,14 +6645,15 @@ int32 Bot::GetActSpellCost(uint16 spell_id, int32 cost) { float Bot::GetActSpellRange(uint16 spell_id, float range) { float extrange = 100; - extrange += GetBotFocusEffect(focusRange, spell_id); + extrange += GetFocusEffect(focusRange, spell_id); return ((range * extrange) / 100); } int32 Bot::GetActSpellDuration(uint16 spell_id, int32 duration) { int increase = 100; - increase += GetBotFocusEffect(focusSpellDuration, spell_id); - int tic_inc = 0; tic_inc = GetBotFocusEffect(focusSpellDurByTic, spell_id); + increase += GetFocusEffect(focusSpellDuration, spell_id); + int64 tic_inc = 0; + tic_inc = GetFocusEffect(focusSpellDurByTic, spell_id); if(IsBeneficialSpell(spell_id)) { switch (GetAA(aaSpellCastingReinforcement)) { diff --git a/zone/bot.h b/zone/bot.h index 7113879f8..e76dbe1c1 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -364,7 +364,6 @@ public: // Mob Spell Virtual Override Methods virtual void SpellProcess(); - virtual int64 GetActSpellDamage(uint16 spell_id, int64 value, Mob* target = nullptr); virtual int64 GetActSpellHealing(uint16 spell_id, int64 value, Mob* target = nullptr); virtual int32 GetActSpellCasttime(uint16 spell_id, int32 casttime); virtual int32 GetActSpellCost(uint16 spell_id, int32 cost); @@ -389,7 +388,7 @@ public: void EquipBot(std::string* error_message); bool CheckLoreConflict(const EQ::ItemData* item); virtual void UpdateEquipmentLight() { m_Light.Type[EQ::lightsource::LightEquipment] = m_inv.FindBrightestLightType(); m_Light.Level[EQ::lightsource::LightEquipment] = EQ::lightsource::TypeToLevel(m_Light.Type[EQ::lightsource::LightEquipment]); } - inline EQ::InventoryProfile& GetBotInv() { return m_inv; } + inline EQ::InventoryProfile& GetInv() { return m_inv; } // Static Class Methods //static void DestroyBotRaidObjects(Client* client); // Can be removed after bot raids are dumped @@ -737,9 +736,6 @@ protected: virtual void PetAIProcess(); virtual void BotMeditate(bool isSitting); virtual bool CheckBotDoubleAttack(bool Triple = false); - virtual int32 GetBotFocusEffect(focusType bottype, uint16 spell_id, bool from_buff_tic = false); - virtual int32 CalcBotFocusEffect(focusType bottype, uint16 focus_id, uint16 spell_id, bool best_focus=false); - virtual int32 CalcBotAAFocus(focusType type, uint32 aa_ID, uint32 points, uint16 spell_id); virtual void PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client* client); virtual bool AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgainBefore = 0); diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 0d5029544..4a17aeb9b 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -3727,7 +3727,7 @@ void bot_command_item_use(Client* c, const Seperator* sep) continue; } - auto equipped_item = bot_iter->GetBotInv()[slot_iter]; + auto equipped_item = bot_iter->GetInv()[slot_iter]; if (equipped_item && !empty_only) { linker.SetItemInst(equipped_item); diff --git a/zone/client.h b/zone/client.h index d9672c812..d4a594abf 100644 --- a/zone/client.h +++ b/zone/client.h @@ -947,7 +947,6 @@ public: void SendClearPlayerAA(); inline uint32 GetAAXP() const { return m_pp.expAA; } inline uint32 GetAAPercent() const { return m_epp.perAA; } - int64 CalcAAFocus(focusType type, const AA::Rank &rank, uint16 spell_id); void SetAATitle(std::string title); void SetTitleSuffix(std::string suffix); void MemorizeSpell(uint32 slot, uint32 spellid, uint32 scribing, uint32 reduction = 0); @@ -1683,7 +1682,6 @@ protected: void MakeBuffFadePacket(uint16 spell_id, int slot_id, bool send_message = true); bool client_data_loaded; - int64 GetFocusEffect(focusType type, uint16 spell_id, Mob *caster = nullptr, bool from_buff_tic = false); uint16 GetSympatheticFocusEffect(focusType type, uint16 spell_id); void FinishAlternateAdvancementPurchase(AA::Rank *rank, bool ignore_cost); diff --git a/zone/effects.cpp b/zone/effects.cpp index 328fdfaae..879ae374a 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -57,7 +57,7 @@ int64 Mob::GetActSpellDamage(uint16 spell_id, int64 value, Mob* target) { value -= (GetLevel() - 40) * 20; //This adds the extra damage from the AA Unholy Touch, 450 per level to the AA Improved Harm TOuch. - if (spell_id == SPELL_IMP_HARM_TOUCH && IsClient()) //Improved Harm Touch + if (spell_id == SPELL_IMP_HARM_TOUCH && (IsClient() || IsBot())) //Improved Harm Touch value -= GetAA(aaUnholyTouch) * 450; //Unholy Touch chance = RuleI(Spells, BaseCritChance); //Wizard base critical chance is 2% (Does not scale with level) @@ -65,12 +65,12 @@ int64 Mob::GetActSpellDamage(uint16 spell_id, int64 value, Mob* target) { chance += itembonuses.FrenziedDevastation + spellbonuses.FrenziedDevastation + aabonuses.FrenziedDevastation; //Crtical Hit Calculation pathway - if (chance > 0 || (IsClient() && GetClass() == WIZARD && GetLevel() >= RuleI(Spells, WizCritLevel))) { + if (chance > 0 || ((IsClient() || IsBot()) && GetClass() == WIZARD && GetLevel() >= RuleI(Spells, WizCritLevel))) { int32 ratio = RuleI(Spells, BaseCritRatio); //Critical modifier is applied from spell effects only. Keep at 100 for live like criticals. //Improved Harm Touch is a guaranteed crit if you have at least one level of SCF. - if (spell_id == SPELL_IMP_HARM_TOUCH && IsClient() && (GetAA(aaSpellCastingFury) > 0) && (GetAA(aaUnholyTouch) > 0)) + if (spell_id == SPELL_IMP_HARM_TOUCH && (IsClient() || IsBot()) && (GetAA(aaSpellCastingFury) > 0) && (GetAA(aaUnholyTouch) > 0)) chance = 100; if (spells[spell_id].override_crit_chance > 0 && chance > spells[spell_id].override_crit_chance) @@ -82,7 +82,7 @@ int64 Mob::GetActSpellDamage(uint16 spell_id, int64 value, Mob* target) { ratio += itembonuses.SpellCritDmgIncNoStack + spellbonuses.SpellCritDmgIncNoStack + aabonuses.SpellCritDmgIncNoStack; } - else if ((IsClient() && GetClass() == WIZARD) || (IsMerc() && GetClass() == CASTERDPS)) { + else if (((IsClient() || IsBot()) && GetClass() == WIZARD) || (IsMerc() && GetClass() == CASTERDPS)) { if ((GetLevel() >= RuleI(Spells, WizCritLevel)) && zone->random.Roll(RuleI(Spells, WizCritChance))){ //Wizard innate critical chance is calculated seperately from spell effect and is not a set ratio. (20-70 is parse confirmed) ratio += zone->random.Int(20,70); @@ -90,7 +90,7 @@ int64 Mob::GetActSpellDamage(uint16 spell_id, int64 value, Mob* target) { } } - if (IsClient() && GetClass() == WIZARD) + if ((IsClient() || IsBot()) && GetClass() == WIZARD) ratio += RuleI(Spells, WizCritRatio); //Default is zero if (Critical){ diff --git a/zone/inventory.cpp b/zone/inventory.cpp index c1115cdbb..ad6e27310 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -4213,22 +4213,26 @@ int EQ::InventoryProfile::GetItemStatValue(uint32 item_id, const char* identifie // Returns a slot's item ID (returns INVALID_ID if not found) int32 Bot::GetItemIDAt(int16 slot_id) { if (slot_id <= EQ::invslot::POSSESSIONS_END && slot_id >= EQ::invslot::POSSESSIONS_BEGIN) { - if ((((uint64)1 << slot_id) & GetBotInv().GetLookup()->PossessionsBitmask) == 0) + if ((((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask) == 0) { return INVALID_ID; + } } else if (slot_id <= EQ::invbag::GENERAL_BAGS_END && slot_id >= EQ::invbag::GENERAL_BAGS_BEGIN) { auto temp_slot = EQ::invslot::GENERAL_BEGIN + ((slot_id - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT); - if ((((uint64)1 << temp_slot) & GetBotInv().GetLookup()->PossessionsBitmask) == 0) + if ((((uint64)1 << temp_slot) & GetInv().GetLookup()->PossessionsBitmask) == 0) { return INVALID_ID; + } } else if (slot_id <= EQ::invslot::BANK_END && slot_id >= EQ::invslot::BANK_BEGIN) { - if ((slot_id - EQ::invslot::BANK_BEGIN) >= GetBotInv().GetLookup()->InventoryTypeSize.Bank) + if ((slot_id - EQ::invslot::BANK_BEGIN) >= GetInv().GetLookup()->InventoryTypeSize.Bank) { return INVALID_ID; + } } else if (slot_id <= EQ::invbag::BANK_BAGS_END && slot_id >= EQ::invbag::BANK_BAGS_BEGIN) { auto temp_slot = (slot_id - EQ::invbag::BANK_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT; - if (temp_slot >= GetBotInv().GetLookup()->InventoryTypeSize.Bank) + if (temp_slot >= GetInv().GetLookup()->InventoryTypeSize.Bank) { return INVALID_ID; + } } const EQ::ItemInstance* inst = m_inv[slot_id]; @@ -4243,22 +4247,26 @@ int32 Bot::GetItemIDAt(int16 slot_id) { // Pass in the slot ID of the item and which augslot you want to check (0-5) int32 Bot::GetAugmentIDAt(int16 slot_id, uint8 augslot) { if (slot_id <= EQ::invslot::POSSESSIONS_END && slot_id >= EQ::invslot::POSSESSIONS_BEGIN) { - if ((((uint64)1 << slot_id) & GetBotInv().GetLookup()->PossessionsBitmask) == 0) + if ((((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask) == 0) { return INVALID_ID; + } } else if (slot_id <= EQ::invbag::GENERAL_BAGS_END && slot_id >= EQ::invbag::GENERAL_BAGS_BEGIN) { auto temp_slot = EQ::invslot::GENERAL_BEGIN + ((slot_id - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT); - if ((((uint64)1 << temp_slot) & GetBotInv().GetLookup()->PossessionsBitmask) == 0) + if ((((uint64)1 << temp_slot) & GetInv().GetLookup()->PossessionsBitmask) == 0) { return INVALID_ID; + } } else if (slot_id <= EQ::invslot::BANK_END && slot_id >= EQ::invslot::BANK_BEGIN) { - if ((slot_id - EQ::invslot::BANK_BEGIN) >= GetBotInv().GetLookup()->InventoryTypeSize.Bank) + if ((slot_id - EQ::invslot::BANK_BEGIN) >= GetInv().GetLookup()->InventoryTypeSize.Bank) { return INVALID_ID; + } } else if (slot_id <= EQ::invbag::BANK_BAGS_END && slot_id >= EQ::invbag::BANK_BAGS_BEGIN) { auto temp_slot = (slot_id - EQ::invbag::BANK_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT; - if (temp_slot >= GetBotInv().GetLookup()->InventoryTypeSize.Bank) + if (temp_slot >= GetInv().GetLookup()->InventoryTypeSize.Bank) { return INVALID_ID; + } } const EQ::ItemInstance* inst = m_inv[slot_id]; diff --git a/zone/lua_bot.cpp b/zone/lua_bot.cpp index 7d9396a81..5dcf7f971 100644 --- a/zone/lua_bot.cpp +++ b/zone/lua_bot.cpp @@ -207,22 +207,22 @@ void Lua_Bot::SetSpellDurationGroup(int spell_id, int duration, bool allow_pets) int Lua_Bot::CountAugmentEquippedByID(uint32 item_id) { Lua_Safe_Call_Int(); - return self->GetBotInv().CountAugmentEquippedByID(item_id); + return self->GetInv().CountAugmentEquippedByID(item_id); } bool Lua_Bot::HasAugmentEquippedByID(uint32 item_id) { Lua_Safe_Call_Bool(); - return self->GetBotInv().HasAugmentEquippedByID(item_id); + return self->GetInv().HasAugmentEquippedByID(item_id); } int Lua_Bot::CountItemEquippedByID(uint32 item_id) { Lua_Safe_Call_Int(); - return self->GetBotInv().CountItemEquippedByID(item_id); + return self->GetInv().CountItemEquippedByID(item_id); } bool Lua_Bot::HasItemEquippedByID(uint32 item_id) { Lua_Safe_Call_Bool(); - return self->GetBotInv().HasItemEquippedByID(item_id); + return self->GetInv().HasItemEquippedByID(item_id); } void Lua_Bot::Escape() { diff --git a/zone/mob.h b/zone/mob.h index a45e88baf..ab2523850 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -1402,6 +1402,7 @@ public: int GetAlternateAdvancementCooldownReduction(AA::Rank *rank_in); void ExpendAlternateAdvancementCharge(uint32 aa_id); void CalcAABonuses(StatBonuses* newbon); + int64 CalcAAFocus(focusType type, const AA::Rank &rank, uint16 spell_id); void ApplyAABonuses(const AA::Rank &rank, StatBonuses* newbon); bool CheckAATimer(int timer); @@ -1592,7 +1593,8 @@ protected: virtual #endif int GetBaseSkillDamage(EQ::skills::SkillType skill, Mob *target = nullptr); - virtual int64 GetFocusEffect(focusType type, uint16 spell_id, Mob *caster = nullptr, bool from_buff_tic = false) { return 0; } + int64 GetFocusEffect(focusType type, uint16 spell_id, Mob *caster = nullptr, bool from_buff_tic = false); + virtual const EQ::InventoryProfile& GetInv() { return EQ::InventoryProfile(); } void CalculateNewFearpoint(); float FindGroundZ(float new_x, float new_y, float z_offset=0.0); float FindDestGroundZ(glm::vec3 dest, float z_offset=0.0); diff --git a/zone/npc.h b/zone/npc.h index 34a5a1038..8977e5c79 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -285,8 +285,6 @@ public: content_db.GetFactionIdsForNPC(npc_faction_id, &faction_list, &primary_faction); } - int64 GetFocusEffect(focusType type, uint16 spell_id, Mob* caster = nullptr); - glm::vec4 m_SpawnPoint; uint32 GetMaxDMG() const {return max_dmg;} @@ -585,7 +583,7 @@ protected: virtual bool AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes, bool bInnates = false); virtual bool AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgainBefore = 0); AISpellsVar_Struct AISpellVar; - int64 GetFocusEffect(focusType type, uint16 spell_id, Mob* caster, bool from_buff_tic = false); + int64 GetFocusEffect(focusType type, uint16 spell_id, Mob *caster = nullptr, bool from_buff_tic = false); uint16 innate_proc_spell_id; uint32 npc_spells_effects_id; diff --git a/zone/perl_bot.cpp b/zone/perl_bot.cpp index de5e2ee2e..89e6eb544 100644 --- a/zone/perl_bot.cpp +++ b/zone/perl_bot.cpp @@ -103,7 +103,7 @@ void Perl_Bot_RemoveBotItem(Bot* self, uint32 item_id) EQ::ItemInstance* Perl_Bot_GetAugmentAt(Bot* self, uint32 slot, uint32 aug_slot) { - EQ::ItemInstance* inst = self->GetBotInv().GetItem(slot); + EQ::ItemInstance* inst = self->GetInv().GetItem(slot); if (inst) { return inst->GetAugment(aug_slot); @@ -113,22 +113,22 @@ EQ::ItemInstance* Perl_Bot_GetAugmentAt(Bot* self, uint32 slot, uint32 aug_slot) int Perl_Bot_CountAugmentEquippedByID(Bot* self, uint32 item_id) { - return self->GetBotInv().CountAugmentEquippedByID(item_id); + return self->GetInv().CountAugmentEquippedByID(item_id); } bool Perl_Bot_HasAugmentEquippedByID(Bot* self, uint32 item_id) { - return self->GetBotInv().HasAugmentEquippedByID(item_id); + return self->GetInv().HasAugmentEquippedByID(item_id); } int Perl_Bot_CountItemEquippedByID(Bot* self, uint32 item_id) { - return self->GetBotInv().CountItemEquippedByID(item_id); + return self->GetInv().CountItemEquippedByID(item_id); } bool Perl_Bot_HasItemEquippedByID(Bot* self, uint32 item_id) { - return self->GetBotInv().HasItemEquippedByID(item_id); + return self->GetInv().HasItemEquippedByID(item_id); } int Perl_Bot_GetRawItemAC(Bot* self) // @categories Inventory and Items @@ -288,7 +288,7 @@ int Perl_Bot_GetInstrumentMod(Bot* self, uint16 spell_id) // @categories Spells EQ::ItemInstance* Perl_Bot_GetItemAt(Bot* self, uint32 slot) // @categories Inventory and Items { - return self->GetBotInv().GetItem(slot); + return self->GetInv().GetItem(slot); } bool Perl_Bot_IsGrouped(Bot* self) // @categories Account and Character, Group diff --git a/zone/pets.cpp b/zone/pets.cpp index f8156ffd5..54d143066 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -200,7 +200,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, } #ifdef BOTS else if (IsBot()) - act_power = CastToBot()->GetBotFocusEffect(focusPetPower, spell_id); + act_power = CastToBot()->GetFocusEffect(focusPetPower, spell_id); #endif } else if (petpower > 0) diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 6408b7266..e03347119 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -4564,7 +4564,7 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses) CalcBonuses(); } -int64 Client::CalcAAFocus(focusType type, const AA::Rank &rank, uint16 spell_id) +int64 Mob::CalcAAFocus(focusType type, const AA::Rank &rank, uint16 spell_id) { const SPDat_Spell_Struct &spell = spells[spell_id]; @@ -6348,7 +6348,7 @@ uint16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { return 0; } -int64 Client::GetFocusEffect(focusType type, uint16 spell_id, Mob *caster, bool from_buff_tic) +int64 Mob::GetFocusEffect(focusType type, uint16 spell_id, Mob *caster, bool from_buff_tic) { if (IsBardSong(spell_id) && type != focusFcBaseEffects && type != focusSpellDuration && type != focusReduceRecastTime) { return 0; @@ -6448,38 +6448,40 @@ int64 Client::GetFocusEffect(focusType type, uint16 spell_id, Mob *caster, bool } } - //Tribute Focus - for (int x = EQ::invslot::TRIBUTE_BEGIN; x <= EQ::invslot::TRIBUTE_END; ++x) - { - TempItem = nullptr; - EQ::ItemInstance* ins = GetInv().GetItem(x); - if (!ins) - continue; - TempItem = ins->GetItem(); - 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; + if (IsClient()) { + //Tribute Focus + for (int x = EQ::invslot::TRIBUTE_BEGIN; x <= EQ::invslot::TRIBUTE_END; ++x) + { + TempItem = nullptr; + EQ::ItemInstance* ins = GetInv().GetItem(x); + if (!ins) + continue; + TempItem = ins->GetItem(); + 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; + 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; + } } } }