Configurations for monster aggro distance reset.
This commit is contained in:
		| @@ -28,11 +28,6 @@ AltAttackableNpcs = True | ||||
| # Default: False | ||||
| AltGameViewNpc = False | ||||
|  | ||||
| # Maximum distance mobs can randomly go from spawn point. | ||||
| # DEFAULT NEEDS TO BE VERIFIED, MUST BE CHANGED HERE AND IN CONFIG.JAVA IF NOT CORRECT | ||||
| # Default: 300 | ||||
| MaxDriftRange = 300 | ||||
|  | ||||
| # Default: False | ||||
| ShowNpcLevel = False | ||||
|  | ||||
| @@ -90,6 +85,31 @@ SpoiledCorpseExtendTime = 10 | ||||
| # Default: 2000 | ||||
| CorpseConsumeSkillAllowedTimeBeforeDecay = 2000 | ||||
|  | ||||
| # Maximum distance monsters can randomly move from spawn. | ||||
| # Default: 300 | ||||
| MaxDriftRange = 300 | ||||
|  | ||||
| # Enable monster aggro distance check. | ||||
| # When enabled monsters will lose aggro if pulled far away from spawn. | ||||
| # Default: False | ||||
| AggroDistanceCheckEnabled = False | ||||
|  | ||||
| # Maximum distance monsters can be pulled away from spawn. | ||||
| # Default: 1500 | ||||
| AggroDistanceCheckRange = 1500 | ||||
|  | ||||
| # Use maximum aggro distance check for raids. | ||||
| # Default: False | ||||
| AggroDistanceCheckRaids = False | ||||
|  | ||||
| # Use maximum aggro distance check in instances. | ||||
| # Default: False | ||||
| AggroDistanceCheckInstances = False | ||||
|  | ||||
| # Restore monster HP and MP when aggro is reset by distance. | ||||
| # Default: True | ||||
| AggroDistanceCheckRestoreLife = True | ||||
|  | ||||
|  | ||||
| # --------------------------------------------------------------------------- | ||||
| # Guards | ||||
|   | ||||
| @@ -619,7 +619,6 @@ public class Config | ||||
| 	public static boolean ALT_MOB_AGRO_IN_PEACEZONE; | ||||
| 	public static boolean ALT_ATTACKABLE_NPCS; | ||||
| 	public static boolean ALT_GAME_VIEWNPC; | ||||
| 	public static int MAX_DRIFT_RANGE; | ||||
| 	public static boolean SHOW_NPC_LVL; | ||||
| 	public static boolean SHOW_NPC_AGGRESSION; | ||||
| 	public static boolean SHOW_CREST_WITHOUT_QUEST; | ||||
| @@ -633,6 +632,12 @@ public class Config | ||||
| 	public static int DEFAULT_CORPSE_TIME; | ||||
| 	public static int SPOILED_CORPSE_EXTEND_TIME; | ||||
| 	public static int CORPSE_CONSUME_SKILL_ALLOWED_TIME_BEFORE_DECAY; | ||||
| 	public static int MAX_DRIFT_RANGE; | ||||
| 	public static boolean AGGRO_DISTANCE_CHECK_ENABLED; | ||||
| 	public static int AGGRO_DISTANCE_CHECK_RANGE; | ||||
| 	public static boolean AGGRO_DISTANCE_CHECK_RAIDS; | ||||
| 	public static boolean AGGRO_DISTANCE_CHECK_INSTANCES; | ||||
| 	public static boolean AGGRO_DISTANCE_CHECK_RESTORE_LIFE; | ||||
| 	public static boolean GUARD_ATTACK_AGGRO_MOB; | ||||
| 	public static double RAID_HP_REGEN_MULTIPLIER; | ||||
| 	public static double RAID_MP_REGEN_MULTIPLIER; | ||||
| @@ -2049,7 +2054,6 @@ public class Config | ||||
| 			ALT_MOB_AGRO_IN_PEACEZONE = NPC.getBoolean("AltMobAgroInPeaceZone", true); | ||||
| 			ALT_ATTACKABLE_NPCS = NPC.getBoolean("AltAttackableNpcs", true); | ||||
| 			ALT_GAME_VIEWNPC = NPC.getBoolean("AltGameViewNpc", false); | ||||
| 			MAX_DRIFT_RANGE = NPC.getInt("MaxDriftRange", 300); | ||||
| 			SHOW_NPC_LVL = NPC.getBoolean("ShowNpcLevel", false); | ||||
| 			SHOW_NPC_AGGRESSION = NPC.getBoolean("ShowNpcAggression", false); | ||||
| 			SHOW_CREST_WITHOUT_QUEST = NPC.getBoolean("ShowCrestWithoutQuest", false); | ||||
| @@ -2063,6 +2067,12 @@ public class Config | ||||
| 			DEFAULT_CORPSE_TIME = NPC.getInt("DefaultCorpseTime", 7); | ||||
| 			SPOILED_CORPSE_EXTEND_TIME = NPC.getInt("SpoiledCorpseExtendTime", 10); | ||||
| 			CORPSE_CONSUME_SKILL_ALLOWED_TIME_BEFORE_DECAY = NPC.getInt("CorpseConsumeSkillAllowedTimeBeforeDecay", 2000); | ||||
| 			MAX_DRIFT_RANGE = NPC.getInt("MaxDriftRange", 300); | ||||
| 			AGGRO_DISTANCE_CHECK_ENABLED = NPC.getBoolean("AggroDistanceCheckEnabled", true); | ||||
| 			AGGRO_DISTANCE_CHECK_RANGE = NPC.getInt("AggroDistanceCheckRange", 1500); | ||||
| 			AGGRO_DISTANCE_CHECK_RAIDS = NPC.getBoolean("AggroDistanceCheckRaids", false); | ||||
| 			AGGRO_DISTANCE_CHECK_INSTANCES = NPC.getBoolean("AggroDistanceCheckInstances", false); | ||||
| 			AGGRO_DISTANCE_CHECK_RESTORE_LIFE = NPC.getBoolean("AggroDistanceCheckRestoreLife", true); | ||||
| 			GUARD_ATTACK_AGGRO_MOB = NPC.getBoolean("GuardAttackAggroMob", false); | ||||
| 			RAID_HP_REGEN_MULTIPLIER = NPC.getDouble("RaidHpRegenMultiplier", 100) / 100; | ||||
| 			RAID_MP_REGEN_MULTIPLIER = NPC.getDouble("RaidMpRegenMultiplier", 100) / 100; | ||||
|   | ||||
| @@ -36,6 +36,7 @@ import org.l2jmobius.gameserver.geoengine.GeoEngine; | ||||
| import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; | ||||
| import org.l2jmobius.gameserver.model.AggroInfo; | ||||
| import org.l2jmobius.gameserver.model.Location; | ||||
| import org.l2jmobius.gameserver.model.Spawn; | ||||
| import org.l2jmobius.gameserver.model.World; | ||||
| import org.l2jmobius.gameserver.model.WorldObject; | ||||
| import org.l2jmobius.gameserver.model.actor.Attackable; | ||||
| @@ -629,12 +630,63 @@ public class AttackableAI extends CreatureAI | ||||
| 	protected void thinkAttack() | ||||
| 	{ | ||||
| 		final Attackable npc = getActiveChar(); | ||||
| 		 | ||||
| 		if ((npc == null) || npc.isCastingNow()) | ||||
| 		{ | ||||
| 			return; | ||||
| 		} | ||||
| 		 | ||||
| 		if (Config.AGGRO_DISTANCE_CHECK_ENABLED && npc.isMonster() && !npc.isWalker()) | ||||
| 		{ | ||||
| 			final Spawn spawn = npc.getSpawn(); | ||||
| 			if ((spawn != null) && (npc.calculateDistance3D(spawn.getLocation()) > Config.AGGRO_DISTANCE_CHECK_RANGE)) | ||||
| 			{ | ||||
| 				if ((Config.AGGRO_DISTANCE_CHECK_RAIDS || !npc.isRaid()) && (Config.AGGRO_DISTANCE_CHECK_INSTANCES || !npc.isInInstance())) | ||||
| 				{ | ||||
| 					if (Config.AGGRO_DISTANCE_CHECK_RESTORE_LIFE) | ||||
| 					{ | ||||
| 						npc.setCurrentHp(npc.getMaxHp()); | ||||
| 						npc.setCurrentMp(npc.getMaxMp()); | ||||
| 					} | ||||
| 					npc.abortAttack(); | ||||
| 					npc.clearAggroList(); | ||||
| 					npc.getAttackByList().clear(); | ||||
| 					if (npc.hasAI()) | ||||
| 					{ | ||||
| 						npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, spawn.getLocation()); | ||||
| 					} | ||||
| 					else | ||||
| 					{ | ||||
| 						npc.teleToLocation(spawn.getLocation(), true); | ||||
| 					} | ||||
| 					 | ||||
| 					// Minions should return as well. | ||||
| 					if (((MonsterInstance) _actor).hasMinions()) | ||||
| 					{ | ||||
| 						for (MonsterInstance minion : ((MonsterInstance) _actor).getMinionList().getSpawnedMinions()) | ||||
| 						{ | ||||
| 							if (Config.AGGRO_DISTANCE_CHECK_RESTORE_LIFE) | ||||
| 							{ | ||||
| 								minion.setCurrentHp(minion.getMaxHp()); | ||||
| 								minion.setCurrentMp(minion.getMaxMp()); | ||||
| 							} | ||||
| 							minion.abortAttack(); | ||||
| 							minion.clearAggroList(); | ||||
| 							minion.getAttackByList().clear(); | ||||
| 							if (minion.hasAI()) | ||||
| 							{ | ||||
| 								minion.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, spawn.getLocation()); | ||||
| 							} | ||||
| 							else | ||||
| 							{ | ||||
| 								minion.teleToLocation(spawn.getLocation(), true); | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 					return; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		Creature target = npc.getMostHated(); | ||||
| 		if (getTarget() != target) | ||||
| 		{ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 MobiusDevelopment
					MobiusDevelopment