[b]Purpose :[/b] Making a working Hunting Skill!
[b]Difficulty :[/b] 5
[b]Assumed Knowledge :[/b] Copy & Paste and search.
[b]Server Base :[/b] Pimpscape (Should work for others also, havn't tried)
[b]Classes Modified : [/b] Client.java
[b]Procedure[/b]
[b]Step one:[/b]
Add these voids:
[code]public void squash(int emote, int gfx)
{
setAnimation(emote);
stillgfx(gfx, absY, absX);
}
public void flee(int NPCID) {
int follow = npcHandler.npcs[NPCID].followPlayer;
int playerX = server.playerHandler.players[follow].absX;
int playerY = server.playerHandler.players[follow].absY;
npcHandler.npcs[NPCID].RandomWalk = false;
if(server.playerHandler.players[follow] != null)
{
if(playerY > npcHandler.npcs[NPCID].absY) {
npcHandler.npcs[NPCID].moveX = npcHandler.GetMove(npcHandler.npcs[NPCID].absX, playerX);
npcHandler.npcs[NPCID].moveY = npcHandler.GetMove(npcs[NPCID].absY, playerY+1);
}
else if(playerY < npcHandler.npcs[NPCID].absY) {
npcHandler.npcs[NPCID].moveX = npcHandler.GetMove(npcHandler.npcs[NPCID].absX, playerX);
npcHandler.npcs[NPCID].moveY = npcHandler.GetMove(npcHandler.npcs[NPCID].absY, playerY-1);
}
else if(playerX > npcHandler.npcs[NPCID].absX) {
npcHandler.npcs[NPCID].moveX = npcHandler.GetMove(npcHandler.npcs[NPCID].absX, playerX+1);
npcHandler.npcs[NPCID].moveY = npcHandler.GetMove(npcHandler.npcs[NPCID].absY, playerY);
}
else if(playerX < npcHandler.npcs[NPCID].absX) {
npcHandler.npcs[NPCID].moveX = npcHandler.GetMove(npcHandler.npcs[NPCID].absX, playerX-1);
npcHandler.npcs[NPCID].moveY = npcHandler.GetMove(npcHandler.npcs[NPCID].absY, playerY);
}
npcHandler.npcs[NPCID].getNextNPCMovement();
npcHandler.npcs[NPCID].updateRequired = true;
}
}
public void hunt(int lvlreq, int npctype, int expgain, int itemgain, int amount, int requiredweapon, int hit)
{
int chance = 135 - misc.random(playerLevel[30];
if(requiredweapon != -1)
{
if(playerEquipment[playerWeapon] == requiredweapon && playerLevel[30] == lvlreq)
{
if(absX == npcHandler.npcs[npctype].absX && absY == npcHandler.npcs[npctype].absY)
{
if(chance == 0)
{
addItem(itemgain, amount);
addXP(30, expgain);
squash(406, 341);
npcHandler.npcs[npctype].IsDead = true;
sendMessage("You kill the " + GetNpcName(npctype) + ", and manage to rip " + GetItemName(requiredweapon) + " off of it!";
else
{
playerLevel[3] -= hit;
updateRequired = true;
sendMessage("You fail to capture and kill the " + GetNpcName(npctype) + ", next time try harder!";
}
}
}
else
{
sendMessage("You aren't wearing a " + GetItemName(requiredweapon) + " please go equip one!";
}
}
else
{
if(absX == npcHandler.npcs[npctype].absX && absY == npcHandler.npcs[npctype].absY)
{
if(chance == 0)
{
addItem(itemgain, amount);
addXP(30, expgain);
squash(406, 341);
npcHandler.npcs[npctype].IsDead = true;
else
{
currentHealth -= hit;
updateRequired = true;
hitUpdateRequired = true;
sendMessage("You fail to capture and kill the " + GetNpcName(npctype) + ", next time try harder!";
}
}
}
if(npcHandler.npcs[npctype].absX >= absX - 10 && npcHandler.npcs[npctype].absX <= absX + 10 && npcHandler.npcs[npctype].absY >= absY - 10 && npcHandler.npcs[npctype].absY <= absY + 10)
{
flee(npctype);
}
}
public void hunting()
{
hunt(0, 1192, 30, 1037, 1, -1, 2); //rabbits
}[/code]
[b]Step two:[/b]
Find [code]public boolean process[/code] and add this right below it [code]hunting();[/code]
[b]Step three:[/b]
Search for [code]public void saveStats()[/code] and add this [code]int hunting = playerLevel[30];
int Hunting = playerXP[30];[/code] under [code]int Farmingxp = playerXP[19];[/code]
Now search for this [code]int pIndex2 = inStream.readUnsignedWordBigEndian();
client p2 = (client) server.playerHandler.players[pIndex2];[/code] and below [code]int Farminglvl = p2.playerLevel[19];[/code]
add this [code]int huntinglvl = p2.playerLevel[30];[/code]
Now search for this [code]public boolean addSkillXP(int amount, int skill){[/code] and add this [code] int hunting = getLevelForXP(playerXP[30]);[/code]
under [code]int Runecrafting = getLevelForXP(playerXP[20]); [/code]
Search for this [code]if (Attack < getLevelForXP(playerXP[0])) {[/code] and then add this [code] if (hunting < getLevelForXP(playerXP[24])) {
playerLevel[24] = getLevelForXP(playerXP[24]);
levelup(24);
stillgfx(199, absX, absY);
updateRequired = true;
appearanceUpdateRequired = true;
}[/code] above [code]if (Defence < getLevelForXP(playerXP[1])) {[/code]
[b]Step four:[/b]
Search for [code]case 20: //Runecrafting[/code] and right after the [code]break;[/code] add this [code] case 30: //Rarecrafting (Made 100% by Mod Taharok and it is a test skill)
sendFrame164(4882);
stillgfx(199, absX, absY);
sendFrame126("Congratulations, you just advanced a Hunting level!", 4884);
sendFrame126("Your Hunting level is now "+playerLevel[24]+" .", 4885);
sendMessage("Congratulations, you just advanced a Hunting level.");
NpcDialogueSend = true;
break;[/code]
[b]Step five:[/b]
Search for [code]public class client extends Player implements Runnable[/code] and add these under it [code]public String npcHandler;
public String npcHandler.npcs;[/code]
[b]Credits:[/b] 5% Mod Taharok for his tutorial on how to make a new skill, 5% billysmither for the first tutorial on how to make hunting (This isn't a spin off from his, this is totally different) and 90% me (Eh Pretty Easy). :)