瀏覽代碼

- 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://svn.code.sf.net/p/rathena/svn/trunk@7039 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 19 年之前
父節點
當前提交
b6a5dc4547
共有 8 個文件被更改,包括 70 次插入1 次删除
  1. 4 0
      Changelog-Trunk.txt
  2. 6 0
      conf-tmpl/battle/monster.conf
  3. 2 0
      src/map/battle.c
  4. 1 0
      src/map/battle.h
  5. 24 1
      src/map/mob.c
  6. 29 0
      src/map/npc.c
  7. 1 0
      src/map/npc.h
  8. 3 0
      src/map/unit.c

+ 4 - 0
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

+ 6 - 0
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
 

+ 2 - 0
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;

+ 1 - 0
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;

+ 24 - 1
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;

+ 29 - 0
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;
+}
+
 /*==========================================
  * ‹ß‚­‚©‚Ç‚¤‚©‚Ì”»’è
  *------------------------------------------

+ 1 - 0
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);

+ 3 - 0
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) &&