Sync with L2jServer HighFive Mar 3rd 2016.

This commit is contained in:
MobiusDev
2016-03-05 15:16:23 +00:00
parent 36448c168e
commit 7a9de77047
20 changed files with 269 additions and 237 deletions

View File

@@ -36,6 +36,9 @@ final class SummonPc extends AbstractNpcAI
private static final int PERUM = 20221; private static final int PERUM = 20221;
// Skill // Skill
private static final SkillHolder SUMMON_PC = new SkillHolder(4161, 1); private static final SkillHolder SUMMON_PC = new SkillHolder(4161, 1);
// Misc
private static final int MIN_DISTANCE = 300;
private static final int MIN_DISTANCE_MOST_HATED = 100;
private SummonPc() private SummonPc()
{ {
@@ -47,39 +50,29 @@ final class SummonPc extends AbstractNpcAI
@Override @Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
{ {
final int chance = getRandom(100);
final boolean attacked = npc.getVariables().getBoolean("attacked", false); final boolean attacked = npc.getVariables().getBoolean("attacked", false);
if ((npc.calculateDistance(attacker, true, false) > 300) && !attacked) if (attacked)
{
return super.onAttack(npc, attacker, damage, isSummon);
}
final int chance = getRandom(100);
final double distance = npc.calculateDistance(attacker, true, false);
if (distance > MIN_DISTANCE)
{ {
if (chance < 50) if (chance < 50)
{ {
if ((SUMMON_PC.getSkill().getMpConsume() < npc.getCurrentMp()) && (SUMMON_PC.getSkill().getHpConsume() < npc.getCurrentHp()) && !npc.isSkillDisabled(SUMMON_PC.getSkill())) doSummonPc(npc, attacker);
{
npc.setTarget(attacker);
npc.doCast(SUMMON_PC.getSkill());
}
if ((SUMMON_PC.getSkill().getMpConsume() < npc.getCurrentMp()) && (SUMMON_PC.getSkill().getHpConsume() < npc.getCurrentHp()) && !npc.isSkillDisabled(SUMMON_PC.getSkill()))
{
npc.setTarget(attacker);
npc.doCast(SUMMON_PC.getSkill());
npc.getVariables().set("attacked", true);
}
} }
} }
else if ((npc.calculateDistance(attacker, true, false) > 100) && !attacked) else if (distance > MIN_DISTANCE_MOST_HATED)
{ {
final L2Attackable monster = (L2Attackable) npc; final L2Attackable monster = (L2Attackable) npc;
if (monster.getMostHated() != null) if (monster.getMostHated() != null)
{ {
if (((monster.getMostHated() == attacker) && (chance < 50)) || (chance < 10)) if (((monster.getMostHated() == attacker) && (chance < 50)) || (chance < 10))
{ {
if ((SUMMON_PC.getSkill().getMpConsume() < npc.getCurrentMp()) && (SUMMON_PC.getSkill().getHpConsume() < npc.getCurrentHp()) && !npc.isSkillDisabled(SUMMON_PC.getSkill())) doSummonPc(npc, attacker);
{
npc.setTarget(attacker);
npc.doCast(SUMMON_PC.getSkill());
npc.getVariables().set("attacked", true);
}
} }
} }
} }
@@ -93,10 +86,23 @@ final class SummonPc extends AbstractNpcAI
{ {
player.teleToLocation(npc); player.teleToLocation(npc);
npc.getVariables().set("attacked", false); npc.getVariables().set("attacked", false);
// TODO(Zoey76): Teleport removes the player from all known lists, affecting aggro lists.
addAttackDesire(npc, player);
} }
return super.onSpellFinished(npc, player, skill); return super.onSpellFinished(npc, player, skill);
} }
private static void doSummonPc(L2Npc npc, L2PcInstance attacker)
{
if ((SUMMON_PC.getSkill().getMpConsume() < npc.getCurrentMp()) && (SUMMON_PC.getSkill().getHpConsume() < npc.getCurrentHp()) && !npc.isSkillDisabled(SUMMON_PC.getSkill()))
{
npc.setTarget(attacker);
npc.doCast(SUMMON_PC.getSkill());
npc.getVariables().set("attacked", true);
}
}
public static void main(String[] args) public static void main(String[] args)
{ {
new SummonPc(); new SummonPc();

View File

@@ -16,10 +16,9 @@
*/ */
package handlers.targethandlers; package handlers.targethandlers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import com.l2jmobius.gameserver.GeoData; import com.l2jmobius.gameserver.GeoData;
@@ -34,17 +33,19 @@ import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.SystemMessageId;
/** /**
* @author Adry_85 * Area Friendly target handler implementation.
* @author Adry_85, Zoey76
*/ */
public class AreaFriendly implements ITargetTypeHandler public class AreaFriendly implements ITargetTypeHandler
{ {
private static final CharComparator CHAR_COMPARATOR = new CharComparator();
@Override @Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target) public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{ {
final List<L2Character> targetList = new ArrayList<>();
final L2PcInstance player = activeChar.getActingPlayer(); final L2PcInstance player = activeChar.getActingPlayer();
if ((target == null) || (!checkTarget(player, target) && (skill.getCastRange() >= 0))) if (!checkTarget(player, target) && (skill.getCastRange() >= 0))
{ {
player.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); player.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST; return EMPTY_TARGET_LIST;
@@ -65,27 +66,31 @@ public class AreaFriendly implements ITargetTypeHandler
player player
}; };
} }
targetList.add(target); // Add target to target list
final int maxTargets = skill.getAffectLimit(); final List<L2Character> targetList = new LinkedList<>();
final Collection<L2Character> objs = target.getKnownList().getKnownCharactersInRadius(skill.getAffectRange()); if (target != null)
// TODO: Chain Heal - The recovery amount decreases starting from the most injured person.
Collections.sort(targetList, new CharComparator());
for (L2Character obj : objs)
{ {
if (!checkTarget(player, obj) || (obj == activeChar)) // Add target to target list.
targetList.add(target);
final int maxTargets = skill.getAffectLimit();
for (L2Character obj : target.getKnownList().getKnownCharactersInRadius(skill.getAffectRange()))
{ {
continue; if ((maxTargets > 0) && (targetList.size() >= maxTargets))
{
break;
}
if (!checkTarget(player, obj) || (obj == activeChar))
{
continue;
}
targetList.add(obj);
} }
if ((maxTargets > 0) && (targetList.size() >= maxTargets)) // Sort creatures, the most injured first.
{ Collections.sort(targetList, CHAR_COMPARATOR);
break;
}
targetList.add(obj);
} }
if (targetList.isEmpty()) if (targetList.isEmpty())
@@ -107,9 +112,15 @@ public class AreaFriendly implements ITargetTypeHandler
return false; return false;
} }
// GMs and hidden creatures.
if (target.isInvisible())
{
return false;
}
if (target.isPlayable()) if (target.isPlayable())
{ {
final L2PcInstance targetPlayer = target.getActingPlayer(); L2PcInstance targetPlayer = target.getActingPlayer();
if (activeChar == targetPlayer) if (activeChar == targetPlayer)
{ {
@@ -131,6 +142,12 @@ public class AreaFriendly implements ITargetTypeHandler
return true; return true;
} }
// Only siege allies.
if (activeChar.isInSiege() && !activeChar.isOnSameSiegeSideWith(targetPlayer))
{
return false;
}
if (target.isInsideZone(ZoneId.PVP)) if (target.isInsideZone(ZoneId.PVP))
{ {
return false; return false;
@@ -149,7 +166,7 @@ public class AreaFriendly implements ITargetTypeHandler
return true; return true;
} }
class CharComparator implements Comparator<L2Character> static class CharComparator implements Comparator<L2Character>
{ {
@Override @Override
public int compare(L2Character char1, L2Character char2) public int compare(L2Character char1, L2Character char2)

View File

@@ -25,6 +25,7 @@ import com.l2jmobius.gameserver.model.skills.targets.L2TargetType;
import com.l2jmobius.gameserver.model.zone.ZoneId; import com.l2jmobius.gameserver.model.zone.ZoneId;
/** /**
* Enemy Summon target handler implementation.
* @author UnAfraid * @author UnAfraid
*/ */
public class EnemySummon implements ITargetTypeHandler public class EnemySummon implements ITargetTypeHandler
@@ -32,7 +33,7 @@ public class EnemySummon implements ITargetTypeHandler
@Override @Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target) public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{ {
if (target.isSummon()) if ((target != null) && target.isSummon())
{ {
final L2Summon targetSummon = (L2Summon) target; final L2Summon targetSummon = (L2Summon) target;
if ((activeChar.isPlayer() && (activeChar.getPet() != targetSummon) && activeChar.hasServitor(targetSummon.getObjectId()) && !targetSummon.isDead() && ((targetSummon.getOwner().getPvpFlag() != 0) || (targetSummon.getOwner().getReputation() < 0))) || (targetSummon.getOwner().isInsideZone(ZoneId.PVP) && activeChar.getActingPlayer().isInsideZone(ZoneId.PVP)) || (targetSummon.getOwner().isInDuel() && activeChar.getActingPlayer().isInDuel() && (targetSummon.getOwner().getDuelId() == activeChar.getActingPlayer().getDuelId()))) if ((activeChar.isPlayer() && (activeChar.getPet() != targetSummon) && activeChar.hasServitor(targetSummon.getObjectId()) && !targetSummon.isDead() && ((targetSummon.getOwner().getPvpFlag() != 0) || (targetSummon.getOwner().getReputation() < 0))) || (targetSummon.getOwner().isInsideZone(ZoneId.PVP) && activeChar.getActingPlayer().isInsideZone(ZoneId.PVP)) || (targetSummon.getOwner().isInDuel() && activeChar.getActingPlayer().isInDuel() && (targetSummon.getOwner().getDuelId() == activeChar.getActingPlayer().getDuelId())))

View File

@@ -740,20 +740,27 @@
<set name="reuseDelay" val="3000" /> <set name="reuseDelay" val="3000" />
<set name="rideState" val="NONE" /> <set name="rideState" val="NONE" />
<set name="targetType" val="ONE" /> <set name="targetType" val="ONE" />
<enchant1 name="abnormalLvl" val="3" />
<enchant1 name="abnormalTime" val="30" /> <enchant1 name="abnormalTime" val="30" />
<enchant1 name="abnormalType" val="ATTACK_TIME_UP" />
<enchant1 name="activateRate" val="#ench1ActivateRates" /> <enchant1 name="activateRate" val="#ench1ActivateRates" />
<enchant1 name="basicProperty" val="MEN" /> <enchant1 name="basicProperty" val="MEN" />
<enchant1 name="isDebuff" val="true" /> <enchant1 name="isDebuff" val="true" />
<enchant1 name="lvlBonusRate" val="1" /> <enchant1 name="lvlBonusRate" val="1" />
<enchant1 name="operateType" val="ACTIVE_CONTINUOUS" /> <enchant1 name="operateType" val="ACTIVE_CONTINUOUS" />
<enchant1 name="magicLvl" val="#enchMagicLvl" /> <enchant1 name="magicLvl" val="#enchMagicLvl" />
<enchant2 name="abnormalLvl" val="3" />
<enchant2 name="abnormalTime" val="15" /> <enchant2 name="abnormalTime" val="15" />
<enchant2 name="abnormalType" val="DOT_ATTR" />
<enchant2 name="operateType" val="ACTIVE_CONTINUOUS" />
<enchant2 name="activateRate" val="#ench2ActivateRates" /> <enchant2 name="activateRate" val="#ench2ActivateRates" />
<enchant2 name="basicProperty" val="MEN" /> <enchant2 name="basicProperty" val="MEN" />
<enchant2 name="isDebuff" val="true" /> <enchant2 name="isDebuff" val="true" />
<enchant2 name="lvlBonusRate" val="1" /> <enchant2 name="lvlBonusRate" val="1" />
<enchant2 name="magicLvl" val="#enchMagicLvl" /> <enchant2 name="magicLvl" val="#enchMagicLvl" />
<enchant3 name="abnormalLvl" val="1" />
<enchant3 name="abnormalTime" val="15" /> <enchant3 name="abnormalTime" val="15" />
<enchant3 name="abnormalType" val="HOLY_ATTACK" />
<enchant3 name="activateRate" val="80" /> <enchant3 name="activateRate" val="80" />
<enchant3 name="basicProperty" val="MEN" /> <enchant3 name="basicProperty" val="MEN" />
<enchant3 name="isDebuff" val="true" /> <enchant3 name="isDebuff" val="true" />

View File

@@ -66,7 +66,9 @@
<set name="reuseDelay" val="3000" /> <set name="reuseDelay" val="3000" />
<set name="rideState" val="NONE" /> <set name="rideState" val="NONE" />
<set name="targetType" val="AREA" /> <set name="targetType" val="AREA" />
<enchant1 name="abnormalLvl" val="3" />
<enchant1 name="abnormalTime" val="30" /> <enchant1 name="abnormalTime" val="30" />
<enchant1 name="abnormalType" val="ATTACK_TIME_UP" />
<enchant1 name="activateRate" val="#ench1ActivateRates" /> <enchant1 name="activateRate" val="#ench1ActivateRates" />
<enchant1 name="basicProperty" val="MEN" /> <enchant1 name="basicProperty" val="MEN" />
<enchant1 name="element" val="3" /> <!-- Earth --> <enchant1 name="element" val="3" /> <!-- Earth -->
@@ -76,7 +78,9 @@
<enchant1 name="lvlBonusRate" val="1" /> <enchant1 name="lvlBonusRate" val="1" />
<enchant1 name="magicLvl" val="#enchMagicLvl" /> <enchant1 name="magicLvl" val="#enchMagicLvl" />
<enchant1 name="offensive" val="true" /> <enchant1 name="offensive" val="true" />
<enchant2 name="abnormalLvl" val="3" />
<enchant2 name="abnormalTime" val="15" /> <enchant2 name="abnormalTime" val="15" />
<enchant2 name="abnormalType" val="DOT_ATTR" />
<enchant2 name="activateRate" val="#ench2ActivateRates" /> <enchant2 name="activateRate" val="#ench2ActivateRates" />
<enchant2 name="basicProperty" val="MEN" /> <enchant2 name="basicProperty" val="MEN" />
<enchant2 name="element" val="3" /> <!-- Earth --> <enchant2 name="element" val="3" /> <!-- Earth -->
@@ -86,7 +90,9 @@
<enchant2 name="lvlBonusRate" val="1" /> <enchant2 name="lvlBonusRate" val="1" />
<enchant2 name="magicLvl" val="#enchMagicLvl" /> <enchant2 name="magicLvl" val="#enchMagicLvl" />
<enchant2 name="offensive" val="true" /> <enchant2 name="offensive" val="true" />
<enchant3 name="abnormalLvl" val="1" />
<enchant3 name="abnormalTime" val="15" /> <enchant3 name="abnormalTime" val="15" />
<enchant3 name="abnormalType" val="HOLY_ATTACK" />
<enchant3 name="activateRate" val="80" /> <enchant3 name="activateRate" val="80" />
<enchant3 name="basicProperty" val="MEN" /> <enchant3 name="basicProperty" val="MEN" />
<enchant3 name="element" val="3" /> <!-- Earth --> <enchant3 name="element" val="3" /> <!-- Earth -->

View File

@@ -885,6 +885,11 @@
<enchant2 name="mpConsume" val="#ench2mpConsume" /> <enchant2 name="mpConsume" val="#ench2mpConsume" />
<enchant2 name="mpInitialConsume" val="#ench2mpInitialConsume" /> <enchant2 name="mpInitialConsume" val="#ench2mpInitialConsume" />
<enchant2 name="power" val="#ench2Power" /> <enchant2 name="power" val="#ench2Power" />
<enchant3 name="abnormalLvl" val="1" />
<enchant3 name="abnormalTime" val="60" />
<enchant3 name="abnormalType" val="HOLY_ATTACK" />
<enchant3 name="activateRate" val="40" />
<enchant3 name="lvlBonusRate" val="1" />
<enchant3 name="basicProperty" val="MEN" /> <enchant3 name="basicProperty" val="MEN" />
<enchant3 name="magicLvl" val="#enchMagicLvl" /> <enchant3 name="magicLvl" val="#enchMagicLvl" />
<enchant3 name="operateType" val="ACTIVE_CONTINUOUS" /> <enchant3 name="operateType" val="ACTIVE_CONTINUOUS" />
@@ -1128,10 +1133,15 @@
<enchant2 name="mpConsume" val="#ench2mpConsume" /> <enchant2 name="mpConsume" val="#ench2mpConsume" />
<enchant2 name="mpInitialConsume" val="#ench2mpInitialConsume" /> <enchant2 name="mpInitialConsume" val="#ench2mpInitialConsume" />
<enchant2 name="power" val="#ench2Power" /> <enchant2 name="power" val="#ench2Power" />
<enchant3 name="abnormalLvl" val="1" />
<enchant3 name="abnormalTime" val="60" />
<enchant3 name="abnormalType" val="HOLY_ATTACK" />
<enchant3 name="activateRate" val="40" />
<enchant3 name="lvlBonusRate" val="1" />
<enchant3 name="basicProperty" val="MEN" /> <enchant3 name="basicProperty" val="MEN" />
<enchant3 name="isDebuff" val="true" />
<enchant3 name="operateType" val="ACTIVE_CONTINUOUS" />
<enchant3 name="magicLvl" val="#enchMagicLvl" /> <enchant3 name="magicLvl" val="#enchMagicLvl" />
<enchant3 name="operateType" val="ACTIVE_CONTINUOUS" />
<enchant3 name="isDebuff" val="true" />
<enchant4 name="elementPower" val="#ench4ElementPower" /> <enchant4 name="elementPower" val="#ench4ElementPower" />
<enchant4 name="magicLvl" val="#enchMagicLvl" /> <enchant4 name="magicLvl" val="#enchMagicLvl" />
<for> <for>
@@ -1355,9 +1365,14 @@
<enchant1 name="power" val="#ench1Power" /> <enchant1 name="power" val="#ench1Power" />
<enchant2 name="elementPower" val="#ench2elementPower" /> <enchant2 name="elementPower" val="#ench2elementPower" />
<enchant2 name="magicLvl" val="#enchMagicLvl" /> <enchant2 name="magicLvl" val="#enchMagicLvl" />
<enchant3 name="operateType" val="ACTIVE_CONTINUOUS" /> <enchant3 name="abnormalLvl" val="1" />
<enchant3 name="abnormalTime" val="60" />
<enchant3 name="abnormalType" val="HOLY_ATTACK" />
<enchant3 name="activateRate" val="40" />
<enchant3 name="lvlBonusRate" val="1" />
<enchant3 name="basicProperty" val="MEN" /> <enchant3 name="basicProperty" val="MEN" />
<enchant3 name="magicLvl" val="#enchMagicLvl" /> <enchant3 name="magicLvl" val="#enchMagicLvl" />
<enchant3 name="operateType" val="ACTIVE_CONTINUOUS" />
<enchant3 name="isDebuff" val="true" /> <enchant3 name="isDebuff" val="true" />
<for> <for>
<effect name="MagicalAttack" /> <effect name="MagicalAttack" />

View File

@@ -594,7 +594,7 @@ public class Shutdown extends Thread
if (Config.BOTREPORT_ENABLE) if (Config.BOTREPORT_ENABLE)
{ {
BotReportTable.getInstance().saveReportedCharData(); BotReportTable.getInstance().saveReportedCharData();
_log.info("Bot Report Table: Sucessfully saved reports to database!"); _log.info("Bot Report Table: Successfully saved reports to database!");
} }
try try

View File

@@ -1771,6 +1771,10 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
double dist = 0; double dist = 0;
double dist2 = 0; double dist2 = 0;
int range = 0; int range = 0;
if (getAttackTarget() == null)
{
return;
}
try try
{ {
if (npc.getTarget() == null) if (npc.getTarget() == null)

View File

@@ -244,6 +244,7 @@ public class L2PlayerAI extends L2PlayableAI
return; return;
} }
clientStopMoving(null);
_actor.doAttack(target); _actor.doAttack(target);
} }

View File

@@ -16,12 +16,10 @@
*/ */
package com.l2jmobius.gameserver.data.sql.impl; package com.l2jmobius.gameserver.data.sql.impl;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ConcurrentHashMap;
import com.l2jmobius.gameserver.model.actor.L2Summon; import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -39,11 +37,14 @@ public class SummonEffectsTable
// -> key: charObjectId, value: classIndex Map // -> key: charObjectId, value: classIndex Map
// --> key: classIndex, value: servitors Map // --> key: classIndex, value: servitors Map
// ---> key: servitorSkillId, value: Effects list // ---> key: servitorSkillId, value: Effects list
private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>(); private final Map<Integer, Map<Integer, Map<Integer, Map<Integer, SummonEffect>>>> _servitorEffects = new HashMap<>();
/** Pets **/
// key: petItemObjectId, value: Effects list
private final Map<Integer, Map<Integer, SummonEffect>> _petEffects = new HashMap<>();
private Map<Integer, List<SummonEffect>> getServitorEffects(L2PcInstance owner) private Map<Integer, Map<Integer, SummonEffect>> getServitorEffects(L2PcInstance owner)
{ {
final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId()); final Map<Integer, Map<Integer, Map<Integer, SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
if (servitorMap == null) if (servitorMap == null)
{ {
return null; return null;
@@ -51,7 +52,7 @@ public class SummonEffectsTable
return servitorMap.get(owner.getClassIndex()); return servitorMap.get(owner.getClassIndex());
} }
private List<SummonEffect> getServitorEffects(L2PcInstance owner, int referenceSkill) private Map<Integer, SummonEffect> getServitorEffects(L2PcInstance owner, int referenceSkill)
{ {
return containsOwner(owner) ? getServitorEffects(owner).get(referenceSkill) : null; return containsOwner(owner) ? getServitorEffects(owner).get(referenceSkill) : null;
} }
@@ -61,28 +62,21 @@ public class SummonEffectsTable
return _servitorEffects.getOrDefault(owner.getObjectId(), Collections.emptyMap()).containsKey(owner.getClassIndex()); return _servitorEffects.getOrDefault(owner.getObjectId(), Collections.emptyMap()).containsKey(owner.getClassIndex());
} }
private void removeEffects(List<SummonEffect> effects, int skillId) private void removeEffects(Map<Integer, SummonEffect> map, int skillId)
{ {
if ((effects != null) && !effects.isEmpty()) if (map != null)
{ {
for (SummonEffect effect : effects) map.remove(skillId);
{
final Skill skill = effect.getSkill();
if ((skill != null) && (skill.getId() == skillId))
{
effects.remove(effect);
}
}
} }
} }
private void applyEffects(L2Summon summon, List<SummonEffect> summonEffects) private void applyEffects(L2Summon summon, Map<Integer, SummonEffect> map)
{ {
if (summonEffects == null) if (map == null)
{ {
return; return;
} }
for (SummonEffect se : summonEffects) for (SummonEffect se : map.values())
{ {
if (se != null) if (se != null)
{ {
@@ -100,16 +94,16 @@ public class SummonEffectsTable
{ {
if (containsOwner(owner)) if (containsOwner(owner))
{ {
getServitorEffects(owner).getOrDefault(referenceSkill, Collections.emptyList()).clear(); getServitorEffects(owner).getOrDefault(referenceSkill, Collections.emptyMap()).clear();
} }
} }
public void addServitorEffect(L2PcInstance owner, int referenceSkill, Skill skill, int effectCurTime) public void addServitorEffect(L2PcInstance owner, int referenceSkill, Skill skill, int effectCurTime)
{ {
_servitorEffects.putIfAbsent(owner.getObjectId(), new HashMap<Integer, Map<Integer, List<SummonEffect>>>()); _servitorEffects.putIfAbsent(owner.getObjectId(), new HashMap<Integer, Map<Integer, Map<Integer, SummonEffect>>>());
_servitorEffects.get(owner.getObjectId()).putIfAbsent(owner.getClassIndex(), new HashMap<Integer, List<SummonEffect>>()); _servitorEffects.get(owner.getObjectId()).putIfAbsent(owner.getClassIndex(), new HashMap<Integer, Map<Integer, SummonEffect>>());
getServitorEffects(owner).putIfAbsent(referenceSkill, new CopyOnWriteArrayList<SummonEffect>()); getServitorEffects(owner).putIfAbsent(referenceSkill, new ConcurrentHashMap<Integer, SummonEffect>());
getServitorEffects(owner).get(referenceSkill).add(new SummonEffect(skill, effectCurTime)); getServitorEffects(owner).get(referenceSkill).put(skill.getId(), new SummonEffect(skill, effectCurTime));
} }
public void removeServitorEffects(L2PcInstance owner, int referenceSkill, int skillId) public void removeServitorEffects(L2PcInstance owner, int referenceSkill, int skillId)
@@ -117,17 +111,14 @@ public class SummonEffectsTable
removeEffects(getServitorEffects(owner, referenceSkill), skillId); removeEffects(getServitorEffects(owner, referenceSkill), skillId);
} }
public void applyServitorEffects(L2ServitorInstance l2ServitorInstance, L2PcInstance owner, int referenceSkill) public void applyServitorEffects(L2ServitorInstance servitor, L2PcInstance owner, int referenceSkill)
{ {
applyEffects(l2ServitorInstance, getServitorEffects(owner, referenceSkill)); applyEffects(servitor, getServitorEffects(owner, referenceSkill));
} }
/** Pets **/
private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list
public void addPetEffect(int controlObjectId, Skill skill, int effectCurTime) public void addPetEffect(int controlObjectId, Skill skill, int effectCurTime)
{ {
_petEffects.computeIfAbsent(controlObjectId, k -> new ArrayList<>()).add(new SummonEffect(skill, effectCurTime)); _petEffects.computeIfAbsent(controlObjectId, k -> new ConcurrentHashMap<>()).put(skill.getId(), new SummonEffect(skill, effectCurTime));
} }
public boolean containsPetId(int controlObjectId) public boolean containsPetId(int controlObjectId)
@@ -142,7 +133,11 @@ public class SummonEffectsTable
public void clearPetEffects(int controlObjectId) public void clearPetEffects(int controlObjectId)
{ {
_petEffects.getOrDefault(controlObjectId, Collections.emptyList()).clear(); final Map<Integer, SummonEffect> effects = _petEffects.get(controlObjectId);
if (effects != null)
{
effects.clear();
}
} }
public void removePetEffects(int controlObjectId, int skillId) public void removePetEffects(int controlObjectId, int skillId)
@@ -174,11 +169,11 @@ public class SummonEffectsTable
public static SummonEffectsTable getInstance() public static SummonEffectsTable getInstance()
{ {
return SingletonHolder._instance; return SingletonHolder.INSTANCE;
} }
private static class SingletonHolder private static class SingletonHolder
{ {
protected static final SummonEffectsTable _instance = new SummonEffectsTable(); protected static final SummonEffectsTable INSTANCE = new SummonEffectsTable();
} }
} }

View File

@@ -51,10 +51,12 @@ import com.l2jmobius.util.data.xml.IXmlReader;
public final class WalkingManager implements IXmlReader public final class WalkingManager implements IXmlReader
{ {
// Repeat style: // Repeat style:
// -1 - no repeat
// 0 - go back // 0 - go back
// 1 - go to first point (circle style) // 1 - go to first point (circle style)
// 2 - teleport to first point (conveyor style) // 2 - teleport to first point (conveyor style)
// 3 - random walking between points. // 3 - random walking between points.
public static final byte NO_REPEAT = -1;
public static final byte REPEAT_GO_BACK = 0; public static final byte REPEAT_GO_BACK = 0;
public static final byte REPEAT_GO_FIRST = 1; public static final byte REPEAT_GO_FIRST = 1;
public static final byte REPEAT_TELE_FIRST = 2; public static final byte REPEAT_TELE_FIRST = 2;
@@ -86,27 +88,36 @@ public final class WalkingManager implements IXmlReader
{ {
final String routeName = parseString(d.getAttributes(), "name"); final String routeName = parseString(d.getAttributes(), "name");
final boolean repeat = parseBoolean(d.getAttributes(), "repeat"); final boolean repeat = parseBoolean(d.getAttributes(), "repeat");
final String repeatStyle = d.getAttributes().getNamedItem("repeatStyle").getNodeValue(); final String repeatStyle = d.getAttributes().getNamedItem("repeatStyle").getNodeValue().toLowerCase();
byte repeatType;
if (repeatStyle.equalsIgnoreCase("back")) final byte repeatType;
switch (repeatStyle)
{ {
repeatType = REPEAT_GO_BACK; case "back":
} {
else if (repeatStyle.equalsIgnoreCase("cycle")) repeatType = REPEAT_GO_BACK;
{ break;
repeatType = REPEAT_GO_FIRST; }
} case "cycle":
else if (repeatStyle.equalsIgnoreCase("conveyor")) {
{ repeatType = REPEAT_GO_FIRST;
repeatType = REPEAT_TELE_FIRST; break;
} }
else if (repeatStyle.equalsIgnoreCase("random")) case "conveyor":
{ {
repeatType = REPEAT_RANDOM; repeatType = REPEAT_TELE_FIRST;
} break;
else }
{ case "random":
repeatType = -1; {
repeatType = REPEAT_RANDOM;
break;
}
default:
{
repeatType = NO_REPEAT;
break;
}
} }
final List<L2NpcWalkerNode> list = new ArrayList<>(); final List<L2NpcWalkerNode> list = new ArrayList<>();

View File

@@ -358,7 +358,8 @@ public final class L2World
} }
/** /**
* Remove a L2Object from the world. <B><U> Concept</U> :</B> L2Object (including L2PcInstance) are identified in <B>_visibleObjects</B> of his current L2WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR> * Remove an object from the world.<br>
* <B><U> Concept</U> :</B> L2Object (including L2PcInstance) are identified in <B>_visibleObjects</B> of his current L2WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <BR>
* L2PcInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his current L2WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <B><U> Actions</U> :</B> * L2PcInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his current L2WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <B><U> Actions</U> :</B>
* <li>Remove the L2Object object from _allPlayers* of L2World</li> * <li>Remove the L2Object object from _allPlayers* of L2World</li>
* <li>Remove the L2Object object from _visibleObjects and _allPlayers* of L2WorldRegion</li> * <li>Remove the L2Object object from _visibleObjects and _allPlayers* of L2WorldRegion</li>
@@ -369,39 +370,39 @@ public final class L2World
* <li>Pickup an Item</li> * <li>Pickup an Item</li>
* <li>Decay a L2Character</li> * <li>Decay a L2Character</li>
* @param object L2object to remove from the world * @param object L2object to remove from the world
* @param oldRegion L2WorldRegion in which the object was before removing * @param oldWorldRegion L2WorldRegion in which the object was before removing
*/ */
public void removeVisibleObject(L2Object object, L2WorldRegion oldRegion) public void removeVisibleObject(L2Object object, L2WorldRegion oldWorldRegion)
{ {
if (object == null) if (object == null)
{ {
return; return;
} }
if (oldRegion != null) if (oldWorldRegion == null)
{ {
// Remove the object from the L2ObjectHashSet(L2Object) _visibleObjects of L2WorldRegion return;
// If object is a L2PcInstance, remove it from the L2ObjectHashSet(L2PcInstance) _allPlayers of this L2WorldRegion }
oldRegion.removeVisibleObject(object);
// Go through all surrounding L2WorldRegion L2Characters // Removes the object from the visible objects of world region.
for (L2WorldRegion reg : oldRegion.getSurroundingRegions()) // If object is a player, removes it from the players map of this world region.
oldWorldRegion.removeVisibleObject(object);
// Goes through all surrounding world region's creatures.
// And removes the object from their known lists.
for (L2WorldRegion worldRegion : oldWorldRegion.getSurroundingRegions())
{
for (L2Object obj : worldRegion.getVisibleObjects().values())
{ {
final Collection<L2Object> vObj = reg.getVisibleObjects().values(); if (obj != null)
for (L2Object obj : vObj)
{ {
if (obj != null) obj.getKnownList().removeKnownObject(object);
{
obj.getKnownList().removeKnownObject(object);
}
} }
} }
// If object is a L2Character :
// Remove all L2Object from L2ObjectHashSet(L2Object) containing all L2Object detected by the L2Character
// Remove all L2PcInstance from L2ObjectHashSet(L2PcInstance) containing all player ingame detected by the L2Character
object.getKnownList().removeAllKnownObjects();
} }
// Removes all objects from the object's known list.
object.getKnownList().removeAllKnownObjects();
} }
/** /**

View File

@@ -25,13 +25,12 @@ import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcMoveRouteFi
import com.l2jmobius.util.Rnd; import com.l2jmobius.util.Rnd;
/** /**
* Holds info about current walk progress * Holds info about current walk progress.
* @author GKR, UnAfraid * @author GKR, UnAfraid
*/ */
public class WalkInfo public class WalkInfo
{ {
private final String _routeName; private final String _routeName;
private ScheduledFuture<?> _walkCheckTask; private ScheduledFuture<?> _walkCheckTask;
private boolean _blocked = false; private boolean _blocked = false;
private boolean _suspended = false; private boolean _suspended = false;
@@ -65,7 +64,7 @@ public class WalkInfo
* Calculate next node for this WalkInfo and send debug message from given npc * Calculate next node for this WalkInfo and send debug message from given npc
* @param npc NPC to debug message to be sent from * @param npc NPC to debug message to be sent from
*/ */
public void calculateNextNode(L2Npc npc) public synchronized void calculateNextNode(L2Npc npc)
{ {
// Check this first, within the bounds of random moving, we have no conception of "first" or "last" node // Check this first, within the bounds of random moving, we have no conception of "first" or "last" node
if (getRoute().getRepeatType() == WalkingManager.REPEAT_RANDOM) if (getRoute().getRepeatType() == WalkingManager.REPEAT_RANDOM)
@@ -124,7 +123,7 @@ public class WalkInfo
} }
} }
} }
else if (_currentNode == -1) // First node arrived, when direction is first <-- last else if (_currentNode == WalkingManager.NO_REPEAT) // First node arrived, when direction is first <-- last
{ {
_currentNode = 1; _currentNode = 1;
_forward = true; _forward = true;
@@ -219,4 +218,10 @@ public class WalkInfo
{ {
_walkCheckTask = val; _walkCheckTask = val;
} }
@Override
public String toString()
{
return "WalkInfo [_routeName=" + _routeName + ", _walkCheckTask=" + _walkCheckTask + ", _blocked=" + _blocked + ", _suspended=" + _suspended + ", _stoppedByAttack=" + _stoppedByAttack + ", _currentNode=" + _currentNode + ", _forward=" + _forward + ", _lastActionTime=" + _lastActionTime + "]";
}
} }

View File

@@ -11552,7 +11552,7 @@ public final class L2PcInstance extends L2Playable
{ {
for (int i = 0; i < _htmlActionCaches.length; ++i) for (int i = 0; i < _htmlActionCaches.length; ++i)
{ {
if (validateHtmlAction(_htmlActionCaches[i], action)) if ((_htmlActionCaches[i] != null) && validateHtmlAction(_htmlActionCaches[i], action))
{ {
_lastHtmlActionOriginObjId = _htmlActionOriginObjectIds[i]; _lastHtmlActionOriginObjId = _htmlActionOriginObjectIds[i];
return _lastHtmlActionOriginObjId; return _lastHtmlActionOriginObjId;
@@ -11567,13 +11567,13 @@ public final class L2PcInstance extends L2Playable
* <ul> * <ul>
* <li>Inventory contains item</li> * <li>Inventory contains item</li>
* <li>Item owner id == owner id</li> * <li>Item owner id == owner id</li>
* <li>It isnt pet control item while mounting pet or pet summoned</li> * <li>It isn't pet control item while mounting pet or pet summoned</li>
* <li>It isnt active enchant item</li> * <li>It isn't active enchant item</li>
* <li>It isnt cursed weapon/item</li> * <li>It isn't cursed weapon/item</li>
* <li>It isnt wear item</li> * <li>It isn't wear item</li>
* </ul> * </ul>
* @param objectId item object id * @param objectId item object id
* @param action just for login porpouse * @param action just for login purpose
* @return * @return
*/ */
public boolean validateItemManipulation(int objectId, String action) public boolean validateItemManipulation(int objectId, String action)

View File

@@ -135,26 +135,4 @@ public final class SubClass
{ {
_vitalityPoints = vit; _vitalityPoints = vit;
} }
public void incLevel()
{
if (!_dualClass && (getLevel() == _maxLevel))
{
return;
}
_level++;
setExp(ExperienceData.getInstance().getExpForLevel(getLevel()));
}
public void decLevel()
{
if (getLevel() == Config.BASE_SUBCLASS_LEVEL)
{
return;
}
_level--;
setExp(ExperienceData.getInstance().getExpForLevel(getLevel()));
}
} }

View File

@@ -1148,7 +1148,6 @@ public final class Fort extends AbstractResidence
for (L2Spawn spawnDat : _specialEnvoys) for (L2Spawn spawnDat : _specialEnvoys)
{ {
spawnDat.doSpawn(); spawnDat.doSpawn();
spawnDat.startRespawn();
} }
} }

View File

@@ -2481,7 +2481,7 @@ public class Quest extends AbstractScript implements IIdentifiable
* The lucky member is chosen by standard loot roll rules -<br> * The lucky member is chosen by standard loot roll rules -<br>
* each member rolls a random number, the one with the highest roll wins. * each member rolls a random number, the one with the highest roll wins.
* @param player the player whose party to check * @param player the player whose party to check
* @param npc the NPC used for distance and other checks (if {@link #checkPartyMember(L2PcInstance, L2Npc)} is overriden) * @param npc the NPC used for distance and other checks (if {@link #checkPartyMember(L2PcInstance, L2Npc)} is overridden)
* @return the random party member or {@code null} * @return the random party member or {@code null}
*/ */
public L2PcInstance getRandomPartyMember(L2PcInstance player, L2Npc npc) public L2PcInstance getRandomPartyMember(L2PcInstance player, L2Npc npc)
@@ -2523,7 +2523,7 @@ public class Quest extends AbstractScript implements IIdentifiable
/** /**
* This method is called for every party member in {@link #getRandomPartyMember(L2PcInstance, L2Npc)}.<br> * This method is called for every party member in {@link #getRandomPartyMember(L2PcInstance, L2Npc)}.<br>
* It is intended to be overriden by the specific quest implementations. * It is intended to be overridden by the specific quest implementations.
* @param player the player to check * @param player the player to check
* @param npc the NPC that was passed to {@link #getRandomPartyMember(L2PcInstance, L2Npc)} * @param npc the NPC that was passed to {@link #getRandomPartyMember(L2PcInstance, L2Npc)}
* @return {@code true} if this party member passes the check, {@code false} otherwise * @return {@code true} if this party member passes the check, {@code false} otherwise
@@ -2612,7 +2612,7 @@ public class Quest extends AbstractScript implements IIdentifiable
/** /**
* This method is called for every party member in {@link #getRandomPartyMemberState(L2PcInstance, int, int, L2Npc)} if/after all the standard checks are passed.<br> * This method is called for every party member in {@link #getRandomPartyMemberState(L2PcInstance, int, int, L2Npc)} if/after all the standard checks are passed.<br>
* It is intended to be overriden by the specific quest implementations.<br> * It is intended to be overridden by the specific quest implementations.<br>
* It can be used in cases when there are more checks performed than simply a quest condition check,<br> * It can be used in cases when there are more checks performed than simply a quest condition check,<br>
* for example, if an item is required in the player's inventory. * for example, if an item is required in the player's inventory.
* @param qs the {@link QuestState} object of the party member * @param qs the {@link QuestState} object of the party member

View File

@@ -112,7 +112,8 @@ public class EnterWorld extends L2GameClientPacket
{ {
private final static String _C__11_ENTERWORLD = "[C] 11 EnterWorld"; private final static String _C__11_ENTERWORLD = "[C] 11 EnterWorld";
private final int[][] tracert = new int[5][4]; private final int[][] tracert = new int[5][4];
private final static double MIN_HP = 0.5;
private static final int COMBAT_FLAG = 9819;
private final static int ERTHEIA_INTRO_FOR_ERTHEIA_USM_ID = 147; private final static int ERTHEIA_INTRO_FOR_ERTHEIA_USM_ID = 147;
private final static int ERTHEIA_INTRO_FOR_OTHERS_USM_ID = 148; private final static int ERTHEIA_INTRO_FOR_OTHERS_USM_ID = 148;
@@ -138,7 +139,7 @@ public class EnterWorld extends L2GameClientPacket
@Override @Override
protected void runImpl() protected void runImpl()
{ {
final L2PcInstance activeChar = getClient().getActiveChar(); final L2PcInstance activeChar = getActiveChar();
if (activeChar == null) if (activeChar == null)
{ {
_log.warning("EnterWorld failed! activeChar returned 'null'."); _log.warning("EnterWorld failed! activeChar returned 'null'.");
@@ -146,13 +147,13 @@ public class EnterWorld extends L2GameClientPacket
return; return;
} }
final String[] adress = new String[5]; final String[] address = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; address[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(activeChar.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(activeChar.getAccountName(), address);
getClient().setClientTracert(tracert); getClient().setClientTracert(tracert);
@@ -170,9 +171,9 @@ public class EnterWorld extends L2GameClientPacket
} }
} }
if (L2World.getInstance().findObject(activeChar.getObjectId()) != null) if (Config.DEBUG)
{ {
if (Config.DEBUG) if (L2World.getInstance().findObject(activeChar.getObjectId()) != null)
{ {
_log.warning("User already exists in Object ID map! User " + activeChar.getName() + " is a character clone."); _log.warning("User already exists in Object ID map! User " + activeChar.getName() + " is a character clone.");
} }
@@ -224,7 +225,7 @@ public class EnterWorld extends L2GameClientPacket
} }
// Set dead status if applies // Set dead status if applies
if (activeChar.getCurrentHp() < 0.5) if (activeChar.getCurrentHp() < MIN_HP)
{ {
activeChar.setIsDead(true); activeChar.setIsDead(true);
} }
@@ -325,14 +326,14 @@ public class EnterWorld extends L2GameClientPacket
boolean showClanNotice = false; boolean showClanNotice = false;
// Clan related checks are here // Clan related checks are here
if (activeChar.getClan() != null) final L2Clan clan = activeChar.getClan();
if (clan != null)
{ {
notifyClanMembers(activeChar); notifyClanMembers(activeChar);
notifySponsorOrApprentice(activeChar); notifySponsorOrApprentice(activeChar);
final AuctionableHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan()); final AuctionableHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(clan);
if (clanHall != null) if (clanHall != null)
{ {
if (!clanHall.getPaid()) if (!clanHall.getPaid())
@@ -348,12 +349,12 @@ public class EnterWorld extends L2GameClientPacket
continue; continue;
} }
if (siege.checkIsAttacker(activeChar.getClan())) if (siege.checkIsAttacker(clan))
{ {
activeChar.setSiegeState((byte) 1); activeChar.setSiegeState((byte) 1);
activeChar.setSiegeSide(siege.getCastle().getResidenceId()); activeChar.setSiegeSide(siege.getCastle().getResidenceId());
} }
else if (siege.checkIsDefender(activeChar.getClan())) else if (siege.checkIsDefender(clan))
{ {
activeChar.setSiegeState((byte) 2); activeChar.setSiegeState((byte) 2);
activeChar.setSiegeSide(siege.getCastle().getResidenceId()); activeChar.setSiegeSide(siege.getCastle().getResidenceId());
@@ -367,12 +368,12 @@ public class EnterWorld extends L2GameClientPacket
continue; continue;
} }
if (siege.checkIsAttacker(activeChar.getClan())) if (siege.checkIsAttacker(clan))
{ {
activeChar.setSiegeState((byte) 1); activeChar.setSiegeState((byte) 1);
activeChar.setSiegeSide(siege.getFort().getResidenceId()); activeChar.setSiegeSide(siege.getFort().getResidenceId());
} }
else if (siege.checkIsDefender(activeChar.getClan())) else if (siege.checkIsDefender(clan))
{ {
activeChar.setSiegeState((byte) 2); activeChar.setSiegeState((byte) 2);
activeChar.setSiegeSide(siege.getFort().getResidenceId()); activeChar.setSiegeSide(siege.getFort().getResidenceId());
@@ -386,7 +387,7 @@ public class EnterWorld extends L2GameClientPacket
continue; continue;
} }
if (hall.isRegistered(activeChar.getClan())) if (hall.isRegistered(clan))
{ {
activeChar.setSiegeState((byte) 1); activeChar.setSiegeState((byte) 1);
activeChar.setSiegeSide(hall.getId()); activeChar.setSiegeSide(hall.getId());
@@ -395,27 +396,27 @@ public class EnterWorld extends L2GameClientPacket
} }
// Residential skills support // Residential skills support
if (activeChar.getClan().getCastleId() > 0) if (clan.getCastleId() > 0)
{ {
CastleManager.getInstance().getCastleByOwner(activeChar.getClan()).giveResidentialSkills(activeChar); CastleManager.getInstance().getCastleByOwner(clan).giveResidentialSkills(activeChar);
} }
if (activeChar.getClan().getFortId() > 0) if (clan.getFortId() > 0)
{ {
FortManager.getInstance().getFortByOwner(activeChar.getClan()).giveResidentialSkills(activeChar); FortManager.getInstance().getFortByOwner(clan).giveResidentialSkills(activeChar);
} }
showClanNotice = activeChar.getClan().isNoticeEnabled(); showClanNotice = clan.isNoticeEnabled();
// Show clan crest // Show clan crest
if (activeChar.getClan().getCrestId() > 0) if (clan.getCrestId() > 0)
{ {
sendPacket(new PledgeCrest(activeChar.getClan().getCrestId())); sendPacket(new PledgeCrest(clan.getCrestId()));
} }
// Show ally crest // Show ally crest
if (activeChar.getClan().getAllyCrestId() > 0) if (clan.getAllyCrestId() > 0)
{ {
sendPacket(new AllyCrest(activeChar.getClan().getAllyCrestId())); sendPacket(new AllyCrest(clan.getAllyCrestId()));
} }
} }
@@ -484,8 +485,8 @@ public class EnterWorld extends L2GameClientPacket
} }
} }
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_FRIEND_S1_JUST_LOGGED_IN); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_FRIEND_S1_JUST_LOGGED_IN);
sm.addString(activeChar.getName()); sm.addCharName(activeChar);
for (int id : activeChar.getFriendList().keySet()) for (int id : activeChar.getFriendList().keySet())
{ {
final L2Object obj = L2World.getInstance().findObject(id); final L2Object obj = L2World.getInstance().findObject(id);
@@ -541,23 +542,23 @@ public class EnterWorld extends L2GameClientPacket
sendPacket(new SkillCoolTime(activeChar)); sendPacket(new SkillCoolTime(activeChar));
sendPacket(new ExVoteSystemInfo(activeChar)); sendPacket(new ExVoteSystemInfo(activeChar));
for (L2ItemInstance i : activeChar.getInventory().getItems()) for (L2ItemInstance item : activeChar.getInventory().getItems())
{ {
if (i.isTimeLimitedItem()) if (item.isTimeLimitedItem())
{ {
i.scheduleLifeTimeTask(); item.scheduleLifeTimeTask();
} }
if (i.isShadowItem() && i.isEquipped()) if (item.isShadowItem() && item.isEquipped())
{ {
i.decreaseMana(false); item.decreaseMana(false);
} }
} }
for (L2ItemInstance i : activeChar.getWarehouse().getItems()) for (L2ItemInstance whItem : activeChar.getWarehouse().getItems())
{ {
if (i.isTimeLimitedItem()) if (whItem.isTimeLimitedItem())
{ {
i.scheduleLifeTimeTask(); whItem.scheduleLifeTimeTask();
} }
} }
@@ -567,7 +568,8 @@ public class EnterWorld extends L2GameClientPacket
} }
// remove combat flag before teleporting // remove combat flag before teleporting
if (activeChar.getInventory().getItemByItemId(9819) != null) final L2ItemInstance combatFlag = activeChar.getInventory().getItemByItemId(COMBAT_FLAG);
if (combatFlag != null)
{ {
final Fort fort = FortManager.getInstance().getFort(activeChar); final Fort fort = FortManager.getInstance().getFort(activeChar);
if (fort != null) if (fort != null)
@@ -576,9 +578,9 @@ public class EnterWorld extends L2GameClientPacket
} }
else else
{ {
final int slot = activeChar.getInventory().getSlotFromItem(activeChar.getInventory().getItemByItemId(9819)); final int slot = activeChar.getInventory().getSlotFromItem(combatFlag);
activeChar.getInventory().unEquipItemInBodySlot(slot); activeChar.getInventory().unEquipItemInBodySlot(slot);
activeChar.destroyItem("CombatFlag", activeChar.getInventory().getItemByItemId(9819), null, true); activeChar.destroyItem("CombatFlag", combatFlag, null, true);
} }
} }
@@ -624,9 +626,9 @@ public class EnterWorld extends L2GameClientPacket
} }
else if (birthday != -1) else if (birthday != -1)
{ {
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_ARE_S1_DAYS_REMAINING_UNTIL_YOUR_BIRTHDAY_ON_YOUR_BIRTHDAY_YOU_WILL_RECEIVE_A_GIFT_THAT_ALEGRIA_HAS_CAREFULLY_PREPARED); final SystemMessage sm1 = SystemMessage.getSystemMessage(SystemMessageId.THERE_ARE_S1_DAYS_REMAINING_UNTIL_YOUR_BIRTHDAY_ON_YOUR_BIRTHDAY_YOU_WILL_RECEIVE_A_GIFT_THAT_ALEGRIA_HAS_CAREFULLY_PREPARED);
sm.addString(Integer.toString(birthday)); sm1.addInt(birthday);
activeChar.sendPacket(sm); activeChar.sendPacket(sm1);
} }
if (!activeChar.getPremiumItemList().isEmpty()) if (!activeChar.getPremiumItemList().isEmpty())
@@ -668,7 +670,6 @@ public class EnterWorld extends L2GameClientPacket
private void engage(L2PcInstance cha) private void engage(L2PcInstance cha)
{ {
final int chaId = cha.getObjectId(); final int chaId = cha.getObjectId();
for (Couple cl : CoupleManager.getInstance().getCouples()) for (Couple cl : CoupleManager.getInstance().getCouples())
{ {
if ((cl.getPlayer1Id() == chaId) || (cl.getPlayer2Id() == chaId)) if ((cl.getPlayer1Id() == chaId) || (cl.getPlayer2Id() == chaId))
@@ -698,14 +699,10 @@ public class EnterWorld extends L2GameClientPacket
*/ */
private void notifyPartner(L2PcInstance cha, int partnerId) private void notifyPartner(L2PcInstance cha, int partnerId)
{ {
final int objId = cha.getPartnerId(); final L2PcInstance partner = L2World.getInstance().getPlayer(cha.getPartnerId());
if (objId != 0) if (partner != null)
{ {
final L2PcInstance partner = L2World.getInstance().getPlayer(objId); partner.sendMessage("Your Partner has logged in.");
if (partner != null)
{
partner.sendMessage("Your Partner has logged in.");
}
} }
} }

View File

@@ -34,7 +34,7 @@ public class RequestTutorialClientEvent extends L2GameClientPacket
@Override @Override
protected void runImpl() protected void runImpl()
{ {
final L2PcInstance player = getClient().getActiveChar(); final L2PcInstance player = getActiveChar();
if (player == null) if (player == null)
{ {

View File

@@ -24,27 +24,6 @@ import com.l2jmobius.gameserver.model.quest.QuestState;
public class QuestList extends L2GameServerPacket public class QuestList extends L2GameServerPacket
{ {
private List<Quest> _activeQuests;
private List<Quest> _completedQuests;
private L2PcInstance _activeChar;
private byte[] _info;
public QuestList()
{
}
@Override
public void runImpl()
{
if ((getClient() != null) && (getClient().getActiveChar() != null))
{
_activeChar = getClient().getActiveChar();
_activeQuests = _activeChar.getAllActiveQuests();
_completedQuests = _activeChar.getAllCompletedQuests();
_info = new byte[128];
}
}
@Override @Override
protected final void writeImpl() protected final void writeImpl()
{ {
@@ -81,12 +60,22 @@ public class QuestList extends L2GameServerPacket
* </pre> * </pre>
*/ */
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
final List<Quest> activeQuests = activeChar.getAllActiveQuests();
final List<Quest> completedQuests = activeChar.getAllCompletedQuests();
final byte[] info = new byte[128];
writeC(0x86); writeC(0x86);
writeH(_activeQuests.size()); writeH(activeQuests.size());
for (Quest q : _activeQuests) for (Quest q : activeQuests)
{ {
writeD(q.getId()); writeD(q.getId());
final QuestState qs = _activeChar.getQuestState(q.getName()); final QuestState qs = activeChar.getQuestState(q.getName());
if (qs == null) if (qs == null)
{ {
writeD(0); writeD(0);
@@ -104,7 +93,7 @@ public class QuestList extends L2GameServerPacket
} }
} }
for (Quest q : _completedQuests) for (Quest q : completedQuests)
{ {
// add completed quests // add completed quests
int questId = q.getId(); int questId = q.getId();
@@ -157,8 +146,8 @@ public class QuestList extends L2GameServerPacket
break; break;
} }
} }
_info[pos] = (byte) (_info[pos] + add); info[pos] = (byte) (info[pos] + add);
} }
writeB(_info); writeB(info);
} }
} }