[Improved]:
- Fake NPC interface to use real NPCs. - Scripting interface to restore and save sd->npc_id. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@6873 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
2268d4b763
commit
8236d2c93f
@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
|
||||
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
|
||||
2006/05/30
|
||||
* [Improved]:
|
||||
- Fake NPC interface to use real NPCs.
|
||||
- Scripting interface to restore and save sd->npc_id. [Lance]
|
||||
* Added function pc_check_skilltree for checking if you unlocked new
|
||||
tree-skills when raising non-passive skills. [Skotlex]
|
||||
* Fixed flee/hit calculation in status_calc_bl to account for bonuses from
|
||||
|
@ -1874,7 +1874,7 @@ int clif_scriptclose(struct map_session_data *sd, int npcid) {
|
||||
*/
|
||||
void clif_sendfakenpc(struct map_session_data *sd, int npcid) {
|
||||
int fd = sd->fd;
|
||||
sd->npc_id = npcid;
|
||||
//sd->npc_id = npcid;
|
||||
sd->state.using_fake_npc = 1;
|
||||
memset(WFIFOP(fd,0), 0, packet_len_table[0x78]);
|
||||
WFIFOW(fd,0)=0x78;
|
||||
@ -1899,7 +1899,7 @@ int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) {
|
||||
|
||||
nullpo_retr(0, sd);
|
||||
|
||||
if (!sd->state.using_fake_npc && (npcid == fake_npc_id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
|
||||
if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
|
||||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
|
||||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
|
||||
clif_sendfakenpc(sd, npcid);
|
||||
@ -1924,7 +1924,7 @@ int clif_scriptinput(struct map_session_data *sd, int npcid) {
|
||||
|
||||
nullpo_retr(0, sd);
|
||||
|
||||
if (!sd->state.using_fake_npc && (npcid == fake_npc_id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
|
||||
if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
|
||||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
|
||||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
|
||||
clif_sendfakenpc(sd, npcid);
|
||||
@ -1948,7 +1948,7 @@ int clif_scriptinputstr(struct map_session_data *sd, int npcid) {
|
||||
|
||||
nullpo_retr(0, sd);
|
||||
|
||||
if (!sd->state.using_fake_npc && (npcid == fake_npc_id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
|
||||
if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
|
||||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
|
||||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
|
||||
clif_sendfakenpc(sd, npcid);
|
||||
|
@ -1478,6 +1478,6 @@ typedef struct homun_data TBL_HOMUNCULUS;
|
||||
extern int lowest_gm_level;
|
||||
extern char main_chat_nick[16];
|
||||
|
||||
int fake_npc_id;
|
||||
struct npc_data *fake_nd;
|
||||
|
||||
#endif
|
||||
|
@ -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;
|
||||
}
|
||||
|
12
src/map/pc.c
12
src/map/pc.c
@ -2785,8 +2785,8 @@ int pc_useitem(struct map_session_data *sd,int n)
|
||||
}
|
||||
|
||||
sd->canuseitem_tick= tick + battle_config.item_use_interval; //Update item use time.
|
||||
sd->npc_id = fake_npc_id;
|
||||
run_script(script,0,sd->bl.id,fake_npc_id);
|
||||
//sd->npc_id = fake_nd->bl.id;
|
||||
run_script(script,0,sd->bl.id,fake_nd->bl.id);
|
||||
potion_flag = 0;
|
||||
return 1;
|
||||
}
|
||||
@ -6077,7 +6077,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos)
|
||||
int i;
|
||||
struct item_data *data;
|
||||
if (sd->inventory_data[n]->equip_script)
|
||||
run_script(sd->inventory_data[n]->equip_script,0,sd->bl.id,0);
|
||||
run_script(sd->inventory_data[n]->equip_script,0,sd->bl.id,fake_nd->bl.id);
|
||||
if(sd->status.inventory[n].card[0]==0x00ff ||
|
||||
sd->status.inventory[n].card[0]==0x00fe ||
|
||||
sd->status.inventory[n].card[0]==(short)0xff00)
|
||||
@ -6089,7 +6089,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos)
|
||||
continue;
|
||||
data = itemdb_exists(sd->status.inventory[n].card[i]);
|
||||
if (data && data->equip_script)
|
||||
run_script(data->equip_script,0,sd->bl.id,0);
|
||||
run_script(data->equip_script,0,sd->bl.id,fake_nd->bl.id);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -6175,7 +6175,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag)
|
||||
if (sd->inventory_data[n]) {
|
||||
struct item_data *data;
|
||||
if (sd->inventory_data[n]->unequip_script)
|
||||
run_script(sd->inventory_data[n]->unequip_script,0,sd->bl.id,0);
|
||||
run_script(sd->inventory_data[n]->unequip_script,0,sd->bl.id,fake_nd->bl.id);
|
||||
if(sd->status.inventory[n].card[0]==0x00ff ||
|
||||
sd->status.inventory[n].card[0]==0x00fe ||
|
||||
sd->status.inventory[n].card[0]==(short)0xff00)
|
||||
@ -6187,7 +6187,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag)
|
||||
continue;
|
||||
data = itemdb_exists(sd->status.inventory[n].card[i]);
|
||||
if (data && data->unequip_script)
|
||||
run_script(data->unequip_script,0,sd->bl.id,0);
|
||||
run_script(data->unequip_script,0,sd->bl.id,fake_nd->bl.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11438,7 +11438,7 @@ int run_script(struct script_code *rootscript,int pos,int rid,int oid)
|
||||
//Variables for backing up the previous script and restore it if needed. [Skotlex]
|
||||
struct script_code *bck_script = NULL;
|
||||
struct script_code *bck_scriptroot = NULL;
|
||||
int bck_scriptstate = 0;
|
||||
int bck_scriptstate = 0,bck_npcid = 0;
|
||||
struct script_stack *bck_stack = NULL;
|
||||
|
||||
if (rootscript == NULL || pos < 0)
|
||||
@ -11473,6 +11473,8 @@ int run_script(struct script_code *rootscript,int pos,int rid,int oid)
|
||||
bck_scriptstate = sd->npc_scriptstate;
|
||||
bck_stack = sd->stack;
|
||||
sd->stack = NULL;
|
||||
bck_npcid = sd->npc_id;
|
||||
sd->npc_id = st->oid;
|
||||
}
|
||||
}
|
||||
st->pos = pos;
|
||||
@ -11513,6 +11515,7 @@ int run_script(struct script_code *rootscript,int pos,int rid,int oid)
|
||||
sd->npc_scriptroot = bck_scriptroot;
|
||||
sd->npc_scriptstate = bck_scriptstate;
|
||||
sd->stack = bck_stack;
|
||||
sd->npc_id = bck_npcid;
|
||||
//Since the script is done, save any changed account variables [Skotlex]
|
||||
if (sd->state.reg_dirty&2)
|
||||
intif_saveregistry(sd,2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user