summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFate <fate-tmw@googlemail.com>2008-12-30 04:15:32 -0700
committerFate <fate-tmw@googlemail.com>2008-12-30 04:15:32 -0700
commitef1cac570726f59c821ebafd1980302c0035d3ce (patch)
tree1e07cc5de2a43494fd35cb78bf59f4c3d39c3c55 /src
parente22cc45c0dfffa33b981f8674743cacd9915d6e0 (diff)
downloadtmwa-ef1cac570726f59c821ebafd1980302c0035d3ce.tar.gz
tmwa-ef1cac570726f59c821ebafd1980302c0035d3ce.tar.bz2
tmwa-ef1cac570726f59c821ebafd1980302c0035d3ce.tar.xz
tmwa-ef1cac570726f59c821ebafd1980302c0035d3ce.zip
Added OnPCDieEvent and OnPCKillEvent label support
Diffstat (limited to 'src')
-rw-r--r--src/map/npc.c30
-rw-r--r--src/map/npc.h7
-rw-r--r--src/map/pc.c12
-rw-r--r--src/map/script.h2
4 files changed, 39 insertions, 12 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 849030f..a2ad04d 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -266,6 +266,8 @@ int npc_event_export(void *key,void *data,va_list ap)
int npc_event_doall_sub(void *key,void *data,va_list ap)
{
char *p=(char *)key;
+ int rid, argc;
+ argrec_t *argv;
struct event_data *ev;
int *c;
const char *name;
@@ -275,53 +277,63 @@ int npc_event_doall_sub(void *key,void *data,va_list ap)
nullpo_retr(0, c=va_arg(ap,int *));
name=va_arg(ap,const char *);
+ rid = va_arg(ap, int);
+ argc = va_arg(ap, int);
+ argv = va_arg(ap, argrec_t *);
+
if( (p=strchr(p,':')) && p && strcasecmp(name,p)==0 ){
- run_script(ev->nd->u.scr.script,ev->pos,0,ev->nd->bl.id);
+ run_script_l(ev->nd->u.scr.script,ev->pos,rid,ev->nd->bl.id, argc, argv);
(*c)++;
}
return 0;
}
-int npc_event_doall(const char *name)
+int npc_event_doall_l(const char *name, int rid, int argc, argrec_t *args)
{
int c=0;
char buf[64]="::";
strncpy(buf+2,name,62);
- strdb_foreach(ev_db,npc_event_doall_sub,&c,buf);
- return c;
+ strdb_foreach(ev_db,npc_event_doall_sub,&c,buf, rid, argc, args);
+ return c;
}
-int npc_event_do_sub(void *key,void *data,va_list ap)
+int npc_event_do_sub(void *key,void *data, va_list ap)
{
char *p=(char *)key;
struct event_data *ev;
int *c;
const char *name;
+ int rid, argc;
+ argrec_t *argv;
nullpo_retr(0, ev=(struct event_data *)data);
nullpo_retr(0, ap);
nullpo_retr(0, c=va_arg(ap,int *));
name=va_arg(ap,const char *);
+ rid = va_arg(ap, int);
+ argc = va_arg(ap, int);
+ argv = va_arg(ap, argrec_t *);
+
if (p && strcasecmp(name,p)==0 ) {
- run_script(ev->nd->u.scr.script,ev->pos,0,ev->nd->bl.id);
+ run_script_l(ev->nd->u.scr.script,ev->pos, rid, ev->nd->bl.id, argc, argv);
(*c)++;
}
return 0;
}
-int npc_event_do(const char *name)
+int npc_event_do_l(const char *name, int rid, int argc, argrec_t *args)
{
int c=0;
if (*name==':' && name[1]==':') {
- return npc_event_doall(name+2);
+ return npc_event_doall_l(name+2, rid, argc, args);
}
- strdb_foreach(ev_db,npc_event_do_sub,&c,name);
+ strdb_foreach(ev_db,npc_event_do_sub,&c,name, rid, argc, args);
return c;
}
diff --git a/src/map/npc.h b/src/map/npc.h
index c843b56..03ad138 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -50,8 +50,11 @@ int do_init_npc(void);
int npc_event_do_oninit(void);
int npc_do_ontimer(int,struct map_session_data *,int);
-int npc_event_doall(const char *name);
-int npc_event_do(const char *name);
+struct argrec;
+int npc_event_doall_l(const char *name, int rid, int argc, struct argrec *argv);
+int npc_event_do_l(const char *name, int rid, int argc, struct argrec *argv);
+#define npc_event_doall(name) npc_event_doall_l(name, 0, 0, NULL)
+#define npc_event_do(name) npc_event_do_l(name, 0, 0, NULL)
int npc_timerevent_start(struct npc_data *nd);
int npc_timerevent_stop(struct npc_data *nd);
diff --git a/src/map/pc.c b/src/map/pc.c
index bed6fc6..0d9e1ff 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -5067,6 +5067,9 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage)
return 0;
}
+
+ // Character is dead!
+
sd->status.hp = 0;
// [Fate] Stop quickregen
sd->quick_regeneration_hp.amount = 0;
@@ -5213,6 +5216,15 @@ int pc_damage(struct block_list *src,struct map_session_data *sd,int damage)
pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,0);
}
+ if (src && src->type == BL_PC) {
+ // [Fate] PK death, trigger scripts
+ argrec_t arg;
+ arg.name = "@killerrid";
+ arg.v.i = src->id;
+ npc_event_doall_l("OnPCKillEvent", sd->bl.id, 1, &arg);
+ }
+ npc_event_doall_l("OnPCDieEvent", sd->bl.id, 0, NULL);
+
return 0;
}
diff --git a/src/map/script.h b/src/map/script.h
index 3391643..c5ff909 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -24,7 +24,7 @@ struct script_state {
};
unsigned char * parse_script(unsigned char *,int);
-typedef struct {
+typedef struct argrec {
char *name;
union {
int i;