Code improvements.

This commit is contained in:
MobiusDev
2016-04-24 16:30:15 +00:00
parent 8bd51aba1c
commit 2dd14bef9b
860 changed files with 8865 additions and 17041 deletions

View File

@@ -24,7 +24,6 @@ import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
import com.l2jmobius.gameserver.model.quest.QuestTimer;
import ai.npc.AbstractNpcAI;
@@ -62,8 +61,7 @@ final class Anais extends AbstractNpcAI
if (pot < 4)
{
_current = npc;
final QuestTimer checkAround = getQuestTimer("CHECK", anais, null);
if (checkAround == null) // || !checkAround.getIsActive()
if (getQuestTimer("CHECK", anais, null) == null)
{
startQuestTimer("CHECK", 3000, anais, null);
}

View File

@@ -633,13 +633,10 @@ public final class Antharas extends AbstractNpcAI
attacker.teleToLocation(80464, 152294, -3534);
}
if ((attacker.getMountType() == MountType.STRIDER) && !attacker.isAffectedBySkill(ANTH_ANTI_STRIDER.getSkillId()))
if ((attacker.getMountType() == MountType.STRIDER) && !attacker.isAffectedBySkill(ANTH_ANTI_STRIDER.getSkillId()) && npc.checkDoCastConditions(ANTH_ANTI_STRIDER.getSkill()))
{
if (npc.checkDoCastConditions(ANTH_ANTI_STRIDER.getSkill()))
{
npc.setTarget(attacker);
npc.doCast(ANTH_ANTI_STRIDER.getSkill());
}
npc.setTarget(attacker);
npc.doCast(ANTH_ANTI_STRIDER.getSkill());
}
if (skill == null)

View File

