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

@@ -735,9 +735,7 @@ public class EnergySeeds extends AbstractNpcAI
// if the AI is inactive, do not spawn the NPC
if (isSeedActive(_seedId))
{
// get a random NPC that should spawn at this location
final Integer spawnId = _spawnId; // the map uses "Integer", not "int"
_spawnedNpcs.put(addSpawn(_npcIds[getRandom(_npcIds.length)], _loc, false, 0), spawnId);
_spawnedNpcs.put(addSpawn(_npcIds[getRandom(_npcIds.length)], _loc, false, 0), _spawnId);
}
}, waitTime);
}

View File

@@ -110,8 +110,7 @@ public class Lindvior extends AbstractNpcAI
private void scheduleNextLindviorVisit()
{
final long delay = (ALT_MODE) ? ALT_MODE_MIN * 60000 : scheduleNextLindviorDate();
startQuestTimer("start", delay, null, null);
startQuestTimer("start", ((ALT_MODE) ? ALT_MODE_MIN * 60000 : scheduleNextLindviorDate()), null, null);
}
private long scheduleNextLindviorDate()

View File

@@ -260,103 +260,100 @@ public final class Maguen extends AbstractNpcAI
@Override
public String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
{
if ((skill == MACHINE.getSkill()) && (caster == npc.getVariables().getObject("SUMMON_PLAYER", L2PcInstance.class)))
if ((skill == MACHINE.getSkill()) && (caster == npc.getVariables().getObject("SUMMON_PLAYER", L2PcInstance.class)) && (npc.getVariables().getInt("NPC_EFFECT") != 0) && (npc.getVariables().getInt("BLOCKED_SKILLSEE") == 0))
{
if ((npc.getVariables().getInt("NPC_EFFECT") != 0) && (npc.getVariables().getInt("BLOCKED_SKILLSEE") == 0))
final BuffInfo i1_info = caster.getEffectList().getBuffInfoByAbnormalType(B_PLASMA1.getSkill().getAbnormalType());
final BuffInfo i2_info = caster.getEffectList().getBuffInfoByAbnormalType(C_PLASMA1.getSkill().getAbnormalType());
final BuffInfo i3_info = caster.getEffectList().getBuffInfoByAbnormalType(R_PLASMA1.getSkill().getAbnormalType());
final int i1 = i1_info == null ? 0 : i1_info.getSkill().getAbnormalLvl();
final int i2 = i2_info == null ? 0 : i2_info.getSkill().getAbnormalLvl();
final int i3 = i3_info == null ? 0 : i3_info.getSkill().getAbnormalLvl();
caster.getEffectList().stopSkillEffects(true, B_PLASMA1.getSkill().getAbnormalType());
caster.getEffectList().stopSkillEffects(true, C_PLASMA1.getSkill().getAbnormalType());
caster.getEffectList().stopSkillEffects(true, R_PLASMA1.getSkill().getAbnormalType());
cancelQuestTimer("FIRST_TIMER", npc, caster);
cancelQuestTimer("SECOND_TIMER", npc, caster);
cancelQuestTimer("THIRD_TIMER", npc, caster);
cancelQuestTimer("FORTH_TIMER", npc, caster);
npc.getVariables().set("BLOCKED_SKILLSEE", 1);
SkillHolder skillToCast = null;
switch (npc.getVariables().getInt("NPC_EFFECT"))
{
final BuffInfo i1_info = caster.getEffectList().getBuffInfoByAbnormalType(B_PLASMA1.getSkill().getAbnormalType());
final BuffInfo i2_info = caster.getEffectList().getBuffInfoByAbnormalType(C_PLASMA1.getSkill().getAbnormalType());
final BuffInfo i3_info = caster.getEffectList().getBuffInfoByAbnormalType(R_PLASMA1.getSkill().getAbnormalType());
final int i1 = i1_info == null ? 0 : i1_info.getSkill().getAbnormalLvl();
final int i2 = i2_info == null ? 0 : i2_info.getSkill().getAbnormalLvl();
final int i3 = i3_info == null ? 0 : i3_info.getSkill().getAbnormalLvl();
caster.getEffectList().stopSkillEffects(true, B_PLASMA1.getSkill().getAbnormalType());
caster.getEffectList().stopSkillEffects(true, C_PLASMA1.getSkill().getAbnormalType());
caster.getEffectList().stopSkillEffects(true, R_PLASMA1.getSkill().getAbnormalType());
cancelQuestTimer("FIRST_TIMER", npc, caster);
cancelQuestTimer("SECOND_TIMER", npc, caster);
cancelQuestTimer("THIRD_TIMER", npc, caster);
cancelQuestTimer("FORTH_TIMER", npc, caster);
npc.getVariables().set("BLOCKED_SKILLSEE", 1);
SkillHolder skillToCast = null;
switch (npc.getVariables().getInt("NPC_EFFECT"))
case 1:
{
case 1:
switch (i1)
{
switch (i1)
case 0:
{
case 0:
{
skillToCast = B_PLASMA1;
break;
}
case 1:
{
skillToCast = B_PLASMA2;
break;
}
case 2:
{
skillToCast = B_PLASMA3;
break;
}
skillToCast = B_PLASMA1;
break;
}
break;
}
case 2:
{
switch (i2)
case 1:
{
case 0:
{
skillToCast = C_PLASMA1;
break;
}
case 1:
{
skillToCast = C_PLASMA2;
break;
}
case 2:
{
skillToCast = C_PLASMA3;
break;
}
skillToCast = B_PLASMA2;
break;
}
break;
}
case 3:
{
switch (i3)
case 2:
{
case 0:
{
skillToCast = R_PLASMA1;
break;
}
case 1:
{
skillToCast = R_PLASMA2;
break;
}
case 2:
{
skillToCast = R_PLASMA3;
break;
}
skillToCast = B_PLASMA3;
break;
}
break;
}
break;
}
if (skillToCast != null)
case 2:
{
npc.setTarget(caster);
npc.doCast(skillToCast.getSkill());
switch (i2)
{
case 0:
{
skillToCast = C_PLASMA1;
break;
}
case 1:
{
skillToCast = C_PLASMA2;
break;
}
case 2:
{
skillToCast = C_PLASMA3;
break;
}
}
break;
}
case 3:
{
switch (i3)
{
case 0:
{
skillToCast = R_PLASMA1;
break;
}
case 1:
{
skillToCast = R_PLASMA2;
break;
}
case 2:
{
skillToCast = R_PLASMA3;
break;
}
}
break;
}
}
if (skillToCast != null)
{
npc.setTarget(caster);
npc.doCast(skillToCast.getSkill());
}
}
return super.onSkillSee(npc, caster, skill, targets, isSummon);

View File

@@ -339,8 +339,7 @@ public class SeedOfAnnihilation extends AbstractNpcAI
{
if (TELEPORT_ZONES.containsKey(zone.getId()))
{
final Location teleLoc = TELEPORT_ZONES.get(zone.getId());
character.teleToLocation(teleLoc, false);
character.teleToLocation(TELEPORT_ZONES.get(zone.getId()), false);
}
return super.onEnterZone(character, zone);
}

View File

@@ -86,7 +86,7 @@ public final class SecretArea extends Quest
enterInstance(player);
return "32566-01.html";
}
else if ((npc.getId() == LELRIKIA) && event.equalsIgnoreCase("exit"))
if ((npc.getId() == LELRIKIA) && event.equalsIgnoreCase("exit"))
{
teleportPlayer(player, TELEPORTS[EXIT], 0);
return "32567-01.html";

View File

@@ -298,43 +298,30 @@ public final class Stage1 extends Quest
attrs = cd.getAttributes();
final SODSpawn spw = new SODSpawn();
spw.npcId = npcId;
att = attrs.getNamedItem("x");
if (att != null)
{
spw.x = Integer.parseInt(att.getNodeValue());
}
else
if (att == null)
{
continue;
}
spw.x = Integer.parseInt(att.getNodeValue());
att = attrs.getNamedItem("y");
if (att != null)
{
spw.y = Integer.parseInt(att.getNodeValue());
}
else
if (att == null)
{
continue;
}
spw.y = Integer.parseInt(att.getNodeValue());
att = attrs.getNamedItem("z");
if (att != null)
{
spw.z = Integer.parseInt(att.getNodeValue());
}
else
if (att == null)
{
continue;
}
spw.z = Integer.parseInt(att.getNodeValue());
att = attrs.getNamedItem("heading");
if (att != null)
{
spw.h = Integer.parseInt(att.getNodeValue());
}
else
if (att == null)
{
continue;
}
spw.h = Integer.parseInt(att.getNodeValue());
att = attrs.getNamedItem("mustKill");
if (att != null)
{
@@ -353,25 +340,18 @@ public final class Stage1 extends Quest
final SODSpawn spw = new SODSpawn();
spw.npcId = npcId;
spw.isZone = true;
att = attrs.getNamedItem("id");
if (att != null)
{
spw.zone = Integer.parseInt(att.getNodeValue());
}
else
if (att == null)
{
continue;
}
spw.zone = Integer.parseInt(att.getNodeValue());
att = attrs.getNamedItem("count");
if (att != null)
{
spw.count = Integer.parseInt(att.getNodeValue());
}
else
if (att == null)
{
continue;
}
spw.count = Integer.parseInt(att.getNodeValue());
att = attrs.getNamedItem("mustKill");
if (att != null)
{
@@ -425,24 +405,17 @@ public final class Stage1 extends Quest
attrs = cd.getAttributes();
int x, y;
att = attrs.getNamedItem("x");
if (att != null)
{
x = Integer.parseInt(att.getNodeValue());
}
else
if (att == null)
{
continue;
}
x = Integer.parseInt(att.getNodeValue());
att = attrs.getNamedItem("y");
if (att != null)
{
y = Integer.parseInt(att.getNodeValue());
}
else
if (att == null)
{
continue;
}
y = Integer.parseInt(att.getNodeValue());
ter.add(x, y, minz, maxz, 0);
}
}
@@ -505,8 +478,7 @@ public final class Stage1 extends Quest
party.broadcastPacket(sm);
return false;
}
final Long reentertime = InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), INSTANCEID);
if (System.currentTimeMillis() < reentertime)
if (System.currentTimeMillis() < InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), INSTANCEID))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_RE_ENTER_YET);
sm.addPcName(partyMember);
@@ -834,24 +806,17 @@ public final class Stage1 extends Quest
if (!isSummon && (player != null))
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
if (tmpworld instanceof SOD1World)
if ((tmpworld instanceof SOD1World) && (((SOD1World) tmpworld).getStatus() == 7) && spawnState(((SOD1World) tmpworld)))
{
final SOD1World world = (SOD1World) tmpworld;
if (world.getStatus() == 7)
for (int objId : ((SOD1World) tmpworld).getAllowed())
{
if (spawnState(world))
final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
if (pl != null)
{
for (int objId : world.getAllowed())
{
final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
if (pl != null)
{
pl.showQuestMovie(5);
}
}
npc.deleteMe();
pl.showQuestMovie(5);
}
}
npc.deleteMe();
}
}
return null;
@@ -874,16 +839,10 @@ public final class Stage1 extends Quest
world.setStatus(4);
spawnFlaggedNPCs(world, 2);
}
else if ((world.getStatus() <= 8) && (npc.getId() == TIAT))
else if ((world.getStatus() <= 8) && (npc.getId() == TIAT) && (npc.getCurrentHp() < (npc.getMaxHp() / 2)) && spawnState(world))
{
if (npc.getCurrentHp() < (npc.getMaxHp() / 2))
{
if (spawnState(world))
{
startQuestTimer("TiatFullHp", 3000, npc, null);
setInstanceTimeRestrictions(world);
}
}
startQuestTimer("TiatFullHp", 3000, npc, null);
setInstanceTimeRestrictions(world);
}
}
return null;
@@ -922,8 +881,7 @@ public final class Stage1 extends Quest
{
world.deviceSpawnedMobCount = 0;
spawnFlaggedNPCs(world, 6);
final ExShowScreenMessage message3 = new ExShowScreenMessage(NpcStringId.ENEMIES_ARE_TRYING_TO_DESTROY_THE_FORTRESS_EVERYONE_DEFEND_THE_FORTRESS, 5, 1);
sendScreenMessage(world, message3);
sendScreenMessage(world, new ExShowScreenMessage(NpcStringId.ENEMIES_ARE_TRYING_TO_DESTROY_THE_FORTRESS_EVERYONE_DEFEND_THE_FORTRESS, 5, 1));
}
else
{
@@ -1061,7 +1019,6 @@ public final class Stage1 extends Quest
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(trap.getInstanceId());
if (tmpworld instanceof SOD1World)
{
final SOD1World world = (SOD1World) tmpworld;
switch (action)
{
case TRAP_TRIGGERED:
@@ -1070,14 +1027,14 @@ public final class Stage1 extends Quest
{
for (int npcId : TRAP_18771_NPCS)
{
addSpawn(npcId, trap.getX(), trap.getY(), trap.getZ(), trap.getHeading(), true, 0, true, world.getInstanceId());
addSpawn(npcId, trap.getX(), trap.getY(), trap.getZ(), trap.getHeading(), true, 0, true, ((SOD1World) tmpworld).getInstanceId());
}
}
else
{
for (int npcId : TRAP_OTHER_NPCS)
{
addSpawn(npcId, trap.getX(), trap.getY(), trap.getZ(), trap.getHeading(), true, 0, true, world.getInstanceId());
addSpawn(npcId, trap.getX(), trap.getY(), trap.getZ(), trap.getHeading(), true, 0, true, ((SOD1World) tmpworld).getInstanceId());
}
}
break;

View File

@@ -232,8 +232,7 @@ public final class HallOfSuffering extends AbstractNpcAI
party.broadcastPacket(sm);
return false;
}
final long reentertime = InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), TEMPLATE_ID);
if (System.currentTimeMillis() < reentertime)
if (System.currentTimeMillis() < InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), TEMPLATE_ID))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_RE_ENTER_YET);
sm.addPcName(partyMember);
@@ -457,9 +456,7 @@ public final class HallOfSuffering extends AbstractNpcAI
private String getPtLeaderText(L2PcInstance player, HSWorld world)
{
String htmltext = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-10.htm");
htmltext = htmltext.replaceAll("%ptLeader%", String.valueOf(world.ptLeaderName));
return htmltext;
return HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-10.htm").replaceAll("%ptLeader%", String.valueOf(world.ptLeaderName));
}
@Override
@@ -619,20 +616,17 @@ public final class HallOfSuffering extends AbstractNpcAI
runTwins(world);
}
}
else if ((world.getStatus() == 6) && ((npc.getId() == KLODEKUS) || (npc.getId() == KLANIKUS)))
else if ((world.getStatus() == 6) && ((npc.getId() == KLODEKUS) || (npc.getId() == KLANIKUS)) && world.klanikus.isDead() && world.klodekus.isDead())
{
if (world.klanikus.isDead() && world.klodekus.isDead())
{
world.incStatus();
// instance end
calcRewardItemId(world);
world.klanikus = null;
world.klodekus = null;
cancelQuestTimers("ressurectTwin");
cancelQuestTimers("spawnBossGuards");
cancelQuestTimers("isTwinSeparated");
addSpawn(TEPIOS, TEPIOS_SPAWN, false, 0, false, world.getInstanceId());
}
world.incStatus();
// instance end
calcRewardItemId(world);
world.klanikus = null;
world.klodekus = null;
cancelQuestTimers("ressurectTwin");
cancelQuestTimers("spawnBossGuards");
cancelQuestTimers("isTwinSeparated");
addSpawn(TEPIOS, TEPIOS_SPAWN, false, 0, false, world.getInstanceId());
}
}
return super.onKill(npc, killer, isSummon);

View File

@@ -285,34 +285,31 @@ public abstract class AirShipController extends Quest
@Override
public String onEnterZone(L2Character character, L2ZoneType zone)
{
if (character instanceof L2ControllableAirShipInstance)
if ((character instanceof L2ControllableAirShipInstance) && (_dockedShip == null))
{
if (_dockedShip == null)
_dockedShip = (L2ControllableAirShipInstance) character;
_dockedShip.setInDock(_dockZone);
_dockedShip.setOustLoc(_oustLoc);
// Ship is not empty - display movie to passengers and dock
if (!_dockedShip.isEmpty())
{
_dockedShip = (L2ControllableAirShipInstance) character;
_dockedShip.setInDock(_dockZone);
_dockedShip.setOustLoc(_oustLoc);
// Ship is not empty - display movie to passengers and dock
if (!_dockedShip.isEmpty())
if (_movieId != 0)
{
if (_movieId != 0)
for (L2PcInstance passenger : _dockedShip.getPassengers())
{
for (L2PcInstance passenger : _dockedShip.getPassengers())
if (passenger != null)
{
if (passenger != null)
{
passenger.showQuestMovie(_movieId);
}
passenger.showQuestMovie(_movieId);
}
}
ThreadPoolManager.getInstance().scheduleGeneral(_decayTask, 1000);
}
else
{
_departSchedule = ThreadPoolManager.getInstance().scheduleGeneral(_departTask, DEPART_INTERVAL);
}
ThreadPoolManager.getInstance().scheduleGeneral(_decayTask, 1000);
}
else
{
_departSchedule = ThreadPoolManager.getInstance().scheduleGeneral(_departTask, DEPART_INTERVAL);
}
}
return null;
@@ -321,20 +318,17 @@ public abstract class AirShipController extends Quest
@Override
public String onExitZone(L2Character character, L2ZoneType zone)
{
if (character instanceof L2ControllableAirShipInstance)
if ((character instanceof L2ControllableAirShipInstance) && character.equals(_dockedShip))
{
if (character.equals(_dockedShip))
if (_departSchedule != null)
{
if (_departSchedule != null)
{
_departSchedule.cancel(false);
_departSchedule = null;
}
_dockedShip.setInDock(0);
_dockedShip = null;
_isBusy = false;
_departSchedule.cancel(false);
_departSchedule = null;
}
_dockedShip.setInDock(0);
_dockedShip = null;
_isBusy = false;
}
return null;
}
@@ -373,14 +367,11 @@ public abstract class AirShipController extends Quest
}
}
}
if (_arrivalPath == null)
if ((_arrivalPath == null) && !ZoneManager.getInstance().getZoneById(_dockZone, L2ScriptZone.class).isInsideZone(_shipSpawnX, _shipSpawnY, _shipSpawnZ))
{
if (!ZoneManager.getInstance().getZoneById(_dockZone, L2ScriptZone.class).isInsideZone(_shipSpawnX, _shipSpawnY, _shipSpawnZ))
{
_log.log(Level.WARNING, getName() + ": Arrival path is null and spawn point not in zone " + _dockZone + ", controller disabled");
_isBusy = true;
return;
}
_log.log(Level.WARNING, getName() + ": Arrival path is null and spawn point not in zone " + _dockZone + ", controller disabled");
_isBusy = true;
return;
}
if (_departPath != null)