Issue information

Issue ID
#1608
Status
Fixed
Severity
None
Started
Hercules Elf Bot
Jun 3, 2008 5:01
Last Post
Hercules Elf Bot
Jun 3, 2008 5:01
Confirmation
N/A

Hercules Elf Bot - Jun 3, 2008 5:01

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

npc.c
[codebox] int npc_touch_areanpc2(struct mob_data *md)
{
int i, m = md->bl.m, x = md->bl.x, y = md->bl.y;
char eventname[NAME_LENGTH*2+3];
struct event_data* ev;
int xs, ys;

for( i = 0; i < map[m].npc_num; i++ )
{
if( map[m].npc[i]->sc.option&OPTION_INVISIBLE )
continue;

switch( map[m].npc[i]->subtype )
{
case WARP:
if( battle_config.mob_warp&1 )
{
xs = map[m].npc[i]->u.warp.xs;
ys = map[m].npc[i]->u.warp.ys;
}
else
continue;
break;
case SCRIPT:
xs = map[m].npc[i]->u.scr.xs;
ys = map[m].npc[i]->u.scr.ys;
snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", map[m].npc[i]->exname);
break;
default:
continue;
}
if( x >= map[m].npc[i]->bl.x-xs && x <= map[m].npc[i]->bl.x+xs && y >= map[m].npc[i]->bl.y-ys && y <= map[m].npc[i]->bl.y+ys )
{
if( map[m].npc[i]->subtype == SCRIPT
&& ((ev = (struct event_data*)strdb_get(ev_db, eventname)) == NULL || ev->nd == NULL) )
continue; // No OnTouchNPC Event found

break;
}
}

if( i == map[m].npc_num ) return 0;

switch( map[m].npc[i]->subtype )
{
case WARP:
xs = map_mapindex2mapid(map[m].npc[i]->u.warp.mapindex);
if( xs < 0 )
return 0; // Can't warp object between map servers...
if( unit_warp(&md->bl, xs, map[m].npc[i]->u.warp.x, map[m].npc[i]->u.warp.y, 0) )
return 0; // Failed to warp.
break;
case SCRIPT:
{
if( md->areanpc_id == map[m].npc[i]->bl.id )
return 0; // Allready touch this NPC

md->areanpc_id = map[m].npc[i]->bl.id;
run_script(ev->nd->u.scr.script, ev->pos, md->bl.id, ev->nd->bl.id);

return 0;
break;
}
}

return 1;
} [/codebox]

[codebox] int npc_touch_areanpc2(struct block_list* bl); // [Skotlex] [/codebox]

[codebox] if( npc_touch_areanpc2(md) ) return 0; // Warped [/codebox]

This post has been edited by OmegaWeapon: Jun 2 2008, 10:04 PM