Configurations for monster aggro distance reset.

This commit is contained in:
MobiusDevelopment
2020-02-13 19:56:19 +00:00
parent 49456557d5
commit e56dad5f81
54 changed files with 1636 additions and 170 deletions

View File

@@ -28,17 +28,6 @@ AltAttackableNpcs = True
# Default: False
AltGameViewNpc = False
# Maximum distance mobs can get aggro.
# Related post at https://l2jserver.com/forum/viewtopic.php?f=128&t=31588
# Default: 1500
# L2jMobius: 450
MaxAggroRange = 450
# 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
@@ -103,6 +92,37 @@ SpoiledCorpseExtendTime = 10
# Default: 2000
CorpseConsumeSkillAllowedTimeBeforeDecay = 2000
# Maximum distance mobs can get aggro.
# Related post at https://l2jserver.com/forum/viewtopic.php?f=128&t=31588
# Default: 1500
# L2jMobius: 450
MaxAggroRange = 450
# 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

View File

@@ -713,8 +713,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_AGGRO_RANGE;
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;
@@ -729,6 +727,13 @@ 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_AGGRO_RANGE;
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 boolean ENABLE_GUARD_RETURN;
public static boolean ALLOW_WYVERN_UPGRADER;
@@ -2244,8 +2249,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_AGGRO_RANGE = NPC.getInt("MaxAggroRange", 450);
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);
@@ -2260,6 +2263,13 @@ 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_AGGRO_RANGE = NPC.getInt("MaxAggroRange", 450);
MAX_DRIFT_RANGE = NPC.getInt("MaxDriftRange", 300);
AGGRO_DISTANCE_CHECK_ENABLED = NPC.getBoolean("AggroDistanceCheckEnabled", false);
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);
ENABLE_GUARD_RETURN = NPC.getBoolean("EnableGuardReturn", false);
ALLOW_WYVERN_UPGRADER = NPC.getBoolean("AllowWyvernUpgrader", false);

View File

@@ -35,6 +35,7 @@ import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.instancemanager.DimensionalRiftManager;
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
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;
@@ -760,11 +761,63 @@ public class AttackableAI extends CreatureAI
protected void thinkAttack()
{
final Attackable npc = getActiveChar();
if (npc.isCastingNow())
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.getInstanceId() == 0)))
{
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;
}
}
}
if (npc.isCoreAIDisabled())
{
return;