Code improvements.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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).
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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))
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user