Sanity 436 Posted September 28, 2017 Report Share Posted September 28, 2017 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(); } } Link to comment Share on other sites More sharing options...
SpiritOfTheLau 0 Posted May 9, 2020 Report Share Posted May 9, 2020 Nice work. If you ever feel like revisiting this, it Would be cool for this to include guards in the case of stalls Link to comment Share on other sites More sharing options...
Diddy Ranqe 0 Posted January 13, 2022 Report Share Posted January 13, 2022 (edited) Does not work at all. Edited January 13, 2022 by Diddy Ranqe Link to comment Share on other sites More sharing options...
Mevaderiseenhoer 1 Posted January 19, 2022 Report Share Posted January 19, 2022 Thanks Link to comment Share on other sites More sharing options...
06 Prod 0 Posted January 24, 2022 Report Share Posted January 24, 2022 Thanks for posting! Could use a lil sprucing Link to comment Share on other sites More sharing options...
Farsken 0 Posted February 7, 2022 Report Share Posted February 7, 2022 Ty Link to comment Share on other sites More sharing options...
Adarsh 0 Posted February 7, 2022 Report Share Posted February 7, 2022 thanks i dint use im just making posts Link to comment Share on other sites More sharing options...
Laced 0 Posted February 9, 2022 Report Share Posted February 9, 2022 ThAnks for this Link to comment Share on other sites More sharing options...
Ary3x 0 Posted February 14, 2022 Report Share Posted February 14, 2022 Was looking for this thanks Link to comment Share on other sites More sharing options...
test710 0 Posted June 3, 2022 Report Share Posted June 3, 2022 Stealing this one Link to comment Share on other sites More sharing options...
iqux 0 Posted June 5, 2022 Report Share Posted June 5, 2022 Going to use this thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now