Adjusted OnTouch overlap behavior (#2382)

* Fixes #1939 and fixes #2274.
* OnTouch NPC are now able to overlap one another and properly trigger as they do on official servers.
* When entering an overlap area it should trigger both NPC.
* Walking from overlap area to either NPC should trigger neither.
* Walking from one NPC to the other (skipping the overlap area) should trigger the NPC area you enter.
* Entering an OnTouch area will no longer stop the player from walking unless a message or menu window opens (or other events that should stop the player).
* Resolves OnTouch_ overlapping issues.
* Dead players don't trigger OnTouch_ anymore.
* Hidden players don't trigger NPC clicks when OnTouch_ label is defined.
Thanks to @Tokeiburu, @Lemongrass3110, @Atemo, and @Normynator!
This commit is contained in:
Aleos
2019-04-03 19:25:47 -04:00
committed by GitHub
parent 98a685d706
commit c977558cfd
7 changed files with 185 additions and 113 deletions

View File

@@ -444,14 +444,14 @@ static TIMER_FUNC(unit_walktoxy_timer){
switch(bl->type) {
case BL_PC:
if( sd->touching_id )
if( !sd->npc_ontouch_.empty() )
npc_touchnext_areanpc(sd,false);
if(map_getcell(bl->m,x,y,CELL_CHKNPC)) {
npc_touch_areanpc(sd,bl->m,x,y);
if (bl->prev == NULL) // Script could have warped char, abort remaining of the function.
return 0;
} else
sd->areanpc_id=0;
sd->areanpc.clear();
pc_cell_basilica(sd);
break;
case BL_MOB:
@@ -971,7 +971,7 @@ bool unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, boo
ud->walktimer = INVALID_TIMER;
if(sd) {
if( sd->touching_id )
if( !sd->npc_ontouch_.empty() )
npc_touchnext_areanpc(sd,false);
if(map_getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) {
@@ -980,7 +980,7 @@ bool unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, boo
if (bl->prev == NULL) // Script could have warped char, abort remaining of the function.
return false;
} else
sd->areanpc_id=0;
sd->areanpc.clear();
if( sd->status.pet_id > 0 && sd->pd && sd->pd->pet.intimate > PET_INTIMATE_NONE ) {
// Check if pet needs to be teleported. [Skotlex]
@@ -1102,13 +1102,13 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, enum e_skill_bl
clif_blown(bl);
if(sd) {
if(sd->touching_id)
if(!sd->npc_ontouch_.empty())
npc_touchnext_areanpc(sd, false);
if(map_getcell(bl->m, bl->x, bl->y, CELL_CHKNPC))
npc_touch_areanpc(sd, bl->m, bl->x, bl->y);
else
sd->areanpc_id = 0;
sd->areanpc.clear();
}
}
@@ -2955,7 +2955,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
if(sd->menuskill_id)
sd->menuskill_id = sd->menuskill_val = 0;
if( sd->touching_id )
if( !sd->npc_ontouch_.empty() )
npc_touchnext_areanpc(sd,true);
// Check if warping and not changing the map.