From 0ef56764dc2796cb43e90f10c5eb380c9f94406a Mon Sep 17 00:00:00 2001
From: Jesusaves <cpntb1@ymail.com>
Date: Mon, 26 Aug 2019 21:43:51 -0300
Subject: Implement Status Fruits

---
 npc/functions/resetstatus.txt | 43 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)

(limited to 'npc')

diff --git a/npc/functions/resetstatus.txt b/npc/functions/resetstatus.txt
index c9744d901..4d7d9e09a 100644
--- a/npc/functions/resetstatus.txt
+++ b/npc/functions/resetstatus.txt
@@ -5,6 +5,41 @@
 // Description:
 //    Status Reset NPC utils
 
+// Reset status and return permanent bonuses
+// StatusResetReinvest( - )
+function	script	StatusResetReinvest	{
+    // Compulsory check
+    inventoryplace NPCEyes, 6;
+
+    // Permanent boosts were now lost, return the fruits
+    if (STATUSUP_STR) {
+        getitem StrengthFruit, STATUSUP_STR;
+        STATUSUP_STR=0;
+    }
+    if (STATUSUP_AGI) {
+        getitem AgilityFruit, STATUSUP_AGI;
+        STATUSUP_AGI=0;
+    }
+    if (STATUSUP_VIT) {
+        getitem VitalityFruit, STATUSUP_VIT;
+        STATUSUP_VIT=0;
+    }
+    if (STATUSUP_INT) {
+        getitem IntelligenceFruit, STATUSUP_INT;
+        STATUSUP_INT=0;
+    }
+    if (STATUSUP_DEX) {
+        getitem DexterityFruit, STATUSUP_DEX;
+        STATUSUP_DEX=0;
+    }
+    if (STATUSUP_LUK) {
+        getitem LuckFruit, STATUSUP_LUK;
+        STATUSUP_LUK=0;
+    }
+    resetstatus();
+    return true;
+}
+
 // Return wasSP on success, 0 on failure
 // ConfirmReset( {price} )
 function	script	ConfirmStatusReset	{
@@ -16,6 +51,8 @@ function	script	ConfirmStatusReset	{
     if (getarg(0,-1) >= 0)
         .@plush_count=getarg(0,-1);
 
+    mesc l("WARNING: Permanent boosts will return to their fruit form."), 1;
+
     switch (select(lg("Yes, I am sure."),
                    lg("I need to think about it..."),
                    lg("I won't need it, thank you.")))
@@ -38,10 +75,10 @@ function	script	ConfirmStatusReset	{
                 l("Thank you."),
                 l("Now stand still... It should not take much time...");
 
-            // Delete the GP and THEN reset the status
-            Zeny-=.@plush_count;
+            // Reset status have an inventorycheck, so we charge later.
             .@wasSP = StatusPoint;
-            resetstatus();
+            StatusResetReinvest();
+            Zeny-=.@plush_count;
             if (StatusPoint == .@wasSP) {
                 speech S_LAST_NEXT,
                     l("It seems that you have no status points to reset!"),
-- 
cgit v1.2.3-70-g09d2