diff options
author | zephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-06-02 15:54:50 +0000 |
---|---|---|
committer | zephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-06-02 15:54:50 +0000 |
commit | 8f98ecea38aa77e4d0fb53bae0dc6052289b24a8 (patch) | |
tree | b2706d9f9ce8ae44f87583eb58156153de0bcbbd /src/map/npc.c | |
parent | 6b1e40e08d0d42abad80cc8bad1b848091bf0b30 (diff) | |
download | hercules-8f98ecea38aa77e4d0fb53bae0dc6052289b24a8.tar.gz hercules-8f98ecea38aa77e4d0fb53bae0dc6052289b24a8.tar.bz2 hercules-8f98ecea38aa77e4d0fb53bae0dc6052289b24a8.tar.xz hercules-8f98ecea38aa77e4d0fb53bae0dc6052289b24a8.zip |
- Added support for OnTouchNPC event, required for Monster Race. Script commands need to be tested. Already tested sc_start.
- Added status SC_WALKSPEED required in monster Race.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12752 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r-- | src/map/npc.c | 73 |
1 files changed, 54 insertions, 19 deletions
diff --git a/src/map/npc.c b/src/map/npc.c index 24fe8787b..c576295df 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -777,35 +777,70 @@ int npc_touch_areanpc(struct map_session_data* sd, int m, int x, int y) return 0; } -int npc_touch_areanpc2(struct block_list* bl) +int npc_touch_areanpc2(struct mob_data *md) { - int i,m=bl->m; - int xs,ys; + 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++) + for( i = 0; i < map[m].npc_num; i++ ) { - if (map[m].npc[i]->sc.option&OPTION_INVISIBLE) + if( map[m].npc[i]->sc.option&OPTION_INVISIBLE ) continue; - if (map[m].npc[i]->subtype!=WARP) + 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; - - xs=map[m].npc[i]->u.warp.xs; - ys=map[m].npc[i]->u.warp.ys; + } + 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 - if( bl->x >= map[m].npc[i]->bl.x-xs && bl->x <= map[m].npc[i]->bl.x+xs - && bl->y >= map[m].npc[i]->bl.y-ys && bl->y <= map[m].npc[i]->bl.y+ys ) break; + } } - if (i==map[m].npc_num) - return 0; - - xs = map_mapindex2mapid(map[m].npc[i]->u.warp.mapindex); - if (xs < 0) // Can't warp object between map servers... - return 0; - if (unit_warp(bl, xs, map[m].npc[i]->u.warp.x,map[m].npc[i]->u.warp.y,0)) - return 0; //Failed to warp. + 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; } |