summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2017-03-12 04:15:44 +0100
committerGitHub <noreply@github.com>2017-03-12 04:15:44 +0100
commit7950c54a9a912b2c05d53afeaed7ddcda9caf196 (patch)
tree44591edea2069de286a6b0089f0dc55fbaaf450f /src/map
parent5321ac0bc44e4429bb443f7e2a2c9fea0e047cd4 (diff)
parentcc6db9e43dea9b0093d7f7617e6016b2635744dc (diff)
downloadhercules-7950c54a9a912b2c05d53afeaed7ddcda9caf196.tar.gz
hercules-7950c54a9a912b2c05d53afeaed7ddcda9caf196.tar.bz2
hercules-7950c54a9a912b2c05d53afeaed7ddcda9caf196.tar.xz
hercules-7950c54a9a912b2c05d53afeaed7ddcda9caf196.zip
Merge pull request #1610 from mekolat/timer2
allow the PC timer buildins to run on another player
Diffstat (limited to 'src/map')
-rw-r--r--src/map/script.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 6e7598f9b..48c377d24 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10791,19 +10791,29 @@ BUILDIN(donpcevent)
*------------------------------------------*/
BUILDIN(addtimer)
{
- int tick = script_getnum(st,2);
+ int tick = script_getnum(st, 2);
const char* event = script_getstr(st, 3);
struct map_session_data *sd;
script->check_event(st, event);
- sd = script->rid2sd(st);
- if( sd == NULL )
- return true;
- if (!pc->addeventtimer(sd,tick,event)) {
- ShowWarning("buildin_addtimer: Event timer is full, can't add new event timer. (cid:%d timer:%s)\n",sd->status.char_id,event);
+ if (script_hasdata(st, 4))
+ sd = map->id2sd(script_getnum(st, 4));
+ else
+ sd = script->rid2sd(st);
+
+ if (sd == NULL) {
+ script_pushint(st, 0);
+ return false;
+ }
+
+ if (!pc->addeventtimer(sd, tick, event)) {
+ ShowWarning("script:addtimer: Event timer is full, can't add new event timer. (cid:%d timer:%s)\n", sd->status.char_id, event);
+ script_pushint(st, 0);
return false;
}
+
+ script_pushint(st, 1);
return true;
}
/*==========================================
@@ -10814,12 +10824,17 @@ BUILDIN(deltimer)
struct map_session_data *sd;
event=script_getstr(st, 2);
- sd = script->rid2sd(st);
- if( sd == NULL )
+
+ if (script_hasdata(st, 3))
+ sd = map->id2sd(script_getnum(st, 3));
+ else
+ sd = script->rid2sd(st);
+
+ if (sd == NULL)
return true;
script->check_event(st, event);
- pc->deleventtimer(sd,event);
+ pc->deleventtimer(sd, event);
return true;
}
/*==========================================
@@ -10830,14 +10845,19 @@ BUILDIN(addtimercount)
int tick;
struct map_session_data *sd;
- event=script_getstr(st, 2);
- tick=script_getnum(st,3);
- sd = script->rid2sd(st);
- if( sd == NULL )
+ event = script_getstr(st, 2);
+ tick = script_getnum(st, 3);
+
+ if (script_hasdata(st, 4))
+ sd = map->id2sd(script_getnum(st, 4));
+ else
+ sd = script->rid2sd(st);
+
+ if (sd == NULL)
return true;
script->check_event(st, event);
- pc->addeventtimercount(sd,event,tick);
+ pc->addeventtimercount(sd, event, tick);
return true;
}
@@ -21092,9 +21112,9 @@ void script_parse_builtin(void) {
BUILDIN_DEF(clone,"siisi????"),
BUILDIN_DEF(doevent,"s"),
BUILDIN_DEF(donpcevent,"s"),
- BUILDIN_DEF(addtimer,"is"),
- BUILDIN_DEF(deltimer,"s"),
- BUILDIN_DEF(addtimercount,"si"),
+ BUILDIN_DEF(addtimer,"is?"),
+ BUILDIN_DEF(deltimer,"s?"),
+ BUILDIN_DEF(addtimercount,"si?"),
BUILDIN_DEF(initnpctimer,"??"),
BUILDIN_DEF(stopnpctimer,"??"),
BUILDIN_DEF(startnpctimer,"??"),