Issue information

Issue ID
#4554
Status
Working as Intended
Severity
None
Started
Hercules Elf Bot
Nov 17, 2010 13:19
Last Post
Hercules Elf Bot
Mar 19, 2012 19:25
Confirmation
N/A

Hercules Elf Bot - Nov 17, 2010 13:19

Originally posted by [b]zippymccrackin[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=4554

I recently put an NPC with an OnTouch next to another NPC with an OnTouch. The first NPC was to detect if the player was on a quest and if not hide itself, and the other was to warp the player off of the airship depending on where the airship was. When I put the Quest NPC in, the warp stopped working, and I wondered as to why that happened. Investigating further, I found that when searching for an OnTouch, it will call only the first one it finds. My temporary fix is this:

function npc_touch_areanpc:
replace int i; with:
CODE
       int i,j=0;
       int npcs[map[m].npc_num];
       int npccount = 0;

replace
CODE
               &&  y >= map[m].npc[i]->bl.y-ys && y <= map[m].npc[i]->bl.y+ys )
                       break;

with
CODE
               &&  y >= map[m].npc[i]->bl.y-ys && y <= map[m].npc[i]->bl.y+ys ) {
                       npcs[npccount++] = i;
                       f=0;
               }

replace
CODE
if( i == map[m].npc_num )

with
CODE
if( npccount == 0 )


Then add this before the switch:
CODE
       for( j=0; j<npccount; j++ ) {
               i=npcs[j];

after the switch add the }

Any ramifications to doing this? I know this definitely fixed the problem for me.

Hercules Elf Bot - Dec 6, 2011 16:52

Originally posted by [b]Ind[/b]
I can see this kind of overlapping glitching, if two npcs with ontouch are triggered at once and both have "dialogs" one would overlap another (which would create unintended behavior), wouldn't it?

Hercules Elf Bot - Dec 7, 2011 1:41

Originally posted by [b]Epoque[/b]
I don't think we can do much about this, given that NPCs aren't meant to be overlapped like that. I think officially the first collision should be the one to be handled, otherwise we will end up with event queues overlapping and possibly glitching the player or client. I'll change this to Working as Intended.