summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-07 20:15:23 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-07 20:15:23 +0000
commitdd2e4d4fea67858cb39260549de6a2ccb49eb7b9 (patch)
tree2f94180e9494eefcaf6f8a2dd7b0b0c74b5c7da8 /src
parent5d9d254ef290e9cc8acfdd08af279fdc1a439853 (diff)
downloadhercules-dd2e4d4fea67858cb39260549de6a2ccb49eb7b9.tar.gz
hercules-dd2e4d4fea67858cb39260549de6a2ccb49eb7b9.tar.bz2
hercules-dd2e4d4fea67858cb39260549de6a2ccb49eb7b9.tar.xz
hercules-dd2e4d4fea67858cb39260549de6a2ccb49eb7b9.zip
- Added config setting mob_npc_warp, when set to yes, enables mobs to be warped between maps when stepping on a npc-warp.
- Added monster_ai setting &64, when enabled makes a mob run to any nearby npc-warp when their current target has switched maps. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7039 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/battle.c2
-rw-r--r--src/map/battle.h1
-rw-r--r--src/map/mob.c25
-rw-r--r--src/map/npc.c29
-rw-r--r--src/map/npc.h1
-rw-r--r--src/map/unit.c3
6 files changed, 60 insertions, 1 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 24958bb99..487c65c14 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -3424,6 +3424,7 @@ static const struct battle_data_short {
{ "display_snatcher_skill_fail", &battle_config.display_snatcher_skill_fail },
{ "chat_warpportal", &battle_config.chat_warpportal },
{ "mob_warpportal", &battle_config.mob_warpportal },
+ { "mob_npc_warp", &battle_config.mob_npc_warp },
{ "dead_branch_active", &battle_config.dead_branch_active },
{ "show_steal_in_same_party", &battle_config.show_steal_in_same_party },
{ "show_party_share_picker", &battle_config.party_show_share_picker },
@@ -3826,6 +3827,7 @@ void battle_set_defaults() {
battle_config.display_snatcher_skill_fail = 1;
battle_config.chat_warpportal = 0;
battle_config.mob_warpportal = 0;
+ battle_config.mob_npc_warp = 0;
battle_config.dead_branch_active = 0;
battle_config.vending_max_value = 10000000;
battle_config.show_steal_in_same_party = 0;
diff --git a/src/map/battle.h b/src/map/battle.h
index ec472947f..4980ecceb 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -265,6 +265,7 @@ extern struct Battle_Config {
unsigned short display_snatcher_skill_fail;
unsigned short chat_warpportal;
unsigned short mob_warpportal;
+ unsigned short mob_npc_warp;
unsigned short dead_branch_active;
unsigned int vending_max_value;
unsigned short show_steal_in_same_party;
diff --git a/src/map/mob.c b/src/map/mob.c
index 346003618..ea92b5122 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -866,6 +866,23 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
return 0;
}
+static int mob_ai_sub_hard_warpsearch(struct block_list *bl,va_list ap)
+{
+ struct mob_data* md;
+ struct block_list **target;
+
+ md=va_arg(ap,struct mob_data *);
+ target= va_arg(ap,struct block_list**);
+
+ if (*target) return 0;
+
+ if(bl->subtype == WARP)
+ {
+ *target = bl;
+ return 1;
+ }
+ return 0;
+}
/*==========================================
* Processing of slave monsters
*------------------------------------------
@@ -1077,7 +1094,13 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
tbl->type == BL_PC && !(mode&MD_BOSS) &&
((TBL_PC*)tbl)->state.gangsterparadise
)) { //Unlock current target.
- if (battle_config.mob_ai&8) //Inmediately stop chasing.
+ if (tbl && tbl->m != md->bl.m && battle_config.mob_ai&64)
+ { //Chase to a nearby warp [Skotlex]
+ tbl = NULL;
+ map_foreachinrange (mob_ai_sub_hard_warpsearch, &md->bl,
+ view_range, BL_NPC, md, &tbl);
+ if (tbl) unit_walktobl(&md->bl, tbl, 0, 1);
+ } else if (battle_config.mob_ai&8) //Inmediately stop chasing.
mob_stop_walking(md,1);
mob_unlocktarget(md, tick-(battle_config.mob_ai&8?3000:0)); //Imediately do random walk.
tbl = NULL;
diff --git a/src/map/npc.c b/src/map/npc.c
index 6d950399d..e9e472721 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -971,6 +971,35 @@ 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 i,m=bl->m;
+ int xs,ys;
+
+ for(i=0;i<map[m].npc_num;i++) {
+ if (map[m].npc[i]->sc.option&OPTION_INVISIBLE)
+ continue;
+
+ if (map[m].npc[i]->bl.subtype!=WARP)
+ continue;
+
+ xs=map[m].npc[i]->u.warp.xs;
+ ys=map[m].npc[i]->u.warp.ys;
+
+ if (bl->x >= map[m].npc[i]->bl.x-xs/2 && bl->x < map[m].npc[i]->bl.x-xs/2+xs &&
+ bl->y >= map[m].npc[i]->bl.y-ys/2 && bl->y < map[m].npc[i]->bl.y-ys/2+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;
+ unit_warp(bl, xs, map[m].npc[i]->u.warp.x,map[m].npc[i]->u.warp.y,0);
+ return 1;
+}
+
/*==========================================
* 近くかどうかの判定
*------------------------------------------
diff --git a/src/map/npc.h b/src/map/npc.h
index 9710f6476..9640665ba 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -40,6 +40,7 @@ int npc_event(struct map_session_data *sd,const unsigned char *npcname,int);
int npc_timer_event(const unsigned char *eventname); // Added by RoVeRT
int npc_command(struct map_session_data *sd,const unsigned char *npcname,char *command);
int npc_touch_areanpc(struct map_session_data *,int,int,int);
+int npc_touch_areanpc2(struct block_list *bl); // [Skotlex]
int npc_click(struct map_session_data *,int);
int npc_scriptcont(struct map_session_data *,int);
int npc_checknear(struct map_session_data *,int);
diff --git a/src/map/unit.c b/src/map/unit.c
index a87dfa16b..527a4be44 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -192,6 +192,9 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
sc_start(&sd->bl,SC_MIRACLE,100,1,battle_config.sg_miracle_skill_duration);
}
} else if (md) {
+ if(battle_config.mob_npc_warp && map_getcell(bl->m,x,y,CELL_CHKNPC) &&
+ npc_touch_areanpc2(bl)) // Enable mobs to step on warps. [Skotlex]
+ return 0;
if (md->min_chase > md->db->range2) md->min_chase--;
//Walk skills are triggered regardless of target due to the idle-walk mob state.
if(!(ud->walk_count%WALK_SKILL_INTERVAL) &&