فهرست منبع

Additional configs for mobs idle AI (#4503)

* Added conf options to enable/disable monsters using idle skills and move when there's no players nearby.

Thanks to @aleos89
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Daegaladh 5 سال پیش
والد
کامیت
e27aa8b2d8
4فایلهای تغییر یافته به همراه22 افزوده شده و 8 حذف شده
  1. 11 0
      conf/battle/monster.conf
  2. 2 0
      src/map/battle.cpp
  3. 2 0
      src/map/battle.hpp
  4. 7 8
      src/map/mob.cpp

+ 11 - 0
conf/battle/monster.conf

@@ -263,3 +263,14 @@ monster_hp_bars_info: yes
 // This can be legit gameplay (e.g. players keeping an MVP stuck inside icewall), but if you want to prevent any
 // This can be legit gameplay (e.g. players keeping an MVP stuck inside icewall), but if you want to prevent any
 // exploits and be notified about them, you can set this to yes.
 // exploits and be notified about them, you can set this to yes.
 monster_stuck_warning: no
 monster_stuck_warning: no
+
+// Rate at which monsters use their idle skills when there are no players nearby (Note 2)
+// On official servers monsters use their idle skills if they have been spotted once, even if there are no players nearby anymore.
+// On small-medium sized servers this can cause all monsters like eggs and Fabre/Pupa to metamorph.
+// To switch it off, set it to 0.
+mob_nopc_idleskill_rate: 100
+
+// Rate at which monsters move when there are no players nearby (Note 2)
+// On official servers monsters always move if they have been spotted once, even if there are no players nearby anymore.
+// To switch it off, set it to 0.
+mob_nopc_move_rate: 100

+ 2 - 0
src/map/battle.cpp

@@ -8557,6 +8557,8 @@ static const struct _battle_data {
 	{ "feature.equipswitch",                &battle_config.feature_equipswitch,             1,      0,      1,              },
 	{ "feature.equipswitch",                &battle_config.feature_equipswitch,             1,      0,      1,              },
 	{ "pet_walk_speed",                     &battle_config.pet_walk_speed,                  1,      1,      3,              },
 	{ "pet_walk_speed",                     &battle_config.pet_walk_speed,                  1,      1,      3,              },
 	{ "blacksmith_fame_refine_threshold",   &battle_config.blacksmith_fame_refine_threshold,10,     1,      MAX_REFINE,     },
 	{ "blacksmith_fame_refine_threshold",   &battle_config.blacksmith_fame_refine_threshold,10,     1,      MAX_REFINE,     },
+	{ "mob_nopc_idleskill_rate",            &battle_config.mob_nopc_idleskill_rate,       100,      0,    100,              },
+	{ "mob_nopc_move_rate",                 &battle_config.mob_nopc_move_rate,            100,      0,    100,              },
 
 
 #include "../custom/battle_config_init.inc"
 #include "../custom/battle_config_init.inc"
 };
 };

+ 2 - 0
src/map/battle.hpp

@@ -659,6 +659,8 @@ struct Battle_Config
 	int feature_equipswitch;
 	int feature_equipswitch;
 	int pet_walk_speed;
 	int pet_walk_speed;
 	int blacksmith_fame_refine_threshold;
 	int blacksmith_fame_refine_threshold;
+	int mob_nopc_idleskill_rate;
+	int mob_nopc_move_rate;
 
 
 #include "../custom/battle_config_struct.inc"
 #include "../custom/battle_config_struct.inc"
 };
 };

+ 7 - 8
src/map/mob.cpp

@@ -46,12 +46,6 @@ using namespace rathena;
 
 
 #define IDLE_SKILL_INTERVAL 10	//Active idle skills should be triggered every 1 second (1000/MIN_MOBTHINKTIME)
 #define IDLE_SKILL_INTERVAL 10	//Active idle skills should be triggered every 1 second (1000/MIN_MOBTHINKTIME)
 
 
-// Probability for mobs far from players from doing their IDLE skill. (rate of 1000 minute)
-// in Aegis, this is 100% for mobs that have been activated by players and none otherwise.
-#define MOB_LAZYSKILLPERC(md) (mob_is_spotted(md)?1000:0)
-// Move probability for mobs away from players (rate of 1000 minute)
-// in Aegis, this is 100% for mobs that have been activated by players and none otherwise.
-#define MOB_LAZYMOVEPERC(md) (mob_is_spotted(md)?1000:0)
 const t_tick MOB_MAX_DELAY = 24 * 3600 * 1000;
 const t_tick MOB_MAX_DELAY = 24 * 3600 * 1000;
 #define MAX_MINCHASE 30	//Max minimum chase value to use for mobs.
 #define MAX_MINCHASE 30	//Max minimum chase value to use for mobs.
 #define RUDE_ATTACKED_COUNT 1	//After how many rude-attacks should the skill be used?
 #define RUDE_ATTACKED_COUNT 1	//After how many rude-attacks should the skill be used?
@@ -2052,14 +2046,19 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
 
 
 	if( DIFF_TICK(md->next_walktime,tick) < 0 && status_has_mode(&md->status,MD_CANMOVE) && unit_can_move(&md->bl) )
 	if( DIFF_TICK(md->next_walktime,tick) < 0 && status_has_mode(&md->status,MD_CANMOVE) && unit_can_move(&md->bl) )
 	{
 	{
-		if( rnd()%1000 < MOB_LAZYMOVEPERC(md) )
+		// Move probability for mobs away from players
+		// In Aegis, this is 100% for mobs that have been activated by players and none otherwise.
+		if( mob_is_spotted(md) && rnd()%100 < battle_config.mob_nopc_move_rate )
 			mob_randomwalk(md, tick);
 			mob_randomwalk(md, tick);
 	}
 	}
 	else if( md->ud.walktimer == INVALID_TIMER )
 	else if( md->ud.walktimer == INVALID_TIMER )
 	{
 	{
 		//Because it is not unset when the mob finishes walking.
 		//Because it is not unset when the mob finishes walking.
 		md->state.skillstate = MSS_IDLE;
 		md->state.skillstate = MSS_IDLE;
-		if( rnd()%1000 < MOB_LAZYSKILLPERC(md) ) //Chance to do a mob's idle skill.
+
+		// Probability for mobs far from players from doing their IDLE skill.
+		// In Aegis, this is 100% for mobs that have been activated by players and none otherwise.
+		if( mob_is_spotted(md) && rnd()%100 < battle_config.mob_nopc_idleskill_rate )
 			mobskill_use(md, tick, -1);
 			mobskill_use(md, tick, -1);
 	}
 	}