From 0daef27de9b26aa1cdd61cd7c620d554c5517795 Mon Sep 17 00:00:00 2001
From: mekolat <mekolat@users.noreply.github.com>
Date: Sat, 30 Apr 2016 20:28:42 -0400
Subject: take mdef into account for `rain` spell

---
 world/map/npc/magic/level2-rain.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/world/map/npc/magic/level2-rain.txt b/world/map/npc/magic/level2-rain.txt
index d3718170..53161b28 100644
--- a/world/map/npc/magic/level2-rain.txt
+++ b/world/map/npc/magic/level2-rain.txt
@@ -86,7 +86,7 @@ OnHit:
     if(target(.caster, @target_id, 16) != 16 && .caster != @target_id) end;
     if((get(BL_TYPE, @target_id) & 1) == 0) end; // either mob or pc
     if(get(ELTTYPE, @target_id) == ELT_FIRE)
-        injure .caster, @target_id, rand((@spellpower/15)+5)+2;
+        injure .caster, @target_id, ((rand((@spellpower/15)+5)+2) * (100 - get(MDEF1, @target_id))) / 100;
     end;
 
 OnDestroy:
-- 
cgit v1.2.3-70-g09d2


From 615231b146f22c08eead3ac0b2f0572042f0c4d6 Mon Sep 17 00:00:00 2001
From: mekolat <mekolat@users.noreply.github.com>
Date: Sat, 30 Apr 2016 20:34:38 -0400
Subject: take mdef into account for elt and melee spells

---
 world/map/npc/magic/_procedures.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/world/map/npc/magic/_procedures.txt b/world/map/npc/magic/_procedures.txt
index b53aaa7c..aa59905b 100644
--- a/world/map/npc/magic/_procedures.txt
+++ b/world/map/npc/magic/_procedures.txt
@@ -46,7 +46,7 @@ function|script|elt_damage
     set .@source, .caster;
     if (!.@source) set .@source, getcharid(3);
 
-    injure .@source, @target_id, .@dmg;
+    injure .@source, @target_id, (.@dmg * (100 - get(MDEF1, @target_id))) / 100;
     misceffect getarg(4), @target_id;
     return;
 }
@@ -56,7 +56,7 @@ function|script|melee_damage
     // args are spell power, target id, dmg
     if ((getarg(0) - rand(100)) < (get(BaseLevel, getarg(1)) + get(MDEF1, getarg(1))))
         injure BL_ID, getarg(1), 0;
-    else injure BL_ID, getarg(1), getarg(2);
+    else injure BL_ID, getarg(1), (getarg(2) * (100 - get(MDEF1, @target_id))) / 100;
     return;
 }
 
-- 
cgit v1.2.3-70-g09d2