Browse Source

- Some cleaning of the mob slave ai.
- Moved MOB_SLAVEDISTANCE to mob.h
- NPC_CALLSLAVES now uses the slave-distance previously mentioned.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@6940 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 19 năm trước cách đây
mục cha
commit
00082797ae
4 tập tin đã thay đổi với 14 bổ sung16 xóa
  1. 1 0
      Changelog-Trunk.txt
  2. 9 15
      src/map/mob.c
  3. 3 0
      src/map/mob.h
  4. 1 1
      src/map/skill.c

+ 1 - 0
Changelog-Trunk.txt

@@ -4,6 +4,7 @@ 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/02
+	* Some cleaning of the mob slave ai. [Skotlex]
 	* Corrected Brandish Spear to work on levels above 10. [Skotlex]
 	* Updated Two-HandQuicken, One-HandQuicken to give 30 +2*lv% aspd-rate for
 	  skill levels above 10 (meant for boss casted skills) [Skotlex]

+ 9 - 15
src/map/mob.c

@@ -41,8 +41,6 @@
 #define MOB_LAZYMOVEPERC 50	// Move probability in the negligent mode MOB (rate of 1000 minute)
 #define MOB_LAZYWARPPERC 20	// Warp probability in the negligent mode MOB (rate of 1000 minute)
 
-#define MOB_SLAVEDISTANCE 2	//Distance that slaves should keep from their master.
-
 #define MAX_MINCHASE 30	//Max minimum chase value to use for mobs.
 //Dynamic mob database, allows saving of memory when there's big gaps in the mob_db [Skotlex]
 struct mob_db *mob_db_data[MAX_MOB_DB+1];
@@ -879,7 +877,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
 
 	bl=map_id2bl(md->master_id);
 
-	if (!bl || status_isdead(bl)) {	//主が死亡しているか見つからない
+	if (!bl || status_isdead(bl)) {
 		status_kill(&md->bl);
 		return 0;
 	}
@@ -887,27 +885,22 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
 	if(status_get_mode(&md->bl)&MD_CANMOVE)
 	{	//If the mob can move, follow around. [Check by Skotlex]
 		
-		if(bl->m != md->bl.m || md->master_dist > 30)
-		{	// Since it is not in the same map (or is way to far), just warp it
-			unit_warp(&md->bl,bl->m,bl->x,bl->y,3);
-			md->master_dist = 0;
-			return 0;
-		}
-
 		// Distance with between slave and master is measured.
 		old_dist=md->master_dist;
 		md->master_dist=distance_bl(&md->bl, bl);
 
 		// Since the master was in near immediately before, teleport is carried out and it pursues.
-		if(old_dist<10 && md->master_dist>18){
-			unit_warp(&md->bl,-1,bl->x,bl->y,3);
+		if(bl->m != md->bl.m || 
+			(old_dist<10 && md->master_dist>18) ||
+			md->master_dist > MAX_MINCHASE
+		){
 			md->master_dist = 0;
+			unit_warp(&md->bl,bl->m,bl->x,bl->y,3);
 			return 0;
 		}
 
 		// Approach master if within view range, chase back to Master's area also if standing on top of the master.
-		if(md->master_dist<AREA_SIZE &&
-			(md->master_dist>MOB_SLAVEDISTANCE || md->master_dist == 0) &&
+		if((md->master_dist>MOB_SLAVEDISTANCE || md->master_dist == 0) &&
 			unit_can_move(&md->bl))
 		{
 			short x = bl->x, y = bl->y;
@@ -922,7 +915,8 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
 	}
 	
 	//Avoid attempting to lock the master's target too often to avoid unnecessary overload. [Skotlex]
-	if (DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id) {
+	if (DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id)
+  	{
 		struct unit_data *ud = unit_bl2ud(bl);
 		md->last_linktime = tick;
 		

+ 3 - 0
src/map/mob.h

@@ -18,6 +18,9 @@
 //Min time before mobs do a check to call nearby friends for help (or for slaves to support their master)
 #define MIN_MOBLINKTIME 1000
 
+//Distance that slaves should keep from their master.
+#define MOB_SLAVEDISTANCE 2
+
 // These define the range of available IDs for clones. [Valaris]
 #define MOB_CLONE_START 9001
 #define MOB_CLONE_END 10000

+ 1 - 1
src/map/skill.c

@@ -4828,7 +4828,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
 		break;
 
 	case NPC_CALLSLAVE:
-		mob_warpslave(src,2);
+		mob_warpslave(src,MOB_SLAVEDISTANCE);
 		break;
 
 	case NPC_RANDOMMOVE: