From e6daabfe8687f6713f8c94591e6758d6b7d04df0 Mon Sep 17 00:00:00 2001
From: Jesusaves <cpntb1@ymail.com>
Date: Sat, 25 Jan 2020 22:30:56 -0300
Subject: Wands no longer give passive MP regeneration. Only equipment does so.
 Instead, wands will allow you to use a skill to convert 20% of HP to MP. The
 ratio is 6:1 (as opposed to official ratio, something close to 4:1)

---
 db/re/item_db.conf    | 12 ++++++------
 db/re/skill_db.conf   | 15 ++++++++++++++-
 db/re/skill_tree.conf |  1 +
 npc/functions/hub.txt |  3 +++
 npc/magic/mpgen.txt   | 36 ++++++++++++++++++++++++++++++++++++
 npc/scripts.conf      |  1 +
 6 files changed, 61 insertions(+), 7 deletions(-)
 create mode 100644 npc/magic/mpgen.txt

diff --git a/db/re/item_db.conf b/db/re/item_db.conf
index 4a753cbab..a98a63f4e 100644
--- a/db/re/item_db.conf
+++ b/db/re/item_db.conf
@@ -13528,7 +13528,7 @@ item_db: (
 	Script: <"
 		//bonus bAttack2,-100;
 		bonus bMaxSP,10;
-		bonus bSPrecovRate,11;
+		skill TMW2_MPREGEN, 1;
 		bonus bDef,-32767;
 	">
 },
@@ -13566,7 +13566,7 @@ item_db: (
 	Script: <"
 		//bonus bAttack2,-150;
 		bonus bMaxSP,20;
-		bonus bSPrecovRate,12;
+		skill TMW2_MPREGEN, 1;
 		bonus bMaxHPrate, -8;
 		bonus bDef,-32767;
 	">
@@ -13605,7 +13605,7 @@ item_db: (
 	Script: <"
 		//bonus bAttack2,-200;
 		bonus bMaxSP,30;
-		bonus bSPrecovRate,13;
+		skill TMW2_MPREGEN, 1;
 		bonus bMaxHPrate, -12;
 		bonus bDef,-32767;
 	">
@@ -13644,7 +13644,7 @@ item_db: (
 	Script: <"
 		//bonus bAttack2,-250;
 		bonus bMaxSP,40;
-		bonus bSPrecovRate,14;
+		skill TMW2_MPREGEN, 1;
 		bonus bMaxHPrate, -16;
 		bonus bDef,-32767;
 	">
@@ -13683,7 +13683,7 @@ item_db: (
 	Script: <"
 		//bonus bAttack2,-300;
 		bonus bMaxSP,50;
-		bonus bSPrecovRate,15;
+		skill TMW2_MPREGEN, 1;
 		bonus bMaxHPrate, -20;
 		bonus bDef,-32767;
 	">
@@ -13722,7 +13722,7 @@ item_db: (
 	Script: <"
 		//bonus bAttack2,-125;
 		bonus bMaxSP,25;
-		bonus bSPrecovRate,15;
+		skill TMW2_MPREGEN, 1;
 		bonus bMaxHPrate, -5;
 		bonus bDef,-32767;
 	">
diff --git a/db/re/skill_db.conf b/db/re/skill_db.conf
index a619cd4d4..9b5b5fca7 100644
--- a/db/re/skill_db.conf
+++ b/db/re/skill_db.conf
@@ -38563,7 +38563,20 @@ skill_db: (
 		Passive: true
 	}
 },
-// 20022 end of Evol Reserved Space
+// 20021 end of Evol Reserved Space
+{
+	Id: 20022
+	Name: "TMW2_MPREGEN"
+	Description: "MP Regen"
+	MaxLevel: 1
+	SkillType: {
+		Self: true
+	}
+	AfterCastWalkDelay: 1000
+	SkillInfo: {
+		Quest: true
+	}
+},
 {
 	Id: 20023
 	Name: "TMW2_ZARKOR"
diff --git a/db/re/skill_tree.conf b/db/re/skill_tree.conf
index 722b35bc8..a4ba90a72 100644
--- a/db/re/skill_tree.conf
+++ b/db/re/skill_tree.conf
@@ -35,6 +35,7 @@ Human: {
 		TMW2_CRAFT: 0
 		TMW2_ANCIENTLANGUAGES: 0
 		TMW2_SPEECH: 0
+		TMW2_MPREGEN: 0
 		WE_MALE: 0
 		WE_FEMALE: 0
 		GD_EXTENSION: 0
diff --git a/npc/functions/hub.txt b/npc/functions/hub.txt
index 0e052720e..2a1bb9fed 100644
--- a/npc/functions/hub.txt
+++ b/npc/functions/hub.txt
@@ -187,6 +187,9 @@ function	script	HUB_SkillInvoke	{
         case TMW2_FAKESKILL:
             atcommand("@refresh");
             break;
+        case TMW2_MPREGEN:
+            SK_mpregen();
+            break;
         case TMW2_FAKESKILL2:
             //CMD_lang(); next; closeclientdialog;
             CMD_toevent();
diff --git a/npc/magic/mpgen.txt b/npc/magic/mpgen.txt
new file mode 100644
index 000000000..1a45de552
--- /dev/null
+++ b/npc/magic/mpgen.txt
@@ -0,0 +1,36 @@
+// TMW2 script
+// Author: Jesusalva <jesusalva@tmw2.org>
+//
+// Magic Script: -
+//
+// mpgen to make mana from HP
+
+function	script	SK_mpregen	{
+    // Convert HP to mana (20% HP - 1) (To prevent 5 casts from killing)
+    .@basehp=(MaxHp/5)-1;
+    // How much MP is that worth?
+    // Well, 400HP:120MP so base formula is 4:1
+    // Let's have a 50% penalty, so, 6:1
+    .@mpheal=.@basehp/6;
+    heal -.@basehp, .@mpheal;
+    return;
+}
+
+/*
+-	script	sk#mpgen	32767,{
+    end;
+
+OnCall:
+    // Must have magic
+    if (!MAGIC_LVL)
+        end;
+
+    unitskilluseid(getcharid(3), TMW2_MPREGEN, 1, getcharid(3));
+    end;
+
+OnInit:
+    bindatcmd "sk-mpgen", "sk#mpgen::OnCall", 0, 100, 0;
+    end;
+}
+*/
+
diff --git a/npc/scripts.conf b/npc/scripts.conf
index a7e0b2345..1b5cba8c0 100644
--- a/npc/scripts.conf
+++ b/npc/scripts.conf
@@ -125,6 +125,7 @@
 "npc/magic/kalspike.txt",
 "npc/magic/kalwulf.txt",
 "npc/magic/limerizer.txt",
+"npc/magic/mpregen.txt",
 "npc/magic/transmigration.txt",
 "npc/magic/parum.txt",
 "npc/magic/plantkingdom.txt",
-- 
cgit v1.2.3-70-g09d2