Ver código fonte

- Some clean-ups in the mob_ai

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@6478 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 anos atrás
pai
commit
352ba1bd12
4 arquivos alterados com 11 adições e 13 exclusões
  1. 1 0
      Changelog-Trunk.txt
  2. 8 6
      src/map/mob.c
  3. 2 6
      src/map/skill.c
  4. 0 1
      src/map/unit.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/05/04
+	* Some clean-ups in the mob_ai [Skotlex]
 	* Improved atcommand autoloot, now displays droprate in percents and notices
 	  player if autoloot is already on or off. Also simplified the code [Harbin, Kain],
 	  commited by erKURITA

+ 8 - 6
src/map/mob.c

@@ -792,7 +792,7 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
 	switch (bl->type)
 	{
 	case BL_PC:
-		if (((struct map_session_data*)bl)->state.gangsterparadise &&
+		if (((TBL_PC*)bl)->state.gangsterparadise &&
 			!(status_get_mode(&md->bl)&MD_BOSS))
 			return 0; //Gangster paradise protection.
 	case BL_MOB:
@@ -1038,7 +1038,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
 	int dist;
 	int mode;
 	int search_size;
-	int view_range, can_move, can_walk;
+	int view_range, can_move;
 
 	md = (struct mob_data*)bl;
 	tick = va_arg(ap, unsigned int);
@@ -1068,8 +1068,6 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
 
 	can_move = (mode&MD_CANMOVE)&&unit_can_move(&md->bl);
 	//Since can_move is false when you are casting or the damage-delay kicks in, some special considerations
-	//must be taken to avoid unlocking the target or triggering rude-attacked skills in said cases. [Skotlex]
-	can_walk = DIFF_TICK(tick, md->ud.canmove_tick) > 0;
 
 	if (md->target_id)
 	{	//Check validity of current target. [Skotlex]
@@ -1079,7 +1077,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
 			(md->ud.walktimer != -1 && !check_distance_bl(&md->bl, tbl, md->min_chase)) ||
 			(
 				tbl->type == BL_PC && !(mode&MD_BOSS) &&
-				((struct map_session_data*)tbl)->state.gangsterparadise
+				((TBL_PC*)tbl)->state.gangsterparadise
 		)) {	//Unlock current target.
 			if (battle_config.mob_ai&8) //Inmediately stop chasing.
 				mob_stop_walking(md,1);
@@ -1184,6 +1182,10 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
 					mob_unlocktarget(md,tick);
 					return 0;
 				}
+
+				if (!can_move) //Stuck. Wait before walking.
+					return 0;
+
 				md->state.skillstate = md->state.aggressive?MSS_FOLLOW:MSS_RUSH;
 				if (md->ud.walktimer != -1 && md->ud.target == tbl->id &&
 					(
@@ -1222,7 +1224,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
 					mob_unlocktarget(md,tick);
 					return 0;
 				}
-				if (!can_move)	// 動けない状態にある
+				if (!can_move) //Stuck. Wait before walking.
 					return 0;
 				md->state.skillstate = MSS_LOOT;	// ルート時スキル使用
 				if (!unit_walktobl(&md->bl, tbl, 0, 1))

+ 2 - 6
src/map/skill.c

@@ -4340,12 +4340,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
 				skill_get_time2(skillid, skilllv) * (100-(status_get_int(bl)+status_get_vit(bl))/2)/100,10);
 		}
 		clif_skill_nodamage(src,bl,skillid,skilllv,1);
-		if(dstmd){
-			dstmd->attacked_id=0;
-			dstmd->target_id=0;
-			dstmd->state.skillstate=MSS_IDLE;
-			dstmd->next_walktime=tick+rand()%3000+3000;
-		}
+		if(dstmd)
+			mob_unlocktarget(dstmd,tick);
 		break;
 
 	case WZ_ESTIMATION:			/* ƒ‚ƒ“ƒXƒ^??î•ñ */

+ 0 - 1
src/map/unit.c

@@ -562,7 +562,6 @@ int unit_stop_walking(struct block_list *bl,int type)
 		unit_walktoxy_timer(-1, tick, bl->id, ud->walkpath.path_pos);
 	}
 
-//	if(md) { md->state.skillstate = MSS_IDLE; }
 	if(type&0x01)
 		clif_fixpos(bl);