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

@@ -605,21 +605,15 @@ final class AteliaStatus extends AbstractNpcAI
final int chance = getRandom(1000);
if (Util.contains(ATELIA_CURSE, npc.getId()))
{
if (!npc.isCastingNow())
if (!npc.isCastingNow() && (chance <= 20))
{
if (chance <= 20)
{
npc.setTarget(attacker);
npc.doCast(ATELIA_POISON[getRandom(ATELIA_POISON.length)].getSkill());
}
npc.setTarget(attacker);
npc.doCast(ATELIA_POISON[getRandom(ATELIA_POISON.length)].getSkill());
}
}
else if (Util.contains(FLOOR_MOBS, npc.getId()))
else if (Util.contains(FLOOR_MOBS, npc.getId()) && (chance > 90))
{
if (chance > 90)
{
broadcastNpcSay(npc, ChatType.NPC_GENERAL, ATELIA_MSG[getRandom(1)], attacker.getName());
}
broadcastNpcSay(npc, ChatType.NPC_GENERAL, ATELIA_MSG[getRandom(1)], attacker.getName());
}
return super.onAttack(npc, attacker, damage, isSummon);
}

View File

@@ -75,11 +75,7 @@ final class HandysBlockCheckerEvent extends Quest
player.sendPacket(tl);
final int countBlue = holder.getBlueTeamSize();
final int countRed = holder.getRedTeamSize();
final int minMembers = Config.MIN_BLOCK_CHECKER_TEAM_MEMBERS;
if ((countBlue >= minMembers) && (countRed >= minMembers))
if ((holder.getBlueTeamSize() >= Config.MIN_BLOCK_CHECKER_TEAM_MEMBERS) && (holder.getRedTeamSize() >= Config.MIN_BLOCK_CHECKER_TEAM_MEMBERS))
{
holder.updateEvent();
holder.broadCastPacketToTeam(new ExCubeGameRequestReady());

View File

@@ -308,8 +308,7 @@ final class MC_Show extends AbstractNpcAI
diff = hourDiff + minDiff;
if (Config.DEBUG)
{
final SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
_log.info("Fantasy Isle: MC show script starting at " + format.format(System.currentTimeMillis() + diff) + " and is scheduled each next 4 hours.");
_log.info("Fantasy Isle: MC show script starting at " + (new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")).format(System.currentTimeMillis() + diff) + " and is scheduled each next 4 hours.");
}
// TODO startRepeatingQuestTimer("Start", diff, 14400000, null, null);
// missing option to provide different initial delay

View File

@@ -137,8 +137,7 @@ final class Parade extends AbstractNpcAI
// final long diff = timeLeftMilli(8, 0, 0), cycle = 600000L;
// ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Start(), 180000L, cycle);
final SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm");
_log.info("Fantasy Isle: Parade starting at " + format.format(System.currentTimeMillis() + diff) + " and is scheduled each next " + (cycle / 3600000) + " hours.");
_log.info("Fantasy Isle: Parade starting at " + new SimpleDateFormat("yyyy/MM/dd HH:mm").format(System.currentTimeMillis() + diff) + " and is scheduled each next " + (cycle / 3600000) + " hours.");
}
void load()
@@ -214,27 +213,28 @@ final class Parade extends AbstractNpcAI
@Override
public void run()
{
if (spawns.size() > 0)
if (spawns.size() <= 0)
{
for (L2Npc actor : spawns)
return;
}
for (L2Npc actor : spawns)
{
if (actor != null)
{
if (actor != null)
if (actor.calculateDistance(actor.getXdestination(), actor.getYdestination(), 0, false, true) < (100 * 100))
{
if (actor.calculateDistance(actor.getXdestination(), actor.getYdestination(), 0, false, true) < (100 * 100))
{
actor.deleteMe();
spawns.remove(actor);
}
else if (!actor.isMoving())
{
actor.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(actor.getXdestination(), actor.getYdestination(), actor.getZdestination(), actor.getHeading()));
}
actor.deleteMe();
spawns.remove(actor);
}
else if (!actor.isMoving())
{
actor.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(actor.getXdestination(), actor.getYdestination(), actor.getZdestination(), actor.getHeading()));
}
}
if (spawns.size() == 0)
{
deleteTask.cancel(false);
}
}
if (spawns.size() == 0)
{
deleteTask.cancel(false);
}
}
}

View File

@@ -224,8 +224,7 @@ final class ArcanRitual extends Quest
player.sendPacket(trigger);
if (message)
{
final L2GameServerPacket sm = new ExShowScreenMessage(NpcStringId.DARK_POWER_SEEPS_OUT_FROM_THE_MIDDLE_OF_THE_TOWN, ExShowScreenMessage.TOP_CENTER, 5000);
player.sendPacket(sm);
player.sendPacket(new ExShowScreenMessage(NpcStringId.DARK_POWER_SEEPS_OUT_FROM_THE_MIDDLE_OF_THE_TOWN, ExShowScreenMessage.TOP_CENTER, 5000));
}
}
}

