Skip to content

Commit

Permalink
Merge pull request #1509 from rathena/feature/stat_reduce_pot
Browse files Browse the repository at this point in the history
Implemented status reduction potion support
  • Loading branch information
secretdataz committed Aug 27, 2016
2 parents bf84469 + eb8ea91 commit 51ef911
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/script_commands.txt
Expand Up @@ -4294,6 +4294,14 @@ This command will force a stat recalculation for the attached player.

---------------------------------------

*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.

---------------------------------------

*get_revision()

This command will return the SVN revision number that the server is currently
Expand Down
25 changes: 25 additions & 0 deletions npc/other/CashShop_Functions.txt
Expand Up @@ -304,3 +304,28 @@ 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;
}
17 changes: 17 additions & 0 deletions src/map/script.c
Expand Up @@ -21661,6 +21661,22 @@ BUILDIN_FUNC(setrandomoption) {
return SCRIPT_CMD_FAILURE;
}

/// Returns the number of stat points needed to change the specified stat 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.
/// *needed_status_point(<type>,<val>{,<char id>});
/// @author [secretdataz]
BUILDIN_FUNC(needed_status_point) {
struct map_session_data *sd;
int type, val;
if (!script_charid2sd(4, sd))
return SCRIPT_CMD_FAILURE;
type = script_getnum(st, 2);
val = script_getnum(st, 3);

script_pushint(st, pc_need_status_point(sd, type, val));
return SCRIPT_CMD_SUCCESS;
}
#include "../custom/script.inc"

// declarations that were supposed to be exported from npc_chat.c
Expand Down Expand Up @@ -22243,6 +22259,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(getrandomoptinfo, "i"),
BUILDIN_DEF(getequiprandomoption, "iii?"),
BUILDIN_DEF(setrandomoption,"iiiii?"),
BUILDIN_DEF(needed_status_point,"ii?"),

#include "../custom/script_def.inc"

Expand Down

0 comments on commit 51ef911

Please sign in to comment.