From 0c666ccc332859f5fdcd3346165cc07c0503a7d4 Mon Sep 17 00:00:00 2001 From: gumi Date: Fri, 15 Jun 2018 09:38:21 -0400 Subject: allow to pass an account id to buildin_readparam Co-authored-by: "Wolfie" --- src/map/script.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/map/script.c b/src/map/script.c index d9350081a..f74debabb 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); } @@ -18157,7 +18162,7 @@ BUILDIN(setpcblock) if ((type & PCBLOCK_IMMUNE) != 0) sd->block_action.immune = state; - if ((type & PCBLOCK_SITSTAND) != 0) + if ((type & PCBLOCK_SITSTAND) != 0) sd->block_action.sitstand = state; if ((type & PCBLOCK_COMMANDS) != 0) @@ -25263,7 +25268,7 @@ void script_hardcoded_constants(void) script->set_constant("MST_AROUND3", MST_AROUND3, false, false); script->set_constant("MST_AROUND4", MST_AROUND4, false, false); script->set_constant("MST_AROUND", MST_AROUND , false, false); - + script->constdb_comment("pc block constants, use with *setpcblock* and *checkpcblock*"); script->set_constant("PCBLOCK_NONE", PCBLOCK_NONE, false, false); script->set_constant("PCBLOCK_MOVE", PCBLOCK_MOVE, false, false); -- cgit v1.2.3-70-g09d2 From a1e86508ed517be79d27c9bc0e725e5b1df9cd50 Mon Sep 17 00:00:00 2001 From: gumi Date: Fri, 15 Jun 2018 09:41:35 -0400 Subject: update documentation following changes to buildin_readparam --- doc/script_commands.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 36c4da35a..dae698702 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -2473,6 +2473,7 @@ arrays: --------------------------------------- *readparam({, ""}) +*readparam({, }) 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 @@ -6195,7 +6196,7 @@ Examples: @ /!\ This command is deprecated @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -Prevents the player from moving when the option != 0, and 0 enables the +Prevents the player from moving when the option != 0, and 0 enables the player to move again. The player has to be the account ID of a character, and will run for the attached player if zero is supplied. @@ -10068,4 +10069,4 @@ the available flags are: Opens the styling shop on client ---------------------------------------- \ No newline at end of file +--------------------------------------- -- cgit v1.2.3-70-g09d2 From def62fb51d473886e92545e0477c1184ed30f888 Mon Sep 17 00:00:00 2001 From: gumi Date: Fri, 15 Jun 2018 09:50:25 -0400 Subject: add buildin_setparam Co-authored-by: "Wolfie" --- src/map/script.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/map/script.c b/src/map/script.c index f74debabb..78dd63fdc 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8628,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 : @@ -24391,6 +24428,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"), -- cgit v1.2.3-70-g09d2 From 340f4ee90ec199aa715cc4cabe8d5e91c90d531c Mon Sep 17 00:00:00 2001 From: gumi Date: Fri, 15 Jun 2018 10:02:20 -0400 Subject: add documentation for buildin_setparam --- doc/script_commands.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index dae698702..051c392e5 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -2510,6 +2510,21 @@ Example 3: // Display your current weight mes("Your current weight is "+ (Weight/10) + "/" + (MaxWeight/10)); +--------------------------------------- + +*setparam(, {, ""}) +*setparam(, {, }) + +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({, ""}) -- cgit v1.2.3-70-g09d2