Bläddra i källkod

Skill menu and looter fixes
- Fixed a bug that stopped characters server-sided and caused position lag when closing a skill menu (bugreport:9117)
- Fixed behavior of looter monsters (#125=fixed)
* They will now always target the oldest item in their view range (which makes it seemingly random), rather than always the most south-western item available
* Their loot range is now "0" meaning they need to be on the same cell as the item to loot it
* Their AI will no longer get stuck in an endless loop when someone drops an item around the corner

Playtester 10 år sedan
förälder
incheckning
e6caa9569b
3 ändrade filer med 10 tillägg och 8 borttagningar
  1. 5 6
      src/map/mob.c
  2. 0 1
      src/map/skill.c
  3. 5 1
      src/map/unit.c

+ 5 - 6
src/map/mob.c

@@ -1180,12 +1180,11 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
 	target = va_arg(ap,struct block_list**);
 
 	dist = distance_bl(&md->bl, bl);
-	if (mob_can_reach(md,bl,dist+1, MSS_LOOT) && (*target) == NULL) {
+	if (mob_can_reach(md,bl,dist+1, MSS_LOOT) && ((*target) == NULL || md->target_id > bl->id)) {
 		(*target) = bl;
 		md->target_id = bl->id;
 		md->min_chase = md->db->range3;
-	} else
-		mob_stop_walking(md, 1); // Stop walking immediately if item is no longer on the ground.
+	}
 	return 0;
 }
 
@@ -1561,7 +1560,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
 	if (!tbl && mode&MD_LOOTER && md->lootitem && DIFF_TICK(tick, md->ud.canact_tick) > 0 &&
 		(md->lootitem_count < LOOTITEM_SIZE || battle_config.monster_loot_type != 1))
 	{	// Scan area for items to loot, avoid trying to loot if the mob is full and can't consume the items.
-		map_foreachinrange (mob_ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl);
+		map_foreachinshootrange (mob_ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl);
 	}
 
 	if ((!tbl && mode&MD_AGGRESSIVE) || md->state.skillstate == MSS_FOLLOW)
@@ -1607,7 +1606,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
 			mob_unlocktarget(md, tick);
 			return true;
 		}
-		if (!check_distance_bl(&md->bl, tbl, 1))
+		if (!check_distance_bl(&md->bl, tbl, 0))
 		{	//Still not within loot range.
 			if (!(mode&MD_CANMOVE))
 			{	//A looter that can't move? Real smart.
@@ -1617,7 +1616,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
 			if (!can_move) //Stuck. Wait before walking.
 				return true;
 			md->state.skillstate = MSS_LOOT;
-			if (!unit_walktobl(&md->bl, tbl, 1, 1))
+			if (!unit_walktobl(&md->bl, tbl, 0, 1))
 				mob_unlocktarget(md, tick); //Can't loot...
 			return true;
 		}

+ 0 - 1
src/map/skill.c

@@ -11664,7 +11664,6 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char
 	}
 
 	pc_stop_attack(sd);
-	pc_stop_walking(sd,0);
 
 	if(battle_config.skill_log && battle_config.skill_log&BL_PC)
 		ShowInfo("PC %d skill castend skill =%d map=%s\n",sd->bl.id,skill_id,mapname);

+ 5 - 1
src/map/unit.c

@@ -722,7 +722,7 @@ static int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data)
  * @param tbl: Target object
  * @param range: How close to get to target (or attack range if flag&2)
  * @param flag: Extra behaviour
- *	&1: Use hard path seek (obstacles will be walked around if possible)
+ *	&1: Use easy path seek (obstacles will not be walked around)
  *	&2: Start attacking upon arrival within range, otherwise just walk to target
  * @return 1: Started walking or set timer 0: Failed
  */
@@ -748,6 +748,10 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, unsi
 		ud->target_to = 0;
 
 		return 0;
+	} else if (range == 0) {
+		//Should walk on the same cell as target (for looters)
+		ud->to_x = tbl->x;
+		ud->to_y = tbl->y;
 	}
 
 	ud->state.walk_easy = flag&1;