Difficulty: 1/10
Purpose: add npc pit pocketing
Source Used: rs related
Classes Modified: client.java
first off add this method
this is all that is going to be used for the npc thieving
its alittle long but it works
has the animations
Installing Thieving:
Code:
public int theifstun = 0;
public void theiving(int npc, int levelNeeded, double exp, int itemID, int amount, int amountOfTrys, int leastAmountOfTrys, int damage, int amountOfFails, int x, int y, int hieght, String teleMessage, boolean teleTrue) {
if (playerLevel[17] >= levelNeeded) {
if (misc.random(amountOfTrys) <= leastAmountOfTrys) {
addItem(itemID, amount);
addSkillXP(exp, 17);
} else if (misc.random(amountOfTrys) >= leastAmountOfTrys) {
updateRequired = true;
hitUpdateRequired = true;
hitDiff = damage;
shoutText("Ouch!");
server.npcHandler.npcs[npc].updateRequired = true;
server.npcHandler.npcs[npc].textUpdateRequired = true;
server.npcHandler.npcs[npc].textUpdate = "What do you think you're doing?";
gfx100(80);
theifstun = 30;
}
if (amountOfTrys == amountOfFails && teleTrue) {
tele2(x, y, hieght);
sendMessage(teleMessage);
}
setAnimation(881);
} else if (playerLevel[17] < levelNeeded) {
sendMessage(
"You need a theiving levle of " + levelNeeded
+ " to complete this task.");
}
}
public void shoutText(String text) {
txt4 = text;
string4UpdateRequired = true;
}
public void tele2(int x, int y, int hieght) {
teleportToX = x;
teleportToY = y;
heightLevel = hieght;
updateRequired = true;
appearanceUpdateRequired = true;
}
add this to your boolean process
Code:
if (theifstun > 0) {
theifstun -= 1;
}
in packet 98 (case 96)
add
Code:
if (theifstun > 0) {
sendMessage("You are stuned and can't move.");
}
in the same packet find
or
and next to it add
example
Code:
if (IsDead == false && EntangleDelay <= 0 && theifstun < 1) {
next go to second click npc or case 17:
heres a example i am going to be using
(switch statement)
Code:
case 1:
theiving(NPCSlot, 1, 5, 995, 3, 3, 2, 3, absX, absY, heightLevel, "", false);
break;
(no switch)
Code:
if(NPCID == 1) {
theiving(NPCSlot, 1, 5, 995, 3, 3, 2, 3, absX, absY, heightLevel, "", false);
}
this will be the basic man
Explaining:
the first part NPCSlot is used for finding the id of the npc and sending the message "what do you think your doing?"
next is the level needed and then the exp
995 is the item id and the first 3 is the amount
the next 3 is the amount of trys you have before getting hit
it is used as the rareity
right not you have 1/3 chance of getting the coins
after the amount of tries is the damage you get if you fail to steal the coins
which will result in say "Ouch!"
at the end of the method if it is declared true once your amount of fails are used up you get teled out like the ham camp
after the damge is the amount Of Fails reading above you'll know whats that is for
it has to be equal to the amount of trys or some where below
so absX, absY, and heightlevel are the cords of where you are going to tele to
then the tele message is used for saying what has just happend to you
example
"You have been teleported out of the ham camp to an unknow area"
tudah now you got a basic thieving system for your server
have fun
Few More Examples:
Code:
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
theiving(NPCSlot, 1, 5, 995, 3, 3, 1, 2, 3, absX, absY,
heightLevel, "", false);
break;
case 7:
if (misc.random(1) == 1) {
theiving(NPCSlot, 10, 14.5, randomSeeds(),
misc.random(9), 5, 2, 5, 3, absX, absY,
heightLevel, "", false);
}
if (misc.random(1) == 0) {
theiving(NPCSlot, 10, 14.5, 995, 9, 5, 2, 5, 3, absX,
absY, heightLevel, "", false);
}
break;
add this somewhere in client.java
Code:
public static int seeds[] = {
299, 5096, 5097, 5098, 5305, 5306, 5307, 5308, 5309, 5318, 5319, 5320,
5321, 5322, 5323, 5324, 299, 5096, 5097, 5098, 5305, 5306, 5307, 5308,
5309, 5318, 5319, 5320, 5321, 5322, 5323, 5324, 5280, 5281, 5283, 5284,
5285, 5286, 5287, 5288, 5289, 5290, 5291, 5292, 5293, 5294, 5103, 5104,
5105, 5100, 5099, 5100};
public static int randomSeeds() {
return seeds[(int) (Math.random() * seeds.length)];
}