View File

@@ -230,12 +230,9 @@ final class BeastFarm extends AbstractNpcAI
public void spawnNext(L2Npc npc, L2PcInstance player, int nextNpcId, int food)
{
// remove the feedinfo of the mob that got despawned, if any
if (FEED_INFO.containsKey(npc.getObjectId()))
if (FEED_INFO.containsKey(npc.getObjectId()) && (FEED_INFO.get(npc.getObjectId()) == player.getObjectId()))
{
if (FEED_INFO.get(npc.getObjectId()) == player.getObjectId())
{
FEED_INFO.remove(npc.getObjectId());
}
FEED_INFO.remove(npc.getObjectId());
}
// despawn the old mob
// TODO: same code? FIXED?
@@ -322,12 +319,7 @@ final class BeastFarm extends AbstractNpcAI
// first gather some values on local variables
final int objectId = npc.getObjectId();
int growthLevel = 3; // if a mob is in FEEDABLE_BEASTS but not in _GrowthCapableMobs, then it's at max growth (3)
if (GROWTH_CAPABLE_MONSTERS.containsKey(npcId))
{
growthLevel = GROWTH_CAPABLE_MONSTERS.get(npcId).getGrowthLevel();
}
final int growthLevel = GROWTH_CAPABLE_MONSTERS.containsKey(npcId) ? GROWTH_CAPABLE_MONSTERS.get(npcId).getGrowthLevel() : 3; // if a mob is in FEEDABLE_BEASTS but not in _GrowthCapableMobs, then it's at max growth (3)
// prevent exploit which allows 2 players to simultaneously raise the same 0-growth beast
// If the mob is at 0th level (when it still listens to all feeders) lock it to the first feeder!
if ((growthLevel == 0) && FEED_INFO.containsKey(objectId))
@@ -364,7 +356,7 @@ final class BeastFarm extends AbstractNpcAI
}
return super.onSkillSee(npc, caster, skill, targets, isSummon);
}
else if ((growthLevel > 0) && (FEED_INFO.get(objectId) != caster.getObjectId()))
if ((growthLevel > 0) && (FEED_INFO.get(objectId) != caster.getObjectId()))
{
// check if this is the same player as the one who raised it from growth 0.
// if no, then do not allow a chance to raise the pet (food gets consumed but has no effect).

View File

@@ -23,7 +23,6 @@ import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.zone.type.L2EffectZone;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
@@ -109,9 +108,7 @@ final class DenOfEvil extends AbstractNpcAI
private int getSkillIdByNpcId(int npcId)
{
int diff = npcId - EYE_IDS[0];
diff *= 2;
return SKILL_ID + diff;
return SKILL_ID + ((npcId - EYE_IDS[0]) * 2);
}
@Override
@@ -211,22 +208,13 @@ final class DenOfEvil extends AbstractNpcAI
}
if (character.isPlayable())
{
final Skill skill = SkillData.getInstance().getSkill(6149, 1);
skill.applyEffects(character, character);
SkillData.getInstance().getSkill(6149, 1).applyEffects(character, character);
}
else
{
if (character.doDie(null)) // mobs die
if (character.doDie(null) && character.isNpc() && Util.contains(EYE_IDS, ((L2Npc) character).getId())) // mobs die
{
if (character.isNpc())
{
// respawn eye
final L2Npc npc = (L2Npc) character;
if (Util.contains(EYE_IDS, npc.getId()))
{
ThreadPoolManager.getInstance().scheduleAi(new RespawnNewEye(npc.getLocation()), 15000);
}
}
ThreadPoolManager.getInstance().scheduleAi(new RespawnNewEye(((L2Npc) character).getLocation()), 15000);
}
}
}

View File

