From ac006cde6a20b2d39732e57e58a9936540f9abf9 Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Fri, 3 Jul 2015 21:10:51 +0000 Subject: [PATCH] Sync with L2jServer HighFive Jul 3rd 2015. --- .../scripts/ai/individual/Baium/Baium.java | 59 +++--- .../HallOfSuffering/32530-00.htm | 2 +- .../HallOfSuffering/32530-01.htm | 2 +- .../HallOfSuffering/32530-02.htm | 2 +- .../HallOfSuffering/32530-03.htm | 2 +- .../HallOfSuffering/32530-04.htm | 2 +- .../HallOfSuffering/32530-05.htm | 2 +- .../HallOfSuffering/32530-06.htm | 2 +- .../HallOfSuffering/32530-07.htm | 2 +- .../HallOfSuffering/32530-08.htm | 2 +- .../HallOfSuffering/32530-09.htm | 2 +- .../HallOfSuffering/HallOfSuffering.java | 4 +- .../gameserver/ai/L2AttackableAI.java | 32 ++-- .../data/sql/impl/AnnouncementsTable.java | 4 +- .../data/sql/impl/SummonEffectsTable.java | 2 +- .../data/xml/impl/SkillTreesData.java | 63 ++++--- .../gameserver/model/actor/L2Attackable.java | 7 +- .../gameserver/model/actor/L2Character.java | 7 +- .../model/actor/instance/L2CubicInstance.java | 55 +++--- .../model/actor/tasks/cubics/CubicAction.java | 170 +++++++++--------- .../model/actor/tasks/cubics/CubicHeal.java | 33 ++-- .../gameserver/model/entity/TvTEventTeam.java | 2 +- .../gameserver/model/event/LongTimeEvent.java | 12 +- .../model/itemcontainer/Inventory.java | 14 +- .../gameserver/model/items/L2Weapon.java | 19 +- .../gameserver/model/quest/QuestState.java | 4 +- .../gameserver/model/skills/Skill.java | 55 ++++-- .../gameserver/script/DateRange.java | 3 +- trunk/java/com/l2jserver/util/IPv4Filter.java | 14 +- 29 files changed, 311 insertions(+), 268 deletions(-) diff --git a/trunk/dist/game/data/scripts/ai/individual/Baium/Baium.java b/trunk/dist/game/data/scripts/ai/individual/Baium/Baium.java index c08c045abc..25b5cab9df 100644 --- a/trunk/dist/game/data/scripts/ai/individual/Baium/Baium.java +++ b/trunk/dist/game/data/scripts/ai/individual/Baium/Baium.java @@ -100,7 +100,6 @@ public final class Baium extends AbstractNpcAI // Misc private L2GrandBossInstance _baium = null; private static long _lastAttack = 0; - private static L2PcInstance _standbyPlayer = null; private Baium() { @@ -213,6 +212,7 @@ public final class Baium extends AbstractNpcAI _lastAttack = System.currentTimeMillis(); startQuestTimer("WAKEUP_ACTION", 50, _baium, null); startQuestTimer("MANAGE_EARTHQUAKE", 2000, _baium, null); + startQuestTimer("SOCIAL_ACTION", 10000, _baium, player); startQuestTimer("CHECK_ATTACK", 60000, _baium, null); } break; @@ -231,7 +231,6 @@ public final class Baium extends AbstractNpcAI { zone.broadcastPacket(new Earthquake(npc.getX(), npc.getY(), npc.getZ(), 40, 10)); zone.broadcastPacket(new PlaySound("BS02_A")); - startQuestTimer("SOCIAL_ACTION", 8000, npc, player); } break; } @@ -253,10 +252,18 @@ public final class Baium extends AbstractNpcAI player.teleToLocation(BAIUM_GIFT_LOC); startQuestTimer("PLAYER_KILL", 3000, npc, player); } - else if ((_standbyPlayer != null) && _standbyPlayer.isInsideRadius(npc, 16000, true, false)) + else { - _standbyPlayer.teleToLocation(BAIUM_GIFT_LOC); - startQuestTimer("PLAYER_KILL", 3000, npc, _standbyPlayer); + L2PcInstance randomPlayer = getRandomPlayer(npc); + if (randomPlayer != null) + { + randomPlayer.teleToLocation(BAIUM_GIFT_LOC); + startQuestTimer("PLAYER_KILL", 3000, npc, randomPlayer); + } + else + { + startQuestTimer("PLAYER_KILL", 3000, npc, null); + } } } break; @@ -266,20 +273,20 @@ public final class Baium extends AbstractNpcAI if ((player != null) && player.isInsideRadius(npc, 16000, true, false)) { zone.broadcastPacket(new SocialAction(npc.getObjectId(), 1)); - broadcastNpcSay(npc, ChatType.NPC_GENERAL, player.getName() + ", How dare you wake me! Now you shall die!"); // TODO: replace with NpcStringId when are done core support + broadcastNpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.HOW_DARE_YOU_WAKE_ME_NOW_YOU_SHALL_DIE, player.getName()); npc.setTarget(player); npc.doCast(BAIUM_PRESENT.getSkill()); } - for (L2PcInstance players : zone.getPlayersInside()) + for (L2PcInstance insidePlayer : zone.getPlayersInside()) { - if (players.isHero()) + if (insidePlayer.isHero()) { - zone.broadcastPacket(new ExShowScreenMessage(NpcStringId.NOT_EVEN_THE_GODS_THEMSELVES_COULD_TOUCH_ME_BUT_YOU_S1_YOU_DARE_CHALLENGE_ME_IGNORANT_MORTAL, 2, 4000, players.getName())); + zone.broadcastPacket(new ExShowScreenMessage(NpcStringId.NOT_EVEN_THE_GODS_THEMSELVES_COULD_TOUCH_ME_BUT_YOU_S1_YOU_DARE_CHALLENGE_ME_IGNORANT_MORTAL, 2, 4000, insidePlayer.getName())); break; } } - startQuestTimer("SPAWN_ARCHANGEL", 8000, npc, null); + startQuestTimer("SPAWN_ARCHANGEL", 8000, npc, player); break; } case "SPAWN_ARCHANGEL": @@ -296,19 +303,12 @@ public final class Baium extends AbstractNpcAI { addAttackPlayerDesire(npc, player); } - else if ((_standbyPlayer != null) && !_standbyPlayer.isDead()) - { - addAttackPlayerDesire(npc, _standbyPlayer); - } else { - for (L2Character creature : npc.getKnownList().getKnownCharactersInRadius(2000)) + L2PcInstance randomPlayer = getRandomPlayer(npc); + if (randomPlayer != null) { - if ((creature != null) && creature.isPlayer() && zone.isInsideZone(creature) && !creature.isDead()) - { - addAttackPlayerDesire(npc, (L2Playable) creature); - break; - } + addAttackPlayerDesire(npc, randomPlayer); } } break; @@ -377,6 +377,7 @@ public final class Baium extends AbstractNpcAI { if ((npc != null) && ((_lastAttack + 1800000) < System.currentTimeMillis())) { + cancelQuestTimers("SELECT_TARGET"); notifyEvent("CLEAR_ZONE", null, null); addSpawn(BAIUM_STONE, BAIUM_LOC, false, 0); setStatus(ALIVE); @@ -560,6 +561,7 @@ public final class Baium extends AbstractNpcAI startQuestTimer("CLEAR_STATUS", respawnTime, null, null); startQuestTimer("CLEAR_ZONE", 900000, null, null); cancelQuestTimer("CHECK_ATTACK", npc, null); + cancelQuestTimers("SELECT_TARGET"); } return super.onKill(npc, killer, isSummon); } @@ -572,11 +574,6 @@ public final class Baium extends AbstractNpcAI return super.onSeeCreature(npc, creature, isSummon); } - if (creature.isPlayer() && !creature.isDead() && (_standbyPlayer == null)) - { - _standbyPlayer = (L2PcInstance) creature; - } - if (creature.isInCategory(CategoryType.CLERIC_GROUP)) { if (npc.getCurrentHp() < (npc.getMaxHp() * 0.25)) @@ -785,6 +782,18 @@ public final class Baium extends AbstractNpcAI } } + private L2PcInstance getRandomPlayer(L2Npc npc) + { + for (L2Character creature : npc.getKnownList().getKnownCharactersInRadius(2000)) + { + if ((creature != null) && creature.isPlayer() && zone.isInsideZone(creature) && !creature.isDead()) + { + return (L2PcInstance) creature; + } + } + return null; + } + public static void main(String[] args) { new Baium(); diff --git a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-00.htm b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-00.htm index 0202fb4f98..e600211cbb 100644 --- a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-00.htm +++ b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-00.htm @@ -3,5 +3,5 @@ I'm very impressed.
No one has ever broken through this fast to the Hall of Suffering. Extraordinary! In recognition of your achievement, I will give you a Jeweled Battle Supply.
It is granted only to those who achieve an especially impressive feat in battle.
Your leader may receive it on your behalf.
-Receive the supply. +Receive the supply. \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-01.htm b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-01.htm index 194693207b..84ba9013e5 100644 --- a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-01.htm +++ b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-01.htm @@ -2,5 +2,5 @@ Unknown Text!
The reward is Mother-of-Pearl Ornamented Duel Supplies.
I'll grant this reward to the leader who represents all of you.
-Receive the supply. +Receive the supply. \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-02.htm b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-02.htm index cb372f0c46..628d042d00 100644 --- a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-02.htm +++ b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-02.htm @@ -2,5 +2,5 @@ Unknown Text!
The reward is Gold-Ornamented Duel Supplies.
I'll grant this reward to the leader who represents all of you.
-Receive the supply. +Receive the supply. \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-03.htm b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-03.htm index 5b71f5e6b9..216ba86b02 100644 --- a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-03.htm +++ b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-03.htm @@ -2,5 +2,5 @@ Unknown Text!
The reward is Silver-Ornamented Duel Supplies.
I'll grant this reward to the leader who represents all of you.
-Receive the supply. +Receive the supply. \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-04.htm b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-04.htm index 5382488f28..fc5f7d237c 100644 --- a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-04.htm +++ b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-04.htm @@ -2,5 +2,5 @@ Unknown Text!
The reward is Bronze-Ornamented Duel Supplies.
I'll grant this reward to the leader who represents all of you.
-Receive the supply. +Receive the supply. \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-05.htm b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-05.htm index a1fc93eb10..2c0e07243f 100644 --- a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-05.htm +++ b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-05.htm @@ -2,5 +2,5 @@ Unknown Text!
The reward is Non-Ornamented Duel Supplies.
I'll grant this reward to the leader who represents all of you.
-Receive the supply. +Receive the supply. \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-06.htm b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-06.htm index df1d72b6a6..b15c729f14 100644 --- a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-06.htm +++ b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-06.htm @@ -2,5 +2,5 @@ Unknown Text!
The reward is Weak-Looking Duel Supplies.
I'll grant this reward to the leader who represents all of you.
-Receive the supply. +Receive the supply. \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-07.htm b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-07.htm index cbd0f32fa6..9056ffde2c 100644 --- a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-07.htm +++ b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-07.htm @@ -2,5 +2,5 @@ Unknown Text!
The reward is Sad-Looking Duel Supplies.
I'll grant this reward to the leader who represents all of you.
-Receive the supply. +Receive the supply. \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-08.htm b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-08.htm index 0cdfac369c..c995d4a11b 100644 --- a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-08.htm +++ b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-08.htm @@ -2,5 +2,5 @@ Unknown Text!
The reward is Poor-Looking Duel Supplies.
I'll grant this reward to the leader who represents all of you.
-Receive the supply. +Receive the supply. \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-09.htm b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-09.htm index bbd83941be..5a798bf6dc 100644 --- a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-09.htm +++ b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/32530-09.htm @@ -2,5 +2,5 @@ I'm very disappointed.
If I had known your skills were this embarrasingly poor, I would not have assigned you this mission. You're lucky to still be alive! Still, a promise is a promise, so I will give you this Worthless Battle Supply.
I'll grant this reward to the leader who represents all of you.
-Receive the supply. +Receive the supply. \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/HallOfSuffering.java b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/HallOfSuffering.java index 2965406431..da012e695e 100644 --- a/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/HallOfSuffering.java +++ b/trunk/dist/game/data/scripts/gracia/instances/SeedOfInfinity/HallOfSuffering/HallOfSuffering.java @@ -188,7 +188,7 @@ public final class HallOfSuffering extends AbstractNpcAI public HallOfSuffering() { - super(HallOfSuffering.class.getSimpleName(), "gracia/instances/SeedOfInfinity/HallOfSuffering"); + super(HallOfSuffering.class.getSimpleName(), "gracia/instances/SeedOfInfinity"); addStartNpc(MOUTHOFEKIMUS, TEPIOS); addTalkId(MOUTHOFEKIMUS, TEPIOS); addFirstTalkId(TEPIOS); @@ -449,7 +449,7 @@ public final class HallOfSuffering extends AbstractNpcAI private String getPtLeaderText(L2PcInstance player, HSWorld world) { - String htmltext = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "/scripts/instances/SeedOfInfinity/HallOfSuffering/32530-10.htm"); + 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; } diff --git a/trunk/java/com/l2jserver/gameserver/ai/L2AttackableAI.java b/trunk/java/com/l2jserver/gameserver/ai/L2AttackableAI.java index a431b3eb95..758de62481 100644 --- a/trunk/java/com/l2jserver/gameserver/ai/L2AttackableAI.java +++ b/trunk/java/com/l2jserver/gameserver/ai/L2AttackableAI.java @@ -1355,11 +1355,13 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable setAttackTarget(caster.getMostHated()); } } - L2Character attackTarget = getAttackTarget(); + + final L2Character attackTarget = getAttackTarget(); if (attackTarget == null) { return false; } + double dist = caster.calculateDistance(attackTarget, false, false); double dist2 = dist - attackTarget.getTemplate().getCollisionRadius(); double range = caster.getPhysicalAttackRange() + caster.getTemplate().getCollisionRadius() + attackTarget.getTemplate().getCollisionRadius(); @@ -1376,10 +1378,9 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable if (!caster.isAffectedBySkill(sk.getId())) { clientStopMoving(null); - // L2Object target = attackTarget; caster.setTarget(caster); caster.doCast(sk); - // _actor.setTarget(target); + _actor.setTarget(attackTarget); return true; } // ---------------------------------------- @@ -1394,20 +1395,18 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable if (target != null) { clientStopMoving(null); - L2Object targets = attackTarget; caster.setTarget(target); caster.doCast(sk); - caster.setTarget(targets); + caster.setTarget(attackTarget); return true; } } if (canParty(sk)) { clientStopMoving(null); - L2Object targets = attackTarget; caster.setTarget(caster); caster.doCast(sk); - caster.setTarget(targets); + caster.setTarget(attackTarget); return true; } } @@ -1464,10 +1463,9 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable if (target != null) { clientStopMoving(null); - L2Object targets = attackTarget; caster.setTarget(target); caster.doCast(sk); - caster.setTarget(targets); + caster.setTarget(attackTarget); return true; } } @@ -1506,15 +1504,18 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable clientStopMoving(null); caster.setTarget(leader); caster.doCast(sk); + caster.setTarget(attackTarget); return true; } } } + if (Rnd.get(100) < ((100 - percentage) / 3)) { clientStopMoving(null); caster.setTarget(caster); caster.doCast(sk); + caster.setTarget(attackTarget); return true; } @@ -1541,6 +1542,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable clientStopMoving(null); caster.setTarget(obj); caster.doCast(sk); + caster.setTarget(attackTarget); return true; } } @@ -1554,6 +1556,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable { continue; } + L2Npc targets = ((L2Npc) obj); if (targets.isInMyClan(caster)) { @@ -1562,6 +1565,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable clientStopMoving(null); caster.setTarget(caster); caster.doCast(sk); + caster.setTarget(attackTarget); return true; } } @@ -1584,10 +1588,9 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable if (target != null) { clientStopMoving(null); - L2Object targets = attackTarget; caster.setTarget(target); caster.doCast(sk); - caster.setTarget(targets); + caster.setTarget(attackTarget); return true; } } @@ -1738,6 +1741,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable clientStopMoving(null); caster.setTarget(leader); caster.doCast(sk); + caster.setTarget(attackTarget); return true; } } @@ -1755,6 +1759,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable { continue; } + if (Rnd.get(100) < 10) { if (GeoData.getInstance().canSeeTarget(caster, targets)) @@ -1762,6 +1767,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable clientStopMoving(null); caster.setTarget(obj); caster.doCast(sk); + caster.setTarget(attackTarget); return true; } } @@ -1783,6 +1789,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable clientStopMoving(null); caster.setTarget(caster); caster.doCast(sk); + caster.setTarget(attackTarget); return true; } } @@ -1804,10 +1811,9 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable if (target != null) { clientStopMoving(null); - L2Object targets = attackTarget; caster.setTarget(target); caster.doCast(sk); - caster.setTarget(targets); + caster.setTarget(attackTarget); return true; } } diff --git a/trunk/java/com/l2jserver/gameserver/data/sql/impl/AnnouncementsTable.java b/trunk/java/com/l2jserver/gameserver/data/sql/impl/AnnouncementsTable.java index a236ec8b06..cc73e87ee7 100644 --- a/trunk/java/com/l2jserver/gameserver/data/sql/impl/AnnouncementsTable.java +++ b/trunk/java/com/l2jserver/gameserver/data/sql/impl/AnnouncementsTable.java @@ -112,7 +112,9 @@ public final class AnnouncementsTable { if (announce.isValid() && (announce.getType() == type)) { - player.sendPacket(new CreatureSay(0, ChatType.ANNOUNCEMENT, player.getName(), announce.getContent())); + player.sendPacket(new CreatureSay(0, // + type == AnnouncementType.CRITICAL ? ChatType.CRITICAL_ANNOUNCE : ChatType.ANNOUNCEMENT, // + player.getName(), announce.getContent())); } } } diff --git a/trunk/java/com/l2jserver/gameserver/data/sql/impl/SummonEffectsTable.java b/trunk/java/com/l2jserver/gameserver/data/sql/impl/SummonEffectsTable.java index 3bc599a822..4725e03f5c 100644 --- a/trunk/java/com/l2jserver/gameserver/data/sql/impl/SummonEffectsTable.java +++ b/trunk/java/com/l2jserver/gameserver/data/sql/impl/SummonEffectsTable.java @@ -130,7 +130,7 @@ public class SummonEffectsTable public void addPetEffect(int controlObjectId, Skill skill, int effectCurTime) { - _petEffects.putIfAbsent(controlObjectId, new ArrayList<>()).add(new SummonEffect(skill, effectCurTime)); + _petEffects.computeIfAbsent(controlObjectId, k -> new ArrayList<>()).add(new SummonEffect(skill, effectCurTime)); } public boolean containsPetId(int controlObjectId) diff --git a/trunk/java/com/l2jserver/gameserver/data/xml/impl/SkillTreesData.java b/trunk/java/com/l2jserver/gameserver/data/xml/impl/SkillTreesData.java index 943ca254aa..e7eeb15d5f 100644 --- a/trunk/java/com/l2jserver/gameserver/data/xml/impl/SkillTreesData.java +++ b/trunk/java/com/l2jserver/gameserver/data/xml/impl/SkillTreesData.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -79,29 +80,30 @@ import com.l2jserver.util.data.xml.IXmlReader; public final class SkillTreesData implements IXmlReader { // ClassId, HashMap of Skill Hash Code, L2SkillLearn - private static final Map> _classSkillTrees = new HashMap<>(); - private static final Map> _transferSkillTrees = new HashMap<>(); - private static final Map> _raceSkillTree = new HashMap<>(); - private static final Map> _revelationSkillTree = new HashMap<>(); + // ClassId, Map of Skill Hash Code, L2SkillLearn + private final Map> _classSkillTrees = new LinkedHashMap<>(); + private final Map> _transferSkillTrees = new LinkedHashMap<>(); + private static final Map> _raceSkillTree = new LinkedHashMap<>(); + private static final Map> _revelationSkillTree = new LinkedHashMap<>(); // Skill Hash Code, L2SkillLearn - private static final Map _collectSkillTree = new HashMap<>(); - private static final Map _fishingSkillTree = new HashMap<>(); - private static final Map _pledgeSkillTree = new HashMap<>(); - private static final Map _subClassSkillTree = new HashMap<>(); - private static final Map _subPledgeSkillTree = new HashMap<>(); - private static final Map _transformSkillTree = new HashMap<>(); - private static final Map _commonSkillTree = new HashMap<>(); - private static final Map _subClassChangeSkillTree = new HashMap<>(); - private static final Map _abilitySkillTree = new HashMap<>(); - private static final Map _alchemySkillTree = new HashMap<>(); - private static final Map _dualClassSkillTree = new HashMap<>(); + private static final Map _collectSkillTree = new LinkedHashMap<>(); + private static final Map _fishingSkillTree = new LinkedHashMap<>(); + private static final Map _pledgeSkillTree = new LinkedHashMap<>(); + private static final Map _subClassSkillTree = new LinkedHashMap<>(); + private static final Map _subPledgeSkillTree = new LinkedHashMap<>(); + private static final Map _transformSkillTree = new LinkedHashMap<>(); + private static final Map _commonSkillTree = new LinkedHashMap<>(); + private static final Map _subClassChangeSkillTree = new LinkedHashMap<>(); + private static final Map _abilitySkillTree = new LinkedHashMap<>(); + private static final Map _alchemySkillTree = new LinkedHashMap<>(); + private static final Map _dualClassSkillTree = new LinkedHashMap<>(); // Other skill trees - private static final Map _nobleSkillTree = new HashMap<>(); - private static final Map _heroSkillTree = new HashMap<>(); - private static final Map _gameMasterSkillTree = new HashMap<>(); - private static final Map _gameMasterAuraSkillTree = new HashMap<>(); + private static final Map _nobleSkillTree = new LinkedHashMap<>(); + private static final Map _heroSkillTree = new LinkedHashMap<>(); + private static final Map _gameMasterSkillTree = new LinkedHashMap<>(); + private static final Map _gameMasterAuraSkillTree = new LinkedHashMap<>(); // Remove skill tree - private static final Map> _removeSkillCache = new HashMap<>(); + private static final Map> _removeSkillCache = new LinkedHashMap<>(); // Checker, sorted arrays of hash codes private Map _skillsByClassIdHashCodes; // Occupation skills @@ -110,8 +112,8 @@ public final class SkillTreesData implements IXmlReader private boolean _loading = true; - /** Parent class Ids are read from XML and stored in this map, to allow easy customization. */ - private static final Map _parentClassMap = new HashMap<>(); + /** Parent class IDs are read from XML and stored in this map, to allow easy customization. */ + private final Map _parentClassMap = new LinkedHashMap<>(); /** * Instantiates a new skill trees data. @@ -418,14 +420,25 @@ public final class SkillTreesData implements IXmlReader */ public Map getCompleteClassSkillTree(ClassId classId) { - final Map skillTree = new HashMap<>(); + final Map skillTree = new LinkedHashMap<>(); // Add all skills that belong to all classes. skillTree.putAll(_commonSkillTree); - while ((classId != null) && (_classSkillTrees.get(classId) != null)) + + final LinkedList classSequence = new LinkedList<>(); + while (classId != null) { - skillTree.putAll(_classSkillTrees.get(classId)); + classSequence.addFirst(classId); classId = _parentClassMap.get(classId); } + + for (ClassId cid : classSequence) + { + final Map classSkillTree = _classSkillTrees.get(cid); + if (classSkillTree != null) + { + skillTree.putAll(classSkillTree); + } + } return skillTree; } diff --git a/trunk/java/com/l2jserver/gameserver/model/actor/L2Attackable.java b/trunk/java/com/l2jserver/gameserver/model/actor/L2Attackable.java index e28d8792e2..9a9b5e7b21 100644 --- a/trunk/java/com/l2jserver/gameserver/model/actor/L2Attackable.java +++ b/trunk/java/com/l2jserver/gameserver/model/actor/L2Attackable.java @@ -685,7 +685,7 @@ public class L2Attackable extends L2Npc } /** - * Add damage and hate to the attacker AggroInfo of the L2Attackable _aggroList. + * Adds damage and hate to the attacker aggression list for this character. * @param attacker The L2Character that gave damages to this L2Attackable * @param damage The number of damages given by the attacker L2Character * @param aggro The hate (=damage) given by the attacker L2Character @@ -697,13 +697,14 @@ public class L2Attackable extends L2Npc return; } - final L2PcInstance targetPlayer = attacker.getActingPlayer(); // Get the AggroInfo of the attacker L2Character from the _aggroList of the L2Attackable final AggroInfo ai = getAggroList().computeIfAbsent(attacker, AggroInfo::new); ai.addDamage(damage); - // traps does not cause aggro + + // Traps does not cause aggro // making this hack because not possible to determine if damage made by trap // so just check for triggered trap here + final L2PcInstance targetPlayer = attacker.getActingPlayer(); if ((targetPlayer == null) || (targetPlayer.getTrap() == null) || !targetPlayer.getTrap().isTriggered()) { ai.addHate(aggro); diff --git a/trunk/java/com/l2jserver/gameserver/model/actor/L2Character.java b/trunk/java/com/l2jserver/gameserver/model/actor/L2Character.java index d8c86c080c..075160b2b2 100644 --- a/trunk/java/com/l2jserver/gameserver/model/actor/L2Character.java +++ b/trunk/java/com/l2jserver/gameserver/model/actor/L2Character.java @@ -5387,7 +5387,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe if (newSkill.isPassive()) { - newSkill.applyEffects(this, null, this, false, true, false, 0); + newSkill.applyEffects(this, this, false, true, false, 0); } } return oldSkill; @@ -6070,8 +6070,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe } } } + // Notify AI - if (skill.isBad() && (skill.getTargetType() != L2TargetType.SELF) && !skill.hasEffectType(L2EffectType.HATE)) + if (skill.isBad() && !skill.hasEffectType(L2EffectType.HATE)) { for (L2Object target : targets) { @@ -6080,7 +6081,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe final L2Character creature = (L2Character) target; if (creature.hasAI()) { - // notify target AI about the attack + // Notify target AI about the attack creature.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, this); } } diff --git a/trunk/java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java b/trunk/java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java index 575c488674..d32f0af87d 100644 --- a/trunk/java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java +++ b/trunk/java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java @@ -33,7 +33,6 @@ import com.l2jserver.gameserver.model.L2Object; import com.l2jserver.gameserver.model.L2Party; import com.l2jserver.gameserver.model.actor.L2Attackable; import com.l2jserver.gameserver.model.actor.L2Character; -import com.l2jserver.gameserver.model.actor.L2Playable; import com.l2jserver.gameserver.model.actor.L2Summon; import com.l2jserver.gameserver.model.actor.tasks.cubics.CubicAction; import com.l2jserver.gameserver.model.actor.tasks.cubics.CubicDisappear; @@ -356,7 +355,7 @@ public final class L2CubicInstance implements IIdentifiable { if (_owner.isOlympiadStart()) { - if (ownerTarget instanceof L2Playable) + if (ownerTarget.isPlayable()) { final L2PcInstance targetPlayer = ownerTarget.getActingPlayer(); if ((targetPlayer != null) && (targetPlayer.getOlympiadGameId() == _owner.getOlympiadGameId()) && (targetPlayer.getOlympiadSide() != _owner.getOlympiadSide())) @@ -372,23 +371,24 @@ public final class L2CubicInstance implements IIdentifiable if (ownerTarget.isCharacter() && (ownerTarget != pet) && !_owner.hasServitor(ownerTarget.getObjectId()) && (ownerTarget != _owner)) { // target mob which has aggro on you or your summon - if (ownerTarget instanceof L2Attackable) + if (ownerTarget.isAttackable()) { - if ((((L2Attackable) ownerTarget).getAggroList().get(_owner) != null) && !((L2Attackable) ownerTarget).isDead()) + final L2Attackable attackable = (L2Attackable) ownerTarget; + if ((attackable.getAggroList().get(_owner) != null) && !attackable.isDead()) { _target = (L2Character) ownerTarget; return; } if (_owner.hasSummon()) { - if ((((L2Attackable) ownerTarget).getAggroList().get(pet) != null) && !((L2Attackable) ownerTarget).isDead()) + if ((attackable.getAggroList().get(pet) != null) && !attackable.isDead()) { _target = (L2Character) ownerTarget; return; } for (L2Summon servitor : _owner.getServitors().values()) { - if ((((L2Attackable) ownerTarget).getAggroList().get(servitor) != null) && !((L2Attackable) ownerTarget).isDead()) + if ((attackable.getAggroList().get(servitor) != null) && !attackable.isDead()) { _target = (L2Character) ownerTarget; return; @@ -482,21 +482,21 @@ public final class L2CubicInstance implements IIdentifiable if (skill.isBad()) { - byte shld = Formulas.calcShldUse(getOwner(), target, skill); + byte shld = Formulas.calcShldUse(_owner, target, skill); boolean acted = Formulas.calcCubicSkillSuccess(this, target, skill, shld); if (!acted) { - getOwner().sendPacket(SystemMessageId.YOUR_ATTACK_HAS_FAILED); + _owner.sendPacket(SystemMessageId.YOUR_ATTACK_HAS_FAILED); continue; } } // Apply effects - skill.applyEffects(getOwner(), this, target, false, false, true, 0); + skill.applyEffects(_owner, target, false, false, true, 0); // If this is a bad skill notify the duel manager, so it can be removed after the duel (player & target must be in the same duel). - if (target.isPlayer() && target.getActingPlayer().isInDuel() && skill.isBad() && (getOwner().getDuelId() == target.getActingPlayer().getDuelId())) + if (target.isPlayer() && target.getActingPlayer().isInDuel() && skill.isBad() && (_owner.getDuelId() == target.getActingPlayer().getDuelId())) { DuelManager.getInstance().onBuff(target.getActingPlayer(), skill); } @@ -504,11 +504,10 @@ public final class L2CubicInstance implements IIdentifiable } /** - * @param activeCubic * @param skill * @param targets */ - public void useCubicMdam(L2CubicInstance activeCubic, Skill skill, L2Object[] targets) + public void useCubicMdam(Skill skill, L2Object[] targets) { for (L2Character target : (L2Character[]) targets) { @@ -529,9 +528,9 @@ public final class L2CubicInstance implements IIdentifiable } } - boolean mcrit = Formulas.calcMCrit(activeCubic.getOwner().getMCriticalHit(target, skill)); - byte shld = Formulas.calcShldUse(activeCubic.getOwner(), target, skill); - int damage = (int) Formulas.calcMagicDam(activeCubic, target, skill, mcrit, shld); + boolean mcrit = Formulas.calcMCrit(_owner.getMCriticalHit(target, skill)); + byte shld = Formulas.calcShldUse(_owner, target, skill); + int damage = (int) Formulas.calcMagicDam(this, target, skill, mcrit, shld); if (Config.DEBUG) { @@ -554,14 +553,14 @@ public final class L2CubicInstance implements IIdentifiable } else { - activeCubic.getOwner().sendDamageMessage(target, damage, mcrit, false, false); - target.reduceCurrentHp(damage, activeCubic.getOwner(), skill); + _owner.sendDamageMessage(target, damage, mcrit, false, false); + target.reduceCurrentHp(damage, _owner, skill); } } } } - public void useCubicDrain(L2CubicInstance activeCubic, Skill skill, L2Object[] targets) + public void useCubicDrain(Skill skill, L2Object[] targets) { if (Config.DEBUG) { @@ -575,10 +574,10 @@ public final class L2CubicInstance implements IIdentifiable continue; } - boolean mcrit = Formulas.calcMCrit(activeCubic.getOwner().getMCriticalHit(target, skill)); - byte shld = Formulas.calcShldUse(activeCubic.getOwner(), target, skill); + boolean mcrit = Formulas.calcMCrit(_owner.getMCriticalHit(target, skill)); + byte shld = Formulas.calcShldUse(_owner, target, skill); - int damage = (int) Formulas.calcMagicDam(activeCubic, target, skill, mcrit, shld); + int damage = (int) Formulas.calcMagicDam(this, target, skill, mcrit, shld); if (Config.DEBUG) { _log.info("L2SkillDrain: useCubicSkill() -> damage = " + damage); @@ -586,7 +585,7 @@ public final class L2CubicInstance implements IIdentifiable // TODO: Unhardcode fixed value double hpAdd = (0.4 * damage); - L2PcInstance owner = activeCubic.getOwner(); + L2PcInstance owner = _owner; double hp = ((owner.getCurrentHp() + hpAdd) > owner.getMaxHp() ? owner.getMaxHp() : (owner.getCurrentHp() + hpAdd)); owner.setCurrentHp(hp); @@ -594,7 +593,7 @@ public final class L2CubicInstance implements IIdentifiable // Check to see if we should damage the target if ((damage > 0) && !target.isDead()) { - target.reduceCurrentHp(damage, activeCubic.getOwner(), skill); + target.reduceCurrentHp(damage, _owner, skill); // Manage attack or cast break of the target (calculating rate, sending message...) if (!target.isRaid() && Formulas.calcAtkBreak(target, damage)) @@ -621,17 +620,17 @@ public final class L2CubicInstance implements IIdentifiable continue; } - byte shld = Formulas.calcShldUse(getOwner(), target, skill); + byte shld = Formulas.calcShldUse(_owner, target, skill); if (skill.hasEffectType(L2EffectType.STUN, L2EffectType.PARALYZE, L2EffectType.ROOT)) { if (Formulas.calcCubicSkillSuccess(this, target, skill, shld)) { // Apply effects - skill.applyEffects(getOwner(), this, target, false, false, true, 0); + skill.applyEffects(_owner, target, false, false, true, 0); // If this is a bad skill notify the duel manager, so it can be removed after the duel (player & target must be in the same duel). - if (target.isPlayer() && target.getActingPlayer().isInDuel() && skill.isBad() && (getOwner().getDuelId() == target.getActingPlayer().getDuelId())) + if (target.isPlayer() && target.getActingPlayer().isInDuel() && skill.isBad() && (_owner.getDuelId() == target.getActingPlayer().getDuelId())) { DuelManager.getInstance().onBuff(target.getActingPlayer(), skill); } @@ -656,11 +655,11 @@ public final class L2CubicInstance implements IIdentifiable { if (target.isAttackable()) { - target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, getOwner(), (int) ((150 * skill.getPower()) / (target.getLevel() + 7))); + target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _owner, (int) ((150 * skill.getPower()) / (target.getLevel() + 7))); } // Apply effects - skill.applyEffects(getOwner(), this, target, false, false, true, 0); + skill.applyEffects(_owner, target, false, false, true, 0); if (Config.DEBUG) { diff --git a/trunk/java/com/l2jserver/gameserver/model/actor/tasks/cubics/CubicAction.java b/trunk/java/com/l2jserver/gameserver/model/actor/tasks/cubics/CubicAction.java index 9e466f418c..761a9f20a9 100644 --- a/trunk/java/com/l2jserver/gameserver/model/actor/tasks/cubics/CubicAction.java +++ b/trunk/java/com/l2jserver/gameserver/model/actor/tasks/cubics/CubicAction.java @@ -121,100 +121,102 @@ public final class CubicAction implements Runnable } else if (Rnd.get(1, 100) < _chance) { - Skill skill = _cubic.getSkills().get(Rnd.get(_cubic.getSkills().size())); - if (skill != null) + final Skill skill = _cubic.getSkills().get(Rnd.get(_cubic.getSkills().size())); + if (skill == null) { - if (skill.getId() == L2CubicInstance.SKILL_CUBIC_HEAL) + return; + } + + if (skill.getId() == L2CubicInstance.SKILL_CUBIC_HEAL) + { + // friendly skill, so we look a target in owner's party + _cubic.cubicTargetForHeal(); + } + else + { + // offensive skill, we look for an enemy target + _cubic.getCubicTarget(); + if (!L2CubicInstance.isInCubicRange(_cubic.getOwner(), _cubic.getTarget())) { - // friendly skill, so we look a target in owner's party - _cubic.cubicTargetForHeal(); + _cubic.setTarget(null); } - else + } + L2Character target = _cubic.getTarget(); + if ((target != null) && !target.isDead()) + { + if (Config.DEBUG) { - // offensive skill, we look for an enemy target - _cubic.getCubicTarget(); - if (!L2CubicInstance.isInCubicRange(_cubic.getOwner(), _cubic.getTarget())) - { - _cubic.setTarget(null); - } + _log.info("L2CubicInstance: Action.run();"); + _log.info("Cubic ID: " + _cubic.getId() + " Target: " + target.getName() + " distance: " + target.calculateDistance(_cubic.getOwner(), true, false)); } - L2Character target = _cubic.getTarget(); - if ((target != null) && !target.isDead()) + + _cubic.getOwner().broadcastPacket(new MagicSkillUse(_cubic.getOwner(), target, skill.getId(), skill.getLevel(), 0, 0)); + + L2Character[] targets = + { + target + }; + + if (skill.isContinuous()) { if (Config.DEBUG) { - _log.info("L2CubicInstance: Action.run();"); - _log.info("Cubic ID: " + _cubic.getId() + " Target: " + target.getName() + " distance: " + target.calculateDistance(_cubic.getOwner(), true, false)); + _log.info("L2CubicInstance: Action.run() skill " + skill); } - - _cubic.getOwner().broadcastPacket(new MagicSkillUse(_cubic.getOwner(), target, skill.getId(), skill.getLevel(), 0, 0)); - - L2Character[] targets = - { - target - }; - - if (skill.isContinuous()) - { - if (Config.DEBUG) - { - _log.info("L2CubicInstance: Action.run() skill " + skill); - } - _cubic.useCubicContinuous(skill, targets); - } - else - { - skill.activateSkill(_cubic.getOwner(), targets); - if (Config.DEBUG) - { - _log.info("L2CubicInstance: Action.run(); other handler"); - } - } - - if (skill.hasEffectType(L2EffectType.MAGICAL_ATTACK)) - { - if (Config.DEBUG) - { - _log.info("L2CubicInstance: Action.run() skill " + skill); - } - _cubic.useCubicMdam(_cubic, skill, targets); - } - else if (skill.hasEffectType(L2EffectType.HP_DRAIN)) - { - if (Config.DEBUG) - { - _log.info("L2CubicInstance: Action.run() skill " + skill); - } - _cubic.useCubicDrain(_cubic, skill, targets); - } - else if (skill.hasEffectType(L2EffectType.STUN, L2EffectType.ROOT, L2EffectType.PARALYZE)) - { - if (Config.DEBUG) - { - _log.info("L2CubicInstance: Action.run() skill " + skill); - } - _cubic.useCubicDisabler(skill, targets); - } - else if (skill.hasEffectType(L2EffectType.DMG_OVER_TIME, L2EffectType.DMG_OVER_TIME_PERCENT)) - { - if (Config.DEBUG) - { - _log.info("L2CubicInstance: Action.run() skill " + skill); - } - _cubic.useCubicContinuous(skill, targets); - } - else if (skill.hasEffectType(L2EffectType.AGGRESSION)) - { - if (Config.DEBUG) - { - _log.info("L2CubicInstance: Action.run() skill " + skill); - } - _cubic.useCubicDisabler(skill, targets); - } - - // The cubic has done an action, increase the current count - _currentCount.incrementAndGet(); + _cubic.useCubicContinuous(skill, targets); } + else + { + skill.activateSkill(_cubic, targets); + if (Config.DEBUG) + { + _log.info("L2CubicInstance: Action.run(); other handler"); + } + } + + if (skill.hasEffectType(L2EffectType.MAGICAL_ATTACK)) + { + if (Config.DEBUG) + { + _log.info("L2CubicInstance: Action.run() skill " + skill); + } + _cubic.useCubicMdam(skill, targets); + } + else if (skill.hasEffectType(L2EffectType.HP_DRAIN)) + { + if (Config.DEBUG) + { + _log.info("L2CubicInstance: Action.run() skill " + skill); + } + _cubic.useCubicDrain(skill, targets); + } + else if (skill.hasEffectType(L2EffectType.STUN, L2EffectType.ROOT, L2EffectType.PARALYZE)) + { + if (Config.DEBUG) + { + _log.info("L2CubicInstance: Action.run() skill " + skill); + } + _cubic.useCubicDisabler(skill, targets); + } + else if (skill.hasEffectType(L2EffectType.DMG_OVER_TIME, L2EffectType.DMG_OVER_TIME_PERCENT)) + { + if (Config.DEBUG) + { + _log.info("L2CubicInstance: Action.run() skill " + skill); + } + _cubic.useCubicContinuous(skill, targets); + } + else if (skill.hasEffectType(L2EffectType.AGGRESSION)) + { + if (Config.DEBUG) + { + _log.info("L2CubicInstance: Action.run() skill " + skill); + } + _cubic.useCubicDisabler(skill, targets); + } + + // The cubic has done an action, increase the current count + _currentCount.incrementAndGet(); } } } diff --git a/trunk/java/com/l2jserver/gameserver/model/actor/tasks/cubics/CubicHeal.java b/trunk/java/com/l2jserver/gameserver/model/actor/tasks/cubics/CubicHeal.java index 3443e0f4b2..96a574a3ac 100644 --- a/trunk/java/com/l2jserver/gameserver/model/actor/tasks/cubics/CubicHeal.java +++ b/trunk/java/com/l2jserver/gameserver/model/actor/tasks/cubics/CubicHeal.java @@ -56,35 +56,24 @@ public class CubicHeal implements Runnable _cubic.cancelDisappear(); return; } + try { - Skill skill = null; - for (Skill sk : _cubic.getSkills()) + final Skill skill = _cubic.getSkills().stream().filter(s -> s.getId() == L2CubicInstance.SKILL_CUBIC_HEAL).findFirst().orElse(null); + if (skill == null) { - if (sk.getId() == L2CubicInstance.SKILL_CUBIC_HEAL) - { - skill = sk; - break; - } + return; } - if (skill != null) + _cubic.cubicTargetForHeal(); + final L2Character target = _cubic.getTarget(); + if ((target != null) && !target.isDead()) { - _cubic.cubicTargetForHeal(); - final L2Character target = _cubic.getTarget(); - if ((target != null) && !target.isDead()) + if ((target.getMaxHp() - target.getCurrentHp()) > skill.getPower()) { - if ((target.getMaxHp() - target.getCurrentHp()) > skill.getPower()) - { - L2Character[] targets = - { - target - }; - - skill.activateSkill(_cubic.getOwner(), targets); - - _cubic.getOwner().broadcastPacket(new MagicSkillUse(_cubic.getOwner(), target, skill.getId(), skill.getLevel(), 0, 0)); - } + skill.activateSkill(_cubic, target); + + _cubic.getOwner().broadcastPacket(new MagicSkillUse(_cubic.getOwner(), target, skill.getId(), skill.getLevel(), 0, 0)); } } } diff --git a/trunk/java/com/l2jserver/gameserver/model/entity/TvTEventTeam.java b/trunk/java/com/l2jserver/gameserver/model/entity/TvTEventTeam.java index 71e276c208..616e6f9299 100644 --- a/trunk/java/com/l2jserver/gameserver/model/entity/TvTEventTeam.java +++ b/trunk/java/com/l2jserver/gameserver/model/entity/TvTEventTeam.java @@ -135,7 +135,7 @@ public class TvTEventTeam } /** - * Returns name and instance of all participated players in FastMap
+ * Returns name and instance of all participated players in Map
*
* @return Map: map of players in this team
*/ diff --git a/trunk/java/com/l2jserver/gameserver/model/event/LongTimeEvent.java b/trunk/java/com/l2jserver/gameserver/model/event/LongTimeEvent.java index 9cd3d67497..346d176c0d 100644 --- a/trunk/java/com/l2jserver/gameserver/model/event/LongTimeEvent.java +++ b/trunk/java/com/l2jserver/gameserver/model/event/LongTimeEvent.java @@ -97,7 +97,7 @@ public class LongTimeEvent extends Quest { long delay = _eventPeriod.getStartDate().getTime() - System.currentTimeMillis(); ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleStart(), delay); - _log.info("Event " + _eventName + " will be started at " + _eventPeriod.getEndDate()); + _log.info("Event " + _eventName + " will be started at " + _eventPeriod.getStartDate()); } else { @@ -266,17 +266,21 @@ public class LongTimeEvent extends Quest */ protected void startEvent() { + long currentTime = System.currentTimeMillis(); // Add drop if (_dropList != null) { - for (GeneralDropItem drop : _dropList) + if (currentTime < _dropPeriod.getEndDate().getTime()) { - EventDroplist.getInstance().addGlobalDrop(drop.getItemId(), drop.getMin(), drop.getMax(), (int) drop.getChance(), _dropPeriod); + for (GeneralDropItem drop : _dropList) + { + EventDroplist.getInstance().addGlobalDrop(drop.getItemId(), drop.getMin(), drop.getMax(), (int) drop.getChance(), _dropPeriod); + } } } // Add spawns - Long millisToEventEnd = _eventPeriod.getEndDate().getTime() - System.currentTimeMillis(); + Long millisToEventEnd = _eventPeriod.getEndDate().getTime() - currentTime; if (_spawnList != null) { for (NpcSpawn spawn : _spawnList) diff --git a/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java b/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java index b3f07c63b1..0b5832ad8d 100644 --- a/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java +++ b/trunk/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java @@ -385,12 +385,7 @@ public abstract class Inventory extends ItemContainer final Skill unequipSkill = it.getUnequipSkill(); if (unequipSkill != null) { - L2PcInstance[] targets = - { - player - }; - - unequipSkill.activateSkill(player, targets); + unequipSkill.activateSkill(player, player); } // Remove itemEquip skill @@ -492,12 +487,7 @@ public abstract class Inventory extends ItemContainer final Skill itemEquipSkill = it.getEquipSkill(); if (itemEquipSkill != null) { - L2PcInstance[] targets = - { - player - }; - - itemEquipSkill.activateSkill(player, targets); + itemEquipSkill.activateSkill(player, player); } if (update) diff --git a/trunk/java/com/l2jserver/gameserver/model/items/L2Weapon.java b/trunk/java/com/l2jserver/gameserver/model/items/L2Weapon.java index 8e17161255..0e569e4b42 100644 --- a/trunk/java/com/l2jserver/gameserver/model/items/L2Weapon.java +++ b/trunk/java/com/l2jserver/gameserver/model/items/L2Weapon.java @@ -365,12 +365,7 @@ public final class L2Weapon extends L2Item return; } - L2Character[] targets = - { - target - }; - - onCritSkill.activateSkill(caster, targets); + onCritSkill.activateSkill(caster, target); } /** @@ -429,18 +424,18 @@ public final class L2Weapon extends L2Item return; } - L2Character[] targets = - { - target - }; - // Launch the magic skill and calculate its effects // Get the skill handler corresponding to the skill type - onMagicSkill.activateSkill(caster, targets); + onMagicSkill.activateSkill(caster, target); // notify quests of a skill use if (caster instanceof L2PcInstance) { + L2Character[] targets = + { + target + }; + //@formatter:off caster.getKnownList().getKnownObjects().values().stream() .filter(Objects::nonNull) diff --git a/trunk/java/com/l2jserver/gameserver/model/quest/QuestState.java b/trunk/java/com/l2jserver/gameserver/model/quest/QuestState.java index 7f99090612..240cd2a1ca 100644 --- a/trunk/java/com/l2jserver/gameserver/model/quest/QuestState.java +++ b/trunk/java/com/l2jserver/gameserver/model/quest/QuestState.java @@ -221,8 +221,8 @@ public final class QuestState *
    *
  • Initialize class variable "vars" if is null.
  • *
  • Initialize parameter "val" if is null
  • - *
  • Add/Update couple (var,val) in class variable HashMap "vars"
  • - *
  • If the key represented by "var" exists in HashMap "vars", the couple (var,val) is updated in the database.
    + *
  • Add/Update couple (var,val) in class variable Map "vars"
  • + *
  • If the key represented by "var" exists in Map "vars", the couple (var,val) is updated in the database.
    * The key is known as existing if the preceding value of the key (given as result of function put()) is not null.
    * If the key doesn't exist, the couple is added/created in the database
  • *
      diff --git a/trunk/java/com/l2jserver/gameserver/model/skills/Skill.java b/trunk/java/com/l2jserver/gameserver/model/skills/Skill.java index 66aa699955..3bc197906d 100644 --- a/trunk/java/com/l2jserver/gameserver/model/skills/Skill.java +++ b/trunk/java/com/l2jserver/gameserver/model/skills/Skill.java @@ -886,7 +886,7 @@ public final class Skill implements IIdentifiable public boolean useSoulShot() { - return (hasEffectType(L2EffectType.PHYSICAL_ATTACK, L2EffectType.PHYSICAL_ATTACK_HP_LINK)); + return hasEffectType(L2EffectType.PHYSICAL_ATTACK, L2EffectType.PHYSICAL_ATTACK_HP_LINK); } public boolean useSpiritShot() @@ -1324,18 +1324,18 @@ public final class Skill implements IIdentifiable } /** - * Method overload for {@link Skill#applyEffects(L2Character, L2CubicInstance, L2Character, boolean, boolean, boolean, int)}.
      + * Method overload for {@link Skill#applyEffects(L2Character, L2Character, boolean, boolean, boolean, int)}.
      * Simplify the calls. * @param effector the caster of the skill * @param effected the target of the effect */ public void applyEffects(L2Character effector, L2Character effected) { - applyEffects(effector, null, effected, false, false, true, 0); + applyEffects(effector, effected, false, false, true, 0); } /** - * Method overload for {@link Skill#applyEffects(L2Character, L2CubicInstance, L2Character, boolean, boolean, boolean, int)}.
      + * Method overload for {@link Skill#applyEffects(L2Character, L2Character, boolean, boolean, boolean, int)}.
      * Simplify the calls, allowing abnormal time time customization. * @param effector the caster of the skill * @param effected the target of the effect @@ -1344,20 +1344,19 @@ public final class Skill implements IIdentifiable */ public void applyEffects(L2Character effector, L2Character effected, boolean instant, int abnormalTime) { - applyEffects(effector, null, effected, false, false, instant, abnormalTime); + applyEffects(effector, effected, false, false, instant, abnormalTime); } /** * Applies the effects from this skill to the target. * @param effector the caster of the skill - * @param cubic the cubic that cast the skill, can be {@code null} * @param effected the target of the effect * @param self if {@code true} self-effects will be casted on the caster * @param passive if {@code true} passive effects will be applied to the effector * @param instant if {@code true} instant effects will be applied to the effected * @param abnormalTime custom abnormal time, if equal or lesser than zero will be ignored */ - public void applyEffects(L2Character effector, L2CubicInstance cubic, L2Character effected, boolean self, boolean passive, boolean instant, int abnormalTime) + public void applyEffects(L2Character effector, L2Character effected, boolean self, boolean passive, boolean instant, int abnormalTime) { // null targets cannot receive any effects. if (effected == null) @@ -1449,11 +1448,32 @@ public final class Skill implements IIdentifiable } /** - * Activates the skill to the targets. + * Activates a skill for the given creature and targets. * @param caster the caster * @param targets the targets */ - public void activateSkill(L2Character caster, L2Object[] targets) + public void activateSkill(L2Character caster, L2Object... targets) + { + activateSkill(caster, null, targets); + } + + /** + * Activates a skill for the given cubic and targets. + * @param cubic the cubic + * @param targets the targets + */ + public void activateSkill(L2CubicInstance cubic, L2Object... targets) + { + activateSkill(cubic.getOwner(), cubic, targets); + } + + /** + * Activates the skill to the targets. + * @param caster the caster + * @param cubic the cubic, can be {@code null} + * @param targets the targets + */ + private void activateSkill(L2Character caster, L2CubicInstance cubic, L2Object... targets) { switch (getId()) { @@ -1525,16 +1545,19 @@ public final class Skill implements IIdentifiable { caster.stopSkillEffects(true, getId()); } - applyEffects(caster, null, caster, true, false, true, 0); + applyEffects(caster, caster, true, false, true, 0); } - if (useSpiritShot()) + if (cubic == null) { - caster.setChargedShot(caster.isChargedShot(ShotType.BLESSED_SPIRITSHOTS) ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS, false); - } - else if (useSoulShot()) - { - caster.setChargedShot(ShotType.SOULSHOTS, false); + if (useSpiritShot()) + { + caster.setChargedShot(caster.isChargedShot(ShotType.BLESSED_SPIRITSHOTS) ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS, false); + } + else if (useSoulShot()) + { + caster.setChargedShot(ShotType.SOULSHOTS, false); + } } } diff --git a/trunk/java/com/l2jserver/gameserver/script/DateRange.java b/trunk/java/com/l2jserver/gameserver/script/DateRange.java index 4f217ad829..6552925c69 100644 --- a/trunk/java/com/l2jserver/gameserver/script/DateRange.java +++ b/trunk/java/com/l2jserver/gameserver/script/DateRange.java @@ -65,7 +65,8 @@ public class DateRange public boolean isWithinRange(Date date) { - return date.after(_startDate) && date.before(_endDate); + return (date.equals(_startDate) || date.after(_startDate)) // + && (date.equals(_endDate) || date.before(_endDate)); } public Date getEndDate() diff --git a/trunk/java/com/l2jserver/util/IPv4Filter.java b/trunk/java/com/l2jserver/util/IPv4Filter.java index 5443e65026..b4306c1527 100644 --- a/trunk/java/com/l2jserver/util/IPv4Filter.java +++ b/trunk/java/com/l2jserver/util/IPv4Filter.java @@ -18,20 +18,23 @@ */ package com.l2jserver.util; +import java.net.Inet4Address; import java.net.InetAddress; import java.nio.channels.SocketChannel; import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; +import java.util.logging.Logger; import commons.mmocore.IAcceptFilter; /** * IPv4 filter. - * @author Forsaiken + * @author Forsaiken, Zoey76 */ public class IPv4Filter implements IAcceptFilter, Runnable { + private static final Logger LOG = Logger.getLogger(IPv4Filter.class.getName()); private final HashMap _ipFloodMap; private static final long SLEEP_TIME = 5000; @@ -67,9 +70,14 @@ public class IPv4Filter implements IAcceptFilter, Runnable @Override public boolean accept(SocketChannel sc) { - InetAddress addr = sc.socket().getInetAddress(); - int h = hash(addr.getAddress()); + final InetAddress addr = sc.socket().getInetAddress(); + if (!(addr instanceof Inet4Address)) + { + LOG.info(IPv4Filter.class.getSimpleName() + ": Someone tried to connect from something other than IPv4: " + addr.getHostAddress()); + return false; + } + final int h = hash(addr.getAddress()); long current = System.currentTimeMillis(); Flood f; synchronized (_ipFloodMap)