Thread: Spells: Channeling Fix
View Single Post
  #2  
Old 12-04-2021, 08:00 PM
azxten azxten is offline
Fire Giant

azxten's Avatar

Join Date: May 2010
Posts: 753
Default

Patch file:

https://www.pastefile.com/2969hw

Quote:
--- spells.cpp 2021-12-04 13:17:30.931386378 -0800
+++ /home/eqemu/server_source/zone/spells.cpp 2021-12-04 13:11:13.223277487 -0800
@@ -1130,11 +1122,11 @@
// but cap it so it's not that large a factor
if(attacked_count > 15) attacked_count = 15;

- float channelchance, distance_moved, d_x, d_y, distancemod;
+ float channelchance, channelbonuses, spell_level_diff_bonus, distance_moved, d_x, d_y, distancemod;

if(IsClient())
{
- float channelbonuses = 0.0f;
+ channelbonuses = 0.0f;
//AA that effect Spell channel chance are no longer on live. http://everquest.allakhazam.com/hist...es-2006-2.html
//No harm in maintaining the effects regardless, since we do check for channel chance.
if (IsFromItem)
@@ -1142,9 +1134,17 @@
else
channelbonuses += spellbonuses.ChannelChanceSpells + itembonuses.ChannelChanceSpells + aabonuses.ChannelChanceSpells;

- // max 93% chance at 252 skill
- channelchance = 30 + GetSkill(EQ::skills::SkillChanneling) / 400.0f * 100;
- channelchance -= attacked_count * 2;
+ //
+ spell_level_diff_bonus = GetLevel() - spells[spell_id].classes[GetClass()-1];
+ if(spell_level_diff_bonus < 6) {
+ spell_level_diff_bonus = 0;
+ } else {
+ spell_level_diff_bonus = spell_level_diff_bonus * 3;
+ }
+ channelchance = GetSkill(EQ::skills::SkillChanneling) + GetLevel() + spell_level_diff_bonus;
+ if(channelchance > 370) {
+ channelchance = 370;
+ }
channelchance += channelchance * channelbonuses / 100.0f;
}
#ifdef BOTS
@@ -1164,7 +1164,7 @@
#endif //BOTS
else {
// NPCs are just hard to interrupt, otherwise they get pwned
- channelchance = 85;
+ channelchance = 391;
channelchance -= attacked_count;
}

@@ -1174,13 +1174,13 @@
{
d_x = std::abs(std::abs(GetX()) - std::abs(GetSpellX()));
d_y = std::abs(std::abs(GetY()) - std::abs(GetSpellY()));
- if(d_x < 5 && d_y < 5)
+ if(d_x < 3 && d_y < 3)
{
//avoid the square root...
distance_moved = d_x * d_x + d_y * d_y;
// if you moved 1 unit, that's 25% off your chance to regain.
// if you moved 2, you lose 100% off your chance
- distancemod = distance_moved * 25;
+ distancemod = distance_moved * 100;
channelchance -= distancemod;
}
else
@@ -1189,13 +1189,22 @@
}
}

- LogSpells("Checking Interruption: spell x: [{}] spell y: [{}] cur x: [{}] cur y: [{}] channelchance [{}] channeling skill [{}]\n", GetSpellX(), GetSpellY(), GetX(), GetY(), channelchance, GetSkill(EQ::skills::SkillChanneling));
+ LogSpells("Checking Interruption: spell x: [{}] spell y: [{}] cur x: [{}] cur y: [{}] channelchance [{}] channeling skill [{}] channelbonuses [{}] channel_checks [{}] level diff bonus [{}] \n", GetSpellX(), GetSpellY(), GetX(), GetY(), channelchance, GetSkill(EQ::skills::SkillChanneling), channelbonuses, attacked_count, spell_level_diff_bonus);

- if(!spells[spell_id].uninterruptable && zone->random.Real(0, 100) > channelchance) {
- LogSpells("Casting of [{}] canceled: interrupted", spell_id);
- InterruptSpell();
- return;
+ if(!spells[spell_id].uninterruptable) {
+ LogSpells("Channel chance: [{}]", channelchance);
+ int channel_checks = attacked_count;
+ for(channel_checks; channel_checks > 0; channel_checks--) {
+ int interruptchance = zone->random.Real(0, 391);
+ LogSpells("Interrupt roll: [{}] Check Number: [{}]", interruptchance, channel_checks);
+ if(interruptchance > channelchance && interruptchance > 39) {
+ LogSpells("Casting of [{}] canceled: interrupted", spell_id);
+ InterruptSpell();
+ return;
+ }
+ }
}
+
// if we got here, we regained concentration
regain_conc = true;
MessageString(Chat::Spells, REGAIN_AND_CONTINUE);
Screen shots of testing:

https://imgur.com/a/zncfhij

Successful cast

[You must be logged in to view images. Log in or Register.]

Two rolls failure

[You must be logged in to view images. Log in or Register.]

One roll failure, we don't reroll if you failed the first roll

[You must be logged in to view images. Log in or Register.]
Reply With Quote