mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-07 08:39:07 +00:00
Update drop handling, Allow rares, Remove some logging (#193)
* Fix local Parabot instructions * Add kick command, and force logout function * Allow rare items (phats etc) * remove random server logging * implement random drop amount * fixup random events message
This commit is contained in:
@@ -149,8 +149,6 @@ public class Item {
|
|||||||
|
|
||||||
public static boolean isFullBody(int itemId) {
|
public static boolean isFullBody(int itemId) {
|
||||||
String weapon = getItemName(itemId);
|
String weapon = getItemName(itemId);
|
||||||
System.out.println("ItemName: " + weapon);
|
|
||||||
System.out.println("ItemID: " + itemId);
|
|
||||||
if (weapon == null) {
|
if (weapon == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -192,9 +190,6 @@ public class Item {
|
|||||||
for (ItemList element : Server.itemHandler.ItemList) {
|
for (ItemList element : Server.itemHandler.ItemList) {
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
if (element.itemId == id) {
|
if (element.itemId == id) {
|
||||||
System.out.println("itemName: " + element.itemName);
|
|
||||||
System.out.println("id: " + id);
|
|
||||||
System.out.println("itemID: " + element.itemId);
|
|
||||||
return element.itemName;
|
return element.itemName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,47 +15,51 @@ public class RareProtection {
|
|||||||
private static final int[] EATABLE_RARES = { 1959, 1961, 1989 };
|
private static final int[] EATABLE_RARES = { 1959, 1961, 1989 };
|
||||||
|
|
||||||
public static boolean equipItem(Client c) {// check when wearing, removing
|
public static boolean equipItem(Client c) {// check when wearing, removing
|
||||||
|
/* Allow rares
|
||||||
for (int element : RARE_ITEMS) {
|
for (int element : RARE_ITEMS) {
|
||||||
if (!RARES && c.wearId == element && c.playerRights < 3) {
|
if (!RARES && c.wearId == element && c.playerRights < 3) {
|
||||||
c.getActionSender().sendMessage(
|
c.getActionSender().sendMessage("You shouldn't have that item!");
|
||||||
"You shouldn't have that item!");
|
|
||||||
int amountToDelete = c.getItemAssistant().getItemCount(element);
|
int amountToDelete = c.getItemAssistant().getItemCount(element);
|
||||||
c.getItemAssistant().deleteItem(element, amountToDelete);
|
c.getItemAssistant().deleteItem(element, amountToDelete);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean removeItem(Client c, int itemId) {// check when
|
public static boolean removeItem(Client c, int itemId) {// check when
|
||||||
// wearing, removing
|
// wearing, removing
|
||||||
|
/* Allow rares
|
||||||
for (int element : RARE_ITEMS) {
|
for (int element : RARE_ITEMS) {
|
||||||
if (!RARES && itemId == element && c.playerRights < 3) {
|
if (!RARES && itemId == element && c.playerRights < 3) {
|
||||||
c.getActionSender().sendMessage(
|
c.getActionSender().sendMessage("You shouldn't have that item!");
|
||||||
"You shouldn't have that item!");
|
|
||||||
c.getItemAssistant().deleteEquipment(element, 0);
|
c.getItemAssistant().deleteEquipment(element, 0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasDupedItem(Client c) {// check on login
|
public static boolean hasDupedItem(Client c) {// check on login
|
||||||
|
/* Allow rares
|
||||||
for (int element : RARE_ITEMS) {
|
for (int element : RARE_ITEMS) {
|
||||||
if (!RARES && c.getItemAssistant().playerHasItem(element)
|
if (!RARES && c.getItemAssistant().playerHasItem(element)
|
||||||
&& c.playerRights < 3) {
|
&& c.playerRights < 3) {
|
||||||
c.getActionSender().sendMessage(
|
c.getActionSender().sendMessage("You can't have these items!");
|
||||||
"You can't have these items!");
|
|
||||||
int amountToDelete = c.getItemAssistant().getItemCount(element);
|
int amountToDelete = c.getItemAssistant().getItemCount(element);
|
||||||
c.getItemAssistant().deleteItem(element, amountToDelete);
|
c.getItemAssistant().deleteItem(element, amountToDelete);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean eatDupedItem(Client c, int itemId) {// check when
|
public static boolean eatDupedItem(Client c, int itemId) {// check when
|
||||||
// eating
|
// eating
|
||||||
|
/* Allow rares
|
||||||
for (int element : EATABLE_RARES) {
|
for (int element : EATABLE_RARES) {
|
||||||
if (!RARES && itemId == element && c.playerRights < 3) {
|
if (!RARES && itemId == element && c.playerRights < 3) {
|
||||||
c.getActionSender().sendMessage("You can't eat that item!");
|
c.getActionSender().sendMessage("You can't eat that item!");
|
||||||
@@ -64,6 +68,7 @@ public class RareProtection {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,16 +77,17 @@ public class RareProtection {
|
|||||||
// trading,
|
// trading,
|
||||||
// staking,
|
// staking,
|
||||||
// dropping
|
// dropping
|
||||||
|
/* Allow rares
|
||||||
for (int element : RARE_ITEMS) {
|
for (int element : RARE_ITEMS) {
|
||||||
if (!RARES && c.getItemAssistant().playerHasItem(element)
|
if (!RARES && c.getItemAssistant().playerHasItem(element)
|
||||||
&& c.playerRights < 3) {
|
&& c.playerRights < 3) {
|
||||||
c.getActionSender().sendMessage(
|
c.getActionSender().sendMessage("You shouldnt have that item!");
|
||||||
"You shouldnt have that item!");
|
|
||||||
int amountToDelete = c.getItemAssistant().getItemCount(element);
|
int amountToDelete = c.getItemAssistant().getItemCount(element);
|
||||||
c.getItemAssistant().deleteItem(element, amountToDelete);
|
c.getItemAssistant().deleteItem(element, amountToDelete);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import redone.game.content.music.sound.CombatSounds;
|
|||||||
import redone.game.content.randomevents.FreakyForester;
|
import redone.game.content.randomevents.FreakyForester;
|
||||||
import redone.game.content.randomevents.RandomEventHandler;
|
import redone.game.content.randomevents.RandomEventHandler;
|
||||||
import redone.game.content.randomevents.RiverTroll;
|
import redone.game.content.randomevents.RiverTroll;
|
||||||
|
import redone.game.npcs.drops.ItemDrop;
|
||||||
|
import redone.game.npcs.drops.NPCDrops;
|
||||||
import redone.game.npcs.drops.NPCDropsHandler;
|
import redone.game.npcs.drops.NPCDropsHandler;
|
||||||
import redone.game.players.Client;
|
import redone.game.players.Client;
|
||||||
import redone.game.players.Player;
|
import redone.game.players.Player;
|
||||||
@@ -884,71 +886,86 @@ public class NpcHandler {
|
|||||||
|
|
||||||
public void dropItems(int i) {
|
public void dropItems(int i) {
|
||||||
// TODO: add ring of wealth
|
// TODO: add ring of wealth
|
||||||
int npc = 0;
|
int item_index = 0;
|
||||||
Client c = (Client) PlayerHandler.players[npcs[i].killedBy];
|
Client c = (Client) PlayerHandler.players[npcs[i].killedBy];
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
for (npc = 0; npc < NPCDropsHandler.NPC_DROPS(getNpcListName(npcs[i].npcType).toLowerCase(), npcs[i].npcType).length; npc++) {
|
// These npcs shouldn't have drops
|
||||||
if (Misc.random(NPCDropsHandler.NPC_DROPS(getNpcListName(npcs[i].npcType).toLowerCase(), npcs[i].npcType)[npc][2]) == 0 && npcs[i].npcType != 2627 && npcs[i].npcType != 2638 && npcs[i].npcType != 2630 && npcs[i].npcType != 2631 && npcs[i].npcType != 2641 && npcs[i].npcType != 2643 && npcs[i].npcType != 2645 && npcs[i].npcType != 1532 && npcs[i].npcType != 153 && !PestControl.npcIsPCMonster(npcs[i].npcType)) {
|
if (npcs[i].npcType == 2627 // Tz-Kih
|
||||||
Server.itemHandler.createGroundItem(c, NPCDropsHandler.NPC_DROPS(getNpcListName(npcs[i].npcType).toLowerCase(), npcs[i].npcType)[npc][0], npcs[i].absX, npcs[i].absY, NPCDropsHandler.NPC_DROPS(getNpcListName(npcs[i].npcType).toLowerCase(), npcs[i].npcType)[npc][1], c.playerId);
|
|| npcs[i].npcType == 2630 // Tz-Kek
|
||||||
|
|| npcs[i].npcType == 2631 // Tok-Xil
|
||||||
}
|
|| npcs[i].npcType == 2638 // Neite
|
||||||
}
|
|| npcs[i].npcType == 2641 // Dragonkin
|
||||||
switch (npcs[i].npcType) {
|
|| npcs[i].npcType == 2643 // R4ng3rNo0b889
|
||||||
case 2459:
|
|| npcs[i].npcType == 2645 // Love Cats
|
||||||
FreakyForester.killedPheasant(c, 0);
|
|| npcs[i].npcType == 1532 // Barricade
|
||||||
Server.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
|| npcs[i].npcType == 153 // Butterfly
|
||||||
break;
|
|| PestControl.npcIsPCMonster(npcs[i].npcType)
|
||||||
case 2460:
|
|| FightCaves.isFightCaveNpc(npcs[i].npcType)) {
|
||||||
FreakyForester.killedPheasant(c, 1);
|
// These npcs shouldn't have drops
|
||||||
Server.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
return;
|
||||||
break;
|
}
|
||||||
case 2461:
|
for (ItemDrop possible_drop : NPCDropsHandler.NPC_DROPS(getNpcListName(npcs[i].npcType).toLowerCase(), npcs[i].npcType)) {
|
||||||
FreakyForester.killedPheasant(c, 2);
|
if (Misc.random(possible_drop.getChance()) == 0) {
|
||||||
Server.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
int amt = possible_drop.getAmount();
|
||||||
break;
|
Server.itemHandler.createGroundItem(c, possible_drop.getItemID(), npcs[i].absX, npcs[i].absY, amt, c.playerId);
|
||||||
case 2462:
|
|
||||||
FreakyForester.killedPheasant(c, 3);
|
|
||||||
Server.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
|
||||||
break;
|
|
||||||
case 92:
|
|
||||||
if (c.restGhost == 3) {
|
|
||||||
Server.itemHandler.createGroundItem(c, 553, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
|
||||||
c.restGhost = 4;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 47:
|
|
||||||
if (c.witchspot == 1 || c.romeojuliet > 0 && c.romeojuliet < 9) {
|
|
||||||
Server.itemHandler.createGroundItem(c, 300, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 645:
|
|
||||||
if (c.shieldArrav == 5) {
|
|
||||||
Server.itemHandler.createGroundItem(c, 761, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int level = getNpcListCombat(npcs[i].npcType);
|
|
||||||
// higher level monsters have a better drop rate (max of 1/128)
|
|
||||||
int chance = Math.max(128, 512 - (level * 2));
|
|
||||||
if (Misc.random(1, chance) == 1) {
|
|
||||||
int scroll = -1;
|
|
||||||
if (level <= 1) // none
|
|
||||||
scroll = -1;
|
|
||||||
else if (level <= 24) // easy
|
|
||||||
scroll = 2677;
|
|
||||||
else if (level <= 40) // easy → medium
|
|
||||||
scroll = 2677 + Misc.random(0, 1);
|
|
||||||
else if (level <= 80) // medium
|
|
||||||
scroll = 2678;
|
|
||||||
else if (level <= 150) // medium → hard
|
|
||||||
scroll = 2678 + Misc.random(0, 1);
|
|
||||||
else if (level > 150)// hard
|
|
||||||
scroll = 2679;
|
|
||||||
if (scroll >= 0)
|
|
||||||
Server.itemHandler.createGroundItem(c, scroll, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
switch (npcs[i].npcType) {
|
||||||
|
case 2459:
|
||||||
|
FreakyForester.killedPheasant(c, 0);
|
||||||
|
Server.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||||
|
break;
|
||||||
|
case 2460:
|
||||||
|
FreakyForester.killedPheasant(c, 1);
|
||||||
|
Server.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||||
|
break;
|
||||||
|
case 2461:
|
||||||
|
FreakyForester.killedPheasant(c, 2);
|
||||||
|
Server.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||||
|
break;
|
||||||
|
case 2462:
|
||||||
|
FreakyForester.killedPheasant(c, 3);
|
||||||
|
Server.itemHandler.createGroundItem(c, 6178, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||||
|
break;
|
||||||
|
case 92:
|
||||||
|
if (c.restGhost == 3) {
|
||||||
|
Server.itemHandler.createGroundItem(c, 553, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||||
|
c.restGhost = 4;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 47:
|
||||||
|
if (c.witchspot == 1 || c.romeojuliet > 0 && c.romeojuliet < 9) {
|
||||||
|
Server.itemHandler.createGroundItem(c, 300, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 645:
|
||||||
|
if (c.shieldArrav == 5) {
|
||||||
|
Server.itemHandler.createGroundItem(c, 761, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
int level = getNpcListCombat(npcs[i].npcType);
|
||||||
|
// higher level monsters have a better drop rate (max of 1/128)
|
||||||
|
int chance = Math.max(128, 512 - (level * 2));
|
||||||
|
if (Misc.random(1, chance) == 1) {
|
||||||
|
int scroll = -1;
|
||||||
|
if (level <= 1) // none
|
||||||
|
scroll = -1;
|
||||||
|
else if (level <= 24) // easy
|
||||||
|
scroll = 2677;
|
||||||
|
else if (level <= 40) // easy → medium
|
||||||
|
scroll = 2677 + Misc.random(0, 1);
|
||||||
|
else if (level <= 80) // medium
|
||||||
|
scroll = 2678;
|
||||||
|
else if (level <= 150) // medium → hard
|
||||||
|
scroll = 2678 + Misc.random(0, 1);
|
||||||
|
else if (level > 150)// hard
|
||||||
|
scroll = 2679;
|
||||||
|
if (scroll >= 0)
|
||||||
|
Server.itemHandler.createGroundItem(c, scroll, npcs[i].absX, npcs[i].absY, 1, c.playerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Slayer Experience
|
* Slayer Experience
|
||||||
**/
|
**/
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package redone.game.npcs.drops;
|
||||||
|
|
||||||
|
import redone.util.Misc;
|
||||||
|
|
||||||
|
public class ItemDrop {
|
||||||
|
public int item_id, chance;
|
||||||
|
public int[] amounts;
|
||||||
|
|
||||||
|
ItemDrop (int item_id, int[]amounts, int chance) {
|
||||||
|
this.item_id = item_id;
|
||||||
|
this.amounts = amounts;
|
||||||
|
this.chance = chance;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemDrop (int item_id, int amount, int chance) {
|
||||||
|
this.item_id = item_id;
|
||||||
|
this.amounts = new int[]{amount, amount};
|
||||||
|
this.chance = chance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChance(){
|
||||||
|
return this.chance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getItemID(){
|
||||||
|
return this.item_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmount(){
|
||||||
|
return Misc.random(this.amounts[0], this.amounts[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -14,11 +14,10 @@ public class NPCDropsHandler {
|
|||||||
public static int // found on http://runescape.wikia.com/wiki/Drop_rate
|
public static int // found on http://runescape.wikia.com/wiki/Drop_rate
|
||||||
ALWAYS = 0,
|
ALWAYS = 0,
|
||||||
COINSRATE = 3,
|
COINSRATE = 3,
|
||||||
CHICKEN_RATE = 75 / 100,
|
COMMON = 32,
|
||||||
COMMON = 2 + r(48),
|
UNCOMMON = 64,
|
||||||
UNCOMMON = 51 + r(49),
|
RARE = 256,
|
||||||
RARE = 101 + r(411),
|
VERY_RARE = 512;
|
||||||
VERY_RARE = 513;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the npc drops for the npc names.
|
* Handles the npc drops for the npc names.
|
||||||
@@ -26,7 +25,7 @@ public class NPCDropsHandler {
|
|||||||
* @param NPCId
|
* @param NPCId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static final int[][] NPC_DROPS(String npc, int NPCId) {
|
public static final ItemDrop[] NPC_DROPS(String npc, int NPCId) {
|
||||||
if (npc.equals("man") || npc.equals("woman") || npc.equals("drunken_man")) {
|
if (npc.equals("man") || npc.equals("woman") || npc.equals("drunken_man")) {
|
||||||
return NPCDrops.man;
|
return NPCDrops.man;
|
||||||
} else if (npc.equals("skeletal_wyvern")) {
|
} else if (npc.equals("skeletal_wyvern")) {
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public class Commands implements PacketType {
|
|||||||
case "randomtoggle":
|
case "randomtoggle":
|
||||||
case "togglerandom":
|
case "togglerandom":
|
||||||
player.randomEventsEnabled = !player.randomEventsEnabled;
|
player.randomEventsEnabled = !player.randomEventsEnabled;
|
||||||
player.getActionSender().sendMessage("You will " + (player.debugMode ? "now" : "no longer") + " receieve random events.");
|
player.getActionSender().sendMessage("You will " + (player.randomEventsEnabled ? "now" : "no longer") + " receieve random events.");
|
||||||
break;
|
break;
|
||||||
case "debug":
|
case "debug":
|
||||||
case "debugmode":
|
case "debugmode":
|
||||||
|
|||||||
Reference in New Issue
Block a user