Jump to content
Existing user? Sign In

Sign In



Sign Up

[OSRSPK/Elvarg] Thieving


Sanity

Recommended Posts

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

  • 2 years later...
  • 1 year later...
  • 2 weeks later...
  • 3 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

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...