OK new fixed code, crits match dmg and such. Also modified the GetBuffSlotByType function so that it can return values above 254(since spell effects go above this, the function is not usable on a majority of effects) and added a new function GetSpellIDFromSlot, not sure if its 100% needed but couldn't get it working without it and think it will make further effects easier to do.
code...
attack.cpp
Code:
Index: attack.cpp
===================================================================
--- attack.cpp (revision 1597)
+++ attack.cpp (working copy)
@@ -1252,6 +1252,7 @@
other->AvoidDamage(this, damage);
other->MeleeMitigation(this, damage, min_hit);
ApplyMeleeDamageBonus(skillinuse, damage);
+ damage = GetSkillDmgTaken(skillinuse, damage);
TryCriticalHit(other, skillinuse, damage);
mlog(COMBAT__DAMAGE, "Final damage after all reductions: %d", damage);
}
@@ -1828,6 +1829,7 @@
if(other->IsClient() && other->CastToClient()->IsSitting()) {
mlog(COMBAT__DAMAGE, "Client %s is sitting. Hitting for max damage (%d).", other->GetName(), (max_dmg+eleBane));
damage = (max_dmg+eleBane);
+ damage = GetSkillDmgTaken(skillinuse, damage);
mlog(COMBAT__HITS, "Generating hate %d towards %s", hate, GetName());
// now add done damage to the hate list
@@ -1839,6 +1841,7 @@
other->AvoidDamage(this, damage);
other->MeleeMitigation(this, damage, min_dmg+eleBane);
ApplyMeleeDamageBonus(skillinuse, damage);
+ damage = GetSkillDmgTaken(skillinuse, damage);
TryCriticalHit(other, skillinuse, damage);
mlog(COMBAT__HITS, "Generating hate %d towards %s", hate, GetName());
mob.h
Code:
Index: mob.h
===================================================================
--- mob.h (revision 1597)
+++ mob.h (working copy)
@@ -533,7 +533,8 @@
void DamageShield(Mob* other);
bool FindBuff(int16 spellid);
bool FindType(int8 type, bool bOffensive = false, int16 threshold = 100);
- sint8 GetBuffSlotFromType(int8 type);
+ sint8 GetBuffSlotFromType(int16 type);
+ int16 GetSpellIDFromSlot(int8 slot);
int CountDispellableBuffs();
bool HasBuffIcon(Mob* caster, Mob* target, int16 spell_id);
@@ -778,6 +779,7 @@
bool TryDeathSave();
void DoBuffWearOffEffect(uint32 index);
void TryTriggerOnCast(Mob *target, uint32 spell_id);
+ sint32 GetSkillDmgTaken(const SkillType skill_used, sint32 damage);
static int32 GetAppearanceValue(EmuAppearance iAppearance);
void SendAppearancePacket(int32 type, int32 value, bool WholeZone = true, bool iIgnoreSelf = false, Client *specific_target=NULL);
mob.cpp
Code:
Index: mob.cpp
===================================================================
--- mob.cpp (revision 1597)
+++ mob.cpp (working copy)
@@ -3036,4 +3036,29 @@
}
}
}
+}
+
+sint32 Mob::GetSkillDmgTaken(const SkillType skill_used, sint32 damage)
+{
+ int slot = this->GetTarget()->GetBuffSlotFromType(SE_SkillDamageTaken);
+ if(slot >= 0)
+ {
+ int spell_id = this->GetTarget()->GetSpellIDFromSlot(slot);
+ if (spell_id)
+ {
+ for(int i = 0; i < EFFECT_COUNT; i++)
+ {
+ if (spells[spell_id].effectid[i] == SE_SkillDamageTaken)
+ {
+ // Check the skill against the spell, or allow all melee skills.
+ if(skill_used == spells[spell_id].base2[i] || spells[spell_id].base2[i] == -1)
+ {
+ damage += damage * spells[spell_id].base[i] / 100;
+ return damage;
+ }
+ }
+ }
+ }
+ }
+ return damage;
}
\ No newline at end of file
spell effects.cpp
Code:
Index: spell_effects.cpp
===================================================================
--- spell_effects.cpp (revision 1597)
+++ spell_effects.cpp (working copy)
@@ -2812,6 +2812,7 @@
case SE_LimitCastTime:
case SE_NoCombatSkills:
case SE_TriggerOnCast:
+ case SE_SkillDamageTaken:
{
break;
}
spells.cpp
Code:
Index: spells.cpp
===================================================================
--- spells.cpp (revision 1597)
+++ spells.cpp (working copy)
@@ -4434,7 +4434,7 @@
*/
// solar: TODO get rid of this
-sint8 Mob::GetBuffSlotFromType(int8 type) {
+sint8 Mob::GetBuffSlotFromType(int16 type) {
uint32 buff_count = GetMaxTotalSlots();
for (int i = 0; i < buff_count; i++) {
if (buffs[i].spellid != SPELL_UNKNOWN) {
@@ -4447,6 +4447,12 @@
return -1;
}
+int16 Mob::GetSpellIDFromSlot(int8 slot)
+{
+ if (buffs[slot].spellid != SPELL_UNKNOWN)
+ return buffs[slot].spellid;
+ return 0;
+}
bool Mob::FindType(int8 type, bool bOffensive, int16 threshold) {
uint32 buff_count = GetMaxTotalSlots();