Search the Community
Showing results for tags 'chest'.
Found 10 results
-
I know it's not done the best way possible & it could be improved massively, this is 2 minutes of work though, so meh. [CODE]package server.model.content; import server.model.players.Client; public class CrystalChest { public static int KEY = 989; public static int DRAGONSTONE = 1631; public static int KEY_HALVE1 = 985; public static int KEY_HALVE2 = 987; public static final int ANIMATION = 881; public static int ChestRewards[] = {1079, 1093, 526, 1969, 371, 2363, 451, KEY_HALVE1, KEY_HALVE2}; public static int randomChestRewards() { return ChestRewards[(int)(Math.random()*ChestRewards.length)]; } public static void makeKey(Client c) { if (c.getItems().playerHasItem(KEY_HALVE1, 1) && c.getItems().playerHasItem(KEY_HALVE2, 1)) { c.getItems().deleteItem(KEY_HALVE1, 1); c.getItems().deleteItem(KEY_HALVE2, 1); c.getItems().addItem(KEY, 1); } } public static void searchChest(Client c) { if (c.getItems().playerHasItem(KEY)) { c.getItems().removeItem(KEY, 1); c.startAnimation(ANIMATION); c.getItems().addItem(DRAGONSTONE, 1); c.getItems().addItem(randomChestRewards(), 1); c.sendMessage("You stick your hand in the chest and pull an item out of the chest."); } else { c.sendMessage("The chest is locked, it won't budge!"); return; } } }[/CODE] How to make looting the chest work, ActionHandler import the newly made class, under FirstObjectClick add [CODE] case ####: CrystalChest.searchChest(c); break;[/CODE] pretty basic though.
-
Title.
-
hey guys I need help adding a cyrstal key chest properly with random items to be given.
-
I added the Tokhaar-kal Cape a few minutes ago, And when I equip it it makes anything in the chest area invisible? How can I fix this? Thanks [ATTACH=CONFIG]6066[/ATTACH]
-
I will be showing you a simple CrystalChest system doe Matrix 667/*** [CODE] package com.rs.game.minigames; import com.rs.game.player.Player; import com.rs.game.Animation; import com.rs.utils.Utils; /** * Represents the chest on which the key is used. * @author 'Corey 2010 <[email protected]> */ public class CrystalChest { private static final int[] CHEST_REWARDS = { }; public static final int[] KEY_HALVES = { 985, 987 }; public static final int KEY = 989; public static final int Animation = 881; /** * Represents the key being made. * Using tooth halves. */ public static void makeKey(Player p){ if (p.getInventory().containsItem(toothHalf(), 1) && p.getInventory().containsItem(loopHalf(), 1)){ p.getInventory().deleteItem(toothHalf(), 1); p.getInventory().deleteItem(loopHalf(), 1); p.getInventory().addItem(KEY, 1); p.sendMessage("You succesfully make a crytal key."); } } /** * If the player can open the chest. */ public static boolean canOpen(Player p){ if(p.getInventory().containsItem(KEY, 1)){ return true; }else{ p.sendMessage("<col=FFFF00>This chest is locked.</col>"); return false; } } /** * When the player searches the chest. */ public static void searchChest(final Player p){ if (canOpen(p)){ p.sendMessage("You unlock the chest with your key."); p.getInventory().deleteItem(KEY, 1); p.setNextAnimation(new Animation(Animation)); p.getInventory().addItem(995, Utils.random(8230)); p.getInventory().addItem(CHEST_REWARDS[Utils.random(getLength() - 1)], 1); p.sendMessage("You find some treasure in the chest."); } } public static int getLength() { return CHEST_REWARDS.length; } /** * Represents the toothHalf of the key. */ public static int toothHalf(){ return KEY_HALVES[0]; } /** * Represent the loop half of the key. */ public static int loopHalf(){ return KEY_HALVES[1]; } } [/CODE] InventoryOptionsManager.java [CODE] if (itemUsed.getId() == CrystalChest.toothHalf() && usedWith.getId() == CrystalChest.loopHalf() || itemUsed.getId() == CrystalChest.loopHalf() && usedWith.getId() == CrystalChest.toothHalf()){ CrystalChest.makeKey(player); return; } [/CODE] ObjectHandler.java ItemOnObject method [CODE]}else if (itemId == CrystalChest.KEY && object.getId() == 172) { CrystalChest.searchChest(player); }[/CODE]
-
does anyone know how to make crystal chest work? ive tryed alot of methods im pretty sure this piece is wrong import org.dementhium.content.minigames.CrystalChest; and yes i do have the import :P [code] player.getInventory().addItem(new ChanceItem(CRYSTAL_CHEST_REWARDS));[/code] but here is rest :S itemonobjecthandler.java [code] } else if (def.getName().toLowerCase().equals("closed chest")) { if (player.getInventory().contains(989)) { if (!player.getInventory().contains(989)) { player.sendMessage("You do not have a crystal key."); return; } player.getInventory().getContainer().remove(new Item(989)); player.getInventory().addItem(new ChanceItem(CRYSTAL_CHEST_REWARDS)); player.getInventory().refresh(); player.sendMessage("You open the Closed Chest."); return; }[/code] crystalchest.java [code] private static final ChanceItem[] CRYSTAL_CHEST_REWARDS = new ChanceItem[] { new ChanceItem(new Item(995, 2000), 27), new ChanceItem(new Item(1631, 1), 100), new ChanceItem(new Item(1969, 1), 27), new ChanceItem(new Item(441, 150), 8), new ChanceItem(new Item(454, 1), 7), new ChanceItem(new Item(2363, 3), 9), new ChanceItem(new Item(556, 50), 9), new ChanceItem(new Item(558, 50), 9), new ChanceItem(new Item(559, 50), 9), new ChanceItem(new Item(557, 50), 9), new ChanceItem(new Item(554, 50), 9), new ChanceItem(new Item(555, 50), 9), new ChanceItem(new Item(560, 10), 9), new ChanceItem(new Item(564, 10), 9), new ChanceItem(new Item(562, 10), 9), new ChanceItem(new Item(561, 10), 9), new ChanceItem(new Item(563, 10), 9), new ChanceItem(new Item(985, 1), 3), new ChanceItem(new Item(987, 1), 3), new ChanceItem(new Item(995, 750), 3), };[/code]
-
Anyone know how to make a chest give a random item? and it has to use a certain item? Please post something about this so i can get my server released :D MSN: [email][email protected][/email]
-
And this code will go in object1packethandler correct?