summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-06-29 12:47:03 +0200
committerGitHub <noreply@github.com>2018-06-29 12:47:03 +0200
commit337001c5cd46374709e7cabb63a8c45cff6db847 (patch)
treebc97c7d5f39e0de2570af249cc691853259b7834 /src
parentc038c000b9cd2d14024898586789ee58d62f3ca5 (diff)
parent340f4ee90ec199aa715cc4cabe8d5e91c90d531c (diff)
downloadhercules-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()
Diffstat (limited to 'src')
-rw-r--r--src/map/script.c47
1 files changed, 45 insertions, 2 deletions
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"),