summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-12-16 19:27:15 +0100
committerGitHub <noreply@github.com>2018-12-16 19:27:15 +0100
commit52360f0cee7916f58da6eda0399f74199f957c44 (patch)
treefac36b1c82dcde7128326b4d82a13f3fd5d13bd6
parent176d6d61d1946018398c598a842185745fb0312e (diff)
parentd7bbebdf8526667b288223c8adc2d110204814c5 (diff)
downloadhercules-52360f0cee7916f58da6eda0399f74199f957c44.tar.gz
hercules-52360f0cee7916f58da6eda0399f74199f957c44.tar.bz2
hercules-52360f0cee7916f58da6eda0399f74199f957c44.tar.xz
hercules-52360f0cee7916f58da6eda0399f74199f957c44.zip
Merge pull request #2246 from Emistry/scriptcommand_pcneedstatuspoint
Implement status reduction script command.
-rw-r--r--doc/script_commands.txt16
-rw-r--r--npc/other/CashShop_Functions.txt27
-rw-r--r--src/map/script.c20
3 files changed, 63 insertions, 0 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 5171d65f3..57d47b1b5 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -6048,6 +6048,22 @@ Amount can be negative. See statusup().
---------------------------------------
+*needed_status_point(<type>, <val>, {<char_id>});
+
+Returns the number of stat points needed to change the specified stat <type> by <val>.
+If <val> is negative, returns the number of stat points that would be needed to
+raise the specified stat from (current value - <val>) to current value.
+
+List of <type>:
+bStr - Strength
+bVit - Vitality
+bInt - Intelligence
+bAgi - Agility
+bDex - Dexterity
+bLuk - Luck
+
+---------------------------------------
+
*bonus(<bonus type>, <val1>)
*bonus2(<bonus type>, <val1>, <val2>)
*bonus3(<bonus type>, <val1>, <val2>, <val3>)
diff --git a/npc/other/CashShop_Functions.txt b/npc/other/CashShop_Functions.txt
index 92fe841e1..5b957f9f2 100644
--- a/npc/other/CashShop_Functions.txt
+++ b/npc/other/CashShop_Functions.txt
@@ -310,3 +310,30 @@ function script F_Snowball {
}
end;
}
+
+// Status reduction potion
+//============================================================
+// - Permanently reduces base stat <type> by <val>.
+// - Returns status points equals to points needed to raise
+// that stat to original value.
+// - Doesn't work if base status <type> would become lower than 1 after reduction.
+// * callfunc("F_CashReduceStat", <type>{, <val>, <itemid>});
+function script F_CashReduceStat {
+ .@type = getarg(0);
+ .@amount = getarg(1, -1);
+ .@itemid = getarg(2, 0);
+
+ if ((readparam(.@type) + .@amount) < 1) return;
+
+ if (.@itemid) {
+ if (countitem(.@itemid))
+ delitem .@itemid, 1;
+ else
+ return;
+ }
+
+ StatusPoint += needed_status_point(.@type, .@amount);
+ statusup2 .@type, .@amount;
+
+ return;
+} \ No newline at end of file
diff --git a/src/map/script.c b/src/map/script.c
index 3d3fba867..25bf59839 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9655,6 +9655,25 @@ static BUILDIN(statusup2)
return true;
}
+
+/*==========================================
+* Returns the number of stat points needed to change the specified stat by val.
+* needed_status_point(<type>,<val>{,<char id>}); [secretdataz]
+*------------------------------------------*/
+static BUILDIN(needed_status_point)
+{
+ int type = script_getnum(st, 2);
+ int val = script_getnum(st, 3);;
+ struct map_session_data *sd = script->rid2sd(st);
+
+ if (sd == NULL)
+ script_pushint(st, 0);
+ else
+ script_pushint(st, pc->need_status_point(sd, type, val));
+
+ return true;
+}
+
/// See 'doc/item_bonus.txt'
///
/// bonus <bonus type>,<val1>;
@@ -25149,6 +25168,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(downrefitem,"i?"),
BUILDIN_DEF(statusup,"i"),
BUILDIN_DEF(statusup2,"ii"),
+ BUILDIN_DEF(needed_status_point,"ii?"),
BUILDIN_DEF(bonus,"iv"),
BUILDIN_DEF2(bonus,"bonus2","ivi"),
BUILDIN_DEF2(bonus,"bonus3","ivii"),