@@ -151,19 +151,13 @@ final class FeedableBeasts extends AbstractNpcAI
public Integer getMob(int spice, int mobType, int classType)
{
if (_spiceToMob.containsKey(spice))
{
return _spiceToMob.get(spice)[mobType][classType];
}
return null;
return _spiceToMob.containsKey(spice) ? _spiceToMob.get(spice)[mobType][classType] : null;
}
public Integer getRandomMob(int spice)
{
int[][] temp;
temp = _spiceToMob.get(spice);
final int rand = getRandom(temp[0].length);
return temp[0][rand];
final int[][] temp = _spiceToMob.get(spice);
return temp[0][getRandom(temp[0].length)];
}
public Integer getChance()
@@ -482,24 +476,20 @@ final class FeedableBeasts extends AbstractNpcAI
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if (event.equalsIgnoreCase("polymorph Mad Cow") && (npc != null) && (player != null))
if (event.equalsIgnoreCase("polymorph Mad Cow") && (npc != null) && (player != null) && MAD_COW_POLYMORPH.containsKey(npc.getId()))
{
if (MAD_COW_POLYMORPH.containsKey(npc.getId()))
// remove the feed info from the previous mob
if (FEED_INFO.get(npc.getObjectId()) == player.getObjectId())
{
// remove the feed info from the previous mob
if (FEED_INFO.get(npc.getObjectId()) == player.getObjectId())
{
FEED_INFO.remove(npc.getObjectId());
}
// despawn the mad cow
npc.deleteMe();
// spawn the new mob
final L2Attackable nextNpc = (L2Attackable) addSpawn(MAD_COW_POLYMORPH.get(npc.getId()), npc);
// register the player in the feedinfo for the mob that just spawned
FEED_INFO.put(nextNpc.getObjectId(), player.getObjectId());
addAttackDesire(nextNpc, player);
FEED_INFO.remove(npc.getObjectId());
}
// despawn the mad cow
npc.deleteMe();
// spawn the new mob
final L2Attackable nextNpc = (L2Attackable) addSpawn(MAD_COW_POLYMORPH.get(npc.getId()), npc);
// register the player in the feedinfo for the mob that just spawned
FEED_INFO.put(nextNpc.getObjectId(), player.getObjectId());
addAttackDesire(nextNpc, player);
}
return super.onAdvEvent(event, npc, player);
}
@@ -524,12 +514,7 @@ final class FeedableBeasts extends AbstractNpcAI
// first gather some values on local variables
final int objectId = npc.getObjectId();
int growthLevel = 3; // if a mob is in FEEDABLE_BEASTS but not in _GrowthCapableMobs, then it's at max growth (3)
if (GROWTH_CAPABLE_MONSTERS.containsKey(npcId))
{
growthLevel = GROWTH_CAPABLE_MONSTERS.get(npcId).getGrowthLevel();
}
final int growthLevel = GROWTH_CAPABLE_MONSTERS.containsKey(npcId) ? GROWTH_CAPABLE_MONSTERS.get(npcId).getGrowthLevel() : 3; // if a mob is in FEEDABLE_BEASTS but not in _GrowthCapableMobs, then it's at max growth (3)
// prevent exploit which allows 2 players to simultaneously raise the same 0-growth beast
// If the mob is at 0th level (when it still listens to all feeders) lock it to the first feeder!
if ((growthLevel == 0) && FEED_INFO.containsKey(objectId))

View File

@@ -432,20 +432,13 @@ final class MinionSpawnManager extends AbstractNpcAI
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
{
if (npc.isMonster())
if (npc.isMonster() && !((L2MonsterInstance) npc).isTeleporting() && (getRandom(1, 100) <= npc.getTemplate().getParameters().getInt("SummonPrivateRate", 0)))
{
final L2MonsterInstance monster = (L2MonsterInstance) npc;
if (!monster.isTeleporting())
for (MinionHolder is : npc.getTemplate().getParameters().getMinionList("Privates"))
{
if (getRandom(1, 100) <= npc.getTemplate().getParameters().getInt("SummonPrivateRate", 0))
{
for (MinionHolder is : npc.getTemplate().getParameters().getMinionList("Privates"))
{
addMinion((L2MonsterInstance) npc, is.getId());
}
broadcastNpcSay(npc, ChatType.NPC_GENERAL, ON_ATTACK_MSG[getRandom(ON_ATTACK_MSG.length)]);
}
addMinion((L2MonsterInstance) npc, is.getId());
}
broadcastNpcSay(npc, ChatType.NPC_GENERAL, ON_ATTACK_MSG[getRandom(ON_ATTACK_MSG.length)]);
}
return super.onAttack(npc, attacker, damage, isSummon);
}

View File

@@ -89,20 +89,17 @@ final class PolymorphingOnAttack extends AbstractNpcAI
if (npc.isVisible() && !npc.isDead())
{
final List<Integer> tmp = MOBSPAWNS.get(npc.getId());
if (tmp != null)
if ((tmp != null) && (npc.getCurrentHp() <= ((npc.getMaxHp() * tmp.get(1)) / 100.0)) && (getRandom(100) < tmp.get(2)))
{
if ((npc.getCurrentHp() <= ((npc.getMaxHp() * tmp.get(1)) / 100.0)) && (getRandom(100) < tmp.get(2)))
if (tmp.get(3) >= 0)
{
if (tmp.get(3) >= 0)
{
final NpcStringId npcString = MOBTEXTS[tmp.get(3)][getRandom(MOBTEXTS[tmp.get(3)].length)];
npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), npcString));
}
npc.deleteMe();
final L2Attackable newNpc = (L2Attackable) addSpawn(tmp.get(0), npc.getX(), npc.getY(), npc.getZ() + 10, npc.getHeading(), false, 0, true);
final L2Character originalAttacker = isSummon ? attacker.getServitors().values().stream().findFirst().orElse(attacker.getPet()) : attacker;
addAttackDesire(newNpc, originalAttacker);
final NpcStringId npcString = MOBTEXTS[tmp.get(3)][getRandom(MOBTEXTS[tmp.get(3)].length)];
npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), npcString));
}
npc.deleteMe();
final L2Attackable newNpc = (L2Attackable) addSpawn(tmp.get(0), npc.getX(), npc.getY(), npc.getZ() + 10, npc.getHeading(), false, 0, true);
final L2Character originalAttacker = isSummon ? attacker.getServitors().values().stream().findFirst().orElse(attacker.getPet()) : attacker;
addAttackDesire(newNpc, originalAttacker);
}
}
return super.onAttack(npc, attacker, damage, isSummon);

