Skip to content

Commit eae4dbc

Browse files
committed
Implement status reduction script command.
- for stat reduction support. - return the amount of status point required to increase a status.
1 parent 852c133 commit eae4dbc

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

doc/script_commands.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6034,6 +6034,22 @@ Amount can be negative. See statusup().
60346034

60356035
---------------------------------------
60366036

6037+
*needed_status_point(<type>, <val>, {<char_id>});
6038+
6039+
Returns the number of stat points needed to change the specified stat <type> by <val>.
6040+
If <val> is negative, returns the number of stat points that would be needed to
6041+
raise the specified stat from (current value - <val>) to current value.
6042+
6043+
List of <type>:
6044+
bStr - Strength
6045+
bVit - Vitality
6046+
bInt - Intelligence
6047+
bAgi - Agility
6048+
bDex - Dexterity
6049+
bLuk - Luck
6050+
6051+
---------------------------------------
6052+
60376053
*bonus(<bonus type>, <val1>)
60386054
*bonus2(<bonus type>, <val1>, <val2>)
60396055
*bonus3(<bonus type>, <val1>, <val2>, <val3>)

npc/other/CashShop_Functions.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,30 @@ function script F_Snowball {
310310
}
311311
end;
312312
}
313+
314+
// Status reduction potion
315+
//============================================================
316+
// - Permanently reduces base stat <type> by <val>.
317+
// - Returns status points equals to points needed to raise
318+
// that stat to original value.
319+
// - Doesn't work if base status <type> would become lower than 1 after reduction.
320+
// * callfunc("F_CashReduceStat",<type>{,<val>,<itemid>});
321+
function script F_CashReduceStat {
322+
.@type = getarg(0);
323+
.@amount = getarg(1, -1);
324+
.@itemid = getarg(2, 0);
325+
326+
if((readparam(.@type) + .@amount) < 1) return;
327+
328+
if(.@itemid) {
329+
if(countitem(.@itemid))
330+
delitem .@itemid,1;
331+
else
332+
return;
333+
}
334+
335+
StatusPoint += needed_status_point(.@type, .@amount);
336+
statusup2 .@type,.@amount;
337+
338+
return;
339+
}

src/map/script.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9809,6 +9809,23 @@ static BUILDIN(statusup2)
98099809
return true;
98109810
}
98119811

9812+
9813+
/*==========================================
9814+
* Returns the number of stat points needed to change the specified stat by val.
9815+
* needed_status_point(<type>,<val>{,<char id>}); [secretdataz]
9816+
*------------------------------------------*/
9817+
static BUILDIN(needed_status_point)
9818+
{
9819+
int type = script_getnum(st, 2);
9820+
int val = script_getnum(st, 3);;
9821+
struct map_session_data *sd = script->rid2sd(st);
9822+
9823+
if (sd != NULL)
9824+
script_pushint(st, pc->need_status_point(sd, type, val));
9825+
9826+
return true;
9827+
}
9828+
98129829
/// See 'doc/item_bonus.txt'
98139830
///
98149831
/// bonus <bonus type>,<val1>;
@@ -25048,6 +25065,7 @@ static void script_parse_builtin(void)
2504825065
BUILDIN_DEF(downrefitem,"i?"),
2504925066
BUILDIN_DEF(statusup,"i"),
2505025067
BUILDIN_DEF(statusup2,"ii"),
25068+
BUILDIN_DEF(needed_status_point,"ii?"),
2505125069
BUILDIN_DEF(bonus,"iv"),
2505225070
BUILDIN_DEF2(bonus,"bonus2","ivi"),
2505325071
BUILDIN_DEF2(bonus,"bonus3","ivii"),

0 commit comments

Comments
 (0)