Added "lucky" donor perk - abilities have 25% better chance to activate

This commit is contained in:
GJ
2012-07-02 11:09:55 -04:00
parent 246961887e
commit 819b6fcacb
14 changed files with 226 additions and 28 deletions

View File

@ -91,7 +91,13 @@ public class Excavation {
for (ExcavationTreasure treasure : treasures) {
if (skillLevel >= treasure.getDropLevel()) {
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.excavation")) {
randomChance = (int) (randomChance * 0.75);
}
if (random.nextDouble() * randomChance <= treasure.getDropChance()) {
xp += treasure.getXp();
is.add(treasure.getDrop());
}

View File

@ -102,7 +102,13 @@ public class Fishing {
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 && Permissions.getInstance().fishingTreasures(player)) {
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
randomChance = (int) (randomChance * 0.75);
}
if (random.nextDouble() * randomChance <= treasure.getDropChance()) {
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
theCatch.setItemStack(treasure.getDrop());
}
@ -138,8 +144,15 @@ public class Fishing {
ItemStack fishingResults = theCatch.getItemStack();
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
if (random.nextInt(100) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) {
int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
randomChance = (int) (randomChance * 0.75);
}
if (random.nextInt(randomChance) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) {
for (Enchantment newEnchant : Enchantment.values()) {
if (newEnchant.canEnchantItem(fishingResults)) {
Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();
@ -178,7 +191,13 @@ public class Fishing {
* @param event The event to modify
*/
public static void shakeMob(PlayerFishEvent event) {
final int DROP_NUMBER = random.nextInt(100);
int randomChance = 100;
if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) {
randomChance = (int) (randomChance * 0.75);
}
final int DROP_NUMBER = random.nextInt(randomChance);
LivingEntity le = (LivingEntity) event.getCaught();
EntityType type = le.getType();

View File

@ -92,6 +92,12 @@ public class Herbalism {
boolean customPlant = false;
int randomChance = 1000;
if (player.hasPermission("mcmmo.perks.lucky.herbalism")) {
randomChance = (int) (randomChance * 0.75);
}
switch (type) {
case BROWN_MUSHROOM:
case RED_MUSHROOM:
@ -107,7 +113,7 @@ public class Herbalism {
if (b.getType().equals(Material.CACTUS)) {
mat = Material.CACTUS;
if (!mcMMO.placeStore.isTrue(b)) {
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) {
catciDrops++;
}
xp += Config.getInstance().getHerbalismXPCactus();
@ -163,7 +169,7 @@ public class Herbalism {
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
mat = Material.SUGAR_CANE;
if (!mcMMO.placeStore.isTrue(b)) {
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) {
caneDrops++;
}
xp += Config.getInstance().getHerbalismXPSugarCane();
@ -208,7 +214,7 @@ public class Herbalism {
is = new ItemStack(mat);
}
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) {
Config configInstance = Config.getInstance();
switch (type) {
@ -321,7 +327,13 @@ public class Herbalism {
boolean hasSeeds = inventory.contains(Material.SEEDS);
Location loc = block.getLocation();
if (hasSeeds && PP.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= herbLevel)) {
int randomChance = 1500;
if (player.hasPermission("mcmmo.perks.lucky.herbalism")) {
randomChance = (int) (randomChance * 0.75);
}
if (hasSeeds && PP.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel)) {
event.setCancelled(true);
Misc.dropItem(loc, new ItemStack(Material.WHEAT));
@ -350,7 +362,13 @@ public class Herbalism {
player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1));
if (skillLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= skillLevel) {
int randomChance = 1500;
if (player.hasPermission("mcmmo.perks.lucky.herbalism")) {
randomChance = (int) (randomChance * 0.75);
}
if (skillLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= skillLevel) {
greenTerraConvert(player, block);
}
else {

View File

@ -307,7 +307,13 @@ public class Mining {
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(1000) <= skillCheck && Permissions.getInstance().miningDoubleDrops(player)) {
int randomChance = 1000;
if (player.hasPermission("mcmmo.perks.lucky.mining")) {
randomChance = (int) (randomChance * 0.75);
}
if (random.nextInt(randomChance) <= skillCheck && Permissions.getInstance().miningDoubleDrops(player)) {
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
silkTouchDrops(block);
}

View File

@ -303,7 +303,13 @@ public class WoodCutting {
Tree tree = (Tree) block.getState().getData();
TreeSpecies species = tree.getSpecies();
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) {
int randomChance = 1000;
if (player.hasPermission("mcmmo.perks.lucky.woodcutting")) {
randomChance = (int) (randomChance * 0.75);
}
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(randomChance) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) {
Config configInstance = Config.getInstance();
ItemStack item;
Location location;