summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-31 03:52:56 +0000
committerLance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-05-31 03:52:56 +0000
commitaf2d2bc89af950fe2b780ef72ac6b0f8561ac950 (patch)
tree0044bf40e7f93ec7b089bfe6385bfc07c5cd58f2 /src/map/npc.c
parent4107030428aa608b62524bcde7d211665ab83ca3 (diff)
downloadhercules-af2d2bc89af950fe2b780ef72ac6b0f8561ac950.tar.gz
hercules-af2d2bc89af950fe2b780ef72ac6b0f8561ac950.tar.bz2
hercules-af2d2bc89af950fe2b780ef72ac6b0f8561ac950.tar.xz
hercules-af2d2bc89af950fe2b780ef72ac6b0f8561ac950.zip
[Improved]:
- Fake NPC interface to use real NPCs. - Scripting interface to restore and save sd->npc_id. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6873 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 3c4e09b41..e671c844e 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -816,7 +816,6 @@ int npc_event_sub(struct map_session_data *sd, struct event_data *ev, const unsi
return 0;
}
- sd->npc_id=ev->nd->bl.id;
sd->npc_pos=run_script(ev->nd->u.scr.script,ev->pos,sd->bl.id,ev->nd->bl.id);
return 0;
}
@@ -1050,7 +1049,6 @@ int npc_click(struct map_session_data *sd,int id)
if (nd->class_ < 0 || nd->sc.option&OPTION_INVISIBLE)
return 1;
- sd->npc_id=id;
switch(nd->bl.subtype) {
case SHOP:
clif_npcbuysell(sd,id);
@@ -1079,7 +1077,7 @@ int npc_scriptcont(struct map_session_data *sd,int id)
return 1;
}
- if(sd->npc_id != fake_npc_id){ // Not item script
+ if(sd->npc_id != fake_nd->bl.id){ // Not item script
if (npc_checknear(sd,id)){
ShowWarning("npc_scriptcont: failed npc_checknear test.\n");
return 1;
@@ -1112,7 +1110,7 @@ int npc_buysellsel(struct map_session_data *sd,int id,int type)
if (nd->bl.subtype!=SHOP) {
if (battle_config.error_log)
ShowError("no such shop npc : %d\n",id);
- sd->npc_id=0;
+ //sd->npc_id=0;
return 1;
}
if (nd->sc.option&OPTION_INVISIBLE) // 無効化されている
@@ -2944,7 +2942,27 @@ int do_init_npc(void)
add_timer_func_list(npc_timerevent,"npc_timerevent");
// Init dummy NPC
- fake_npc_id = npc_get_new_npc_id();
+ fake_nd = (struct npc_data *)aCalloc(sizeof(struct npc_data),1);
+ fake_nd->bl.prev = fake_nd->bl.next = NULL;
+ fake_nd->bl.m = -1;
+ fake_nd->bl.x = 0;
+ fake_nd->bl.y = 0;
+ fake_nd->bl.id = npc_get_new_npc_id();
+ fake_nd->class_ = -1;
+ fake_nd->speed = 200;
+ fake_nd->u.scr.script = NULL;
+ fake_nd->u.scr.src_id = 0;
+ strcpy(fake_nd->name,"FAKE_NPC");
+ memcpy(fake_nd->exname, fake_nd->name, 9);
+
+ npc_script++;
+ fake_nd->bl.type = BL_NPC;
+ fake_nd->bl.subtype = SCRIPT;
+
+ strdb_put(npcname_db, fake_nd->exname, fake_nd);
+ fake_nd->u.scr.timerid = -1;
+ map_addiddb(&fake_nd->bl);
+ // End of initialization
return 0;
}