Jump to content
Existing user? Sign In

Sign In



Sign Up

Sanity

Members
  • Posts

    606
  • Joined

  • Last visited

  • Days Won

    23

Everything posted by Sanity

  1. Sanity

    Hi

    Hello katy, Welcome to RuneSoft Community!
  2. Sanity

    Josh

    Hello Josh welcome to the community.
  3. Nice, Looks really good. Might use in the future.
  4. Sanity

    Ikov (arrav) - Release

    Nice one mate. #1
  5. Sanity

    Hello

    Welcome to RuneSoft mate
  6. Sanity

    Hey hey

    Hey Dude, Welcome to runesoft. Best of luck with you're project!
  7. Welcome to the community mate.
  8. No it ain't my work... I was just coping over so people can see it and maybe use it.
  9. Partnership went wrong, as this is %99 my work, i'm releasing it to the public. Do whatever you want with it. has some nice content/interfaces. Feel free to leave a thanks / rep if you're going to use this. Enjoy . More Media [Hidden Content] Download link: [Hidden Content] Use this for sprite editing: Originally Posted by Laith Saw multiple people having issue's with sprite packing for ruse. Use this tool: [Hidden Content]
  10. Very simple to do, kind of nice to have an additional currency that many stakers should be familiar with being introduced into the economy. Modify to your needs. Anyways. Add this into your Items.json file. { "id": 13204, "name": "Platinum Tokens", "examine": "Shiny currency, could be useful to some.", "value": 1000, "stackable": true, "noted": false, "noteId": -1, "tradeable": true, "sellable": false, "dropable": true }, In your UseItemPacketListener class, itemOnObject method if (itemId == 995 && gameObject.getDefinition().getName().contains("Bank")) { final int size = player.getInventory().getAmount(995); player.getInventory().delete(new Item(995, size)); player.getInventory().add(new Item(13204, size / 2)); player.getPacketSender().sendMessage("You exchange " + Misc.format(size) + " Coins for " + Misc.format(player.getInventory().getAmount(13204)) + " Platinum tokens."); }
  11. Since many players asking for it, so here you go : ItemActionPacketListener.java : case #####: ClanChat clan = player.getCurrentClanChat(); if (clan == null) { player.getPacketSender().sendMessage("You need to be in a clan to do this."); return; } else { player.performAnimation(new Animation(774, Priority.HIGH)); player.getPacketSender().sendMessage("@cr2@ [@red@Dice@bla@][" + clan.getName() +"] <shad=16112652>"+player.getUsername()+"<shad=000000> has just rolled a <shad=16112652>" +Misc.getRandom(100)+ "<shad=000000>/100."); } break; Dice [Clanchatname] Your user name and the rest of the message. Looks like this : [Hidden Content] (UPloading the image soon)
  12. Note, if you want to keep a track of clues completed simply create clue scroll points and have them called there. (String 47703) Client (RsInterface) : public static void clueScrolls(TextDrawingArea wid[]) { RSInterface tab = addInterface(47700); addSpriteLoader(47701, 959); addText(47702, "Clues Completed", wid, 1, 16750623, true, true); addText(47703, "-", wid, 2, 0xffffff, true, true); addText(47704, "Dig somewhere in the Edgeville bank", wid, 1, 16750623, true, true); addCloseButton(47705, 18535, 18536); tab.children(5); tab.child(0, 47701, 35, 60); tab.child(1, 47702, 93, 100); tab.child(2, 47703, 103, 123); tab.child(3, 47704, 252, 222); tab.child(4, 47705, 453, 77); } 959.png: Source: Create a Class called Clues: public class Clues { public static void dig(final Player player) { if(!player.getClickDelay().elapsed(2000)) return; player.getMovementQueue().reset(); player.getPacketSender().sendMessage("You start digging for clues.."); player.performAnimation(new Animation(830)); TaskManager.submit(new Task(2, player, false) { @Override public void execute() { /** * Clue scrolls */ if (inOneSpot(player.getPosition(), 1748, 5327) && player.getInventory().contains(2677)) { player.getPA().sendMessage("@gre@ You find a Casket!"); player.getInventory().delete(2677, 1); player.getInventory().add(2818, 1); } else if (inOneSpot(player.getPosition(), 3213, 3421) && player.getInventory().contains(2678)) { player.getPA().sendMessage("@gre@ You find a Casket!"); player.getInventory().delete(2678, 1); player.getInventory().add(2818, 1); } else if (inOneSpot(player.getPosition(), 3094, 3496) && player.getInventory().contains(2679)) { player.getPA().sendMessage("@gre@ You find a Casket!"); player.getInventory().delete(2679, 1); player.getInventory().add(2818, 1); } else if (inOneSpot(player.getPosition(), 3229, 3298) && player.getInventory().contains(2680)) { player.getPA().sendMessage("@gre@ You find a Casket!"); player.getInventory().delete(2680, 1); player.getInventory().add(2818, 1); } else if (inOneSpot(player.getPosition(), 2861, 3539) && player.getInventory().contains(2681)) { player.getPA().sendMessage("@gre@ You find a Casket!"); player.getInventory().delete(2681, 1); player.getInventory().add(2818, 1); } else if (inOneSpot(player.getPosition(), 3204, 3264) && player.getInventory().contains(2682)) { player.getPA().sendMessage("@gre@ You find a Casket!"); player.getInventory().delete(2682, 1); player.getInventory().add(2818, 1); System.out.println("inOneSpot"); } else player.getPacketSender().sendMessage("You find nothing of interest."); player.getMovementQueue().reset(); player.getPacketSender().sendClientRightClickRemoval(); player.getSkillManager().stopSkilling(); stop(); player.getMovementQueue().reset(); }}); player.getClickDelay().reset(); return; } static boolean hasClue(Player player) { if(player.getInventory().containsAny(2677, 2678, 2679, 2680, 2681, 2682)); return true; } private static boolean inOneSpot(Position pos, int x, int y) { return pos.getX() == x && pos.getY() == y; } } The sample I showed you (the clue) is done through ItemActionPacketListener Example of item usage: case 2677: player.getPacketSender().sendString(47704, "Dig in the Ancient Cavern Teleport Area").sendInterface(47700); break; case 2678: player.getPacketSender().sendString(47704, "Dig South of Varrock Square").sendInterface(47700); break; case 2679: player.getPacketSender().sendString(47704, "Dig Somewhere In Edgeville Bank").sendInterface(47700); break; case 2680: player.getPacketSender().sendString(47704, "Dig Somewhere In The Chicken Coop").sendInterface(47700); break; case 2681: player.getPacketSender().sendString(47704, "Dig somewhere In The Warrior Guild Teleport").sendInterface(47700); break; case 2682: player.getPacketSender().sendString(47704, "Dig somewhere in the Yak field").sendInterface(47700); break; Credits: Zivik/Tyler
  13. I've used Ruse a lot and never seen anything even similar to this. OT: int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); From the recoil effect lol. It has nothing to do with barrows degrading. You're making your Dharok's return damage to the attacker.. You also have so much repetetive code. You could do it as simple as this: DegradingItem: public static Optional<DegradingItem> forItem(int item) { for(DegradingItem d : DegradingItem.values()) { if(d.deg == item || d.nonDeg == item) { return Optional.of(d); } } return Optional.empty(); } CombatFactory: //Handle equipped items for our target.. for(Item item : t2.getEquipment().getItems()) { //Check if the target's item should degrade.. Optional<DegradingItem> deg = DegradingItem.forItem(item.getId()); if(deg.isPresent()) { ItemDegrading.handleItemDegrading(t2, deg.get()); } switch(item.getId()) { //Handle other items.. case 2550: //Handle recoil effect.. break; } } Wrote this quickly.
  14. I decided not to add degrading armours so basically it's dead code I made a while back. If you wan't to use it enjoy. CombatFactory: Find: /** PHOENIX NECK **/ Add all this above that line. /** DHAROKS DEGRADE START BY JAKE **/ /** DHAROKS HELM **/ else if(t2.getEquipment().getItems()[Equipment.HEAD_SLOT].getId() == 4716) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_HELM); } /** DHAROKS HELM 100 **/ else if(t2.getEquipment().getItems()[Equipment.HEAD_SLOT].getId() == 4880) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_HELM_100); } /** DHAROKS HELM 75 **/ else if(t2.getEquipment().getItems()[Equipment.HEAD_SLOT].getId() == 4881) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_HELM_75); } /** DHAROKS HELM 50 **/ else if(t2.getEquipment().getItems()[Equipment.HEAD_SLOT].getId() == 4882) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_HELM_50); } /** DHAROKS HELM 25 **/ else if(t2.getEquipment().getItems()[Equipment.HEAD_SLOT].getId() == 4883) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_HELM_25); } /** DHAROKS PLATE **/ else if(t2.getEquipment().getItems()[Equipment.BODY_SLOT].getId() == 4720) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_BODY); } /** DHAROKS PLATE 100 **/ else if(t2.getEquipment().getItems()[Equipment.BODY_SLOT].getId() == 4892) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_BODY_100); } /** DHAROKS PLATE 75 **/ else if(t2.getEquipment().getItems()[Equipment.BODY_SLOT].getId() == 4893) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_BODY_75); } /** DHAROKS PLATE 50 **/ else if(t2.getEquipment().getItems()[Equipment.BODY_SLOT].getId() == 4894) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_BODY_50); } /** DHAROKS PLATE 25 **/ else if(t2.getEquipment().getItems()[Equipment.BODY_SLOT].getId() == 4895) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_BODY_25); } /** DHAROKS LEGS **/ else if(t2.getEquipment().getItems()[Equipment.LEG_SLOT].getId() == 4722) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_LEGS); } /** DHAROKS LEGS 100 **/ else if(t2.getEquipment().getItems()[Equipment.LEG_SLOT].getId() == 4898) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_LEGS_100); } /** DHAROKS LEGES 75 **/ else if(t2.getEquipment().getItems()[Equipment.LEG_SLOT].getId() == 4899) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_LEGS_75); } /** DHAROKS LEGS 50 **/ else if(t2.getEquipment().getItems()[Equipment.LEG_SLOT].getId() == 4900) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_LEGS_50); } /** DHAROKS LEGS 25 **/ else if(t2.getEquipment().getItems()[Equipment.LEG_SLOT].getId() == 4901) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_LEGS_25); } /** DHAROKS AXE **/ else if(t2.getEquipment().getItems()[Equipment.WEAPON_SLOT].getId() == 4718) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_AXE); } /** DHAROKS AXE 100 **/ else if(t2.getEquipment().getItems()[Equipment.WEAPON_SLOT].getId() == 4886) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_AXE_100); } /** DHAROKS AXE 75 **/ else if(t2.getEquipment().getItems()[Equipment.WEAPON_SLOT].getId() == 4887) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_AXE_75); } /** DHAROKS AXE 50 **/ else if(t2.getEquipment().getItems()[Equipment.WEAPON_SLOT].getId() == 4888) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_AXE_50); } /** DHAROKS AXE 25 **/ else if(t2.getEquipment().getItems()[Equipment.WEAPON_SLOT].getId() == 4889) { int recDamage = (int) (damage * 0.001); if (recDamage <= 0) return; if (recDamage > t2.getConstitution()) recDamage = t2.getConstitution(); attacker.dealDamage(new Hit(recDamage, Hitmask.RED, CombatIcon.DEFLECT)); ItemDegrading.handleItemDegrading(t2, DegradingItem.DHAROKS_AXE_25); } /** DHAROKS END BY JAKE **/ DegradingItem: (Under Ring of Wealth) //Dharoks By Jake DHAROKS_HELM(4716, 4880, Equipment.HEAD_SLOT, 20), DHAROKS_HELM_100(4880, 4881, Equipment.HEAD_SLOT, 20), DHAROKS_HELM_75(4881, 4882, Equipment.HEAD_SLOT, 20), DHAROKS_HELM_50(4882, 4883, Equipment.HEAD_SLOT, 20), DHAROKS_HELM_25(4883, 0, Equipment.HEAD_SLOT, 20), DHAROKS_BODY(4720, 4892, Equipment.BODY_SLOT, 20), DHAROKS_BODY_100(4892, 4893, Equipment.BODY_SLOT, 20), DHAROKS_BODY_75(4893, 4894, Equipment.BODY_SLOT, 20), DHAROKS_BODY_50(4894, 4895, Equipment.BODY_SLOT, 20), DHAROKS_BODY_25(4895, 0, Equipment.BODY_SLOT, 20), DHAROKS_LEGS(4722, 4898, Equipment.LEG_SLOT, 20), DHAROKS_LEGS_100(4898, 4899, Equipment.LEG_SLOT, 20), DHAROKS_LEGS_75(4899, 4900, Equipment.LEG_SLOT, 20), DHAROKS_LEGS_50(4900, 4901, Equipment.LEG_SLOT, 20), DHAROKS_LEGS_25(4901, 0, Equipment.LEG_SLOT, 20), DHAROKS_AXE(4718, 4886, Equipment.WEAPON_SLOT, 20), DHAROKS_AXE_100(4886, 4887, Equipment.WEAPON_SLOT, 20), DHAROKS_AXE_75(4887, 4888, Equipment.WEAPON_SLOT, 20), DHAROKS_AXE_50(4888, 4889, Equipment.WEAPON_SLOT, 20), DHAROKS_AXE_25(4889, 0, Equipment.WEAPON_SLOT, 20),
  15. Pretty simple if you have a player and cant keep track of appeals/warnings. Let's start off in PointsHandler: /* * Warning Points */ private int warningPoints; public void setwarningPoints(int points, boolean add) { if(add) this.warningPoints += points; else this.warningPoints = points; } public int getWarningPoints() { return this.warningPoints; } public void incrementWarningPoints() { this.warningPoints++; } public void incrementWarningPoints(int amt) { this.warningPoints += amt; } public void setWarningPoints(int warningPoints) { this.warningPoints = warningPoints; } Now we if they have more than 0 warning points they will get a notification on login. PlayerHandler: (Under get minutes bonus XP method) if(player.getPointsHandler().getWarningPoints() == 10) { World.deregister(player); String p = player.getUsername().toLowerCase(); PlayerPunishment.autoban(p); } if (player.getPointsHandler().getWarningPoints() != 0) { player.getPA().sendMessage("@red@[AUTO-BAN] If you reach 10 Warning Points you will be Auto Banned."); player.getPA().sendMessage("@red@[AUTO-BAN] You currently have "+player.getPointsHandler().getWarningPoints()+" Warning Points."); } Next we head to playerpunishment. public static void autoban(String player) { player = Misc.formatPlayerName(player.toLowerCase()); if(!AccountsBanned.contains(player)) { addToFile(""+BAN_DIRECTORY+"Bans.txt", player); AccountsBanned.add(player); } } Finally the command: (CommandPacketListener) if(command[0].contains("warn")) { String plr = wholeCommand.substring(5); Player playr2 = World.getPlayerByName(plr); if(playr2 != null) { playr2.getPointsHandler().setwarningPoints(1, true); playr2.getPA().sendMessage("@red@You have received 1 warning point!"); playr2.getPointsHandler().refreshPanel(); } else player.getPacketSender().sendMessage("Could not find player: "+plr); } I left a bracket out, if you can't figure it out you probably shouldn't be reading this.
  16. I wanted to release my version of the firemaking skill, it may not be the best but its a script i felt happy enough to release to the public, it has clipped lighting to you can't walk into walls / unwanted places, it has all the log types (Excluding redwood) and has their exp, time to live, and log ids for convenience, the clipping order is West, East, South, North, and the chances that you burn a log was taken from arios' code so if anyone has the mathmatics for that i can add it on. It has checks to make sure the log hasn't been picked up and if it has it will halt all action and reward no experience. ashs on ground also work, and will be there for 60 seconds (should be there for the logs time to live + 200 ticks correct me if im wrong), if anyone has constructive critisim they can post below, pls no flamming if certain areas of the code are bad or can be improved, thanks everyone Start off by defining this in SkillsManager.java private int lastFireTime; and give its getters and setters public int getLastFireTime() { return lastFireTime; } public void setLastFireTime(int lastFireTime) { this.lastFireTime = lastFireTime; } now define Firemaking.java and place in package of choice package com.elvarg.world.content.skills.firemaking; import com.elvarg.GameConstants; import com.elvarg.engine.task.Task; import com.elvarg.engine.task.TaskManager; import com.elvarg.world.entity.impl.object.GameObject; import com.elvarg.world.entity.impl.object.ObjectHandler; import com.elvarg.world.entity.impl.player.Player; import com.elvarg.world.grounditems.GroundItemManager; import com.elvarg.world.model.Animation; import com.elvarg.world.model.GroundItem; import com.elvarg.world.model.Item; import com.elvarg.world.model.PlayerRights; import com.elvarg.world.model.Position; import com.elvarg.world.model.Skill; import com.elvarg.world.model.movement.MovementStatus; /** * The Firemaking class. * @author Oscar Morton <"S C A P E" on Rune-Server> * */ public class Firemaking { /** * The player */ Player player; /** * The log on the ground */ GroundItem groundlog; /** * The log with the data */ LogData log; /** * The fire object */ GameObject fire; /** * Ticks */ int ticks = 0; /** * Firemaking animation */ Animation ANIMATION = new Animation(733); /** * A ground item for the ash */ GroundItem ash; /** * The Original position */ Position OriginalPosition; /** * The light method to light the log, this is basicly the main method, i should spread it all out a bit. * Thats for you guys though :P * @param player the player whos lighting the log. * @param log the log thats getting lit on fire. */ public Firemaking(Player player, LogData log) { this.player = player; this.log = log; /** * Checks if you have even got the right firemaking level to light the log. */ if (player.getSkillManager().getCurrentLevel(Skill.FIREMAKING) < log.getLevel()) { player.getPacketSender().sendMessage("You need a firemaking level of " + log.getLevel() + " to light this."); return; } if (ObjectHandler.objectExists(player.getPosition())) { player.getPacketSender().sendMessage("You can't light a fire here."); return; } /** * Checks if they lit a log .5 ticks ago. */ if (System.currentTimeMillis() - player.getSkillManager().getLastFireTime()<(GameConstants.GAME_ENGINE_PROCESSING_CYCLE_RATE/2)) { return; } /** * Checks if the player has a tinderbox since the last time that the game checked. */ if (!player.getInventory().contains(new Item(590,1))) { player.getPacketSender().sendMessage("You need a tinderbox to light a fire."); return; } /** * The log that gets placed on the ground while the animation goes on. */ groundlog = new GroundItem(new Item(log.getLog()), player.getPosition(), player.getUsername(),player.getHostAddress(),false,5000,false,5000); GroundItemManager.add(groundlog, true);//Adds the log player.performAnimation(ANIMATION);//Plays the lighting animation player.getPacketSender().sendMessage("You attempt to light the logs.");//sends a message to the player //telling them they start to light. player.getInventory().delete(new Item(log.getLog()));//gets rid of the log in the inventory. fire = new GameObject(log.getFire(), player.getPosition());//makes the fire gameobject something. OriginalPosition = player.getPosition(); TaskManager.submit(new Task(1) {//submits a new task taking 1 game tick to perform and wont end until certain conditions are met. @Override protected void execute() { ticks++; if (groundlog == null || groundlog.hasBeenPickedUp() || player.getPosition() != OriginalPosition) { player.performAnimation(Animation.DEFAULT_RESET_ANIMATION); this.stop(); return; } if (ticks == 0) { player.performAnimation(ANIMATION); } if (++ticks % 3 != 0) { return; } if (ticks % 12 == 0) { player.performAnimation(ANIMATION); } if (!success()) { return; } createFire();//creates the fire this.stop(); return; } }); } private boolean success() {//checks the success, script taken from arios. int level = 1 + player.getSkillManager().getCurrentLevel(Skill.FIREMAKING); double hostRatio = Math.random() * log.getLevel(); double clientRatio = Math.random() * ((level - log.getLevel()) * (1 + (log.getLevel() * 0.01))); return hostRatio < clientRatio && !groundlog.hasBeenPickedUp(); } public void createFire() {//creates the fire TaskManager.submit(new Task(1) {//task taking 1 game tick to start @Override protected void execute() { if (groundlog.hasBeenPickedUp() != true) { player.getSkillManager().setLastFireTime(System.currentTimeMillis()); ObjectHandler.spawnGlobalObject(fire); player.performAnimation(Animation.DEFAULT_RESET_ANIMATION); if (player.getMovementQueue().canWalk(1, 0)) { player.getMovementQueue().walkStep(1, 0); } else { if (player.getMovementQueue().canWalk(-1, 0)) { player.getMovementQueue().walkStep(-1, 0); } else { if (player.getMovementQueue().canWalk(0, -1)) { player.getMovementQueue().walkStep(0, -1); } else { if (player.getMovementQueue().canWalk(0,1)) { player.getMovementQueue().walkStep(0, 1); } } } } player.setPositionToFace(fire.getPosition()); GroundItemManager.remove(groundlog, true); player.getSkillManager().addExperience(Skill.FIREMAKING, (int)log.getExperience() * (int)GameConstants.EXP_MULTIPLIER); if (player.getRights() == PlayerRights.DEVELOPER) { player.getPacketSender().sendMessage("[DEBUG]: You have lighten a log at ["+fire.getPosition()+"]."); } player.getPacketSender().sendMessage("You light a fire."); player.getMovementQueue().setMovementStatus(MovementStatus.NONE); ash = new GroundItem(new Item(592), fire.getPosition(), player.getUsername(),player.getHostAddress(),false,100,false,100); TaskManager.submit(new Task((int)log.getLife()) { @Override protected void execute() { ObjectHandler.despawnGlobalObject(fire); if (player.getRights() == PlayerRights.DEVELOPER) { player.getPacketSender().sendMessage("[DEBUG]: Your log at ["+fire.getPosition()+"] has despawned."); } ash(); this.stop(); return; } }); this.stop(); return; } } }); } public void ash() { GroundItemManager.add(ash, true); TaskManager.submit(new Task((100),false) { @Override protected void execute() { GroundItemManager.remove(ash, true); this.stop(); return; } }); return; } } and LogData.java package com.elvarg.world.content.skills; /** * Represents all our log data, for the firemaking skill. * @author Oscar Morton <S C A P E on RuneServer> * */ public enum LogData { LOG(1511, 1, 40, 26185,180), Achey_LOG(2862, 1, 40, 26185,180), OAK_LOG(1521, 15, 60, 26185,200), WILLOW_LOG(1519, 30, 90, 26185,300), TEAK_LOG(6333, 35, 105, 26185,450), ARCTIC_PINE_LOG(10810, 42, 125, 26185,500), MAPLE_LOG(1517, 45, 135, 26185,400), MAHOGANY_LOG(6332, 50, 157.5, 26185,400), YEW_LOG(1515, 60, 202.5, 26185,202.5), MAGIC_LOG(1513, 75, 303.8, 26185,303.8), BLUE_LOG(7406, 1, 250, 26576,180), GREEN_LOG(7405, 1, 250, 26575,180), RED_LOG(7404, 1, 250, 26186,180), WHITE_LOG(10328, 1, 250, 20000,180), PURPLE_LOG(10329, 1, 250, 20001,180); private int log; private int level; private double exp; private int fire; private double life; private LogData(int log, int level, double exp, int fire,double life) { this.log = log; this.level = level; this.exp = exp; this.fire = fire; this.life = life; } public double getLife() { return life; } public void setLife(double life) { this.life = life; } public int getLog() { return log; } public int getLevel() { return level; } public double getExperience() { return exp; } public int getFire() { return fire; } } and finally add this bit of code into your UseItemPacketListener.java for (final LogData log : LogData.values()) { if ((used.getId() == 590 && usedWith.getId() == log.getLog()) || (used.getId() == log.getLog() && usedWith.getId() == 590)) { new Firemaking(player,log); } } here is some footage while in game
  17. I made a quick item on bank un-noting system that took me 5 minuites but i thought I should share. Just copy and paste the below into the itemOnObject method inside of UseItemPacket class For this to work you need to have defined that the item is noted in items.json if (item.getDefinition().isNoted() && gameObject.getDefinition().getName().toLowerCase().contains("bank")) { int id = item.getDefinition().getNoteId(); int amount = item.getAmount(); if (player.getInventory().getFreeSlots() == 0) { player.getPacketSender().sendMessage("You don't have enough space in your inventory."); return; } if (amount > player.getInventory().getFreeSlots()) amount = player.getInventory().getFreeSlots(); player.getInventory().getById(item.getId()).decrementAmountBy(amount); player.getInventory().add(id,amount); player.getPacketSender().sendMessage("You withdraw " + (amount) + " " + item.getDefinition().getName() + (amount > 1 ? "s" : "") + "."); } if (!item.getDefinition().isNoted() && item.getDefinition().getNoteId() != -1 && gameObject.getDefinition().getName().toLowerCase().contains("bank")) { player.setDialogueOptions(new DialogueOptions() { @Override public void handleOption(Player player, int option) { switch (option) { case 1: int amount = player.getInventory().getAmount(item.getId()); int id = item.getDefinition().getNoteId(); player.getInventory().delete(item.getId(),amount); player.getInventory().add(id,amount); player.getPacketSender().sendInterfaceRemoval(); break; case 2: player.getPacketSender().sendInterfaceRemoval(); break; } } }); DialogueManager.start(player, new Dialogue() { @Override public DialogueType type() { return DialogueType.OPTION; } @Override public DialogueExpression animation() { return null; } @Override public String[] dialogue() { return new String[] {"Note","Cancel"}; } }); } UPDATED: Can un-noted AND note using options
  18. Wrote this very quickly cause I had to test some core updates I made to my Elvarg base. Keep in mind 90% of the code was taken from the client. Difficulty: 1/10, just copy paste What you're adding: Let's start, create a new package called "flood" or something, add these in it: package com.elvarg.util.flood; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import com.elvarg.Server; import com.elvarg.game.GameConstants; import com.elvarg.net.NetworkConstants; import com.elvarg.net.login.LoginResponses; import com.elvarg.net.security.IsaacRandom; /** * Represents a client which will attempt * to connect to the server. * * This can be used to stresstest the server. * * Note: Code was copy+pasted from client. * I've barely touched it. * * @author Professor Oak */ public class Client { public Client(String username, String password) { this.username = username; this.password = password; } private final String username; private final String password; private Buffer incoming, login; private ByteBuffer outgoing; private BufferedConnection socketStream; private long serverSeed; private IsaacRandom encryption; public boolean loggedIn; public void attemptLogin() throws Exception { login = Buffer.create(); incoming = Buffer.create(); outgoing = ByteBuffer.create(5000, false, null); socketStream = new BufferedConnection(openSocket(NetworkConstants.GAME_PORT)); outgoing.putByte(14); //REQUEST socketStream.queueBytes(1, outgoing.getBuffer()); int response = socketStream.read(); //Our encryption for outgoing messages for this player's session IsaacRandom cipher = null; if (response == 0) { socketStream.flushInputStream(incoming.payload, 8); incoming.currentPosition = 0; serverSeed = incoming.readLong(); // aka server session key int seed[] = new int[4]; seed[0] = (int) (Math.random() * 99999999D); seed[1] = (int) (Math.random() * 99999999D); seed[2] = (int) (serverSeed >> 32); seed[3] = (int) serverSeed; outgoing.resetPosition(); outgoing.putByte(10); outgoing.putInt(seed[0]); outgoing.putInt(seed[1]); outgoing.putInt(seed[2]); outgoing.putInt(seed[3]); outgoing.putInt(4 >> 1); outgoing.putString(username); outgoing.putString(password); outgoing.encryptRSAContent(); login.currentPosition = 0; login.writeByte(16); //18 if reconnecting, we aren't though login.writeByte(outgoing.getPosition() + 1 + 1 + 2); // size of the // login block login.writeByte(255); login.writeShort(GameConstants.GAME_VERSION); //Client version login.writeByte(0); // low mem login.writeBytes(outgoing.getBuffer(), outgoing.getPosition(), 0); cipher = new IsaacRandom(seed); for (int index = 0; index < 4; index++) seed[index] += 50; encryption = new IsaacRandom(seed); socketStream.queueBytes(login.currentPosition, login.payload); response = socketStream.read(); } if (response == LoginResponses.LOGIN_SUCCESSFUL) { Server.getFlooder().clients.put(username, this); int rights = socketStream.read(); loggedIn = true; outgoing = ByteBuffer.create(5000, true, cipher); incoming.currentPosition = 0; } } int pingCounter = 0; public void process() throws Exception { if(loggedIn) { /*for(int i = 0; i < 5; i++) { if(!readPacket()) break; }*/ if(pingCounter++ >= 25) { outgoing.resetPosition(); //Basic packet ping to keep connection alive outgoing.putOpcode(0); if (socketStream != null) { socketStream.queueBytes(outgoing.bufferLength(), outgoing.getBuffer()); } pingCounter = 0; } } } private boolean readPacket() throws Exception { if (socketStream == null) { return false; } int available = socketStream.available(); if (available < 2) { return false; } int opcode = -1; int packetSize = -1; //First we read opcode... if(opcode == -1) { socketStream.flushInputStream(incoming.payload, 1); opcode = incoming.payload[0] & 0xff; if (encryption != null) { opcode = opcode - encryption.nextInt() & 0xff; } //Now attempt to read packet size.. socketStream.flushInputStream(incoming.payload, 2); packetSize = ((incoming.payload[0] & 0xff) << 8) + (incoming.payload[1] & 0xff); } if(!(opcode >= 0 && opcode < 256)) { opcode = -1; return false; } incoming.currentPosition = 0; socketStream.flushInputStream(incoming.payload, packetSize); switch(opcode) { } return false; } private Socket openSocket(int port) throws IOException { return new Socket(InetAddress.getByName("localhost"), port); } } package com.elvarg.util.flood; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import com.elvarg.util.Misc; /** * An implementation of {@link Runnable} which creates * new clients and tries to connect them with the server. * * @author Professor Oak */ public class Flooder implements Runnable { /** * The clients that are currently active. * We can use this map to distinguish fake-clients * from real ones. */ public final Map<String, Client> clients = new HashMap<String, Client>(); /** * Is this flooder currently running? */ private boolean running; /** * Starts this flooder if it hasn't * been started already. */ public void start() { if(!running) { running = true; new Thread(this).start(); } } /** * Stops this flooder. * * Any logged in clients will eventually be disconnected * from the server automatically for being idle. */ public void stop() { running = false; } /** * Attempts to login the amount of given clients. * @param amount */ public void login(int amount) { //Make sure we have started before logging in clients. start(); //Attempt to login the amount of bots.. synchronized(clients) { for(int i = 0; i < amount; i++) { try { String username = "bot" + Integer.toString(clients.size()); String password = "bot"; new Client(Misc.formatText(username), password).attemptLogin(); } catch(Exception e) { e.printStackTrace(); } } } } @Override public void run() { while(running) { try { Iterator<Entry<String, Client>> i = clients.entrySet().iterator(); while(i.hasNext()) { Entry<String, Client> entry = i.next(); try { entry.getValue().process(); } catch(Exception e) { e.printStackTrace(); i.remove(); } } Thread.sleep(300); } catch(Exception e) { e.printStackTrace(); } } } } Buffers, don't ask why there are two of them lmao package com.elvarg.util.flood; import java.math.BigInteger; import com.elvarg.net.security.IsaacRandom; public final class ByteBuffer { private int bitPosition; private byte[] buffer; private IsaacRandom cipher; private int position; private static final int pkt_opcode_slot = 0; private static final int pkt_size_slot = 1; private static final int pkt_content_start = 2; private boolean reserve_packet_slots; private int size; private ByteBuffer() { } public static ByteBuffer create(int size, boolean reserve_packet_slots, IsaacRandom cipher) { ByteBuffer stream_1 = new ByteBuffer(); stream_1.buffer = new byte[size]; stream_1.reserve_packet_slots = reserve_packet_slots; stream_1.size = size; stream_1.position = reserve_packet_slots ? pkt_content_start : pkt_opcode_slot; stream_1.cipher = cipher; return stream_1; } public void reset(boolean reserve_packet_slots) { this.buffer = new byte[size]; this.reserve_packet_slots = reserve_packet_slots; this.position = reserve_packet_slots ? pkt_content_start : pkt_opcode_slot; } public void encryptRSAContent() { /* Cache the current position for future use */ int currentPosition = position; /* Reset the position */ position = reserve_packet_slots ? pkt_content_start : pkt_opcode_slot; /* An empty byte array with a capacity of {@code #currentPosition} bytes */ byte[] decodeBuffer = new byte[currentPosition]; /* * Gets bytes up to the current position from the buffer and populates * the {@code #decodeBuffer} */ getBytes(currentPosition, 0, decodeBuffer); /* * The decoded big integer which translates the {@code #decodeBuffer} * into a {@link BigInteger} */ BigInteger decodedBigInteger = new BigInteger(decodeBuffer); /* * This is going to be a mouthful... the encoded {@link BigInteger} is * responsible of returning a value which is the value of {@code * #decodedBigInteger}^{@link #RSA_EXPONENT} mod (Modular arithmetic can * be handled mathematically by introducing a congruence relation on the * integers that is compatible with the operations of the ring of * integers: addition, subtraction, and multiplication. For a positive * integer n, two integers a and b are said to be congruent modulo n) * {@link #RSA_MODULES} */ BigInteger encodedBigInteger = decodedBigInteger.modPow(RSA_EXPONENT, RSA_MODULUS); /* * Returns the value of the {@code #encodedBigInteger} translated to a * byte array in big-endian byte-order */ byte[] encodedBuffer = encodedBigInteger.toByteArray(); /* Reset the position so we can write fresh to the buffer */ position = reserve_packet_slots ? pkt_content_start : pkt_opcode_slot; /* * We put the length of the {@code #encodedBuffer} to the buffer as a * standard byte. (Ignore the naming, that really writes a byte...) */ putByte(encodedBuffer.length); /* Put the bytes of the {@code #encodedBuffer} into the buffer. */ putBytes(encodedBuffer, encodedBuffer.length, 0); } public void finishBitAccess() { position = (bitPosition + 7) / 8; } public int getBits(int bitLength) { int k = bitPosition >> 3; int l = 8 - (bitPosition & 7); int i1 = 0; bitPosition += bitLength; for (; bitLength > l; l = 8) { i1 += (buffer[k++] & BIT_CONSTANTS[l]) << bitLength - l; bitLength -= l; } if (bitLength == l) { i1 += buffer[k] & BIT_CONSTANTS[l]; } else { i1 += buffer[k] >> l - bitLength & BIT_CONSTANTS[bitLength]; } return i1; } public byte getByte() { return buffer[position++]; } public void getByte(int value) { buffer[position++] = (byte) value; } public byte[] getBytes() { int pos = position; while (buffer[position++] != 10) { ; } byte[] buf = new byte[position - pos - 1]; System.arraycopy(buffer, pos, buf, pos - pos, position - 1 - pos); return buf; } public void getBytes(int len, int off, byte[] dest) { for (int i = off; i < off + len; i++) { dest[i] = buffer[position++]; } } public int getInt() { position += 4; return ((buffer[position - 4] & 0xFF) << 24) + ((buffer[position - 3] & 0xFF) << 16) + ((buffer[position - 2] & 0xFF) << 8) + (buffer[position - 1] & 0xFF); } public int getIntLittleEndian() { position += 4; return ((buffer[position - 4] & 0xFF) << 24) + ((buffer[position - 3] & 0xFF) << 16) + ((buffer[position - 2] & 0xFF) << 8) + (buffer[position - 1] & 0xFF); } public long getLong() { long msw = getIntLittleEndian() & 0xFFFFFFFFL; long lsw = getIntLittleEndian() & 0xFFFFFFFFL; return msw << 32 | lsw; } public int getShort() { position += 2; return ((buffer[position - 2] & 0xFF) << 8) + (buffer[position - 1] & 0xFF); } public int getShort2() { position += 2; int i = ((buffer[position - 2] & 0xFF) << 8) + (buffer[position - 1] & 0xFF); if (i > 60000) { i = -65535 + i; } return i; } public int getShortBigEndian() { position += 2; return ((buffer[position - 1] & 0xFF) << 8) + (buffer[position - 2] & 0xFF); } public int getShortBigEndianA() { position += 2; return ((buffer[position - 1] & 0xFF) << 8) + (buffer[position - 2] - 128 & 0xFF); } public byte getSignedByte() { return buffer[position++]; } public int getSignedShort() { position += 2; int value = ((buffer[position - 2] & 0xFF) << 8) + (buffer[position - 1] & 0xFF); if (value > 32767) { value -= 0x10000; } return value; } public int getSmart() { try { // checks current without modifying position if (position >= buffer.length) { return buffer[buffer.length - 1] & 0xFF; } int value = buffer[position] & 0xFF; if (value < 128) { return getUnsignedByte(); } else { return getUnsignedShort() - 32768; } } catch (Exception e) { e.printStackTrace(); return getUnsignedShort() - 32768; } } public String getString() { int i = position; while (buffer[position++] != 10) { } return new String(buffer, i, position - i - 1); } public int getTribyte() { position += 3; return ((buffer[position - 3] & 0xFF) << 16) + ((buffer[position - 2] & 0xFF) << 8) + (buffer[position - 1] & 0xFF); } public final int getTribyte(int value) { position += 3; return (0xFF & buffer[position - 3] << 16) + (0xFF & buffer[position - 2] << 8) + (0xFF & buffer[position - 1]); } public int getUnsignedByte() { if (position + 1 > buffer.length) { position = buffer.length - 2; } return buffer[position++] & 0xFF; } public int getUnsignedShort() { if (position + 2 > buffer.length) { return buffer[buffer.length - 1]; } position += 2; return ((buffer[position - 2] & 0xFF) << 8) + (buffer[position - 1] & 0xFF); } public int getUSmart2() { int baseVal = 0; int lastVal = 0; while ((lastVal = getSmart()) == 32767) { baseVal += 32767; } return baseVal + lastVal; } public void initBitAccess() { bitPosition = position << 3; } void method400(int value) { buffer[position++] = (byte) value; buffer[position++] = (byte) (value >> 8); } void method403(int value) { buffer[position++] = (byte) value; buffer[position++] = (byte) (value >> 8); buffer[position++] = (byte) (value >> 16); buffer[position++] = (byte) (value >> 24); } public int method421() { int i = buffer[position] & 0xFF; if (i < 128) { return getUnsignedByte() - 64; } else { return getUnsignedShort() - 49152; } } public void method424(int i) { buffer[position++] = (byte) -i; } public void method425(int j) { buffer[position++] = (byte) (128 - j); } public int method426() { return buffer[position++] - 128 & 0xFF; } public int method427() { return -buffer[position++] & 0xFF; } public int getByteA() { position += 2; return ((buffer[position - 2] & 0xff) << 8) + (buffer[position - 1] - 128 & 0xff); } public int method428() { return 128 - buffer[position++] & 0xFF; } public byte method429() { return (byte) -buffer[position++]; } public byte method430() { return (byte) (128 - buffer[position++]); } public void writeUnsignedWordBigEndian(int i) { buffer[position++] = (byte) i; buffer[position++] = (byte) (i >> 8); } public void writeUnsignedWordA(int j) { buffer[position++] = (byte) (j >> 8); buffer[position++] = (byte) (j + 128); } public void writeSignedBigEndian(int j) { buffer[position++] = (byte) (j + 128); buffer[position++] = (byte) (j >> 8); } public int method435() { position += 2; return ((buffer[position - 2] & 0xFF) << 8) + (buffer[position - 1] - 128 & 0xFF); } public int method437() { position += 2; int j = ((buffer[position - 1] & 0xFF) << 8) + (buffer[position - 2] & 0xFF); if (j > 32767) { j -= 0x10000; } return j; } public int method438() { position += 2; int j = ((buffer[position - 1] & 0xFF) << 8) + (buffer[position - 2] - 128 & 0xFF); if (j > 32767) { j -= 0x10000; } return j; } public int method439() { position += 4; return ((buffer[position - 2] & 0xFF) << 24) + ((buffer[position - 1] & 0xFF) << 16) + ((buffer[position - 4] & 0xFF) << 8) + (buffer[position - 3] & 0xFF); } public int method440() { position += 4; return ((buffer[position - 3] & 0xFF) << 24) + ((buffer[position - 4] & 0xFF) << 16) + ((buffer[position - 1] & 0xFF) << 8) + (buffer[position - 2] & 0xFF); } public void method441(int i, byte abyte0[], int j) { for (int k = i + j - 1; k >= i; k--) { buffer[position++] = (byte) (abyte0[k] + 128); } } public void method442(int i, int j, byte abyte0[]) { for (int k = j + i - 1; k >= j; k--) { abyte0[k] = buffer[position++]; } } public void putBytes(byte[] tmp, int len, int off) { for (int i = off; i < off + len; i++) { buffer[position++] = tmp[i]; } } public void putDWordBigEndian(int value) { buffer[position++] = (byte) (value >> 16); buffer[position++] = (byte) (value >> 8); buffer[position++] = (byte) value; } public void putInt(int i) { buffer[position++] = (byte) (i >> 24); buffer[position++] = (byte) (i >> 16); buffer[position++] = (byte) (i >> 8); buffer[position++] = (byte) i; } public void putLong(long value) { try { buffer[position++] = (byte) (value >> 56); buffer[position++] = (byte) (value >> 48); buffer[position++] = (byte) (value >> 40); buffer[position++] = (byte) (value >> 32); buffer[position++] = (byte) (value >> 24); buffer[position++] = (byte) (value >> 16); buffer[position++] = (byte) (value >> 8); buffer[position++] = (byte) value; } catch (RuntimeException runtimeexception) { throw new RuntimeException(); } } public void putOpcode(int i) { buffer[reserve_packet_slots ? pkt_opcode_slot : position++] = (byte) (i + cipher.nextInt()); } public void putShort(int value) { buffer[position++] = (byte) (value >> 8); buffer[position++] = (byte) value; } public void putString(String s) { System.arraycopy(s.getBytes(), 0, buffer, position, s.length()); position += s.length(); buffer[position++] = 10; } public void putVariableSizeByte(int size) { buffer[position - size - 1] = (byte) size; } public void putByte(int i) { buffer[position++] = (byte) i; } public int getBitPosition() { return bitPosition; } public IsaacRandom getCipher() { return cipher; } public void setCipher(IsaacRandom cipher) { this.cipher = cipher; } public byte[] getBuffer() { return buffer; } public int bufferLength() { int size = position; if(reserve_packet_slots) { /* Update the pkt_size slot and encrypt it */ buffer[pkt_size_slot] = (byte) (size + cipher.nextInt()); } return size; } public void resetPosition() { this.position = reserve_packet_slots ? pkt_content_start : pkt_opcode_slot; } public int getPosition() { return position; } public ByteBuffer(byte[] buffer) { this.buffer = buffer; } private static final int[] BIT_CONSTANTS = { 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 0x1ffff, 0x3ffff, 0x7ffff, 0xFFfff, 0x1fffff, 0x3fffff, 0x7fffff, 0xFFffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xFFfffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, -1 }; public static final BigInteger RSA_MODULUS = new BigInteger("104491769878744214552327916539299463496996457081116392641740420337580247359457531212713234798435269852381858199895582444770363103378419890508986198319599243102737368616946490728678876018327788000439596635223141886089230154991381365099178986572201859664528128354742213167942196819984139030533812106754541601427"); public static final BigInteger RSA_EXPONENT = new BigInteger("65537"); } package com.elvarg.util.flood; import java.math.BigInteger; import com.elvarg.net.security.IsaacRandom; public final class Buffer { public byte payload[]; public int currentPosition; public int bitPosition; private static final int[] BIT_MASKS = { 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, -1 }; public IsaacRandom encryption; public static Buffer create() { Buffer buffer = new Buffer(); buffer.currentPosition = 0; buffer.payload = new byte[5000]; return buffer; } public final int readUTriByte() { currentPosition += 3; return (0xff & payload[currentPosition - 3] << 16) + (0xff & payload[currentPosition - 2] << 8) + (0xff & payload[currentPosition - 1]); } public final int readUTriByte(int i) { currentPosition += 3; return (0xff & payload[currentPosition - 3] << 16) + (0xff & payload[currentPosition - 2] << 8) + (0xff & payload[currentPosition - 1]); } private Buffer() {} public Buffer(byte[] payload) { this.payload = payload; currentPosition = 0; } public int readUSmart2() { int baseVal = 0; int lastVal = 0; while ((lastVal = readUSmart()) == 32767) { baseVal += 32767; } return baseVal + lastVal; } public String readNewString() { int i = currentPosition; while (payload[currentPosition++] != 0) ; return new String(payload, i, currentPosition - i - 1); } public void writeOpcode(int opcode) { payload[currentPosition++] = (byte) (opcode + encryption.nextInt()); } public void writeByte(int value) { payload[currentPosition++] = (byte) value; } public void writeShort(int value) { payload[currentPosition++] = (byte) (value >> 8); payload[currentPosition++] = (byte) value; } public void writeTriByte(int value) { payload[currentPosition++] = (byte) (value >> 16); payload[currentPosition++] = (byte) (value >> 8); payload[currentPosition++] = (byte) value; } public void writeInt(int value) { payload[currentPosition++] = (byte) (value >> 24); payload[currentPosition++] = (byte) (value >> 16); payload[currentPosition++] = (byte) (value >> 8); payload[currentPosition++] = (byte) value; } public void writeLEInt(int value) { payload[currentPosition++] = (byte) value; payload[currentPosition++] = (byte) (value >> 8); payload[currentPosition++] = (byte) (value >> 16); payload[currentPosition++] = (byte) (value >> 24); } public void writeLong(long value) { try { payload[currentPosition++] = (byte) (int) (value >> 56); payload[currentPosition++] = (byte) (int) (value >> 48); payload[currentPosition++] = (byte) (int) (value >> 40); payload[currentPosition++] = (byte) (int) (value >> 32); payload[currentPosition++] = (byte) (int) (value >> 24); payload[currentPosition++] = (byte) (int) (value >> 16); payload[currentPosition++] = (byte) (int) (value >> 8); payload[currentPosition++] = (byte) (int) value; } catch (RuntimeException runtimeexception) { System.err.println("14395, " + 5 + ", " + value + ", " + runtimeexception.toString()); throw new RuntimeException(); } } public void writeString(String text) { System.arraycopy(text.getBytes(), 0, payload, currentPosition, text.length()); currentPosition += text.length(); payload[currentPosition++] = 10; } public void writeBytes(byte data[], int offset, int length) { for (int index = length; index < length + offset; index++) payload[currentPosition++] = data[index]; } public void writeBytes(int value) { payload[currentPosition - value - 1] = (byte) value; } public int method440() { currentPosition += 4; return ((payload[currentPosition - 3] & 0xFF) << 24) + ((payload[currentPosition - 4] & 0xFF) << 16) + ((payload[currentPosition - 1] & 0xFF) << 8) + (payload[ - 2] & 0xFF); } public int readUnsignedByte() { return payload[currentPosition++] & 0xff; } public int readShort2() { currentPosition += 2; int i = ((payload[currentPosition - 2] & 0xff) << 8) + (payload[currentPosition - 1] & 0xff); if(i > 32767) i -= 65537; return i; } public byte readSignedByte() { return payload[currentPosition++]; } public int readUShort() { currentPosition += 2; return ((payload[currentPosition - 2] & 0xff) << 8) + (payload[currentPosition - 1] & 0xff); } public int readShort() { currentPosition += 2; int value = ((payload[currentPosition - 2] & 0xff) << 8) + (payload[currentPosition - 1] & 0xff); if (value > 32767) { value -= 0x10000; } return value; } public int readTriByte() { currentPosition += 3; return ((payload[currentPosition - 3] & 0xff) << 16) + ((payload[currentPosition - 2] & 0xff) << 8) + (payload[currentPosition - 1] & 0xff); } public int readInt() { currentPosition += 4; return ((payload[currentPosition - 4] & 0xff) << 24) + ((payload[currentPosition - 3] & 0xff) << 16) + ((payload[currentPosition - 2] & 0xff) << 8) + (payload[currentPosition - 1] & 0xff); } public long readLong() { long msi = (long) readInt() & 0xffffffffL; long lsi = (long) readInt() & 0xffffffffL; return (msi << 32) + lsi; } public String readString() { int index = currentPosition; while (payload[currentPosition++] != 10) ; return new String(payload, index, currentPosition - index - 1); } public byte[] readBytes() { int index = currentPosition; while (payload[currentPosition++] != 10) ; byte data[] = new byte[currentPosition - index - 1]; System.arraycopy(payload, index, data, index - index, currentPosition - 1 - index); return data; } public void readBytes(int offset, int length, byte data[]) { for (int index = length; index < length + offset; index++) data[index] = payload[currentPosition++]; } public void initBitAccess() { bitPosition = currentPosition * 8; } public int readBits(int amount) { int byteOffset = bitPosition >> 3; int bitOffset = 8 - (bitPosition & 7); int value = 0; bitPosition += amount; for (; amount > bitOffset; bitOffset = 8) { value += (payload[byteOffset++] & BIT_MASKS[bitOffset]) << amount - bitOffset; amount -= bitOffset; } if (amount == bitOffset) value += payload[byteOffset] & BIT_MASKS[bitOffset]; else value += payload[byteOffset] >> bitOffset - amount & BIT_MASKS[amount]; return value; } public void disableBitAccess() { currentPosition = (bitPosition + 7) / 8; } public int readSmart() { int value = payload[currentPosition] & 0xff; if (value < 128) return readUnsignedByte() - 64; else return readUShort() - 49152; } public int getSmart() { try { // checks current without modifying position if (currentPosition >= payload.length) { return payload[payload.length - 1] & 0xFF; } int value = payload[currentPosition] & 0xFF; if (value < 128) { return readUnsignedByte(); } else { return readUShort() - 32768; } } catch (Exception e) { e.printStackTrace(); return readUShort() - 32768; } } public int readUSmart() { int value = payload[currentPosition] & 0xff; if (value < 128) return readUnsignedByte(); else return readUShort() - 32768; } public void encodeRSA(BigInteger exponent, BigInteger modulus) { int length = currentPosition; currentPosition = 0; byte buffer[] = new byte[length]; readBytes(length, 0, buffer); byte rsa[] = buffer; //if (Configuration.ENABLE_RSA) { rsa = new BigInteger(buffer).modPow(exponent, modulus) .toByteArray(); //} currentPosition = 0; writeByte(rsa.length); writeBytes(rsa, rsa.length, 0); } public void writeNegatedByte(int value) { payload[currentPosition++] = (byte) (-value); } public void writeByteS(int value) { payload[currentPosition++] = (byte) (128 - value); } public int readUByteA() { return payload[currentPosition++] - 128 & 0xff; } public int readNegUByte() { return -payload[currentPosition++] & 0xff; } public int readUByteS() { return 128 - payload[currentPosition++] & 0xff; } public byte readNegByte() { return (byte) -payload[currentPosition++]; } public byte readByteS() { return (byte) (128 - payload[currentPosition++]); } public void writeLEShort(int value) { payload[currentPosition++] = (byte) value; payload[currentPosition++] = (byte) (value >> 8); } public void writeShortA(int value) { payload[currentPosition++] = (byte) (value >> 8); payload[currentPosition++] = (byte) (value + 128); } public void writeLEShortA(int value) { payload[currentPosition++] = (byte) (value + 128); payload[currentPosition++] = (byte) (value >> 8); } public int readLEUShort() { currentPosition += 2; return ((payload[currentPosition - 1] & 0xff) << 8) + (payload[currentPosition - 2] & 0xff); } public int readUShortA() { currentPosition += 2; return ((payload[currentPosition - 2] & 0xff) << 8) + (payload[currentPosition - 1] - 128 & 0xff); } public int readLEUShortA() { currentPosition += 2; return ((payload[currentPosition - 1] & 0xff) << 8) + (payload[currentPosition - 2] - 128 & 0xff); } public int readLEShort() { currentPosition += 2; int value = ((payload[currentPosition - 1] & 0xff) << 8) + (payload[currentPosition - 2] & 0xff); if (value > 32767) { value -= 0x10000; } return value; } public int readLEShortA() { currentPosition += 2; int value = ((payload[currentPosition - 1] & 0xff) << 8) + (payload[currentPosition - 2] - 128 & 0xff); if (value > 32767) value -= 0x10000; return value; } public int getIntLittleEndian() { currentPosition += 4; return ((payload[currentPosition - 4] & 0xFF) << 24) + ((payload[currentPosition - 3] & 0xFF) << 16) + ((payload[currentPosition - 2] & 0xFF) << 8) + (payload[currentPosition - 1] & 0xFF); } public int readMEInt() { // V1 currentPosition += 4; return ((payload[currentPosition - 2] & 0xff) << 24) + ((payload[currentPosition - 1] & 0xff) << 16) + ((payload[currentPosition - 4] & 0xff) << 8) + (payload[currentPosition - 3] & 0xff); } public int readIMEInt() { // V2 currentPosition += 4; return ((payload[currentPosition - 3] & 0xff) << 24) + ((payload[currentPosition - 4] & 0xff) << 16) + ((payload[currentPosition - 1] & 0xff) << 8) + (payload[currentPosition - 2] & 0xff); } public void writeReverseDataA(byte data[], int length, int offset) { for (int index = (length + offset) - 1; index >= length; index--) { payload[currentPosition++] = (byte) (data[index] + 128); } } public void readReverseData(byte data[], int offset, int length) { for (int index = (length + offset) - 1; index >= length; index--) { data[index] = payload[currentPosition++]; } } } Socket package com.elvarg.util.flood; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; public final class BufferedConnection implements Runnable { public BufferedConnection(Socket socket1) throws IOException { closed = false; isWriter = false; hasIOError = false; socket = socket1; socket.setSoTimeout(30000); socket.setTcpNoDelay(true); inputStream = socket.getInputStream(); outputStream = socket.getOutputStream(); } public void close() { closed = true; try { if (inputStream != null) inputStream.close(); if (outputStream != null) outputStream.close(); if (socket != null) socket.close(); } catch (IOException _ex) { //System.out.println("Error closing stream"); } isWriter = false; synchronized (this) { notify(); } buffer = null; } public int read() throws IOException { if (closed) return 0; else return inputStream.read(); } public int available() throws IOException { if (closed) return 0; else return inputStream.available(); } public void flushInputStream(byte abyte0[], int j) throws IOException { int i = 0;// was parameter if (closed) return; int k; for (; j > 0; j -= k) { k = inputStream.read(abyte0, i, j); if (k <= 0) throw new IOException("EOF"); i += k; } } public void queueBytes(int i, byte abyte0[]) throws IOException { if (closed) { System.out.println("Closed"); return; } if (hasIOError) { hasIOError = false; //throw new IOException("Error in writer thread"); } if (buffer == null) buffer = new byte[5000]; synchronized (this) { for (int l = 0; l < i; l++) { buffer[buffIndex] = abyte0[l]; buffIndex = (buffIndex + 1) % 5000; if (buffIndex == (writeIndex + 4900) % 5000) throw new IOException("buffer overflow"); } if (!isWriter) { isWriter = true; Thread t = new Thread(this); t.setPriority(3); t.start(); } notify(); } } public void run() { while (isWriter) { int i; int j; synchronized (this) { if (buffIndex == writeIndex) try { wait(); } catch (InterruptedException _ex) { } if (!isWriter) return; j = writeIndex; if (buffIndex >= writeIndex) i = buffIndex - writeIndex; else i = 5000 - writeIndex; } if (i > 0) { try { outputStream.write(buffer, j, i); } catch (IOException _ex) { hasIOError = true; } writeIndex = (writeIndex + i) % 5000; try { if (buffIndex == writeIndex) outputStream.flush(); } catch (IOException _ex) { hasIOError = true; } } } } public void printDebug() { System.out.println("dummy:" + closed); System.out.println("tcycl:" + writeIndex); System.out.println("tnum:" + buffIndex); System.out.println("writer:" + isWriter); System.out.println("ioerror:" + hasIOError); try { System.out.println("available:" + available()); } catch (IOException _ex) { } } private InputStream inputStream; private OutputStream outputStream; private final Socket socket; private boolean closed; private byte[] buffer; private int writeIndex; private int buffIndex; private boolean isWriter; private boolean hasIOError; } Elvarg.java, put: /** * The flooder used to stress-test the server. */ private static Flooder flooder = new Flooder(); public static Flooder getFlooder() { return flooder; } Command for creating logins: if(parts[0].startsWith("flood")) { int amt = Integer.parseInt(parts[1]); Server.getFlooder().login(amt); } Player.java, replace: @Override public boolean equals(Object o) { if (!(o instanceof Player)) { return false; } Player p = (Player) o; return p.getUsername().equals(username); } Disclaimer: Please don't use this to target online servers which haven't changed their rsa keys/login decoder blocks ^ If you're using osrs pk/elvarg, consider updating rsa keys/login decoder blocks You can prob build on this to make pk bots and shit happen Usernames are currently Bot(and bot list size), example: bot23, can be changed easily. Look at the flooder class. Client sends opcode 0 every 25 client ticks. 1 client tick is currently set to 300 ms. Feel free to change that. Keep in mind that if you don't send a packet within a specific timeframe, session will go idle and close. I added the readPacket boolean but commented out the call cause I didn't find any use for it yet, feel free to use it edit: guess this can be used for any base. Just change the login in client class to match yours Note: You can distinguish real clients from bots by checking if their username exists in the clients map in Flooder class. This way you can make the fake clients do actions to actually stress test your server. Having them stand in a spot doing nothing barely does anything.
  19. Hello everyone! im here to release my 2nd snippet for the elvarg base by professor oak, i have kind of changed my designing of code and spaced things out alot so it doesn't look like a clumped up mess. Anyways here is the code Your gonna start off by defining CookingFood.java as an enum for holding the data of your food such as the raw item the cooked item, the burnt item, the exp, level and burn level all inside for use later package com.elvarg.world.content.skills.cooking; import com.elvarg.world.model.Item; /** * * @author Oscar Morton <S C A P E on RuneServer> * */ public enum CookingFood { /** * Defining the food */ SHRIMP(new Item(317),new Item(315),new Item(323),1,30,33), ANCHOVIES(new Item(321),new Item(319),new Item(323),1,30,34), KARAMBWANJI(new Item(3150),new Item(3151),new Item(592),1,10,25), SARDINE(new Item(327),new Item(325),new Item(369),1,40,35), HERRING(new Item(345),new Item(347),new Item(357),5,50,41), MACKEREL(new Item(353),new Item(355),new Item(357),10,60,45), TROUT(new Item(335),new Item(333),new Item(343),15,70,50), COD(new Item(341),new Item(339),new Item(343),18,75,52), PIKE(new Item(349),new Item(351),new Item(343),20,80,59), SLIMY_EEL(new Item(3379),new Item(3381),new Item(3383),28,95,58), SALMON(new Item(331), new Item(329),new Item(343),25,90,58), TUNA(new Item(359),new Item(361),new Item(367),30,100,64), RAINBOW_FISH(new Item(10138),new Item(10136),new Item(10140),35,110,63), CAVE_EEL(new Item(5001),new Item(5003),new Item(5002),38,115,42), LOBSTER(new Item(377),new Item(379),new Item(381),40,120,74), BASS(new Item(363),new Item(365),new Item(367),43,130,80), SWORDFISH(new Item(371),new Item(373),new Item(375),45,140,86), MONKFISH(new Item(7944),new Item(7946),new Item(7948),62,150,90), SHARK(new Item(383),new Item(385),new Item(387),80,210,99), ANGLERFISH(new Item(13439),new Item(13441),new Item(13443),84,230,99), DARK_CRAB(new Item(11934),new Item(11936),new Item(11938),90,215,99), KARAMBWAN(new Item(3142), new Item(3144),new Item(3148),30,190,99) ; private Item raw; private Item cooked; private Item burnt; private int level; private int exp; private int burnlevel; private CookingFood(Item raw, Item cooked, Item burnt, int level,int exp,int burnlevel) { setRaw(raw); setCooked(cooked); setLevel(level); setExp(exp); setBurnt(burnt); setBurnlevel(burnlevel); } public Item getRaw() { return raw; } public void setRaw(Item raw) { this.raw = raw; } public Item getCooked() { return cooked; } public void setCooked(Item cooked) { this.cooked = cooked; } public int getLevel() { return level; } public void setLevel(int level) { this.level = level; } public int getExp() { return exp; } public void setExp(int exp) { this.exp = exp; } public Item getBurnt() { return burnt; } public void setBurnt(Item burnt) { this.burnt = burnt; } public int getBurnlevel() { return burnlevel; } public void setBurnlevel(int burnlevel) { this.burnlevel = burnlevel; } } CookingTask which is the Task which will be submitted to TaskManager and processed, this class will Cook the food check if you can cook it and everything else package com.superscape.world.content.skills.cooking; import java.security.SecureRandom; import com.superscape.GameConstants; import com.superscape.engine.task.Task; import com.superscape.world.entity.impl.object.GameObject; import com.superscape.world.entity.impl.player.Player; import com.superscape.world.model.Position; import com.superscape.world.model.Skill; /** * * @author Oscar Morton <S C A P E On RuneServer> * */ public class CookingTask extends Task { Player player; CookingFood food; Position StartingPos; Cooking cooking; GameObject cookingObject; boolean running = true; private int foodCooked = 0; private int cycles; public CookingTask(Player player,CookingFood food,Cooking cooking,GameObject cookingObject, int cycles) { this.player = player; this.cooking = cooking; this.cookingObject = cookingObject; this.food = food; this.bind(player); this.setDelay(0); this.StartingPos = player.getPosition(); this.cycles = cycles; } @Override protected void execute() { if (foodCooked >= cycles) { stop(); return; } if (cookingObject.getId() == 114 && player.getCooksAssistant().getStage() != 100) { player.getPacketSender().sendMessage("You need to complete the Cooks Assistant quest first!"); stop(); return; } if (!cooking.gotRequierments()) { player.getPacketSender().sendMessage("You need level " + food.getLevel() + " cooking to cook this."); this.stop(); return; } if (!player.getInventory().contains(food.getRaw()) || player.getPosition() != StartingPos || !running || food == null || player == null) { this.stop(); return; } cooking.animatePlayer(); player.setPositionToFace(cookingObject.getPosition()); player.getInventory().delete(food.getRaw()); boolean burnt = false; burnt = isBurned(); player.getInventory().add(!burnt ? food.getCooked() : food.getBurnt()); player.getPacketSender().sendMessage(burnt ? "You burn the " + food.name().toLowerCase().replace("_", " ")+"." : "You succesfully cook the " + food.name().toLowerCase().replace("_", " ")+"."); player.getSkillManager().addExperience(Skill.COOKING, burnt ? 0 : food.getExp() * (int)GameConstants.EXP_MULTIPLIER); if (foodCooked == 0) { this.setDelay(2); foodCooked += 1; return; } if (foodCooked > 0) { foodCooked += 1; this.setDelay(cookingObject.getDefinition().getName().toLowerCase().contains("fir") ? 4 : 5); return; } foodCooked += 1; return; } public boolean isBurned() { SecureRandom RANDOM = new SecureRandom(); if (player.getSkillManager().getCurrentLevel(Skill.COOKING) > food.getBurnlevel() && food.getRaw().getId() != 11934) { return false; } double burn_chance = (55.0 - (cookingObject.getDefinition().getName().toLowerCase().equals("fire") ? 0.0 : 3.0)); double cook_level = (double) player.getSkillManager().getCurrentLevel(Skill.COOKING); double lev_needed = (double) food.getLevel(); double burn_stop = (double) food.getBurnlevel(); double multi_a = (burn_stop - lev_needed); double burn_dec = (burn_chance / multi_a); double multi_b = (cook_level - lev_needed); burn_chance -= (multi_b * burn_dec); double randNum = RANDOM.nextDouble() * 100.0; return burn_chance <= randNum ? false : true; } public int getFoodCooked() { return foodCooked; } public void setFoodCooked(int foodCooked) { this.foodCooked = foodCooked; } public int getCycles() { return cycles; } public void setCycles(int cycles) { this.cycles = cycles; } } Here is the cooking class itself for storing data like anims and the static init method package com.superscape.world.content.skills.cooking; import java.util.ArrayList; import com.superscape.engine.task.TaskManager; import com.superscape.world.entity.impl.object.GameObject; import com.superscape.world.entity.impl.player.Player; import com.superscape.world.model.Animation; import com.superscape.world.model.Skill; import com.superscape.world.model.dialogue.Dialogue; import com.superscape.world.model.dialogue.DialogueExpression; import com.superscape.world.model.dialogue.DialogueManager; import com.superscape.world.model.dialogue.DialogueOptions; import com.superscape.world.model.dialogue.DialogueType; /** * * @author Oscar Morton <S C A P E on RuneServer> * */ public class Cooking { Player p; CookingFood food; GameObject cookingObject; private final static ArrayList<Integer> FIRES = new ArrayList<Integer>(); private final static ArrayList<Integer> RANGES = new ArrayList<Integer>(); final Animation RANGE_ANIM = new Animation(883); final Animation FIRE_ANIM = new Animation(897); public Cooking(Player p,CookingFood food,GameObject cookingObject) { this.p = p; this.food = food; this.cookingObject = cookingObject; } public static void populateFires() { FIRES.add(26185); FIRES.add(20001); FIRES.add(20000); FIRES.add(26186); FIRES.add(26575); FIRES.add(26576); } public static void populateRanges() { RANGES.add(114); RANGES.add(2859); RANGES.add(4172); RANGES.add(7183); RANGES.add(8750); RANGES.add(9682);//use // RANGES.add(e) } public static ArrayList<Integer> getCookingObjects() { ArrayList<Integer> r = new ArrayList<Integer>(); r.addAll(FIRES); r.addAll(RANGES); return r; } public static void init(Player p, CookingFood food, GameObject cookingObject) { new Cooking(p,food,cookingObject).start(); } int cycles = 0; public void start() { CookingTask task = new CookingTask(p,food,this,cookingObject,cycles); p.setDialogueOptions(new DialogueOptions() { @Override public void handleOption(Player player, int option) { switch (option) { case 1: cycles = 1; break; case 2: cycles = 5; break; case 3: cycles = 10; break; case 4: cycles = 28; break; } player.getPacketSender().sendInterfaceRemoval(); task.setCycles(cycles); TaskManager.submit(task); } }); DialogueManager.start(p,new Dialogue() { @Override public DialogueType type() { return DialogueType.OPTION; } @Override public DialogueExpression animation() { // TODO Auto-generated method stub return null; } @Override public String[] dialogue() { return new String[] {"Cook 1", "Cook 5", "Cook 10", "Cook All"}; } }); } public boolean gotRequierments() { return p.getSkillManager().getCurrentLevel(Skill.COOKING) >= food.getLevel(); } public void animatePlayer() { p.performAnimation(!cookingObject.getDefinition().getName().toLowerCase().contains("fir") ? RANGE_ANIM : FIRE_ANIM); } public static ArrayList<Integer> getFires() { return FIRES; } public static ArrayList<Integer> getRanges() { return RANGES; } } and add this to UseItemPacketListener.java under the itemOnObject for (int OBJ : Cooking.getFires()) { if (OBJ == gameObject.getId()) { for (final CookingFood food : CookingFood.values()) { if (food.getRaw().getId() == itemId) { Cooking.init(player, food, gameObject); } } } } Add this to Elvarg.java before the serviceLoader.shutdown(); Cooking.populateFires(); Cooking.populateRanges(); There are things to be added such as the ability of range cooking but that will come later and i will update the thread when such things happen. Any improvments post below. Here is a gif of it working
  20. I believe this was released by someone else for PI, I've had it forever so credits to whoever released it, didn't take long to convert. Make this class wherever you want. package com.arlania.engine; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import com.arlania.util.Stopwatch; public class CharacterBackup { private static final int TIME = 28800000; //8 hours public static Stopwatch timer = new Stopwatch().reset(); public CharacterBackup() { File f1 = new File("./data/saves/characters/"); File f2 = new File("./data/saves/Backup " + getDate() + ".zip"); if (!f2.exists()) { try { System.out .println("[Auto-Backup] The mainsave has been automatically backed up."); zipDirectory(f1, f2); } catch (Exception e) { e.printStackTrace(); } } else { System.out .println("[Auto-Backup] The mainsave has already been backed up today. Backup aborted."); } } public static void sequence() { if(timer.elapsed(TIME)) { timer.reset(); { File f1 = new File("./data/saves/characters/"); File f2 = new File("./data/saves/Backup " + getDate() + ".zip"); if (!f2.exists()) { try { System.out .println("[BACKUP] Characters successfully backed up."); zipDirectory(f1, f2); } catch (Exception e) { e.printStackTrace(); } } else { System.out .println("[BACKUP] Characters already backed up, backup canceled.."); } } } } public static final void zipDirectory(File f, File zf) throws IOException { ZipOutputStream z = new ZipOutputStream(new FileOutputStream(zf)); zip(f, f, z); z.close(); } private static final void zip(File directory, File base, ZipOutputStream zos) throws IOException { File[] files = directory.listFiles(); byte[] buffer = new byte[8192]; int read = 0; for (int i = 0, n = files.length; i < n; i++) { if (files[i].isDirectory()) { zip(files[i], base, zos); } else { FileInputStream in = new FileInputStream(files[i]); ZipEntry entry = new ZipEntry(files[i].getPath().substring( base.getPath().length() + 1)); zos.putNextEntry(entry); while (-1 != (read = in.read(buffer))) { zos.write(buffer, 0, read); } in.close(); } } } public static String getDate() { DateFormat dateFormat = new SimpleDateFormat("MM dd yyyy"); Date date = new Date(); String currentDate = dateFormat.format(date); date = null; dateFormat = null; return currentDate; } } In the World Class add this: CharacterBackup.sequence(); I made a command also if you ever need it. if(command[0].equals("backup")) { CharacterBackup.timer.reset(0); player.getPacketSender().sendConsoleMessage("Backup Method Called."); } Enjoy. If you want it to back up more frequently (less than 24 hours) modify + getDate() +.
  21. Noticed that when I redid projectiles on Elvarg, the magic ones were messed up. To fix it, simply replace CombatSpells.java with mine. It's quite a big class so I'll use pastebin. Click here to get it. Now, some people wanted help with adding tridents so I'll give you a proper base below. Let's make it so when we equip a trident, it will update our autocast spell. To do this, open EquipPacketListener.java and find "void resetWeapon(Player player)" At the bottom of this method, you should find: if(player.getCombat().getAutocastSpell() != null) { Autocasting.setAutocast(player, null); player.getPacketSender().sendMessage("Autocast spell cleared."); } If you examine the current code, you will see that it's currently reseting autocast everytime when switching weapon. Replace it with this: Item weapon = player.getEquipment().getItems()[Equipment.WEAPON_SLOT]; //Check if player is using a trident. If so, set autocast to respective spell.. if(weapon.getId() == 11905) { Autocasting.setAutocast(player, CombatSpells.TRIDENT_OF_THE_SEAS.getSpell()); } else if(weapon.getId() == 12899) { Autocasting.setAutocast(player, CombatSpells.TRIDENT_OF_THE_SWAMP.getSpell()); } else { //Otherwise always reset autocast when switching weapon if(player.getCombat().getAutocastSpell() != null) { Autocasting.setAutocast(player, null); player.getPacketSender().sendMessage("Autocast spell cleared."); } } Now, we're updating autocast if switching to a trident, and reseting autocast if not. Finally we need to make it so players can't choose a different autocast spell when using a trident, just like osrs. Simply open Autocasting.java, and find this code: if(cbSpell.levelRequired() > player.getSkillManager().getCurrentLevel(Skill.MAGIC)) { player.getPacketSender().sendMessage("You need a Magic level of at least "+cbSpell.levelRequired()+" to cast this spell."); setAutocast(player, null); return true; } Under it, add: Item weapon = player.getEquipment().getItems()[Equipment.WEAPON_SLOT]; //Check if player is using a trident. If so, do not allow player to change autocast spell. if(weapon.getId() == 11905 || weapon.getId() == 12899) { player.getPacketSender().sendMessage("You cannot change your autocast spell since you're wearing a trident."); return false; } And you're done! Magic projectiles: Tridents: (Fix the projectile for these two yourself by playing around with the start/end heights etc. For some reason same values as other projectiles didn't work.)
  22. Been working on the base for a while now trying to get skills added. Thought i'd release this to help others do the same as me. I accept any construction criticism as i'm still learning to code. create a new package called thieving, I put mine in com.elvarg.world.content.skills.thieving. In Player.java add: private Thieving thieving = new Thieving(this); public Thieving getThieving() { return thieving; } Stalls.java package com.elvarg.world.content.skills.thieving; import com.elvarg.world.model.Item; /** * This enum stores all our thieving stalls data. * @author Clive/Dinh * */ public enum Stalls { BAKERS_STALL(5, 16, 1, new Item[] {new Item(1891), new Item(1901), new Item(2309)}), GEM_STALL(75, 160, 5, new Item[] {new Item(1623), new Item(1621), new Item(1619), new Item(1617)}), FUR_STALL(35, 36, 2, new Item[] {new Item(958)}), SILVER_STALL(50, 54, 3, new Item[] {new Item(442)}), MARKET_STALL(90, 200, 7, new Item[] {new Item(1333), new Item(385), new Item(442), new Item(958), new Item(1623), new Item(1621), new Item(1619), new Item(1617), new Item(1891), new Item(1901), new Item(2309)}); private final int levelRequirement; private final int experience; private final int clickTime; private final Item[] rewards; private Stalls(final int requirement, final int exp, final int time, final Item[] loot) { this.levelRequirement = requirement; this.experience = exp; this.clickTime = time; this.rewards = loot; } public int getRequirement() { return levelRequirement; } public int getExperience() { return experience; } public int getClickTimer() { return clickTime; } public Item[] getLoot() { return rewards; } } Pickpocket.java package com.elvarg.world.content.skills.thieving; import com.elvarg.world.model.Item; /** * This enum stores all our thieving pickpocket data. * @author Clive/Dinh * */ public enum Pickpocket { MAN(1, 8, new Item[] {new Item(995, 5) }), FARMER(60, 65, new Item[] {new Item(5291), new Item(5292), new Item(5293), new Item(5294), new Item(5291), new Item(5292), new Item(5293), new Item(5294), new Item(5295), new Item(5296), new Item(5297), new Item(5298), new Item(5299), new Item(5300), new Item(5301), new Item(5302), new Item(5303), new Item(5304)}); private final int levelRequirement; private final int experience; private final Item[] rewards; private Pickpocket(final int level, final int experience, final Item[] loot) { this.levelRequirement = level; this.experience = experience; this.rewards = loot; } public int getRequirement() { return levelRequirement; } public int getExperience() { return experience; } public Item[] getLoot() { return rewards; } } Thieving.java package com.elvarg.world.content.skills.thieving; import com.elvarg.util.Misc; import com.elvarg.world.entity.impl.npc.NPC; import com.elvarg.world.entity.impl.player.Player; import com.elvarg.world.model.Animation; import com.elvarg.world.model.Item; import com.elvarg.world.model.Skill; public class Thieving { private Player player; private long lastInteraction; private static final long INTERACTION_DELAY = 2_000L; private final int STEAL_ANIMATION = 881; public Thieving(final Player player) { this.player = player; } public void stealFromStall(Stalls stall, int objectId) { if (System.currentTimeMillis() - lastInteraction < INTERACTION_DELAY) { return; } if (player.getSkillManager().getCurrentLevel(Skill.THIEVING) < stall.getRequirement()) { player.getPacketSender().sendMessage("You need a thieving level of " + stall.getRequirement() + " to steal from this stall."); return; } if (player.getInventory().getFreeSlots() == 0) { player.getPacketSender().sendMessage("You need at least one free slot to steal from this stall."); return; } player.performAnimation(new Animation(STEAL_ANIMATION)); Item lootReceived = Misc.randomElement(stall.getLoot()); player.getInventory().add(lootReceived.getId(), lootReceived.getAmount()); player.getSkillManager().addExperience(Skill.THIEVING, stall.getExperience()); lastInteraction = System.currentTimeMillis(); } public void pickpocket(Pickpocket pickpocket, NPC npc) { player.setPositionToFace(npc.getPosition()); if (System.currentTimeMillis() - lastInteraction < INTERACTION_DELAY) { return; } if (player.getSkillManager().getCurrentLevel(Skill.THIEVING) < pickpocket.getRequirement()) { player.getPacketSender().sendMessage("You need a thieving level of " + pickpocket.getRequirement() + " to pickpocket this npc."); return; } if (player.getInventory().getFreeSlots() == 0) { player.getPacketSender().sendMessage("You need at least one free slot to steal from this npc."); return; } player.performAnimation(new Animation(STEAL_ANIMATION)); Item lootReceived = Misc.randomElement(pickpocket.getLoot()); player.getInventory().add(lootReceived.getId(), lootReceived.getAmount()); player.getSkillManager().addExperience(Skill.THIEVING, pickpocket.getExperience()); lastInteraction = System.currentTimeMillis(); } }

Contact

[email protected]

astra.security

What is a RSPS?

A RSPS, also known as RuneScape private server, is an online game based on RuneScape, and controlled by independent individuals.

Popular RSPS Servers

Runewild Ikov RedemptionRSPS

Disclaimer

Runesuite is not affiliated with runescape, jagex in any way & exists solely for educational purposes.

×
×
  • Create New...