summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-01-11 14:52:10 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-01-11 14:52:10 +0000
commit75b03a564ace1deb3956da35bb0bffd52b3c181b (patch)
tree6ee413fa3524f79709f3bdefe8849ccf918c9853 /src/map
parent0993cb85ba53417a179a0fc8b315e58d2d3a32d5 (diff)
downloadhercules-75b03a564ace1deb3956da35bb0bffd52b3c181b.tar.gz
hercules-75b03a564ace1deb3956da35bb0bffd52b3c181b.tar.bz2
hercules-75b03a564ace1deb3956da35bb0bffd52b3c181b.tar.xz
hercules-75b03a564ace1deb3956da35bb0bffd52b3c181b.zip
Added Shinomori's changes to npc event timers
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@953 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/npc.c14
-rw-r--r--src/map/npc.h2
-rw-r--r--src/map/script.c5
3 files changed, 11 insertions, 10 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index ff752192a..0186fe6de 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -596,7 +596,7 @@ int npc_timerevent(int tid,unsigned int tick,int id,int data)
* タイマーイベント開始
*------------------------------------------
*/
-int npc_timerevent_start(struct npc_data *nd)
+int npc_timerevent_start(struct npc_data *nd, int rid)
{
int j,n, next;
@@ -610,12 +610,13 @@ int npc_timerevent_start(struct npc_data *nd)
if( nd->u.scr.timer_event[j].timer > nd->u.scr.timer )
break;
}
+ if(j>=n) // check if there is a timer to use !!BEFORE!! you write stuff to the structures [Shinomori]
+ return 0;
+
nd->u.scr.nexttimer=j;
nd->u.scr.timertick=gettick();
- nd->u.scr.rid=0; // reset attached player [celest]
-
- if(j>=n)
- return 0;
+ if (rid >= 0) nd->u.scr.rid=rid; // changed to: attaching to given rid by default [Shinomori]
+ // if rid is less than 0 leave it unchanged [celest]
next = nd->u.scr.timer_event[j].timer - nd->u.scr.timer;
nd->u.scr.timerid = add_timer(gettick()+next,npc_timerevent,nd->bl.id,next);
@@ -635,6 +636,7 @@ int npc_timerevent_stop(struct npc_data *nd)
if(nd->u.scr.timerid!=-1)
delete_timer(nd->u.scr.timerid,npc_timerevent);
nd->u.scr.timerid = -1;
+ nd->u.scr.rid = 0;
}
return 0;
}
@@ -669,7 +671,7 @@ int npc_settimerevent_tick(struct npc_data *nd,int newtimer)
npc_timerevent_stop(nd);
nd->u.scr.timer=newtimer;
if(flag>=0)
- npc_timerevent_start(nd);
+ npc_timerevent_start(nd, -1);
return 0;
}
diff --git a/src/map/npc.h b/src/map/npc.h
index b3b38e5e0..a68cc8e54 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -42,7 +42,7 @@ int npc_do_ontimer(int,struct map_session_data *,int);
int npc_event_doall(const char *name);
int npc_event_do(const char *name);
-int npc_timerevent_start(struct npc_data *nd);
+int npc_timerevent_start(struct npc_data *nd, int rid);
int npc_timerevent_stop(struct npc_data *nd);
int npc_gettimerevent_tick(struct npc_data *nd);
int npc_settimerevent_tick(struct npc_data *nd,int newtimer);
diff --git a/src/map/script.c b/src/map/script.c
index 64e4a7692..a6b65e213 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3892,8 +3892,7 @@ int buildin_initnpctimer(struct script_state *st)
nd=(struct npc_data *)map_id2bl(st->oid);
npc_settimerevent_tick(nd,0);
- npc_timerevent_start(nd);
- nd->u.scr.rid=st->rid;
+ npc_timerevent_start(nd, st->rid);
return 0;
}
/*==========================================
@@ -3908,7 +3907,7 @@ int buildin_startnpctimer(struct script_state *st)
else
nd=(struct npc_data *)map_id2bl(st->oid);
- npc_timerevent_start(nd);
+ npc_timerevent_start(nd, st->rid);
return 0;
}
/*==========================================