Skip to content

Commit

Permalink
Implement status reduction script command.
Browse files Browse the repository at this point in the history
- for stat reduction support.
- return the amount of status point required to increase a status.
  • Loading branch information
Emistry committed Oct 4, 2018
1 parent 852c133 commit d7bbebd
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
16 changes: 16 additions & 0 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6034,6 +6034,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>)
Expand Down
27 changes: 27 additions & 0 deletions npc/other/CashShop_Functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
20 changes: 20 additions & 0 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -9809,6 +9809,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>;
Expand Down Expand Up @@ -25048,6 +25067,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"),
Expand Down

0 comments on commit d7bbebd

Please sign in to comment.