@@ -484,13 +484,10 @@ public final class Baium extends AbstractNpcAI
if (npc.getId() == BAIUM)
{
if ((attacker.getMountType() == MountType.STRIDER) && !attacker.isAffectedBySkill(ANTI_STRIDER.getSkillId()))
if ((attacker.getMountType() == MountType.STRIDER) && !attacker.isAffectedBySkill(ANTI_STRIDER.getSkillId()) && !npc.isSkillDisabled(ANTI_STRIDER.getSkill()))
{
if (!npc.isSkillDisabled(ANTI_STRIDER.getSkill()))
{
npc.setTarget(attacker);
npc.doCast(ANTI_STRIDER.getSkill());
}
npc.setTarget(attacker);
npc.doCast(ANTI_STRIDER.getSkill());
}
if (skill == null)

View File

@@ -74,13 +74,10 @@ final class Ballista extends AbstractNpcAI
{
if ((skill != null) && (caster.getTarget() == npc) && (getRandom(100) < 40) && (skill == BOMB.getSkill()))
{
if (npc.getFort().getSiege().isInProgress())
if (npc.getFort().getSiege().isInProgress() && (caster.getClan() != null) && (caster.getClan().getLevel() >= MIN_CLAN_LV))
{
if ((caster.getClan() != null) && (caster.getClan().getLevel() >= MIN_CLAN_LV))
{
caster.getClan().addReputationScore(Config.BALLISTA_POINTS, true);
caster.sendPacket(SystemMessageId.THE_BALLISTA_HAS_BEEN_SUCCESSFULLY_DESTROYED_THE_CLAN_REPUTATION_WILL_BE_INCREASED);
}
caster.getClan().addReputationScore(Config.BALLISTA_POINTS, true);
caster.sendPacket(SystemMessageId.THE_BALLISTA_HAS_BEEN_SUCCESSFULLY_DESTROYED_THE_CLAN_REPUTATION_WILL_BE_INCREASED);
}
npc.doDie(caster);
}

View File

@@ -610,13 +610,10 @@ final class Beleth extends AbstractNpcAI
{
if (!npc.isDead() && !npc.isCastingNow())
{
if (getRandom(100) < 40)
if ((getRandom(100) < 40) && !npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
{
if (!npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
{
npc.doCast(BLEED.getSkill());
return null;
}
npc.doCast(BLEED.getSkill());
return null;
}
npc.setTarget(player);
npc.doCast(FIREBALL.getSkill());
@@ -637,9 +634,7 @@ final class Beleth extends AbstractNpcAI
{
npc.setTarget(player);
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player);
final double speed = npc.isRunning() ? npc.getRunSpeed() : npc.getWalkSpeed();
final int time = (int) (((distance2 - 890) / speed) * 1000);
startQuestTimer("CAST", time, npc, null);
startQuestTimer("CAST", ((int) (((distance2 - 890) / (npc.isRunning() ? npc.getRunSpeed() : npc.getWalkSpeed())) * 1000)), npc, null);
}
else if (distance2 < 890)
{
@@ -648,13 +643,10 @@ final class Beleth extends AbstractNpcAI
}
return null;
}
if (getRandom(100) < 40)
if ((getRandom(100) < 40) && !npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
{
if (!npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
{
npc.doCast(LIGHTENING.getSkill());
return null;
}
npc.doCast(LIGHTENING.getSkill());
return null;
}
for (L2PcInstance plr : npc.getKnownList().getKnownPlayersInRadius(950))
{

View File

@@ -63,20 +63,15 @@ final class Core extends AbstractNpcAI
_firstAttacked = false;
final StatsSet info = GrandBossManager.getInstance().getStatsSet(CORE);
final int status = GrandBossManager.getInstance().getBossStatus(CORE);
if (status == DEAD)
if (GrandBossManager.getInstance().getBossStatus(CORE) == DEAD)
{
// load the unlock date and time for Core from DB
final long temp = (info.getLong("respawn_time") - System.currentTimeMillis());
// if Core is locked until a certain time, mark it so and start the unlock timer
// the unlock time has not yet expired.
if (temp > 0)
{
startQuestTimer("core_unlock", temp, null, null);
}
else
{
// the time has already expired while the server was offline. Immediately spawn Core.
final L2GrandBossInstance core = (L2GrandBossInstance) addSpawn(CORE, 17726, 108915, -6480, 0, false, 0);
GrandBossManager.getInstance().setBossStatus(CORE, ALIVE);
spawnBoss(core);

View File

@@ -206,25 +206,22 @@ final class DarkWaterDragon extends AbstractNpcAI
{
final int npcId = npc.getId();
final int npcObjId = npc.getObjectId();
if (npcId == FAFURION)
if ((npcId == FAFURION) && !MY_TRACKING_SET.contains(npcObjId))
{
if (!MY_TRACKING_SET.contains(npcObjId))
{
MY_TRACKING_SET.add(npcObjId);
// Spawn 4 Detractors on spawn of Fafurion
final int x = npc.getX();
final int y = npc.getY();
addSpawn(DETRACTOR2, x + 100, y + 100, npc.getZ(), 0, false, 40000);
addSpawn(DETRACTOR1, x + 100, y - 100, npc.getZ(), 0, false, 40000);
addSpawn(DETRACTOR2, x - 100, y + 100, npc.getZ(), 0, false, 40000);
addSpawn(DETRACTOR1, x - 100, y - 100, npc.getZ(), 0, false, 40000);
startQuestTimer("first_spawn", 2000, npc, null); // timer to delay timer "1"
startQuestTimer("second_spawn", 4000, npc, null); // timer to delay timer "2"
startQuestTimer("third_spawn", 8000, npc, null); // timer to delay timer "3"
startQuestTimer("fourth_spawn", 10000, npc, null); // timer to delay timer "4"
startQuestTimer("fafurion_poison", 3000, npc, null, true); // Every three seconds reduces Fafurions hp like it is poisoned
startQuestTimer("fafurion_despawn", 120000, npc, null); // Fafurion Kindred disappears after two minutes
}
MY_TRACKING_SET.add(npcObjId);
// Spawn 4 Detractors on spawn of Fafurion
final int x = npc.getX();
final int y = npc.getY();
addSpawn(DETRACTOR2, x + 100, y + 100, npc.getZ(), 0, false, 40000);
addSpawn(DETRACTOR1, x + 100, y - 100, npc.getZ(), 0, false, 40000);
addSpawn(DETRACTOR2, x - 100, y + 100, npc.getZ(), 0, false, 40000);
addSpawn(DETRACTOR1, x - 100, y - 100, npc.getZ(), 0, false, 40000);
startQuestTimer("first_spawn", 2000, npc, null);
startQuestTimer("second_spawn", 4000, npc, null);
startQuestTimer("third_spawn", 8000, npc, null);
startQuestTimer("fourth_spawn", 10000, npc, null);
startQuestTimer("fafurion_poison", 3000, npc, null, true);
startQuestTimer("fafurion_despawn", 120000, npc, null);
}
return super.onSpawn(npc);
}

View File

@@ -64,15 +64,11 @@ final class Devno extends AbstractNpcAI
{
if (event.equalsIgnoreCase("npc_move") && (npc != null))
{
broadcastNpcSay(npc, ChatType.NPC_GENERAL, DEVNO_SHOUT[getRandom(3)], 1000);
if (getRandom(100) > 40)
{
broadcastNpcSay(npc, ChatType.NPC_GENERAL, DEVNO_SHOUT[getRandom(3)], 1000);
addMoveToDesire(npc, DEVNO_LOC[getRandom(10)], 0);
}
else
{
broadcastNpcSay(npc, ChatType.NPC_GENERAL, DEVNO_SHOUT[getRandom(3)], 1000);
}
}
return null;
}

View File

@@ -63,15 +63,11 @@ final class Eleve extends AbstractNpcAI
{
if (event.equalsIgnoreCase("npc_move") && (npc != null))
{
broadcastNpcSay(npc, ChatType.NPC_GENERAL, ELEVE_SHOUT[getRandom(2)], 1000);
if (getRandom(100) > 40)
{
broadcastNpcSay(npc, ChatType.NPC_GENERAL, ELEVE_SHOUT[getRandom(2)], 1000);
addMoveToDesire(npc, ELEVE_LOC[getRandom(10)], 0);
}
else
{
broadcastNpcSay(npc, ChatType.NPC_GENERAL, ELEVE_SHOUT[getRandom(2)], 1000);
}
}
return null;
}

View File

@@ -122,8 +122,7 @@ final class FrightenedRagnaOrc extends AbstractNpcAI
}
else
{
final NpcStringId msg = getRandomBoolean() ? NpcStringId.THANKS_BUT_THAT_THING_ABOUT_10_000_000_ADENA_WAS_A_LIE_SEE_YA : NpcStringId.YOU_RE_PRETTY_DUMB_TO_BELIEVE_ME;
broadcastNpcSay(npc, ChatType.NPC_GENERAL, msg);
broadcastNpcSay(npc, ChatType.NPC_GENERAL, (getRandomBoolean() ? NpcStringId.THANKS_BUT_THAT_THING_ABOUT_10_000_000_ADENA_WAS_A_LIE_SEE_YA : NpcStringId.YOU_RE_PRETTY_DUMB_TO_BELIEVE_ME));
}
startQuestTimer("despawn", 1000, npc, null);
}

View File

@@ -45,9 +45,7 @@ final class Handermonkey extends AbstractNpcAI
{
if (getRandom(100) > 30)
{
final int locX = (npc.getSpawn().getX() - 70) + getRandom(100);
final int locY = (npc.getSpawn().getY() - 70) + getRandom(100);
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(locX, locY, npc.getZ(), 0));
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(((npc.getSpawn().getX() - 70) + getRandom(100)), ((npc.getSpawn().getY() - 70) + getRandom(100)), npc.getZ(), 0));
}
else
{

View File

@@ -89,8 +89,7 @@ final class Orfen extends AbstractNpcAI
_IsTeleported = false;
ZONE = GrandBossManager.getInstance().getZone(POS[0]);
final StatsSet info = GrandBossManager.getInstance().getStatsSet(ORFEN);
final int status = GrandBossManager.getInstance().getBossStatus(ORFEN);
if (status == DEAD)
if (GrandBossManager.getInstance().getBossStatus(ORFEN) == DEAD)
{
// load the unlock date and time for Orfen from DB
final long temp = info.getLong("respawn_time") - System.currentTimeMillis();
@@ -309,13 +308,10 @@ final class Orfen extends AbstractNpcAI
npc.doCast(SkillData.getInstance().getSkill(4064, 1));
}
}
else if (npcId == RIBA_IREN)
else if ((npcId == RIBA_IREN) && !npc.isCastingNow() && ((npc.getCurrentHp() - damage) < (npc.getMaxHp() / 2.0)))
{
if (!npc.isCastingNow() && ((npc.getCurrentHp() - damage) < (npc.getMaxHp() / 2.0)))
{
npc.setTarget(attacker);
npc.doCast(SkillData.getInstance().getSkill(4516, 1));
}
npc.setTarget(attacker);
npc.doCast(SkillData.getInstance().getSkill(4516, 1));
}
return super.onAttack(npc, attacker, damage, isSummon);
}
@@ -328,8 +324,7 @@ final class Orfen extends AbstractNpcAI
npc.broadcastPacket(new PlaySound(1, "BS02_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
GrandBossManager.getInstance().setBossStatus(ORFEN, DEAD);
// Calculate Min and Max respawn times randomly.
long respawnTime = Config.ORFEN_SPAWN_INTERVAL + getRandom(-Config.ORFEN_SPAWN_RANDOM, Config.ORFEN_SPAWN_RANDOM);
respawnTime *= 3600000;
final long respawnTime = (Config.ORFEN_SPAWN_INTERVAL + getRandom(-Config.ORFEN_SPAWN_RANDOM, Config.ORFEN_SPAWN_RANDOM)) * 3600000;
startQuestTimer("orfen_unlock", respawnTime, null, null);
// also save the respawn time so that the info is maintained past reboots
final StatsSet info = GrandBossManager.getInstance().getStatsSet(ORFEN);

View File

@@ -94,8 +94,7 @@ final class QueenAnt extends AbstractNpcAI
_zone = GrandBossManager.getInstance().getZone(QUEEN_X, QUEEN_Y, QUEEN_Z);
final StatsSet info = GrandBossManager.getInstance().getStatsSet(QUEEN);
final int status = GrandBossManager.getInstance().getBossStatus(QUEEN);
if (status == DEAD)
if (GrandBossManager.getInstance().getBossStatus(QUEEN) == DEAD)
{
// load the unlock date and time for queen ant from DB
final long temp = info.getLong("respawn_time") - System.currentTimeMillis();
@@ -121,7 +120,6 @@ final class QueenAnt extends AbstractNpcAI
final int heading = info.getInt("heading");
final int hp = info.getInt("currentHP");
final int mp = info.getInt("currentMP");
final L2GrandBossInstance queen = (L2GrandBossInstance) addSpawn(QUEEN, loc_x, loc_y, loc_z, heading, false, 0);
queen.setCurrentHpMp(hp, mp);
spawnBoss(queen);
@@ -264,13 +262,10 @@ final class QueenAnt extends AbstractNpcAI
return super.onFactionCall(npc, caller, attacker, isSummon);
}
if (!npc.isCastingNow() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_CAST))
if (!npc.isCastingNow() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_CAST) && (caller.getCurrentHp() < caller.getMaxHp()))
{
if (caller.getCurrentHp() < caller.getMaxHp())
{
npc.setTarget(caller);
((L2Attackable) npc).useMagic(HEAL1.getSkill());
}
npc.setTarget(caller);
((L2Attackable) npc).useMagic(HEAL1.getSkill());
}
return null;
}
@@ -341,8 +336,7 @@ final class QueenAnt extends AbstractNpcAI
npc.broadcastPacket(new PlaySound(1, "BS02_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
GrandBossManager.getInstance().setBossStatus(QUEEN, DEAD);
// Calculate Min and Max respawn times randomly.
long respawnTime = Config.QUEEN_ANT_SPAWN_INTERVAL + getRandom(-Config.QUEEN_ANT_SPAWN_RANDOM, Config.QUEEN_ANT_SPAWN_RANDOM);
respawnTime *= 3600000;
final long respawnTime = (Config.QUEEN_ANT_SPAWN_INTERVAL + getRandom(-Config.QUEEN_ANT_SPAWN_RANDOM, Config.QUEEN_ANT_SPAWN_RANDOM)) * 3600000;
startQuestTimer("queen_unlock", respawnTime, null, null);
cancelQuestTimer("action", npc, null);
cancelQuestTimer("heal", null, null);
@@ -364,10 +358,9 @@ final class QueenAnt extends AbstractNpcAI
{
if (npcId == ROYAL)
{
final L2MonsterInstance mob = (L2MonsterInstance) npc;
if (mob.getLeader() != null)
if (((L2MonsterInstance) npc).getLeader() != null)
{
mob.getLeader().getMinionList().onMinionDie(mob, (280 + getRandom(40)) * 1000);
((L2MonsterInstance) npc).getLeader().getMinionList().onMinionDie(((L2MonsterInstance) npc), (280 + getRandom(40)) * 1000);
}
}
else if (npcId == NURSE)

View File

@@ -220,24 +220,21 @@ public final class Valakas extends AbstractNpcAI
else if (event.equalsIgnoreCase("regen_task"))
{
// Inactivity task - 15min
if (GrandBossManager.getInstance().getBossStatus(VALAKAS) == FIGHTING)
if ((GrandBossManager.getInstance().getBossStatus(VALAKAS) == FIGHTING) && ((_timeTracker + 900000) < System.currentTimeMillis()))
{
if ((_timeTracker + 900000) < System.currentTimeMillis())
{
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
npc.teleToLocation(VALAKAS_REGENERATION_LOC);
GrandBossManager.getInstance().setBossStatus(VALAKAS, DORMANT);
npc.setCurrentHpMp(npc.getMaxHp(), npc.getMaxMp());
// Drop all players from the zone.
ZONE.oustAllPlayers();
// Cancel skill_task and regen_task.
cancelQuestTimer("regen_task", npc, null);
cancelQuestTimer("skill_task", npc, null);
return null;
}
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
npc.teleToLocation(VALAKAS_REGENERATION_LOC);
GrandBossManager.getInstance().setBossStatus(VALAKAS, DORMANT);
npc.setCurrentHpMp(npc.getMaxHp(), npc.getMaxMp());
// Drop all players from the zone.
ZONE.oustAllPlayers();
// Cancel skill_task and regen_task.
cancelQuestTimer("regen_task", npc, null);
cancelQuestTimer("skill_task", npc, null);
return null;
}
// Verify if "Valakas Regeneration" skill is active.
@@ -403,14 +400,10 @@ public final class Valakas extends AbstractNpcAI
}
// Debuff strider-mounted players.
if (attacker.getMountType() == MountType.STRIDER)
if ((attacker.getMountType() == MountType.STRIDER) && !attacker.isAffectedBySkill(4258))
{
final Skill skill = SkillData.getInstance().getSkill(4258, 1);
if (!attacker.isAffectedBySkill(4258))
{
npc.setTarget(attacker);
npc.doCast(skill);
}
npc.setTarget(attacker);
npc.doCast(SkillData.getInstance().getSkill(4258, 1));
}
_timeTracker = System.currentTimeMillis();
@@ -439,9 +432,7 @@ public final class Valakas extends AbstractNpcAI
GrandBossManager.getInstance().setBossStatus(VALAKAS, DEAD);
// Calculate Min and Max respawn times randomly.
long respawnTime = Config.VALAKAS_SPAWN_INTERVAL + getRandom(-Config.VALAKAS_SPAWN_RANDOM, Config.VALAKAS_SPAWN_RANDOM);
respawnTime *= 3600000;
final long respawnTime = (Config.VALAKAS_SPAWN_INTERVAL + getRandom(-Config.VALAKAS_SPAWN_RANDOM, Config.VALAKAS_SPAWN_RANDOM)) * 3600000;
startQuestTimer("valakas_unlock", respawnTime, null, null);
// also save the respawn time so that the info is maintained past reboots
final StatsSet info = GrandBossManager.getInstance().getStatsSet(VALAKAS);

View File

@@ -113,8 +113,7 @@ final class Venom extends AbstractNpcAI
final long currentTime = System.currentTimeMillis();
final long startSiegeDate = CastleManager.getInstance().getCastleById(CASTLE).getSiegeDate().getTimeInMillis();
final long openingDungeonDate = startSiegeDate - (HOURS_BEFORE * 360000);
if ((currentTime > openingDungeonDate) && (currentTime < startSiegeDate))
if ((currentTime > (startSiegeDate - (HOURS_BEFORE * 360000))) && (currentTime < startSiegeDate))
{
_prisonIsOpen = true;
}