L2JMobius
Free Users => Solved/Invalid Bug Reports => Topic started by: akado on October 09, 2019, 05:57:14 PM
-
- Summon cubics lvl1 not work. Only Cubics 2lvl + work ok. (Testing Elemental Summoner)
[09/10 20:51:56] PlayerInstance:Поняша[268489789] callSkill() failed.
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at handlers.effecthandlers.SummonCubic.instant(SummonCubic.java:98)
at org.l2jmobius.gameserver.model.skills.Skill.applyEffectScope(Skill.java:1234)
at org.l2jmobius.gameserver.model.skills.Skill.applyEffects(Skill.java:1328)
at org.l2jmobius.gameserver.model.skills.Skill.applyEffects(Skill.java:1280)
at org.l2jmobius.gameserver.model.skills.Skill.activateSkill(Skill.java:1485)
at org.l2jmobius.gameserver.model.skills.Skill.activateSkill(Skill.java:1441)
at org.l2jmobius.gameserver.model.skills.SkillCaster.callSkill(SkillCaster.java:604)
at org.l2jmobius.gameserver.model.skills.SkillCaster.finishSkill(SkillCaster.java:515)
at org.l2jmobius.gameserver.model.skills.SkillCaster.run(SkillCaster.java:212)
at org.l2jmobius.commons.concurrent.RunnableWrapper.run(RunnableWrapper.java:42)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:835)
-
What level player and what skill id/level you used?
-
Try this.
Index: dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java (revision 5990)
+++ dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java (working copy)
@@ -18,7 +18,6 @@
import java.util.logging.Logger;
-import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.impl.CubicData;
import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.Creature;
@@ -93,10 +92,9 @@
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
- for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
+ if (currentCubicCount >= allowedCubicCount)
{
- final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
- final CubicInstance removedCubic = player.getCubicById(removedCubicId);
+ final CubicInstance removedCubic = player.getCubicById(player.getCubics().values().stream().findAny().get().getTemplate().getId());
removedCubic.deactivate();
}
}
-
Try this.
Index: dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java (revision 5990)
+++ dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java (working copy)
@@ -18,7 +18,6 @@
import java.util.logging.Logger;
-import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.impl.CubicData;
import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.Creature;
@@ -93,10 +92,9 @@
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
- for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
+ if (currentCubicCount >= allowedCubicCount)
{
- final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
- final CubicInstance removedCubic = player.getCubicById(removedCubicId);
+ final CubicInstance removedCubic = player.getCubicById(player.getCubics().values().stream().findAny().get().getTemplate().getId());
removedCubic.deactivate();
}
}
tested Mobius with your patch, everything works fine.
-
Improved version.
Need to remove random cubic.
Index: dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java (revision 5990)
+++ dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java (working copy)
@@ -90,14 +90,12 @@
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
- final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
+ final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
- for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
+ if (currentCubicCount >= allowedCubicCount)
{
- final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
- final CubicInstance removedCubic = player.getCubicById(removedCubicId);
- removedCubic.deactivate();
+ player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}
-
Improved version.
Need to remove random cubic.
Index: dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java (revision 5990)
+++ dist/game/data/scripts/handlers/effecthandlers/SummonCubic.java (working copy)
@@ -90,14 +90,12 @@
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
- final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
+ final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
- for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
+ if (currentCubicCount >= allowedCubicCount)
{
- final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
- final CubicInstance removedCubic = player.getCubicById(removedCubicId);
- removedCubic.deactivate();
+ player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}
Tested, everything works fine.
-
Fixed with revision 6014.