I utilized my FindTypeValue I noted on my druid epic click, and improved it to cater for this situation. Included that source change again with the improvements.
I turned the criticaldotchance code into integers instead of floats to match the wizzy AA crit code, feel free to not change this but it's more compatible with spell data raw "30 for 30%" data.
Code:
Index: mob.h
===================================================================
--- mob.h (revision 999)
+++ mob.h (working copy)
@@ -495,6 +495,7 @@
void DamageShield(Mob* other);
bool FindBuff(int16 spellid);
bool FindType(int8 type, bool bOffensive = false, int16 threshold = 100);
+ sint32 FindTypeValue(int8 type, int8 stat); //Shin: Added for finding mob raw spell data.
sint8 GetBuffSlotFromType(int8 type);
int CountDispellableBuffs();
bool HasBuffIcon(Mob* caster, Mob* target, int16 spell_id);
Index: spdat.h
===================================================================
--- spdat.h (revision 999)
+++ spdat.h (working copy)
@@ -378,7 +378,7 @@
//#define SE_Unknown270 270 //not used
#define SE_BaseMovementSpeed 271 //mods basemove speed, doesn't stack with other move mods, aa effect
#define SE_CastingLevel2 272
-#define SE_CriticalDoTChance 273 //not implemented
+#define SE_CriticalDoTChance 273 //Shin: Handled in TryDotCritical()
#define SE_CriticalHealChance 274 //not implemented
//#define SE_Unknown275 275 //not used
#define SE_Ambidexterity 276 //aa effect
Index: spell_effects.cpp
===================================================================
--- spell_effects.cpp (revision 999)
+++ spell_effects.cpp (working copy)
@@ -2752,6 +2753,7 @@
case SE_LimitMinLevel:
case SE_LimitCastTime:
case SE_NoCombatSkills:
+ case SE_CriticalDoTChance: //Shin: This is handled in TryDotCritical()
{
break;
}
@@ -3716,6 +3718,11 @@
value = focus_spell.base[i];
}
break;
+ case SE_CriticalDoTChance: //Shin: Critical DoT effect. Not referenced but put in anyways.
+ break;
#if EQDEBUG >= 6
//this spits up a lot of garbage when calculating spell focuses
//since they have all kinds of extra effects on them.
@@ -3947,19 +3954,18 @@
{
if(!caster)
return;
+ int chance = 0;
- float critChance = 0.00f;
-
switch(caster->GetAA(aaCriticalAffliction))
{
case 1:
- critChance += 0.03f;
+ chance += 3;
break;
case 2:
- critChance += 0.06f;
+ chance += 6;
break;
case 3:
- critChance += 0.10f;
+ chance += 10;
break;
default:
break;
@@ -3968,30 +3974,37 @@
switch (caster->GetAA(aaImprovedCriticalAffliction))
{
case 1:
- critChance += 0.03f;
+ chance += 3;
break;
case 2:
- critChance += 0.06f;
+ chance += 6;
break;
case 3:
- critChance += 0.10f;
+ chance += 10;
break;
default:
break;
}
-
+
+
+ if (caster->IsClient())
+ { //Shin: do a focus check on critical bonus stuff.
+ chance += caster->FindTypeValue(SE_CriticalDoTChance, 0);
+ }
// since DOTs are the Necromancer forte, give an innate bonus
// however, no chance to crit unless they've trained atleast one level in the AA first
- if (caster->GetClass() == NECROMANCER && critChance > 0.0f){
- critChance += 0.05f;
+ if (caster->GetClass() == NECROMANCER && chance > 0){
+ chance += 5;
}
- if (critChance > 0.0f){
- if (MakeRandomFloat(0, 1) <= critChance)
- {
+
+ if (chance > 0 && MakeRandomInt(0,100) <= chance) {
damage *= 2;
- }
+ entity_list.MessageClose(this, false, 100, MT_SpellCrits, "%s delivers a critical blast! (%d)", caster->GetName(), damage);
}
+
}
bool Mob::AffectedExcludingSlot(int slot, int effect)
===================================================================
--- spells.cpp (revision 999)
+++ spells.cpp (working copy)
@@ -4171,6 +4171,70 @@
return false;
}
+//Shin: FindTypeValue is used to return spell data. stat supports 3 values, 0: base, 1: base2, 3: max
+sint32 Mob::FindTypeValue(int8 type, int8 stat) {
+ sint32 value = 0;
+
+ if (this->IsClient())
+ { //Shin: Mob entity is a client, look for item focus effects too.
+ const Item_Struct* TempItem = 0;
+ const Item_Struct* UsedItem = 0;
+ sint16 Total = 0;
+ sint16 realTotal = 0;
+ Client *c = CastToClient();
+
+ //item focus
+ for(int x=0; x<=21; x++) { //Cycle each equipped inventory slot
+ TempItem = NULL;
+ ItemInst* ins = c->GetInv().GetItem(x);
+ if (!ins)
+ continue;
+ TempItem = ins->GetItem();
+ if (TempItem && TempItem->Focus.Effect > 0 && TempItem->Focus.Effect != SPELL_UNKNOWN) {
+ for (int j = 0; j < EFFECT_COUNT; j++) { //Loop each effect on item
+ if (spells[TempItem->Focus.Effect].effectid[j] == type) { //Does effect match our type?
+ if (stat == 0 && value < spells[TempItem->Focus.Effect].base[j]) value = spells[TempItem->Focus.Effect].base[j];
+ if (stat == 1 && value < spells[TempItem->Focus.Effect].base2[j]) value = spells[TempItem->Focus.Effect].base2[j];
+ if (stat == 2 && value < spells[TempItem->Focus.Effect].max[j]) value = spells[TempItem->Focus.Effect].max[j];
+ }
+ }
+ }
+ for(int y = 0; y < MAX_AUGMENT_SLOTS; ++y) { //Cycle each aug slot on the item
+ ItemInst *aug = NULL;
+ aug = ins->GetAugment(y);
+ if(aug) { //Found an Aug
+ const Item_Struct* TempItemAug = aug->GetItem();
+ if (TempItemAug && TempItemAug->Focus.Effect > 0 && TempItemAug->Focus.Effect != SPELL_UNKNOWN) {
+ for (int j = 0; j < EFFECT_COUNT; j++) { //Loop each effect on augitem
+ if (spells[TempItemAug->Focus.Effect].effectid[j] == type) { //Does effect match our type?
+ if (stat == 0 && value < spells[TempItemAug->Focus.Effect].base[j]) value = spells[TempItemAug->Focus.Effect].base[j];
+ if (stat == 1 && value < spells[TempItemAug->Focus.Effect].base2[j]) value = spells[TempItemAug->Focus.Effect].base2[j];
+ if (stat == 2 && value < spells[TempItemAug->Focus.Effect].max[j]) value = spells[TempItemAug->Focus.Effect].max[j];
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //if (realTotal != 0 && UsedItem && spells[spell_id].buffduration == 0) {
+ // Message_StringID(MT_Spells, BEGINS_TO_GLOW, UsedItem->Name);
+ //}
+ }
+ for (int i = 0; i < BUFF_COUNT; i++) { //Loop through each buff on mob
+ if (buffs[i].spellid != SPELL_UNKNOWN) {
+ for (int j = 0; j < EFFECT_COUNT; j++) { //Loop through effects on buff
+ if (spells[buffs[i].spellid].effectid[j] == type ) //Does effect match our type?
+ if (stat == 0 && value < spells[buffs[i].spellid].base[j]) value = spells[buffs[i].spellid].base[j];
+ if (stat == 1 && value < spells[buffs[i].spellid].base2[j]) value = spells[buffs[i].spellid].base2[j];
+ if (stat == 2 && value < spells[buffs[i].spellid].max[j]) value = spells[buffs[i].spellid].max[j];
+ }
+ }
+ }
+ return value;
+}
+
+
bool Mob::AddProcToWeapon(int16 spell_id, bool bPerma, int16 iChance) {
if(spell_id == SPELL_UNKNOWN)
return(false);