[Spells] Updates and fixes to targeted focus effects (#1870)

This commit is contained in:
KayenEQ
2021-12-14 12:31:38 -05:00
committed by GitHub
parent 6da7116c66
commit 73acc3310c
9 changed files with 71 additions and 37 deletions
+34 -21
View File
@@ -5218,13 +5218,12 @@ int32 Client::CalcAAFocus(focusType type, const AA::Rank &rank, uint16 spell_id)
//given an item/spell's focus ID and the spell being cast, determine the focus ammount, if any
//assumes that spell_id is not a bard spell and that both ids are valid spell ids
int32 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, bool best_focus, uint16 casterid)
int32 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, bool best_focus, uint16 casterid, Mob *caster)
{
/*
'this' is always the caster of the spell_id, most foci check for effects on the caster, however some check for effects on the target.
'casterid' is the casterid of the caster of spell_id, used when spell_id is cast on a target with a focus effect that is checked by incoming spell.
*/
if (!IsValidSpell(focus_id) || !IsValidSpell(spell_id)) {
return 0;
}
@@ -5253,6 +5252,7 @@ int32 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo
is_from_item_click = true;
}
bool LimitInclude[MaxLimitInclude] = {false};
/* Certain limits require only one of several Include conditions to be true. Determined by limits being negative or positive
Ie. Add damage to fire OR ice spells. If positive we 'Include', by checking each limit of same type to look for match until found. Opposed to
@@ -5523,23 +5523,25 @@ int32 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo
case SE_Ff_Same_Caster://hmm do i need to pass casterid from buff slot here
if (focus_spell.base_value[i] == 0) {
if (casterid == GetID()) {
if (caster && casterid == caster->GetID()) {
return 0;
}//Mob casting is same as target, fail if you are casting on yourself.
}
else if (focus_spell.base_value[i] == 1) {
if (casterid != GetID()) {
if (caster && casterid != caster->GetID()) {
return 0;
}//Mob casting is not same as target, fail if you are not casting on yourself.
}
break;
case SE_Ff_CasterClass:
case SE_Ff_CasterClass: {
// Do not use this limit more then once per spell. If multiple class, treat value like items would.
if (!PassLimitClass(focus_spell.base_value[i], GetClass())) {
if (caster && !PassLimitClass(focus_spell.base_value[i], caster->GetClass())) {
return 0;
}
break;
}
case SE_Ff_DurationMax:
if (focus_spell.base_value[i] > spell.buff_duration) {
@@ -6247,10 +6249,11 @@ uint16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
return 0;
}
int32 Client::GetFocusEffect(focusType type, uint16 spell_id)
int32 Client::GetFocusEffect(focusType type, uint16 spell_id, Mob *caster)
{
if (IsBardSong(spell_id) && type != focusFcBaseEffects && type != focusSpellDuration && type != focusReduceRecastTime)
if (IsBardSong(spell_id) && type != focusFcBaseEffects && type != focusSpellDuration && type != focusReduceRecastTime) {
return 0;
}
int32 realTotal = 0;
int32 realTotal2 = 0;
@@ -6448,7 +6451,7 @@ int32 Client::GetFocusEffect(focusType type, uint16 spell_id)
continue;
if(rand_effectiveness) {
focus_max2 = CalcFocusEffect(type, focusspellid, spell_id, true);
focus_max2 = CalcFocusEffect(type, focusspellid, spell_id, true, buffs[buff_slot].casterid, caster);
if (focus_max2 > 0 && focus_max_real2 >= 0 && focus_max2 > focus_max_real2) {
focus_max_real2 = focus_max2;
buff_tracker = buff_slot;
@@ -6460,7 +6463,7 @@ int32 Client::GetFocusEffect(focusType type, uint16 spell_id)
}
}
else {
Total2 = CalcFocusEffect(type, focusspellid, spell_id);
Total2 = CalcFocusEffect(type, focusspellid, spell_id, false, buffs[buff_slot].casterid, caster);
if (Total2 > 0 && realTotal2 >= 0 && Total2 > realTotal2) {
realTotal2 = Total2;
buff_tracker = buff_slot;
@@ -6473,8 +6476,13 @@ int32 Client::GetFocusEffect(focusType type, uint16 spell_id)
}
}
uint16 original_caster_id = 0;
if (buff_tracker >= 0 && buffs[buff_tracker].casterid > 0) {
original_caster_id = buffs[buff_tracker].casterid;
}
if(focusspell_tracker && rand_effectiveness && focus_max_real2 != 0)
realTotal2 = CalcFocusEffect(type, focusspell_tracker, spell_id);
realTotal2 = CalcFocusEffect(type, focusspell_tracker, spell_id, false, original_caster_id, caster);
// For effects like gift of mana that only fire once, save the spellid into an array that consists of all available buff slots.
if(buff_tracker >= 0 && buffs[buff_tracker].hit_number > 0) {
@@ -6523,7 +6531,7 @@ int32 Client::GetFocusEffect(focusType type, uint16 spell_id)
return realTotal + realTotal2 + realTotal3 + worneffect_bonus;
}
int32 NPC::GetFocusEffect(focusType type, uint16 spell_id) {
int32 NPC::GetFocusEffect(focusType type, uint16 spell_id, Mob* caster) {
int32 realTotal = 0;
int32 realTotal2 = 0;
@@ -6586,7 +6594,7 @@ int32 NPC::GetFocusEffect(focusType type, uint16 spell_id) {
realTotal = CalcFocusEffect(type, UsedFocusID, spell_id);
}
if (RuleB(Spells, NPC_UseFocusFromSpells) && spellbonuses.FocusEffects[type]){
if ((RuleB(Spells, NPC_UseFocusFromSpells) || IsTargetedFocusEffect(type)) && spellbonuses.FocusEffects[type]){
//Spell Focus
int32 Total2 = 0;
@@ -6604,7 +6612,7 @@ int32 NPC::GetFocusEffect(focusType type, uint16 spell_id) {
continue;
if(rand_effectiveness) {
focus_max2 = CalcFocusEffect(type, focusspellid, spell_id, true);
focus_max2 = CalcFocusEffect(type, focusspellid, spell_id, true, buffs[buff_slot].casterid, caster);
if (focus_max2 > 0 && focus_max_real2 >= 0 && focus_max2 > focus_max_real2) {
focus_max_real2 = focus_max2;
buff_tracker = buff_slot;
@@ -6616,7 +6624,7 @@ int32 NPC::GetFocusEffect(focusType type, uint16 spell_id) {
}
}
else {
Total2 = CalcFocusEffect(type, focusspellid, spell_id);
Total2 = CalcFocusEffect(type, focusspellid, spell_id, false, buffs[buff_slot].casterid, caster);
if (Total2 > 0 && realTotal2 >= 0 && Total2 > realTotal2) {
realTotal2 = Total2;
buff_tracker = buff_slot;
@@ -6629,8 +6637,14 @@ int32 NPC::GetFocusEffect(focusType type, uint16 spell_id) {
}
}
if(focusspell_tracker && rand_effectiveness && focus_max_real2 != 0)
realTotal2 = CalcFocusEffect(type, focusspell_tracker, spell_id);
uint16 original_caster_id = 0;
if (buff_tracker >= 0 && buffs[buff_tracker].casterid > 0) {
original_caster_id = buffs[buff_tracker].casterid;
}
if (focusspell_tracker && rand_effectiveness && focus_max_real2 != 0) {
realTotal2 = CalcFocusEffect(type, focusspell_tracker, spell_id, false, original_caster_id, caster);
}
// For effects like gift of mana that only fire once, save the spellid into an array that consists of all available buff slots.
if(buff_tracker >= 0 && buffs[buff_tracker].hit_number > 0) {
@@ -7027,8 +7041,8 @@ int32 Mob::GetFcDamageAmtIncoming(Mob *caster, int32 spell_id)
{
//THIS is target of spell cast
int32 dmg = 0;
dmg += GetFocusEffect(focusFcDamageAmtIncoming, spell_id); //SPA 297 SE_FcDamageAmtIncoming
dmg += GetFocusEffect(focusFcSpellDamageAmtIncomingPC, spell_id); //SPA 484 SE_Fc_Spell_Damage_Amt_IncomingPC
dmg += GetFocusEffect(focusFcDamageAmtIncoming, spell_id, caster); //SPA 297 SE_FcDamageAmtIncoming
dmg += GetFocusEffect(focusFcSpellDamageAmtIncomingPC, spell_id, caster); //SPA 484 SE_Fc_Spell_Damage_Amt_IncomingPC
return dmg;
}
@@ -7094,7 +7108,6 @@ bool Mob::PassLimitClass(uint32 Classes_, uint16 Class_)
return false;
Class_ += 1;
for (int CurrentClass = 1; CurrentClass <= PLAYER_CLASS_COUNT; ++CurrentClass){
if (Classes_ % 2 == 1){
if (CurrentClass == Class_)
@@ -8351,7 +8364,7 @@ void Mob::CastSpellOnLand(Mob* caster, int32 spell_id)
if ((IsValidSpell(buffs[i].spellid) && (buffs[i].spellid != spell_id) && IsEffectInSpell(buffs[i].spellid, SE_Fc_Cast_Spell_On_Land))) {
//Step 2: Check if we pass all focus limiters and focus chance roll
trigger_spell_id = caster->CalcFocusEffect(focusFcCastSpellOnLand, buffs[i].spellid, spell_id, false, buffs[i].casterid);
trigger_spell_id = CalcFocusEffect(focusFcCastSpellOnLand, buffs[i].spellid, spell_id, false, buffs[i].casterid, caster);
if (IsValidSpell(trigger_spell_id) && (trigger_spell_id != spell_id)) {