summaryrefslogtreecommitdiff
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
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
-rw-r--r--Changelog-Trunk.txt4
-rw-r--r--conf-tmpl/battle/monster.conf6
-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
8 files changed, 70 insertions, 1 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index eef6e65c8..58a45fc11 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,10 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/06/07
+ * Added config setting mob_npc_warp, when set to yes, enables mobs to be
+ warped between maps when stepping on a npc-warp. [Skotlex]
+ * Added monster_ai setting &64, when enabled makes a mob run to any nearby
+ npc-warp when their current target has switched maps. [Skotlex]
* Added pc_calcexp to calculate individual exp bonuses acquired from exp's
source (race bonus cards, SG Exp skills, pk-mode higher level exp) [Skotlex]
* pc_gain_exp now also receives the source of the exp, when said source
diff --git a/conf-tmpl/battle/monster.conf b/conf-tmpl/battle/monster.conf
index bb336074b..59cd67b0d 100644
--- a/conf-tmpl/battle/monster.conf
+++ b/conf-tmpl/battle/monster.conf
@@ -62,8 +62,14 @@ monster_max_aspd: 199
//16: If set, mob skills defined for friends will also trigger on themselves.
//32: When set, the monster ai is executed for all monsters in maps that have
// players on them, instead of only for mobs who are in the vecinity of players.
+//64: When set, when the mob's target changes map, the mob will walk towards
+// any npc-warps in it's sight of view (use with mob_npc_warp below)
monster_ai: 0
+// Should mobs that stand on an npc warp be warped to the destination cell?
+// (Note 1)
+mob_npc_warp: no
+
// Mobs and Pets view-range adjustment (range2 column in the mob_db) (Note 2)
view_range_rate: 100
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) &&