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

@@ -2642,7 +2642,43 @@ bool map_addnpc(int16 m,struct npc_data *nd)
return false;
}
mapdata->npc[mapdata->npc_num]=nd;
int xs = -1, ys = -1;
switch (nd->subtype) {
case NPCTYPE_WARP:
xs = nd->u.warp.xs;
ys = nd->u.warp.ys;
break;
case NPCTYPE_SCRIPT:
xs = nd->u.scr.xs;
ys = nd->u.scr.ys;
break;
default:
break;
}
// npcs with trigger area are grouped
// 0 < npc_num_warp < npc_num_area < npc_num
if (xs < 0 && ys < 0)
mapdata->npc[ mapdata->npc_num ] = nd;
else {
switch (nd->subtype) {
case NPCTYPE_WARP:
mapdata->npc[ mapdata->npc_num ] = mapdata->npc[ mapdata->npc_num_area ];
mapdata->npc[ mapdata->npc_num_area ] = mapdata->npc[ mapdata->npc_num_warp ];
mapdata->npc[ mapdata->npc_num_warp ] = nd;
mapdata->npc_num_warp++;
mapdata->npc_num_area++;
break;
case NPCTYPE_SCRIPT:
mapdata->npc[ mapdata->npc_num ] = mapdata->npc[ mapdata->npc_num_area ];
mapdata->npc[ mapdata->npc_num_area ] = nd;
mapdata->npc_num_area++;
break;
default:
mapdata->npc[ mapdata->npc_num ] = nd;
break;
}
}
mapdata->npc_num++;
idb_put(id_db,nd->bl.id,nd);
return true;
@@ -2709,6 +2745,8 @@ int map_addinstancemap(const char *name, unsigned short instance_id)
memset(dst_map->npc, 0, sizeof(dst_map->npc));
dst_map->npc_num = 0;
dst_map->npc_num_area = 0;
dst_map->npc_num_warp = 0;
// Reallocate cells
num_cell = dst_map->xs * dst_map->ys;