summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-06-04 13:13:34 +0000
committerzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-06-04 13:13:34 +0000
commit4001777de4bc272bbbef792ea08ab1d93cea2ab2 (patch)
treef84f9fa23367b12ece48cd0d3ce0ac8538230325 /src/map/npc.c
parent16bbe71ddbaa0d83cc0bfe55176a1ba43eb5cad0 (diff)
downloadhercules-4001777de4bc272bbbef792ea08ab1d93cea2ab2.tar.gz
hercules-4001777de4bc272bbbef792ea08ab1d93cea2ab2.tar.bz2
hercules-4001777de4bc272bbbef792ea08ab1d93cea2ab2.tar.xz
hercules-4001777de4bc272bbbef792ea08ab1d93cea2ab2.zip
- Little cleanup to OnTouchNPC.
- Updating Release of Wish script. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12757 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c77
1 files changed, 34 insertions, 43 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index c576295df..1a888cd24 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -777,6 +777,8 @@ int npc_touch_areanpc(struct map_session_data* sd, int m, int x, int y)
return 0;
}
+// OnTouch NPC or Warp for Mobs
+// Return 1 if Warped
int npc_touch_areanpc2(struct mob_data *md)
{
int i, m = md->bl.m, x = md->bl.x, y = md->bl.y;
@@ -791,58 +793,47 @@ int npc_touch_areanpc2(struct mob_data *md)
switch( map[m].npc[i]->subtype )
{
- case WARP:
- if( battle_config.mob_warp&1 )
- {
+ case WARP:
+ if( !battle_config.mob_warp&1 )
+ continue;
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;
+ break;
+ case SCRIPT:
+ xs = map[m].npc[i]->u.scr.xs;
+ ys = map[m].npc[i]->u.scr.ys;
+ break;
+ default:
+ continue; // Keep Searching
}
- 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);
+ 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 )
+ { // In the npc touch area
+ switch( map[m].npc[i]->subtype )
+ {
+ case WARP:
+ xs = map_mapindex2mapid(map[m].npc[i]->u.warp.mapindex);
+ if( m < 0 )
+ break; // Cannot Warp between map servers
+ if( unit_warp(&md->bl, xs, map[m].npc[i]->u.warp.x, map[m].npc[i]->u.warp.y, 0) == 0 )
+ return 1; // Warped
+ break;
+ case SCRIPT:
+ if( map[m].npc[i]->bl.id == md->areanpc_id )
+ break; // Already touch this NPC
+ snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", map[m].npc[i]->exname);
+ if( (ev = (struct event_data*)strdb_get(ev_db, eventname)) == NULL || ev->nd == NULL )
+ break; // No OnTouchNPC Event
+ 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);
+ break;
+ }
return 0;
- break;
}
}
- return 1;
+ return 0;
}
//Checks if there are any NPC on-touch objects on the given range.