summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt3
-rw-r--r--doc/Item Inputs and Menus.txt25
-rw-r--r--src/map/clif.c18
-rw-r--r--src/map/npc.c15
-rw-r--r--src/map/script.c13
5 files changed, 29 insertions, 45 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 426c2b2ff..b9a6612d3 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -3,6 +3,9 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
+2006/05/01
+ * Optimized fake npc system. Added npc_checknear back to npc_buysellsel. [Lance]
+
2006/04/30
* Skills with the move_enable state won't get the walkdelay increased on a
skill-cast. [Skotlex]
diff --git a/doc/Item Inputs and Menus.txt b/doc/Item Inputs and Menus.txt
deleted file mode 100644
index a715964a6..000000000
--- a/doc/Item Inputs and Menus.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-============================================================================================================
-Item Menus and Inputs
-============================================================================================================
-
-How to implement -
-1. Create an NPC with the desired script as an event.
-2. Add 'doevent "npcname::eventname";' to your item script.
-
-Example:
-
-- script validation_sys -1,{
-OnValidate:
- mes "Please type: I am validated.";
- input @validate$;
- next;
- if(@validate$ == "I am validated"){
- mes "You are validated";
- }else{
- mes "You are not";
- }
- close;
-}
-
-501,Red_Potion,Red Potion,0,50,,70,,,,,0xFFFFFFFF,7,2,,,,,,{ doevent "validation_sys::OnValidate"; },{},{}
-
diff --git a/src/map/clif.c b/src/map/clif.c
index 0efd160b4..8321368c0 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1809,10 +1809,16 @@ void clif_sendfakenpc(struct map_session_data *sd, int npcid) {
int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) {
int fd;
int slen = strlen(mes) + 8;
+ struct block_list *bl = map_id2bl(npcid);
WFIFOHEAD(fd, slen);
nullpo_retr(0, sd);
+ if (bl->type == BL_PC || 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);
+
fd=sd->fd;
WFIFOW(fd,0)=0xb7;
WFIFOW(fd,2)=slen;
@@ -1829,8 +1835,14 @@ int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) {
*/
int clif_scriptinput(struct map_session_data *sd, int npcid) {
int fd;
+ struct block_list *bl = map_id2bl(npcid);
nullpo_retr(0, sd);
+
+ if (bl->type == BL_PC || 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);
fd=sd->fd;
WFIFOHEAD(fd, packet_len_table[0x142]);
@@ -1847,9 +1859,15 @@ int clif_scriptinput(struct map_session_data *sd, int npcid) {
*/
int clif_scriptinputstr(struct map_session_data *sd, int npcid) {
int fd;
+ struct block_list *bl = map_id2bl(npcid);
nullpo_retr(0, sd);
+ if (bl->type == BL_PC || 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);
+
fd=sd->fd;
WFIFOHEAD(fd, packet_len_table[0x1d4]);
WFIFOW(fd,0)=0x1d4;
diff --git a/src/map/npc.c b/src/map/npc.c
index a38d36a3d..12c17de7a 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -979,9 +979,9 @@ int npc_checknear(struct map_session_data *sd,int id)
return 1;
}
- // Reprecated, please do not uncomment this. [Lance]
- //if (nd->class_<0) // イベント系は常にOK
- // return 0;
+
+ if (nd->class_<0) // イベント系は常にOK
+ return 0;
// エリア判定
if (nd->bl.m!=sd->bl.m ||
@@ -1026,13 +1026,14 @@ int npc_click(struct map_session_data *sd,int id)
return 1;
}
+
if (npc_checknear(sd,id))
return 1;
nd=(struct npc_data *)map_id2bl(id);
- //Disabled npc.
- if (nd->sc.option&OPTION_INVISIBLE)
+ //Hidden/Disabled npc.
+ if (nd->class_ < 0 || nd->sc.option&OPTION_INVISIBLE)
return 1;
sd->npc_id=id;
@@ -1085,8 +1086,8 @@ int npc_buysellsel(struct map_session_data *sd,int id,int type)
nullpo_retr(1, sd);
- //if (npc_checknear(sd,id))
- // return 1;
+ if (npc_checknear(sd,id))
+ return 1;
nd=(struct npc_data *)map_id2bl(id);
if (nd->bl.subtype!=SHOP) {
diff --git a/src/map/script.c b/src/map/script.c
index f9a87e1be..eeb055ed0 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10909,20 +10909,7 @@ int run_script_main(struct script_state *st)
st->state = RUN;
}
} else {
- struct block_list *bl;
st->state = RUN;
- if(st->oid && st->rid && (bl = map_id2bl(st->oid))){
- // Perfomance impact, use buildin_doevent instead for interactive item scripts.
- /*if(bl->type == BL_PC){
- clif_sendfakenpc(((TBL_PC *)bl),dummy_npc_id);
- } else */
- if(bl->type == BL_NPC){
- if((bl = map_id2bl(st->rid))){ // Should be type PC now
- if(npc_checknear(((TBL_PC *)bl), st->oid))
- clif_sendfakenpc(((struct map_session_data *)bl),st->oid);
- }
- }
- }
}
while( st->state == RUN) {
c= get_com((unsigned char *) st->script,&st->pos);