diff options
author | Haru <haru@dotalux.com> | 2018-06-29 12:47:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-29 12:47:03 +0200 |
commit | 337001c5cd46374709e7cabb63a8c45cff6db847 (patch) | |
tree | bc97c7d5f39e0de2570af249cc691853259b7834 | |
parent | c038c000b9cd2d14024898586789ee58d62f3ca5 (diff) | |
parent | 340f4ee90ec199aa715cc4cabe8d5e91c90d531c (diff) | |
download | hercules-337001c5cd46374709e7cabb63a8c45cff6db847.tar.gz hercules-337001c5cd46374709e7cabb63a8c45cff6db847.tar.bz2 hercules-337001c5cd46374709e7cabb63a8c45cff6db847.tar.xz hercules-337001c5cd46374709e7cabb63a8c45cff6db847.zip |
Merge pull request #2081 from EyesOfAHawk/buildin_setparam
Adds setparam(), change optional param for readparam()
-rw-r--r-- | doc/script_commands.txt | 16 | ||||
-rw-r--r-- | src/map/script.c | 47 |
2 files changed, 61 insertions, 2 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 10a0352f4..a00756056 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -2473,6 +2473,7 @@ arrays: --------------------------------------- *readparam(<parameter number>{, "<player name>"}) +*readparam(<parameter number>{, <account id>}) This function will return the basic stats of an invoking character, referred to by the parameter number. Instead of a number, you can use a @@ -2511,6 +2512,21 @@ Example 3: --------------------------------------- +*setparam(<parameter number>, <value>{, "<player name>"}) +*setparam(<parameter number>, <value>{, <account id>}) + +Sets a parameter on the given player. See readparam() for more info about +parameters. Keep in mind that not all read-able parameters are also set-able. + +Parameters that can be modified include: + +StatusPoint, BaseLevel, SkillPoint, Zeny, Sex, Weight, MaxWeight, JobLevel, +BaseExp, JobExp, Hp, MaxHp, Sp, MaxSp, Karma, Manner, Fame, bVit, bDex, bAgi, +bStr, bInt, bLuk + + +--------------------------------------- + *getcharid(<type>{, "<character name>"}) This function will return a unique ID number of the invoking character, diff --git a/src/map/script.c b/src/map/script.c index ceb97ba54..952496486 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8597,7 +8597,8 @@ BUILDIN(disableitemuse) * return the basic stats of sd * chk pc->readparam for available type *------------------------------------------*/ -BUILDIN(readparam) { +BUILDIN(readparam) +{ int type; struct map_session_data *sd; struct script_data *data = script_getdata(st, 2); @@ -8609,7 +8610,11 @@ BUILDIN(readparam) { } if (script_hasdata(st, 3)) { - sd = script->nick2sd(st, script_getstr(st, 3)); + if (script_isstringtype(st, 3)) { + sd = script->nick2sd(st, script_getstr(st, 3)); + } else { + sd = script->id2sd(st, script_getnum(st, 3)); + } } else { sd = script->rid2sd(st); } @@ -8623,6 +8628,43 @@ BUILDIN(readparam) { return true; } +BUILDIN(setparam) +{ + int type; + struct map_session_data *sd; + struct script_data *data = script_getdata(st, 2); + int val = script_getnum(st, 3); + + if (data_isreference(data) && reference_toparam(data)) { + type = reference_getparamtype(data); + } else { + type = script->conv_num(st, data); + } + + if (script_hasdata(st, 4)) { + if (script_isstringtype(st, 4)) { + sd = script->nick2sd(st, script_getstr(st, 4)); + } else { + sd = script->id2sd(st, script_getnum(st, 4)); + } + } else { + sd = script->rid2sd(st); + } + + if (sd == NULL) { + script_pushint(st, 0); + return true; + } + + if (pc->setparam(sd, type, val) == 0) { + script_pushint(st, 0); + return false; + } + + script_pushint(st, 1); + return true; +} + /*========================================== * Return charid identification * return by @num : @@ -24412,6 +24454,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(checkweight,"vi*"), BUILDIN_DEF(checkweight2,"rr"), BUILDIN_DEF(readparam,"i?"), + BUILDIN_DEF(setparam,"ii?"), BUILDIN_DEF(getcharid,"i?"), BUILDIN_DEF(getnpcid,"i?"), BUILDIN_DEF(getpartyname,"i"), |