Make use of script random methods.

This commit is contained in:
MobiusDevelopment
2022-01-28 23:23:29 +00:00
parent 58e0a2cd65
commit 853e48cd81
564 changed files with 2586 additions and 3145 deletions

View File

@@ -21,7 +21,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.MultisellData;
import org.l2jmobius.gameserver.enums.CategoryType;
import org.l2jmobius.gameserver.handler.BypassHandler;
@@ -316,7 +315,7 @@ public class OlyManager extends AbstractNpcAI implements IBypassHandler
LOGGER.warning(getClass().getSimpleName() + ": Zone: " + nextArena.getStadium().getZone() + " doesn't have specatator spawns defined!");
return false;
}
final Location loc = spectatorSpawns.get(Rnd.get(spectatorSpawns.size()));
final Location loc = spectatorSpawns.get(getRandom(spectatorSpawns.size()));
player.enterOlympiadObserverMode(loc, arenaId);
}
}

View File

@@ -16,7 +16,6 @@
*/
package custom.listeners;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
@@ -126,7 +125,7 @@ public class ListenerTest extends AbstractNpcAI
private void OnCreatureKill(OnCreatureDeath event)
{
// 70% chance to drop
if (Rnd.get(100) >= 70)
if (getRandom(100) >= 70)
{
return;
}
@@ -135,7 +134,7 @@ public class ListenerTest extends AbstractNpcAI
if ((event.getAttacker() != null) && event.getAttacker().isPlayable() && event.getTarget().isAttackable())
{
final Attackable monster = (Attackable) event.getTarget();
monster.dropItem(event.getAttacker().getActingPlayer(), new ItemHolder(57, Rnd.get(100, 1000)));
monster.dropItem(event.getAttacker().getActingPlayer(), new ItemHolder(57, getRandom(100, 1000)));
}
}

View File

@@ -19,7 +19,6 @@ package events.MerrySquashmas;
import java.util.Arrays;
import java.util.List;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.ItemTable;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.WorldObject;
@@ -583,7 +582,7 @@ public class MerrySquashmas extends LongTimeEvent
{
continue;
}
if (Rnd.get(100) < drop[2])
if (getRandom(100) < drop[2])
{
if (ItemTable.getInstance().getTemplate(drop[1]).getCrystalType() != CrystalType.NONE)
{
@@ -602,7 +601,7 @@ public class MerrySquashmas extends LongTimeEvent
private void randomSpawn(int low, int medium, int high, Npc npc)
{
final int _random = Rnd.get(100);
final int _random = getRandom(100);
if (_random < 5)
{
spawnNext(low, npc);
@@ -623,25 +622,25 @@ public class MerrySquashmas extends LongTimeEvent
private void ChronoText(Npc npc)
{
if (Rnd.get(100) < 20)
if (getRandom(100) < 20)
{
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[Rnd.get(_CHRONO_TEXT.length)]));
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[getRandom(_CHRONO_TEXT.length)]));
}
}
private void noChronoText(Npc npc)
{
if (Rnd.get(100) < 20)
if (getRandom(100) < 20)
{
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[Rnd.get(_NOCHRONO_TEXT.length)]));
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[getRandom(_NOCHRONO_TEXT.length)]));
}
}
private void nectarText(Npc npc)
{
if (Rnd.get(100) < 30)
if (getRandom(100) < 30)
{
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[Rnd.get(_NECTAR_TEXT.length)]));
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[getRandom(_NECTAR_TEXT.length)]));
}
}

View File

@@ -19,7 +19,6 @@ package events.SquashEvent;
import java.util.Arrays;
import java.util.List;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.ItemTable;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.WorldObject;
@@ -582,7 +581,7 @@ public class SquashEvent extends LongTimeEvent
{
continue;
}
if (Rnd.get(100) < drop[2])
if (getRandom(100) < drop[2])
{
if (ItemTable.getInstance().getTemplate(drop[1]).getCrystalType() != CrystalType.NONE)
{
@@ -601,7 +600,7 @@ public class SquashEvent extends LongTimeEvent
private void randomSpawn(int low, int medium, int high, Npc npc)
{
final int _random = Rnd.get(100);
final int _random = getRandom(100);
if (_random < 5)
{
spawnNext(low, npc);
@@ -622,25 +621,25 @@ public class SquashEvent extends LongTimeEvent
private void ChronoText(Npc npc)
{
if (Rnd.get(100) < 20)
if (getRandom(100) < 20)
{
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[Rnd.get(_CHRONO_TEXT.length)]));
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[getRandom(_CHRONO_TEXT.length)]));
}
}
private void noChronoText(Npc npc)
{
if (Rnd.get(100) < 20)
if (getRandom(100) < 20)
{
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[Rnd.get(_NOCHRONO_TEXT.length)]));
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[getRandom(_NOCHRONO_TEXT.length)]));
}
}
private void nectarText(Npc npc)
{
if (Rnd.get(100) < 30)
if (getRandom(100) < 30)
{
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[Rnd.get(_NECTAR_TEXT.length)]));
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[getRandom(_NECTAR_TEXT.length)]));
}
}

View File

@@ -19,7 +19,6 @@ package events.WatermelonNinja;
import java.util.Arrays;
import java.util.List;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Npc;
@@ -572,7 +571,7 @@ public class WatermelonNinja extends LongTimeEvent
private void dropItem(Npc mob, Player player)
{
final int npcId = mob.getId();
final int chance = Rnd.get(100);
final int chance = getRandom(100);
for (int[] drop : DROPLIST)
{
if ((npcId == drop[0]) && (chance < drop[2]))
@@ -589,7 +588,7 @@ public class WatermelonNinja extends LongTimeEvent
private void randomSpawn(int low, int medium, int high, Npc npc)
{
final int random = Rnd.get(100);
final int random = getRandom(100);
if (random < 5)
{
spawnNext(low, npc);
@@ -610,25 +609,25 @@ public class WatermelonNinja extends LongTimeEvent
private void ChronoText(Npc npc)
{
if (Rnd.get(100) < 20)
if (getRandom(100) < 20)
{
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[Rnd.get(_CHRONO_TEXT.length)]));
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[getRandom(_CHRONO_TEXT.length)]));
}
}
private void noChronoText(Npc npc)
{
if (Rnd.get(100) < 20)
if (getRandom(100) < 20)
{
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[Rnd.get(_NOCHRONO_TEXT.length)]));
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[getRandom(_NOCHRONO_TEXT.length)]));
}
}
private void nectarText(Npc npc)
{
if (Rnd.get(100) < 30)
if (getRandom(100) < 30)
{
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[Rnd.get(_NECTAR_TEXT.length)]));
npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[getRandom(_NECTAR_TEXT.length)]));
}
}