[Bots & Mercs] Add Support for TrySympatheticProc (#2866)

* [Bots & Merrcs] Add Support for TrySympatheticProc

* [Bots & Merrcs] Add Support for TrySympatheticProc

* [Bots & Merrcs] Add Support for TrySympatheticProc

* Cleanup

* formatting

* auto
This commit is contained in:
Aeadoin 2023-02-13 01:16:18 -05:00 committed by GitHub
parent b3fd9dd88a
commit fc7c30977a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 29 deletions

View File

@ -1691,7 +1691,6 @@ protected:
void MakeBuffFadePacket(uint16 spell_id, int slot_id, bool send_message = true); void MakeBuffFadePacket(uint16 spell_id, int slot_id, bool send_message = true);
bool client_data_loaded; bool client_data_loaded;
uint16 GetSympatheticFocusEffect(focusType type, uint16 spell_id);
void FinishAlternateAdvancementPurchase(AA::Rank *rank, bool ignore_cost); void FinishAlternateAdvancementPurchase(AA::Rank *rank, bool ignore_cost);

View File

@ -4661,7 +4661,7 @@ void Mob::TryTwincast(Mob *caster, Mob *target, uint32 spell_id)
return; return;
} }
if (IsClient() || IsBot()) if (IsOfClientBot())
{ {
int focus = GetFocusEffect(focusTwincast, spell_id); int focus = GetFocusEffect(focusTwincast, spell_id);
@ -4955,7 +4955,7 @@ void Mob::TrySympatheticProc(Mob *target, uint32 spell_id)
if(target == nullptr || !IsValidSpell(spell_id) || !IsClient()) if(target == nullptr || !IsValidSpell(spell_id) || !IsClient())
return; return;
uint16 focus_spell = CastToClient()->GetSympatheticFocusEffect(focusSympatheticProc,spell_id); uint16 focus_spell = GetSympatheticFocusEffect(focusSympatheticProc,spell_id);
if(!IsValidSpell(focus_spell)) if(!IsValidSpell(focus_spell))
return; return;

View File

@ -924,6 +924,7 @@ public:
void TryTriggerOnCastRequirement(); void TryTriggerOnCastRequirement();
void TryTwincast(Mob *caster, Mob *target, uint32 spell_id); void TryTwincast(Mob *caster, Mob *target, uint32 spell_id);
void TrySympatheticProc(Mob *target, uint32 spell_id); void TrySympatheticProc(Mob *target, uint32 spell_id);
uint16 GetSympatheticFocusEffect(focusType type, uint16 spell_id);
bool TryFadeEffect(int slot); bool TryFadeEffect(int slot);
uint16 GetSpellEffectResistChance(uint16 spell_id); uint16 GetSpellEffectResistChance(uint16 spell_id);
int32 GetVulnerability(Mob *caster, uint32 spell_id, uint32 ticsremaining, bool from_buff_tic = false); int32 GetVulnerability(Mob *caster, uint32 spell_id, uint32 ticsremaining, bool from_buff_tic = false);

View File

@ -6270,7 +6270,7 @@ bool Mob::TryTriggerOnCastProc(uint16 focusspellid, uint16 spell_id, uint16 proc
return false; return false;
} }
uint16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { uint16 Mob::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
if (IsBardSong(spell_id)) if (IsBardSong(spell_id))
return 0; return 0;
@ -6281,21 +6281,21 @@ uint16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
std::vector<int> SympatheticProcList; std::vector<int> SympatheticProcList;
//item focus //item focus
if (itembonuses.FocusEffects[type]){ if (IsOfClientBot() && itembonuses.FocusEffects[type]) {
const EQ::ItemData* TempItem = nullptr;
for (int x = EQ::invslot::EQUIPMENT_BEGIN; x <= EQ::invslot::EQUIPMENT_END; x++) for (int x = EQ::invslot::EQUIPMENT_BEGIN; x <= EQ::invslot::EQUIPMENT_END; x++)
{ {
if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS) if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS)
continue; continue;
TempItem = nullptr; EQ::ItemInstance const* ins = GetInv().GetItem(x);
EQ::ItemInstance* ins = GetInv().GetItem(x);
if (!ins) if (!ins)
continue; continue;
TempItem = ins->GetItem(); if (
if (TempItem && TempItem->Focus.Effect > 0 && IsValidSpell(TempItem->Focus.Effect)) { auto TempItem = ins->GetItem();
TempItem && TempItem->Focus.Effect > 0 && IsValidSpell(TempItem->Focus.Effect)
) {
proc_spellid = CalcFocusEffect(type, TempItem->Focus.Effect, spell_id); proc_spellid = CalcFocusEffect(type, TempItem->Focus.Effect, spell_id);
if (IsValidSpell(proc_spellid)){ if (IsValidSpell(proc_spellid)){
@ -6310,11 +6310,10 @@ uint16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS) if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS)
continue; continue;
EQ::ItemInstance *aug = nullptr; auto aug = ins->GetAugment(y);
aug = ins->GetAugment(y); if (aug)
if(aug)
{ {
const EQ::ItemData* TempItemAug = aug->GetItem(); auto TempItemAug = aug->GetItem();
if (TempItemAug && TempItemAug->Focus.Effect > 0 && IsValidSpell(TempItemAug->Focus.Effect)) { if (TempItemAug && TempItemAug->Focus.Effect > 0 && IsValidSpell(TempItemAug->Focus.Effect)) {
proc_spellid = CalcFocusEffect(type, TempItemAug->Focus.Effect, spell_id); proc_spellid = CalcFocusEffect(type, TempItemAug->Focus.Effect, spell_id);
if (IsValidSpell(proc_spellid)){ if (IsValidSpell(proc_spellid)){
@ -6330,52 +6329,56 @@ uint16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
//Spell Focus //Spell Focus
if (spellbonuses.FocusEffects[type]){ if (spellbonuses.FocusEffects[type]){
int buff_slot = 0;
uint16 focusspellid = 0; uint16 focusspellid = 0;
int buff_max = GetMaxTotalSlots(); int buff_max = GetMaxTotalSlots();
for (buff_slot = 0; buff_slot < buff_max; buff_slot++) { for (int buff_slot = 0; buff_slot < buff_max; buff_slot++) {
if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS) if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS) {
continue; continue;
}
focusspellid = buffs[buff_slot].spellid; focusspellid = buffs[buff_slot].spellid;
if (!IsValidSpell(focusspellid)) if (!IsValidSpell(focusspellid)) {
continue; continue;
}
proc_spellid = CalcFocusEffect(type, focusspellid, spell_id); proc_spellid = CalcFocusEffect(type, focusspellid, spell_id);
if (IsValidSpell(proc_spellid)){ if (IsValidSpell(proc_spellid)) {
ProcChance = GetSympatheticProcChances(spell_id, GetSympatheticSpellProcRate(proc_spellid)); ProcChance = GetSympatheticProcChances(spell_id, GetSympatheticSpellProcRate(proc_spellid));
if(zone->random.Roll(ProcChance)) if (zone->random.Roll(ProcChance)) {
SympatheticProcList.push_back(proc_spellid); SympatheticProcList.push_back(proc_spellid);
}
} }
} }
} }
/*Note: At present, ff designing custom AA to have a sympathetic proc effect, only use one focus /*Note: At present, ff designing custom AA to have a sympathetic proc effect, only use one focus
effect within the aa_effects data for each AA*[No live AA's use this effect to my knowledge]*/ effect within the aa_effects data for each AA*[No live AA's use this effect to my knowledge]*/
if (aabonuses.FocusEffects[type]) { if (IsOfClientBot() && aabonuses.FocusEffects[type]) {
for (const auto &aa : aa_ranks) { for (const auto &aa : aa_ranks) {
if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS) if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS) {
break; break;
}
auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa.first, aa.second.first); auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(aa.first, aa.second.first);
auto ability = ability_rank.first; auto ability = ability_rank.first;
auto rank = ability_rank.second; auto rank = ability_rank.second;
if(!ability) { if (!ability) {
continue; continue;
} }
if (rank->effects.empty()) if (rank->effects.empty()) {
continue; continue;
}
proc_spellid = CalcAAFocus(type, *rank, spell_id); proc_spellid = CalcAAFocus(type, *rank, spell_id);
if (IsValidSpell(proc_spellid)) { if (IsValidSpell(proc_spellid)) {
ProcChance = GetSympatheticProcChances(spell_id, rank->effects[0].base_value); ProcChance = GetSympatheticProcChances(spell_id, rank->effects[0].base_value);
if (zone->random.Roll(ProcChance)) if (zone->random.Roll(ProcChance)) {
SympatheticProcList.push_back(proc_spellid); SympatheticProcList.push_back(proc_spellid);
}
} }
} }
} }
@ -6387,7 +6390,6 @@ uint16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
SympatheticProcList.clear(); SympatheticProcList.clear();
return FinalSympatheticProc; return FinalSympatheticProc;
} }
return 0; return 0;
} }

View File

@ -1638,7 +1638,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
return; return;
} }
if(IsClient()) { if(IsOfClientBotMerc()) {
TrySympatheticProc(target, spell_id); TrySympatheticProc(target, spell_id);
} }