View File

@@ -322,8 +322,7 @@ final class PrimevalIsle extends AbstractNpcAI
{
if ((characters != null) && (characters.isAttackable()) && (getRandomBoolean()))
{
final L2Attackable monster = (L2Attackable) characters;
addAttackDesire(monster, playable);
addAttackDesire(((L2Attackable) characters), playable);
}
}
}
@@ -424,21 +423,15 @@ final class PrimevalIsle extends AbstractNpcAI
if (target != null)
{
if (getRandom(100) <= (probPhysicalSpecial1 * npc.getVariables().getInt("SKILL_MULTIPLER")))
if ((getRandom(100) <= (probPhysicalSpecial1 * npc.getVariables().getInt("SKILL_MULTIPLER"))) && !npc.isSkillDisabled(physicalSpecial1.getSkill()))
{
if (!npc.isSkillDisabled(physicalSpecial1.getSkill()))
{
npc.setTarget(target);
npc.doCast(physicalSpecial1.getSkill());
}
npc.setTarget(target);
npc.doCast(physicalSpecial1.getSkill());
}
if (getRandom(100) <= (probPhysicalSpecial2 * npc.getVariables().getInt("SKILL_MULTIPLER")))
if ((getRandom(100) <= (probPhysicalSpecial2 * npc.getVariables().getInt("SKILL_MULTIPLER"))) && !npc.isSkillDisabled(physicalSpecial2.getSkill()))
{
if (!npc.isSkillDisabled(physicalSpecial2.getSkill()))
{
npc.setTarget(target);
npc.doCast(physicalSpecial2.getSkill());
}
npc.setTarget(target);
npc.doCast(physicalSpecial2.getSkill());
}
}
}

View File

@@ -78,14 +78,11 @@ final class PrisonGuards extends AbstractNpcAI
{
if (player.isAffectedBySkill(TIMER))
{
if ((getRandom(100) < 10) && (npc.calculateDistance(player, true, false) < 100))
if ((getRandom(100) < 10) && (npc.calculateDistance(player, true, false) < 100) && (getQuestItemsCount(player, STAMP) <= 3) && npc.isScriptValue(0))
{
if ((getQuestItemsCount(player, STAMP) <= 3) && npc.isScriptValue(0))
{
giveItems(player, STAMP, 1);
npc.setScriptValue(1);
startQuestTimer("CLEAR_STATUS", 600000, npc, null);
}
giveItems(player, STAMP, 1);
npc.setScriptValue(1);
startQuestTimer("CLEAR_STATUS", 600000, npc, null);
}
}
else

View File

@@ -58,28 +58,9 @@ final class Remnants extends AbstractNpcAI
@Override
public final String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
{
if (skill.getId() == SKILL_HOLY_WATER)
if ((skill.getId() == SKILL_HOLY_WATER) && !npc.isDead() && (targets.length > 0) && (targets[0] == npc) && (npc.getCurrentHp() < (npc.getMaxHp() * 0.02)))
{
if (!npc.isDead())
{
if ((targets.length > 0) && (targets[0] == npc))
{
if (npc.getCurrentHp() < (npc.getMaxHp() * 0.02)) // Lower, than 2%
{
npc.doDie(caster);
//@formatter:off
/*if (npc.getNpcId() == DEREK)
{
caster.sendMessage(MSG_DEREK);
}
else
{
caster.sendMessage(MSG);
}*/
//@formatter:on
}
}
}
npc.doDie(caster);
}
return super.onSkillSee(npc, caster, skill, targets, isSummon);
}

View File

@@ -170,8 +170,7 @@ final class StakatoNest extends AbstractNpcAI
{
if (killer.isInParty())
{
final List<L2PcInstance> party = killer.getParty().getMembers();
for (L2PcInstance member : party)
for (L2PcInstance member : killer.getParty().getMembers())
{
giveCocoon(member, npc);
}

View File

@@ -65,16 +65,9 @@ final class SummonPc extends AbstractNpcAI
doSummonPc(npc, attacker);
}
}
else if (distance > MIN_DISTANCE_MOST_HATED)
else if ((distance > MIN_DISTANCE_MOST_HATED) && (((L2Attackable) npc).getMostHated() != null) && (((((L2Attackable) npc).getMostHated() == attacker) && (chance < 50)) || (chance < 10)))
{
final L2Attackable monster = (L2Attackable) npc;
if (monster.getMostHated() != null)
{
if (((monster.getMostHated() == attacker) && (chance < 50)) || (chance < 10))
{
doSummonPc(npc, attacker);
}
}
doSummonPc(npc, attacker);
}
return super.onAttack(npc, attacker, damage, isSummon);
}

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;
}

