Prohibit the use of duplicate Rnd methods.
This commit is contained in:
@@ -2100,17 +2100,17 @@ public class SevenSignsFestival implements SpawnListener
|
||||
int x = _startLocation._x;
|
||||
int y = _startLocation._y;
|
||||
|
||||
isPositive = (Rnd.nextInt(2) == 1);
|
||||
isPositive = (Rnd.get(2) == 1);
|
||||
|
||||
if (isPositive)
|
||||
{
|
||||
x += Rnd.nextInt(FESTIVAL_MAX_OFFSET_X);
|
||||
y += Rnd.nextInt(FESTIVAL_MAX_OFFSET_Y);
|
||||
x += Rnd.get(FESTIVAL_MAX_OFFSET_X);
|
||||
y += Rnd.get(FESTIVAL_MAX_OFFSET_Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
x -= Rnd.nextInt(FESTIVAL_MAX_OFFSET_X);
|
||||
y -= Rnd.nextInt(FESTIVAL_MAX_OFFSET_Y);
|
||||
x -= Rnd.get(FESTIVAL_MAX_OFFSET_X);
|
||||
y -= Rnd.get(FESTIVAL_MAX_OFFSET_Y);
|
||||
}
|
||||
|
||||
participant.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
@@ -2196,21 +2196,21 @@ public class SevenSignsFestival implements SpawnListener
|
||||
/*
|
||||
* Random X and Y coords around the player start location, up to half of the maximum allowed offset are generated to prevent the mobs from all moving to the exact same place.
|
||||
*/
|
||||
isPositive = (Rnd.nextInt(2) == 1);
|
||||
isPositive = (Rnd.get(2) == 1);
|
||||
|
||||
if (isPositive)
|
||||
{
|
||||
x += Rnd.nextInt(FESTIVAL_MAX_OFFSET_X);
|
||||
y += Rnd.nextInt(FESTIVAL_MAX_OFFSET_Y);
|
||||
x += Rnd.get(FESTIVAL_MAX_OFFSET_X);
|
||||
y += Rnd.get(FESTIVAL_MAX_OFFSET_Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
x -= Rnd.nextInt(FESTIVAL_MAX_OFFSET_X);
|
||||
y -= Rnd.nextInt(FESTIVAL_MAX_OFFSET_Y);
|
||||
x -= Rnd.get(FESTIVAL_MAX_OFFSET_X);
|
||||
y -= Rnd.get(FESTIVAL_MAX_OFFSET_Y);
|
||||
}
|
||||
|
||||
festivalMob.setRunning();
|
||||
festivalMob.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(x, y, _startLocation._z, Rnd.nextInt(65536)));
|
||||
festivalMob.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(x, y, _startLocation._z, Rnd.get(65536)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2267,7 +2267,7 @@ public class SevenSignsFestival implements SpawnListener
|
||||
final L2Spawn npcSpawn = new L2Spawn(currSpawn._npcId);
|
||||
|
||||
npcSpawn.setXYZ(currSpawn._x, currSpawn._y, currSpawn._z);
|
||||
npcSpawn.setHeading(Rnd.nextInt(65536));
|
||||
npcSpawn.setHeading(Rnd.get(65536));
|
||||
npcSpawn.setAmount(1);
|
||||
npcSpawn.setRespawnDelay(respawnDelay);
|
||||
|
||||
@@ -2430,7 +2430,7 @@ public class SevenSignsFestival implements SpawnListener
|
||||
_z = z;
|
||||
|
||||
// Generate a random heading if no positive one given.
|
||||
_heading = (heading < 0) ? Rnd.nextInt(65536) : heading;
|
||||
_heading = (heading < 0) ? Rnd.get(65536) : heading;
|
||||
|
||||
_npcId = -1;
|
||||
}
|
||||
@@ -2441,7 +2441,7 @@ public class SevenSignsFestival implements SpawnListener
|
||||
_y = spawnData[1];
|
||||
_z = spawnData[2];
|
||||
|
||||
_heading = (spawnData[3] < 0) ? Rnd.nextInt(65536) : spawnData[3];
|
||||
_heading = (spawnData[3] < 0) ? Rnd.get(65536) : spawnData[3];
|
||||
|
||||
if (spawnData.length > 4)
|
||||
{
|
||||
|
@@ -622,7 +622,7 @@ public class L2AttackableAI extends L2CharacterAI
|
||||
}
|
||||
|
||||
// Chance to forget attackers after some time
|
||||
if ((npc.getCurrentHp() == npc.getMaxHp()) && (npc.getCurrentMp() == npc.getMaxMp()) && !npc.getAttackByList().isEmpty() && (Rnd.nextInt(500) == 0))
|
||||
if ((npc.getCurrentHp() == npc.getMaxHp()) && (npc.getCurrentMp() == npc.getMaxMp()) && !npc.getAttackByList().isEmpty() && (Rnd.get(500) == 0))
|
||||
{
|
||||
npc.clearAggroList();
|
||||
npc.getAttackByList().clear();
|
||||
@@ -694,7 +694,7 @@ public class L2AttackableAI extends L2CharacterAI
|
||||
moveTo(x1, y1, z1);
|
||||
return;
|
||||
}
|
||||
if (Rnd.nextInt(RANDOM_WALK_RATE) == 0)
|
||||
if (Rnd.get(RANDOM_WALK_RATE) == 0)
|
||||
{
|
||||
for (Skill sk : npc.getTemplate().getAISkills(AISkillScope.BUFF))
|
||||
{
|
||||
@@ -706,7 +706,7 @@ public class L2AttackableAI extends L2CharacterAI
|
||||
}
|
||||
}
|
||||
// Order to the L2MonsterInstance to random walk (1/100)
|
||||
else if ((npc.getSpawn() != null) && (Rnd.nextInt(RANDOM_WALK_RATE) == 0) && npc.isRandomWalkingEnabled())
|
||||
else if ((npc.getSpawn() != null) && (Rnd.get(RANDOM_WALK_RATE) == 0) && npc.isRandomWalkingEnabled())
|
||||
{
|
||||
int x1 = 0;
|
||||
int y1 = 0;
|
||||
@@ -731,7 +731,7 @@ public class L2AttackableAI extends L2CharacterAI
|
||||
}
|
||||
else
|
||||
{
|
||||
final int deltaX = Rnd.nextInt(range * 2); // x
|
||||
final int deltaX = Rnd.get(range * 2); // x
|
||||
int deltaY = Rnd.get(deltaX, range * 2); // distance
|
||||
deltaY = (int) Math.sqrt((deltaY * deltaY) - (deltaX * deltaX)); // y
|
||||
x1 = (deltaX + x1) - range;
|
||||
@@ -887,7 +887,7 @@ public class L2AttackableAI extends L2CharacterAI
|
||||
// Note from Gnacik:
|
||||
// On l2js because of that sometimes mobs don't attack player only running
|
||||
// around player without any sense, so decrease chance for now
|
||||
if (!npc.isMovementDisabled() && (Rnd.nextInt(100) <= 3))
|
||||
if (!npc.isMovementDisabled() && (Rnd.get(100) <= 3))
|
||||
{
|
||||
for (L2Attackable nearby : L2World.getInstance().getVisibleObjects(npc, L2Attackable.class))
|
||||
{
|
||||
|
@@ -1357,7 +1357,7 @@ public class L2CharacterAI extends AbstractAI
|
||||
public void update(L2Character target)
|
||||
{
|
||||
// update status once in 4 seconds
|
||||
if ((target == character) && (Rnd.nextInt(100) > 25))
|
||||
if ((target == character) && (Rnd.get(100) > 25))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ public final class L2ControllableMobAI extends L2AttackableAI
|
||||
{
|
||||
if (!Util.checkIfInRange(MobGroupTable.FOLLOW_RANGE, _actor, getForcedTarget(), true))
|
||||
{
|
||||
moveTo(getForcedTarget().getX() + (((Rnd.nextInt(2) == 0) ? -1 : 1) * Rnd.nextInt(MobGroupTable.FOLLOW_RANGE)), getForcedTarget().getY() + (((Rnd.nextInt(2) == 0) ? -1 : 1) * Rnd.nextInt(MobGroupTable.FOLLOW_RANGE)), getForcedTarget().getZ());
|
||||
moveTo(getForcedTarget().getX() + (((Rnd.get(2) == 0) ? -1 : 1) * Rnd.get(MobGroupTable.FOLLOW_RANGE)), getForcedTarget().getY() + (((Rnd.get(2) == 0) ? -1 : 1) * Rnd.get(MobGroupTable.FOLLOW_RANGE)), getForcedTarget().getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ public final class L2ControllableMobAI extends L2AttackableAI
|
||||
setAttackTarget(hated);
|
||||
}
|
||||
|
||||
if (!_actor.isMuted() && (Rnd.nextInt(5) == 3))
|
||||
if (!_actor.isMuted() && (Rnd.get(5) == 3))
|
||||
{
|
||||
for (Skill sk : _actor.getAllSkills())
|
||||
{
|
||||
@@ -418,7 +418,7 @@ public final class L2ControllableMobAI extends L2AttackableAI
|
||||
}
|
||||
});
|
||||
|
||||
return !potentialTarget.isEmpty() ? potentialTarget.get(Rnd.nextInt(potentialTarget.size())) : null;
|
||||
return !potentialTarget.isEmpty() ? potentialTarget.get(Rnd.get(potentialTarget.size())) : null;
|
||||
|
||||
}
|
||||
|
||||
|
@@ -584,7 +584,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
|
||||
|
||||
// check for close combat skills && heal/buff skills
|
||||
if (!_actor.isMuted() && (Rnd.nextInt(100) <= 5))
|
||||
if (!_actor.isMuted() && (Rnd.get(100) <= 5))
|
||||
{
|
||||
for (Skill sk : skills)
|
||||
{
|
||||
|
@@ -584,7 +584,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
|
||||
_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
|
||||
|
||||
// check for close combat skills && heal/buff skills
|
||||
if (!_actor.isMuted() && (Rnd.nextInt(100) <= 5))
|
||||
if (!_actor.isMuted() && (Rnd.get(100) <= 5))
|
||||
{
|
||||
for (Skill sk : skills)
|
||||
{
|
||||
|
@@ -304,7 +304,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
|
||||
if (crop.getStartAmount() != crop.getAmount())
|
||||
{
|
||||
long count = (long) ((crop.getStartAmount() - crop.getAmount()) * 0.9);
|
||||
if ((count < 1) && (Rnd.nextInt(99) < 90))
|
||||
if ((count < 1) && (Rnd.get(99) < 90))
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
|
@@ -427,7 +427,7 @@ public class AutoSpawnHandler
|
||||
}
|
||||
|
||||
final int locationCount = locationList.length;
|
||||
int locationIndex = Rnd.nextInt(locationCount);
|
||||
int locationIndex = Rnd.get(locationCount);
|
||||
|
||||
// If random spawning is disabled, the spawn at the next set of co-ordinates after the last.
|
||||
// If the index is greater than the number of possible spawns, reset the counter to zero.
|
||||
@@ -478,7 +478,7 @@ public class AutoSpawnHandler
|
||||
npcInst = newSpawn.doSpawn();
|
||||
|
||||
// To prevent spawning of more than one NPC in the exact same spot, move it slightly by a small random offset.
|
||||
npcInst.setXYZ(npcInst.getX() + Rnd.nextInt(50), npcInst.getY() + Rnd.nextInt(50), npcInst.getZ());
|
||||
npcInst.setXYZ(npcInst.getX() + Rnd.get(50), npcInst.getY() + Rnd.get(50), npcInst.getZ());
|
||||
|
||||
// Add the NPC instance to the list of managed instances.
|
||||
spawnInst.addNpcInstance(npcInst);
|
||||
|
@@ -68,7 +68,7 @@ public class L2GroupSpawn extends L2Spawn
|
||||
final L2Npc mob = new L2ControllableMobInstance(_template);
|
||||
mob.setCurrentHpMp(mob.getMaxHp(), mob.getMaxMp());
|
||||
|
||||
mob.setHeading(getHeading() == -1 ? Rnd.nextInt(61794) : getHeading());
|
||||
mob.setHeading(getHeading() == -1 ? Rnd.get(61794) : getHeading());
|
||||
|
||||
mob.setSpawn(this);
|
||||
mob.spawnMe(newlocx, newlocy, newlocz);
|
||||
|
@@ -433,7 +433,7 @@ public class L2Spawn extends Location implements IIdentifiable, INamable
|
||||
// Set the heading of the L2NpcInstance (random heading if not defined)
|
||||
if (getHeading() == -1)
|
||||
{
|
||||
npc.setHeading(Rnd.nextInt(61794));
|
||||
npc.setHeading(Rnd.get(61794));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -150,7 +150,7 @@ public class L2Territory
|
||||
if (_procMax > 0)
|
||||
{
|
||||
int pos = 0;
|
||||
final int rnd = Rnd.nextInt(_procMax);
|
||||
final int rnd = Rnd.get(_procMax);
|
||||
for (Point p1 : _points)
|
||||
{
|
||||
pos += p1._proc;
|
||||
|
@@ -146,10 +146,10 @@ public final class MobGroup
|
||||
{
|
||||
final L2GroupSpawn spawn = new L2GroupSpawn(_npcTemplate);
|
||||
|
||||
final int signX = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
final int signY = (Rnd.nextInt(2) == 0) ? -1 : 1;
|
||||
final int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
|
||||
final int randY = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
|
||||
final int signX = (Rnd.get(2) == 0) ? -1 : 1;
|
||||
final int signY = (Rnd.get(2) == 0) ? -1 : 1;
|
||||
final int randX = Rnd.get(MobGroupTable.RANDOM_RANGE);
|
||||
final int randY = Rnd.get(MobGroupTable.RANDOM_RANGE);
|
||||
|
||||
spawn.setXYZ(x + (signX * randX), y + (signY * randY), z);
|
||||
spawn.stopRespawn();
|
||||
@@ -184,8 +184,8 @@ public final class MobGroup
|
||||
|
||||
if (!mobInst.isDead())
|
||||
{
|
||||
final int x = player.getX() + Rnd.nextInt(50);
|
||||
final int y = player.getY() + Rnd.nextInt(50);
|
||||
final int x = player.getX() + Rnd.get(50);
|
||||
final int y = player.getY() + Rnd.get(50);
|
||||
|
||||
mobInst.teleToLocation(new Location(x, y, player.getZ()), true);
|
||||
((L2ControllableMobAI) mobInst.getAI()).follow(player);
|
||||
@@ -196,7 +196,7 @@ public final class MobGroup
|
||||
public L2ControllableMobInstance getRandomMob()
|
||||
{
|
||||
removeDead();
|
||||
return getMobs().size() == 0 ? null : getMobs().get(Rnd.nextInt(getMobs().size()));
|
||||
return getMobs().size() == 0 ? null : getMobs().get(Rnd.get(getMobs().size()));
|
||||
}
|
||||
|
||||
public void unspawnGroup()
|
||||
@@ -306,7 +306,7 @@ public final class MobGroup
|
||||
continue;
|
||||
}
|
||||
|
||||
((L2ControllableMobAI) mobInst.getAI()).move(activeChar.getX() + (((Rnd.nextInt(2) == 0) ? -1 : 1) * Rnd.nextInt(MobGroupTable.RANDOM_RANGE)), activeChar.getY() + (((Rnd.nextInt(2) == 0) ? -1 : 1) * Rnd.nextInt(MobGroupTable.RANDOM_RANGE)), activeChar.getZ());
|
||||
((L2ControllableMobAI) mobInst.getAI()).move(activeChar.getX() + (((Rnd.get(2) == 0) ? -1 : 1) * Rnd.get(MobGroupTable.RANDOM_RANGE)), activeChar.getY() + (((Rnd.get(2) == 0) ? -1 : 1) * Rnd.get(MobGroupTable.RANDOM_RANGE)), activeChar.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -66,7 +66,7 @@ public class OlympiadGameClassed extends OlympiadGameNormal
|
||||
Participant[] opponents;
|
||||
while (!classList.isEmpty())
|
||||
{
|
||||
list = classList.get(Rnd.nextInt(classList.size()));
|
||||
list = classList.get(Rnd.get(classList.size()));
|
||||
if ((list == null) || (list.size() < 2))
|
||||
{
|
||||
classList.remove(list);
|
||||
|
@@ -74,14 +74,14 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
while (list.size() > 1)
|
||||
{
|
||||
playerOneObjectId = list.remove(Rnd.nextInt(list.size()));
|
||||
playerOneObjectId = list.remove(Rnd.get(list.size()));
|
||||
playerOne = L2World.getInstance().getPlayer(playerOneObjectId);
|
||||
if ((playerOne == null) || !playerOne.isOnline())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
playerTwo = L2World.getInstance().getPlayer(list.remove(Rnd.nextInt(list.size())));
|
||||
playerTwo = L2World.getInstance().getPlayer(list.remove(Rnd.get(list.size())));
|
||||
if ((playerTwo == null) || !playerTwo.isOnline())
|
||||
{
|
||||
list.add(playerOneObjectId);
|
||||
|
@@ -109,7 +109,7 @@ public class OlympiadGameTeams extends AbstractOlympiadGame
|
||||
|
||||
while (list.size() > 1)
|
||||
{
|
||||
teamOne = list.remove(Rnd.nextInt(list.size()));
|
||||
teamOne = list.remove(Rnd.get(list.size()));
|
||||
|
||||
if ((teamOne == null) || teamOne.isEmpty())
|
||||
{
|
||||
@@ -131,7 +131,7 @@ public class OlympiadGameTeams extends AbstractOlympiadGame
|
||||
continue;
|
||||
}
|
||||
|
||||
teamTwo = list.remove(Rnd.nextInt(list.size()));
|
||||
teamTwo = list.remove(Rnd.get(list.size()));
|
||||
if ((teamTwo == null) || teamTwo.isEmpty())
|
||||
{
|
||||
list.add(teamOne);
|
||||
|
@@ -138,8 +138,8 @@ public class ZoneCylinder extends L2ZoneForm
|
||||
@Override
|
||||
public Location getRandomPoint()
|
||||
{
|
||||
final int q = (int) (Rnd.get() * 2 * Math.PI);
|
||||
final int r = (int) Math.sqrt(Rnd.get());
|
||||
final int q = (int) (Rnd.nextDouble() * 2 * Math.PI);
|
||||
final int r = (int) Math.sqrt(Rnd.nextDouble());
|
||||
final int x = (int) ((_rad * r * Math.cos(q)) + _x);
|
||||
final int y = (int) ((_rad * r * Math.sin(q)) + _y);
|
||||
|
||||
|
@@ -261,7 +261,7 @@ public final class GameServerTable implements IGameXmlReader
|
||||
*/
|
||||
public KeyPair getKeyPair()
|
||||
{
|
||||
return _keyPairs[Rnd.nextInt(10)];
|
||||
return _keyPairs[Rnd.get(10)];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -484,7 +484,7 @@ public class LoginController
|
||||
*/
|
||||
public ScrambledKeyPair getScrambledRSAKeyPair()
|
||||
{
|
||||
return _keyPairs[Rnd.nextInt(10)];
|
||||
return _keyPairs[Rnd.get(10)];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user