|
@@ -1444,8 +1444,17 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,t_tick tick)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if(md->target_id) //Slave is busy with a target.
|
|
|
|
- return 0;
|
|
|
|
|
|
+ // Slave is busy with a target.
|
|
|
|
+ if(md->target_id) {
|
|
|
|
+ // Player's slave should come back when master's too far, even if it is doing with a target.
|
|
|
|
+ if (bl->type == BL_PC && md->master_dist > 5) {
|
|
|
|
+ mob_unlocktarget(md, tick);
|
|
|
|
+ unit_walktobl(&md->bl, bl, MOB_SLAVEDISTANCE, 1);
|
|
|
|
+ return 1;
|
|
|
|
+ } else {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
// Approach master if within view range, chase back to Master's area also if standing on top of the master.
|
|
// Approach master if within view range, chase back to Master's area also if standing on top of the master.
|
|
if ((md->master_dist > MOB_SLAVEDISTANCE || md->master_dist == 0) && unit_can_move(&md->bl)) {
|
|
if ((md->master_dist > MOB_SLAVEDISTANCE || md->master_dist == 0) && unit_can_move(&md->bl)) {
|
|
@@ -3502,6 +3511,33 @@ int mob_countslave(struct block_list *bl)
|
|
return map_foreachinmap(mob_countslave_sub, bl->m, BL_MOB,bl->id);
|
|
return map_foreachinmap(mob_countslave_sub, bl->m, BL_MOB,bl->id);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * Remove slaves if master logs off.
|
|
|
|
+ * @param bl: Mob data
|
|
|
|
+ * @param ap: List of arguments
|
|
|
|
+ * @return 1 on removal, otherwise 0
|
|
|
|
+ */
|
|
|
|
+int mob_removeslaves_sub(block_list *bl, va_list ap) {
|
|
|
|
+ int id = va_arg(ap, int);
|
|
|
|
+ mob_data *md = (mob_data *)bl;
|
|
|
|
+
|
|
|
|
+ if (md != nullptr && md->master_id == id) {
|
|
|
|
+ unit_free(bl, CLR_OUTSIGHT);
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Remove slaves on a map.
|
|
|
|
+ * @param bl: Player data
|
|
|
|
+ * @return 1 on removal, otherwise 0
|
|
|
|
+ */
|
|
|
|
+int mob_removeslaves(block_list *bl) {
|
|
|
|
+ return map_foreachinmap(mob_removeslaves_sub, bl->m, BL_MOB, bl->id);
|
|
|
|
+}
|
|
|
|
+
|
|
/*==========================================
|
|
/*==========================================
|
|
* Summons amount slaves contained in the value[5] array using round-robin. [adapted by Skotlex]
|
|
* Summons amount slaves contained in the value[5] array using round-robin. [adapted by Skotlex]
|
|
*------------------------------------------*/
|
|
*------------------------------------------*/
|