Here's the code.
I have verified that it works by getting a monk and dueling my mage.
I kicked and counted the blow only if the damage would've been > 0 (i.e. didn't block, parry, etc.).
There are other mitigation types, but this handles the calliav type (the kind that blocks a certain number of melee/spell hits).
For some reason, I am not able to cast a DD spell (always says that I can't see my target).
For the melee part, I was only able to use special moves (i.e. kick) to do damage.
The spell casting code was copied + pasted from the melee mitigation part. I expect that it would work, but don't have a way to test it now.
Any ideas why I can't do regular melee and DD?
Thanks!
The Code:
Code:
Index: zone/attack.cpp
===================================================================
--- zone/attack.cpp (revision 1120)
+++ zone/attack.cpp (working copy)
@@ -2766,8 +2766,19 @@
}
sint32 Mob::ReduceDamage(sint32 damage){
+ int slot = GetBuffSlotFromType(SE_NegateAttacks);
+
+ if(damage > 0 && slot >= 0 && this->buffs[slot].melee_rune > 0){
+ this->buffs[slot].melee_rune--;
+ if(buffs[slot].melee_rune == 0){
+ BuffFadeBySlot(slot);
+ SetHasRune((GetBuffSlotFromType(SE_NegateAttacks) >= 0) || (GetBuffSlotFromType(SE_Rune) >= 0));
+ }
+ return -6;
+ }
+
if(damage > 0 && HasRune()) {
- int slot = GetBuffSlotFromType(SE_Rune);
+ slot = GetBuffSlotFromType(SE_Rune);
while(slot >= 0) {
int16 melee_rune_left = this->buffs[slot].melee_rune;
@@ -2796,8 +2807,18 @@
}
sint32 Mob::ReduceMagicalDamage(sint32 damage) {
+ int slot = GetBuffSlotFromType(SE_NegateAttacks);
+
+ if(damage > 0 && slot >= 0 && this->buffs[slot].melee_rune > 0){
+ this->buffs[slot].melee_rune--; // arbitrarily using melee_rune to count both melee and spell attacks
+ if(buffs[slot].melee_rune == 0){
+ BuffFadeBySlot(slot);
+ SetHasSpellRune((GetBuffSlotFromType(SE_NegateAttacks) >= 0) || (GetBuffSlotFromType(SE_AbsorbMagicAtt) >= 0));
+ }
+ return -6;
+ }
if(damage > 0 && HasSpellRune()) {
- int slot = GetBuffSlotFromType(SE_AbsorbMagicAtt);
+ slot = GetBuffSlotFromType(SE_AbsorbMagicAtt);
while(slot >= 0) {
int16 magic_rune_left = this->buffs[slot].magic_rune;
Index: zone/spell_effects.cpp
===================================================================
--- zone/spell_effects.cpp (revision 1120)
+++ zone/spell_effects.cpp (working copy)
@@ -1488,7 +1488,16 @@
AddProcToWeapon(procid, false, spells[spell_id].base2[i]+100);
break;
}
-
+ case SE_NegateAttacks:
+ {
+#ifdef SPELL_EFFECT_SPAM
+ snprintf(effect_desc, _EDLEN, "Melee Negate Attack Rune: %+i", effect_value);
+#endif
+ buffs[buffslot].melee_rune = effect_value;
+ SetHasRune(true);
+ SetHasSpellRune(true);
+ break;
+ }
case SE_AppraiseLDonChest:
{
if(IsNPC())