mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-21 09:02:07 -07:00
Brawling gloves now only drop from Revenants (1/100) or Chaos Elemental (1/75)
This commit is contained in:
parent
8f189ee4ca
commit
dcd47009c1
2 changed files with 31 additions and 22 deletions
|
|
@ -24,6 +24,7 @@ import core.game.world.map.zone.MapZone;
|
|||
import core.game.world.map.zone.RegionZone;
|
||||
import core.game.world.map.zone.ZoneBorders;
|
||||
import core.tools.RandomFunction;
|
||||
import org.rs09.consts.NPCs;
|
||||
import rs09.game.system.config.NPCConfigParser;
|
||||
import rs09.game.world.GameWorld;
|
||||
import rs09.game.world.repository.Repository;
|
||||
|
|
@ -160,17 +161,32 @@ public final class WildernessZone extends MapZone {
|
|||
player.getInterfaceManager().open(new Component(153));
|
||||
}
|
||||
}
|
||||
if (e instanceof NPC && killer instanceof Player && (e.asNpc().getName().contains("Revenant") || e.asNpc().getName().equals("Chaos elemental"))) {
|
||||
|
||||
//Roll for PVP gear and Brawling Gloves from revenants
|
||||
if (e instanceof NPC && killer instanceof Player && (e.asNpc().getName().contains("Revenant") || e.getId() == NPCs.CHAOS_ELEMENTAL_3200)) {
|
||||
|
||||
boolean gloveDrop = e.getId() == NPCs.CHAOS_ELEMENTAL_3200 ? RandomFunction.roll(75) : RandomFunction.roll(100);
|
||||
if (gloveDrop) {
|
||||
byte glove = (byte) RandomFunction.random(1, 13);
|
||||
Item reward = new Item(BrawlingGloves.forIndicator(glove).getId());
|
||||
GroundItemManager.create(reward, e.asNpc().getDropLocation(), killer.asPlayer());
|
||||
Repository.sendNews(killer.getUsername() + " has received " + reward.getName().toLowerCase() + " from a " + e.asNpc().getName() + "!");
|
||||
}
|
||||
e.asNpc().getDefinition().getDropTables().drop(e.asNpc(), killer);
|
||||
if (((NPC) e).getTask() != null && ((Player) killer).getSlayer().getTask() == e.asNpc().getTask()) {
|
||||
((Player) killer).getSlayer().finalizeDeath(killer.asPlayer(), e.asNpc());
|
||||
}
|
||||
|
||||
int combatLevel = e.asNpc().getDefinition().getCombatLevel();
|
||||
int dropRate = getNewDropRate(combatLevel);
|
||||
for (int i = 0; i < PVP_GEAR.length; i++) {
|
||||
boolean chance = RandomFunction.random(dropRate) == dropRate / 2;
|
||||
for (int j : PVP_GEAR) {
|
||||
boolean chance = RandomFunction.roll(dropRate);
|
||||
if (chance) {
|
||||
Item reward;
|
||||
if (PVP_GEAR[i] == 13879 || PVP_GEAR[i] == 13883) { // checks if it's a javelin or throwing axe
|
||||
reward = new Item(PVP_GEAR[i], RandomFunction.random(15, 50));
|
||||
if (j == 13879 || j == 13883) { // checks if it's a javelin or throwing axe
|
||||
reward = new Item(j, RandomFunction.random(15, 50));
|
||||
} else {
|
||||
reward = new Item(PVP_GEAR[i]);
|
||||
reward = new Item(j);
|
||||
}
|
||||
Repository.sendNews(killer.asPlayer().getUsername() + " has received a " + reward.getName() + " from a " + e.asNpc().getName() + "!");
|
||||
GroundItemManager.create(reward, ((NPC) e).getDropLocation(), killer.asPlayer());
|
||||
|
|
@ -178,22 +194,6 @@ public final class WildernessZone extends MapZone {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (killer.isPlayer()) {
|
||||
if (e instanceof NPC) {
|
||||
boolean gloveDrop = RandomFunction.random(1, 100) == 54;
|
||||
if (gloveDrop) {
|
||||
byte glove = (byte) RandomFunction.random(1, 13);
|
||||
Item reward = new Item(BrawlingGloves.forIndicator(glove).getId());
|
||||
GroundItemManager.create(reward, e.asNpc().getDropLocation(), killer.asPlayer());
|
||||
Repository.sendNews(killer.getUsername() + " has received " + reward.getName().toLowerCase() + " from a " + e.asNpc().getName() + "!");
|
||||
}
|
||||
e.asNpc().getDefinition().getDropTables().drop(e.asNpc(), killer);
|
||||
if (((NPC) e).getTask() != null && killer instanceof Player && ((Player) killer).getSlayer().getTask() == e.asNpc().getTask()) {
|
||||
((Player) killer).getSlayer().finalizeDeath(killer.asPlayer(), e.asNpc());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (e instanceof NPC) {
|
||||
e.asNpc().setRespawnTick(GameWorld.getTicks() + e.asNpc().getDefinition().getConfiguration(NPCConfigParser.RESPAWN_DELAY, 17));
|
||||
|
|
|
|||
|
|
@ -44,6 +44,15 @@ public class RandomFunction {
|
|||
return Math.min(a, b) + (n == 0 ? 0 : random(n));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to roll for a random 1/X chance
|
||||
* @param chance the 1/chance rate for the roll to succeed
|
||||
* @return true if you hit the roll, false otherwise
|
||||
*/
|
||||
public static boolean roll(int chance){
|
||||
return random(chance) == chance / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the chance of succeeding at a skilling event
|
||||
* @param low - Success chance at level 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue