mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-26 16:30:52 +01:00
Merge branch '464-raremonsterplantseedrarity' into 'dev'
fix(MonsterplantPet): rare seed should be rare See merge request morningstar/Arcturus-Community!115
This commit is contained in:
commit
295b545b8b
@ -30,6 +30,18 @@ public class InteractionMonsterPlantSeed extends HabboItem {
|
||||
}
|
||||
}
|
||||
|
||||
public static int randomGoldenRarityLevel() {
|
||||
int number = Emulator.getRandom().nextInt(66);
|
||||
int count = 0;
|
||||
for (int i = 8; i < 11; i++) {
|
||||
count += 11 - i;
|
||||
if (number <= count) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 10;
|
||||
}
|
||||
|
||||
public static int randomRarityLevel() {
|
||||
int number = Emulator.getRandom().nextInt(66);
|
||||
int count = 0;
|
||||
|
@ -26,32 +26,32 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
public static final Map<Integer, Pair<String, Integer>> bodyRarity = new LinkedHashMap<Integer, Pair<String, Integer>>() {
|
||||
{
|
||||
this.put(1, new Pair<>("Blungon", 0));
|
||||
this.put(5, new Pair<>("Squarg", 0));
|
||||
this.put(2, new Pair<>("Wailzor", 1));
|
||||
this.put(3, new Pair<>("Stumpy", 1));
|
||||
this.put(4, new Pair<>("Sunspike", 2));
|
||||
this.put(9, new Pair<>("Weggylum", 2));
|
||||
this.put(5, new Pair<>("Squarg", 0));
|
||||
this.put(6, new Pair<>("Shroomer", 3));
|
||||
this.put(7, new Pair<>("Zuchinu", 3));
|
||||
this.put(8, new Pair<>("Abysswirl", 5));
|
||||
this.put(9, new Pair<>("Weggylum", 2));
|
||||
this.put(10, new Pair<>("Wystique", 4));
|
||||
this.put(11, new Pair<>("Hairbullis", 4));
|
||||
this.put(8, new Pair<>("Abysswirl", 5));
|
||||
this.put(12, new Pair<>("Snozzle", 5)); //Rarity???
|
||||
}
|
||||
};
|
||||
public static final Map<Integer, Pair<String, Integer>> colorRarity = new LinkedHashMap<Integer, Pair<String, Integer>>() {
|
||||
{
|
||||
this.put(0, new Pair<>("Aenueus", 0));
|
||||
this.put(9, new Pair<>("Fulvus", 0));
|
||||
this.put(1, new Pair<>("Griseus", 1));
|
||||
this.put(3, new Pair<>("Viridulus", 1));
|
||||
this.put(2, new Pair<>("Phoenicus", 2));
|
||||
this.put(3, new Pair<>("Viridulus", 1));
|
||||
this.put(4, new Pair<>("Cyaneus", 5));
|
||||
this.put(5, new Pair<>("Incarnatus", 2));
|
||||
this.put(8, new Pair<>("Amethyst", 3));
|
||||
this.put(10, new Pair<>("Cinereus", 3));
|
||||
this.put(6, new Pair<>("Azureus", 4));
|
||||
this.put(7, new Pair<>("Atamasc", 4));
|
||||
this.put(4, new Pair<>("Cyaneus", 5));
|
||||
this.put(8, new Pair<>("Amethyst", 3));
|
||||
this.put(9, new Pair<>("Fulvus", 0));
|
||||
this.put(10, new Pair<>("Cinereus", 3));
|
||||
}
|
||||
};
|
||||
public static final ArrayList<Pair<String, Integer>> indexedBody = new ArrayList<>(MonsterplantPet.bodyRarity.values());
|
||||
|
@ -19,6 +19,7 @@ import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
import gnu.trove.procedure.TIntObjectProcedure;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import org.apache.commons.math3.distribution.NormalDistribution;
|
||||
import org.apache.commons.math3.util.Pair;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
@ -101,13 +102,15 @@ public class PetManager {
|
||||
return 100 * level;
|
||||
}
|
||||
|
||||
public static int randomBody(int minimumRarity) {
|
||||
int randomRarity = random(Math.max(minimumRarity - 1, 0), MonsterplantPet.bodyRarity.size(), 2.0);
|
||||
public static int randomBody(int minimumRarity, boolean isRare) {
|
||||
int randomRarity = isRare ? random(Math.max(minimumRarity - 1, 0), (MonsterplantPet.bodyRarity.size() - minimumRarity) + (minimumRarity - 1), 2.0) : random(Math.max(minimumRarity - 1, 0), MonsterplantPet.bodyRarity.size(), 2.0);
|
||||
|
||||
return MonsterplantPet.bodyRarity.get(MonsterplantPet.bodyRarity.keySet().toArray()[randomRarity]).getValue();
|
||||
}
|
||||
|
||||
public static int randomColor(int minimumRarity) {
|
||||
int randomRarity = random(Math.max(minimumRarity - 1, 0), MonsterplantPet.colorRarity.size(), 2.0);
|
||||
public static int randomColor(int minimumRarity, boolean isRare) {
|
||||
int randomRarity = isRare ? random(Math.max(minimumRarity - 1, 0), (MonsterplantPet.colorRarity.size() - minimumRarity) + (minimumRarity - 1), 2.0) : random(Math.max(minimumRarity - 1, 0), MonsterplantPet.colorRarity.size(), 2.0);
|
||||
|
||||
return MonsterplantPet.colorRarity.get(MonsterplantPet.colorRarity.keySet().toArray()[randomRarity]).getValue();
|
||||
}
|
||||
|
||||
@ -426,8 +429,8 @@ public class PetManager {
|
||||
public MonsterplantPet createMonsterplant(Room room, Habbo habbo, boolean rare, RoomTile t, int minimumRarity) {
|
||||
MonsterplantPet pet = new MonsterplantPet(
|
||||
habbo.getHabboInfo().getId(), //Owner ID
|
||||
randomBody(rare ? 4 : minimumRarity),
|
||||
randomColor(rare ? 4 : minimumRarity),
|
||||
randomBody(minimumRarity, rare),
|
||||
randomColor(minimumRarity, rare),
|
||||
Emulator.getRandom().nextInt(12) + 1,
|
||||
Emulator.getRandom().nextInt(11),
|
||||
Emulator.getRandom().nextInt(12) + 1,
|
||||
|
@ -81,14 +81,19 @@ public class ToggleFloorItemEvent extends MessageHandler {
|
||||
if (item instanceof InteractionMonsterPlantSeed) {
|
||||
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));
|
||||
int rarity = 0;
|
||||
if (item.getExtradata().isEmpty()) rarity = InteractionMonsterPlantSeed.randomRarityLevel();
|
||||
|
||||
boolean isRare = item.getBaseItem().getName().contains("rare");
|
||||
|
||||
if ((!item.getExtradata().isEmpty() && Integer.valueOf(item.getExtradata()) - 1 < 0) || item.getExtradata().isEmpty()) {
|
||||
rarity = isRare ? InteractionMonsterPlantSeed.randomGoldenRarityLevel() : InteractionMonsterPlantSeed.randomRarityLevel();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
rarity = Integer.valueOf(item.getExtradata()) - 1;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
MonsterplantPet pet = Emulator.getGameEnvironment().getPetManager().createMonsterplant(room, this.client.getHabbo(), item.getBaseItem().getName().contains("rare"), room.getLayout().getTile(item.getX(), item.getY()), rarity);
|
||||
MonsterplantPet pet = Emulator.getGameEnvironment().getPetManager().createMonsterplant(room, this.client.getHabbo(), isRare, room.getLayout().getTile(item.getX(), item.getY()), rarity);
|
||||
room.sendComposer(new RemoveFloorItemComposer(item, true).compose());
|
||||
room.removeHabboItem(item);
|
||||
room.updateTile(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
|
Loading…
Reference in New Issue
Block a user