View File

@@ -76,22 +76,19 @@ final class Alarm extends AbstractNpcAI
}
case "RECORDER_CRUSHED":
{
if (npc0 != null)
if ((npc0 != null) && npc0.getVariables().getBoolean("SPAWNED"))
{
if (npc0.getVariables().getBoolean("SPAWNED"))
npc0.getVariables().set("SPAWNED", false);
if (player0 != null)
{
npc0.getVariables().set("SPAWNED", false);
if (player0 != null)
broadcastNpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.RECORDER_CRUSHED);
if (verifyMemoState(player0, ART_OF_PERSUASION_ID, -1))
{
broadcastNpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.RECORDER_CRUSHED);
if (verifyMemoState(player0, ART_OF_PERSUASION_ID, -1))
{
setMemoState(player0, ART_OF_PERSUASION_ID, 5);
}
else if (verifyMemoState(player0, NIKOLAS_COOPERATION_ID, -1))
{
setMemoState(player0, NIKOLAS_COOPERATION_ID, 5);
}
setMemoState(player0, ART_OF_PERSUASION_ID, 5);
}
else if (verifyMemoState(player0, NIKOLAS_COOPERATION_ID, -1))
{
setMemoState(player0, NIKOLAS_COOPERATION_ID, 5);
}
}
}
@@ -166,8 +163,7 @@ final class Alarm extends AbstractNpcAI
{
if (verifyMemoState(player, ART_OF_PERSUASION_ID, 3))
{
final int i0 = getMemoStateEx(player, ART_OF_PERSUASION_ID, 1);
if (i0 >= 3)
if (getMemoStateEx(player, ART_OF_PERSUASION_ID, 1) >= 3)
{
if ((npc0 != null) && npc0.getVariables().getBoolean("SPAWNED"))
{
@@ -185,14 +181,12 @@ final class Alarm extends AbstractNpcAI
}
else if (verifyMemoState(player, NIKOLAS_COOPERATION_ID, 3))
{
final int i0 = getMemoStateEx(player, NIKOLAS_COOPERATION_ID, 1);
if (i0 >= 3)
if (getMemoStateEx(player, NIKOLAS_COOPERATION_ID, 1) >= 3)
{
if ((npc0 != null) && npc0.getVariables().getBoolean("SPAWNED"))
{
npc0.getVariables().set("SPAWNED", false);
}
npc.deleteMe();
setMemoState(player, NIKOLAS_COOPERATION_ID, 4);
htmltext = "32367-185_09.html";
@@ -215,8 +209,7 @@ final class Alarm extends AbstractNpcAI
String htmltext = getNoQuestMsg(talker);
if (verifyMemoState(talker, ART_OF_PERSUASION_ID, 3) || verifyMemoState(talker, NIKOLAS_COOPERATION_ID, 3))
{
final L2PcInstance player = npc.getVariables().getObject("player0", L2PcInstance.class);
if (player == talker)
if (npc.getVariables().getObject("player0", L2PcInstance.class) == talker)
{
htmltext = "32367-01.html";
}

View File

@@ -68,13 +68,10 @@ final class BlackJudge extends AbstractNpcAI
{
if (player.getShilensBreathDebuffLevel() > 0)
{
final int cost = COSTS[level];
if (player.getAdena() >= cost)
if (player.getAdena() >= COSTS[level])
{
takeItems(player, Inventory.ADENA_ID, cost);
takeItems(player, Inventory.ADENA_ID, COSTS[level]);
final int nextLv = player.getShilensBreathDebuffLevel() - 1;
if (nextLv > 0)
{
final Skill skill = SkillData.getInstance().getSkill(CommonSkill.SHILENS_BREATH.getId(), nextLv);

View File

@@ -377,8 +377,7 @@ final class CastleChamberlain extends AbstractNpcAI
final List<Integer> fortList = FORTRESS.get(castleId);
for (int i = 0; i < numFort; i++)
{
final Fort fortress = FortManager.getInstance().getFortById(fortList.get(i));
if (fortress.getFortState() == 2)
if (FortManager.getInstance().getFortById(fortList.get(i)).getFortState() == 2)
{
return true;
}
@@ -989,12 +988,9 @@ final class CastleChamberlain extends AbstractNpcAI
{
final int locId = Integer.parseInt(st.nextToken());
final L2TeleportLocation list = TeleportLocationTable.getInstance().getTemplate(locId);
if (list != null)
if ((list != null) && takeItems(player, list.getItemId(), list.getPrice()))
{
if (takeItems(player, list.getItemId(), list.getPrice()))
{
player.teleToLocation(list.getLocX(), list.getLocY(), list.getLocZ());
}
player.teleToLocation(list.getLocX(), list.getLocY(), list.getLocZ());
}
}
else
@@ -1118,10 +1114,9 @@ final class CastleChamberlain extends AbstractNpcAI
htmltext = "chamberlain-08.html";
break;
}
else if (npc.isMyLord(player))
if (npc.isMyLord(player))
{
final int cloakId = npc.getCastle().getSide() == CastleSide.DARK ? LORD_CLOAK_OF_DARK : LORD_CLOAK_OF_LIGHT;
if (hasQuestItems(player, cloakId))
{
htmltext = "chamberlain-03.html";

View File

@@ -69,7 +69,7 @@ final class CastleTeleporter extends AbstractNpcAI
}
return event;
}
else if (event.equalsIgnoreCase("teleport"))
if (event.equalsIgnoreCase("teleport"))
{
final int region = MapRegionManager.getInstance().getMapRegionLocId(npc.getX(), npc.getY());
final NpcSay msg = new NpcSay(npc, ChatType.NPC_SHOUT, NpcStringId.THE_DEFENDERS_OF_S1_CASTLE_WILL_BE_TELEPORTED_TO_THE_INNER_CASTLE);

View File

@@ -63,8 +63,7 @@ final class FortressArcherCaptain extends AbstractNpcAI
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
final int fortOwner = npc.getFort().getOwnerClan() == null ? 0 : npc.getFort().getOwnerClan().getId();
return ((player.getClan() != null) && (player.getClanId() == fortOwner)) ? "FortressArcherCaptain.html" : "FortressArcherCaptain-01.html";
return ((player.getClan() != null) && (player.getClanId() == (npc.getFort().getOwnerClan() == null ? 0 : npc.getFort().getOwnerClan().getId()))) ? "FortressArcherCaptain.html" : "FortressArcherCaptain-01.html";
}
public static void main(String[] args)

View File

@@ -124,9 +124,7 @@ public final class MentorGuide extends AbstractNpcAI implements IXmlReader
{
if ("mentee".equalsIgnoreCase(d.getNodeName()))
{
final int level = parseInteger(d.getAttributes(), "level");
final int coins = parseInteger(d.getAttributes(), "coins");
MENTEE_COINS.put(level, coins);
MENTEE_COINS.put(parseInteger(d.getAttributes(), "level"), parseInteger(d.getAttributes(), "coins"));
}
}
}
@@ -164,8 +162,7 @@ public final class MentorGuide extends AbstractNpcAI implements IXmlReader
final String[] params = event.split(" ");
if (Util.isDigit(params[1]))
{
final int objectId = Integer.valueOf(params[1]);
MentorManager.getInstance().getMentees(objectId).stream().filter(Objects::nonNull).filter(L2Mentee::isOnline).forEach(mentee ->
MentorManager.getInstance().getMentees(Integer.valueOf(params[1])).stream().filter(Objects::nonNull).filter(L2Mentee::isOnline).forEach(mentee ->
{
MentorManager.getInstance().cancelMentoringBuffs(mentee.getPlayerInstance());
mentee.sendPacket(new ExMentorList(mentee.getPlayerInstance()));
@@ -216,9 +213,9 @@ public final class MentorGuide extends AbstractNpcAI implements IXmlReader
{
final L2PcInstance player = event.getMentee();
final L2Mentee mentor = MentorManager.getInstance().getMentor(player.getObjectId());
if (event.isMenteeOnline())
{
final L2Mentee mentor = MentorManager.getInstance().getMentor(player.getObjectId());
if ((mentor != null) && mentor.isOnline())
{
//@formatter:off
@@ -246,25 +243,19 @@ public final class MentorGuide extends AbstractNpcAI implements IXmlReader
// Add the mentee skill
handleMenteeSkills(player);
mentor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_MENTEE_S1_HAS_CONNECTED).addCharName(player));
mentor.sendPacket(new ExMentorList(mentor.getPlayerInstance()));
}
player.sendPacket(new ExMentorList(player));
}
else
else if ((mentor != null) && mentor.isOnline())
{
final L2Mentee mentor = MentorManager.getInstance().getMentor(player.getObjectId());
if ((mentor != null) && mentor.isOnline())
if (MentorManager.getInstance().isAllMenteesOffline(mentor.getObjectId(), player.getObjectId()))
{
if (MentorManager.getInstance().isAllMenteesOffline(mentor.getObjectId(), player.getObjectId()))
{
MentorManager.getInstance().cancelMentoringBuffs(mentor.getPlayerInstance());
}
mentor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_MENTEE_S1_HAS_DISCONNECTED).addCharName(player));
mentor.sendPacket(new ExMentorList(mentor.getPlayerInstance()));
MentorManager.getInstance().cancelMentoringBuffs(mentor.getPlayerInstance());
}
mentor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_MENTEE_S1_HAS_DISCONNECTED).addCharName(player));
mentor.sendPacket(new ExMentorList(mentor.getPlayerInstance()));
}
}
@@ -461,32 +452,29 @@ public final class MentorGuide extends AbstractNpcAI implements IXmlReader
{
MentorManager.getInstance().cancelMentoringBuffs(player);
final L2Mentee mentor = MentorManager.getInstance().getMentor(player.getObjectId());
if (mentor != null)
if (mentor == null)
{
MentorManager.getInstance().setPenalty(mentor.getObjectId(), Config.MENTOR_PENALTY_FOR_MENTEE_COMPLETE);
MentorManager.getInstance().deleteMentor(mentor.getObjectId(), player.getObjectId());
if (mentor.isOnline())
{
mentor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_AWAKENED_AND_THE_MENTOR_MENTEE_RELATIONSHIP_HAS_ENDED_THE_MENTOR_CANNOT_OBTAIN_ANOTHER_MENTEE_FOR_ONE_DAY_AFTER_THE_MENTEE_S_GRADUATION).addPcName(player));
if (MentorManager.getInstance().isAllMenteesOffline(mentor.getObjectId(), player.getObjectId()))
{
MentorManager.getInstance().cancelMentoringBuffs(mentor.getPlayerInstance());
}
mentor.sendPacket(new ExMentorList(mentor.getPlayerInstance()));
}
// Remove the mentee skills
player.removeSkill(MENTEE_MENTOR_SUMMON.getSkill(), true);
// Clear mentee status
player.sendPacket(new ExMentorList(player));
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_MENTOR_MENTEE_RELATIONSHIP_WITH_YOUR_MENTOR_S1_HAS_ENDED_AS_YOU_ARE_AN_AWAKENED_CHARACTER_OF_LV_85_OR_ABOVE_YOU_CAN_NO_LONGER_BE_PAIRED_WITH_A_MENTOR).addPcName(player));
sendMail(player, MENTEE_GRADUATE_TITLE, MENTEE_GRADUATE_BODY, MENTEE_CERT, 1);
return;
}
MentorManager.getInstance().setPenalty(mentor.getObjectId(), Config.MENTOR_PENALTY_FOR_MENTEE_COMPLETE);
MentorManager.getInstance().deleteMentor(mentor.getObjectId(), player.getObjectId());
if (mentor.isOnline())
{
mentor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_AWAKENED_AND_THE_MENTOR_MENTEE_RELATIONSHIP_HAS_ENDED_THE_MENTOR_CANNOT_OBTAIN_ANOTHER_MENTEE_FOR_ONE_DAY_AFTER_THE_MENTEE_S_GRADUATION).addPcName(player));
if (MentorManager.getInstance().isAllMenteesOffline(mentor.getObjectId(), player.getObjectId()))
{
MentorManager.getInstance().cancelMentoringBuffs(mentor.getPlayerInstance());
}
mentor.sendPacket(new ExMentorList(mentor.getPlayerInstance()));
}
// Remove the mentee skills
player.removeSkill(MENTEE_MENTOR_SUMMON.getSkill(), true);
// Clear mentee status
player.sendPacket(new ExMentorList(player));
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_MENTOR_MENTEE_RELATIONSHIP_WITH_YOUR_MENTOR_S1_HAS_ENDED_AS_YOU_ARE_AN_AWAKENED_CHARACTER_OF_LV_85_OR_ABOVE_YOU_CAN_NO_LONGER_BE_PAIRED_WITH_A_MENTOR).addPcName(player));
sendMail(player, MENTEE_GRADUATE_TITLE, MENTEE_GRADUATE_BODY, MENTEE_CERT, 1);
}
/**

View File

@@ -81,7 +81,7 @@ final class Minigame extends AbstractNpcAI
{
return "32758-05.html";
}
else if ((npc.getTarget() != null) && (npc.getTarget() != player))
if ((npc.getTarget() != null) && (npc.getTarget() != player))
{
return "32758-04.html";
}
@@ -261,8 +261,7 @@ final class Minigame extends AbstractNpcAI
public void onSkillUse(OnCreatureSkillUse event)
{
final MinigameRoom room = getRoomByParticipant((L2PcInstance) event.getCaster());
final boolean miniGameStarted = room.getStarted();
if (miniGameStarted && (event.getSkill().getId() == SKILL_TORCH_LIGHT))
if (room.getStarted() && (event.getSkill().getId() == SKILL_TORCH_LIGHT))
{
for (L2Object obj : event.getTargets())
{

View File

@@ -423,9 +423,7 @@ public final class Raina extends AbstractNpcAI
{
final L2PcInstance player = event.getTalker();
final L2Npc npc = event.getNpc();
final int ask = event.getAsk();
switch (ask)
switch (event.getAsk())
{
case 0: // Add subclass confirm menu
{
@@ -658,9 +656,7 @@ public final class Raina extends AbstractNpcAI
for (SubClass subList : player.getSubClasses().values())
{
final ClassId subId = ClassId.getClassId(subList.getClassId());
if (subId.equalsOrChildOf(cid))
if (ClassId.getClassId(subList.getClassId()).equalsOrChildOf(cid))
{
availSubs.remove(cid);
break;
@@ -674,7 +670,7 @@ public final class Raina extends AbstractNpcAI
private boolean haveDoneQuest(L2PcInstance player)
{
final QuestState qs = player.getQuestState("Q10385_RedThreadOfFate"); // TODO: Replace with class name
return qs == null ? false : qs.isCompleted();
return (qs != null) && qs.isCompleted();
}
/**

View File

@@ -272,8 +272,7 @@ final class SupportUnitCaptain extends AbstractNpcAI
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
final int fortOwner = npc.getFort().getOwnerClan() == null ? 0 : npc.getFort().getOwnerClan().getId();
return ((player.getClan() != null) && (player.getClanId() == fortOwner)) ? "unitcaptain.html" : "unitcaptain-04.html";
return ((player.getClan() != null) && (player.getClanId() == (npc.getFort().getOwnerClan() == null ? 0 : npc.getFort().getOwnerClan().getId()))) ? "unitcaptain.html" : "unitcaptain-04.html";
}
public static void main(String[] args)

View File

@@ -55,8 +55,7 @@ final class MithrilMinesTeleporter extends AbstractNpcAI
final int index = Integer.parseInt(event) - 1;
if (LOCS.length > index)
{
final Location loc = LOCS[index];
player.teleToLocation(loc, false);
player.teleToLocation(LOCS[index], false);
}
return super.onAdvEvent(event, npc, player);
}

View File

@@ -73,8 +73,7 @@ public final class YeSagiraTeleporter extends AbstractNpcAI
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
public void OnPlayerCreate(OnPlayerCreate event)
{
final L2PcInstance player = event.getActiveChar();
player.getVariables().set(MOVIE_VAR, true);
event.getActiveChar().getVariables().set(MOVIE_VAR, true);
}
public static void main(String[] args)

View File

@@ -30,7 +30,6 @@ import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogin;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerSubChange;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.variables.PlayerVariables;
import com.l2jmobius.gameserver.network.clientpackets.RequestAcquireSkill;
@@ -418,18 +417,18 @@ public final class Trandon extends AbstractNpcAI
{
final PlayerVariables vars = player.getVariables();
final String list = vars.getString(type, "");
if (!list.isEmpty())
if (list.isEmpty())
{
final String[] skills = list.split(";");
for (String skill : skills)
{
final String[] str = skill.split("-");
final Skill sk = SkillData.getInstance().getSkill(Integer.parseInt(str[0]), Integer.parseInt(str[1]));
player.removeSkill(sk);
}
vars.remove(type);
player.sendSkillList();
return;
}
final String[] skills = list.split(";");
for (String skill : skills)
{
final String[] str = skill.split("-");
player.removeSkill(SkillData.getInstance().getSkill(Integer.parseInt(str[0]), Integer.parseInt(str[1])));
}
vars.remove(type);
player.sendSkillList();
}
private final void giveSkills(L2PcInstance player, String type)
@@ -437,12 +436,10 @@ public final class Trandon extends AbstractNpcAI
final String list = player.getVariables().getString(type, "");
if (!list.isEmpty())
{
final String[] skills = list.split(";");
for (String skill : skills)
for (String skill : list.split(";"))
{
final String[] str = skill.split("-");
final Skill sk = SkillData.getInstance().getSkill(Integer.parseInt(str[0]), Integer.parseInt(str[1]));
player.addSkill(sk, false);
player.addSkill(SkillData.getInstance().getSkill(Integer.parseInt(str[0]), Integer.parseInt(str[1])), false);
}
}
}

View File

@@ -69,11 +69,7 @@ final class Zenya extends AbstractNpcAI
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
if (player.getLevel() < MIN_LEVEL)
{
return "32140-3.html";
}
return "32140.html";
return player.getLevel() < MIN_LEVEL ? "32140-3.html" : "32140.html";
}
public static void main(String[] args)