Okay Well I Really Couldn't Find A Good Woodcutting System In the Tutorials Thread So i Was Thinking to Convert Wous Mining System to a Woodcutting System it Would Be Easier Because Mining And Woodcutting Do Just About The Same Thing So i Was Trying To Converting it To Woodcutting And All i Wan't To Know Is AM I Doing it Right And Will It Work
P.S This Is The First Time I Ever Convert Something To Be Honest
And I Am Not Done With It
Heres What I Got So Far
Code:
/**
* @(#)Woodcutting.java
*
* Woodcutting application
*
* @author DSscape
* @version 1.00 2009/8/26
*/
public class Woodcutting {
Player p;
/**
* Class constructor.
* @param player the player which the constructor should be made for.
*/
public Woodcutting(Player p) {
this.p = p;
}
/**
* Woodcutting system.
*/
public void createWoodcuttingEvent() {
if (p == null) {
resetWoodcuttingEvent();
return;
}
if (getaxe() == -1) {
p.frames.sendMessage(p, "You don't have a axe");
return;
}
if (getlevelaxe(getaxe()) < p.getLevelForXP(8) == false) {
p.frames.sendMessage(p, "You need a level of " + getlevelaxe(getaxe()) + " to use the axe");
resetWoodcuttingEvent();
return;
}
if (getLevelForlogs() < p.getLevelForXP(8) == false) {
p.frames.sendMessage(p, "You need a level of " + getLevelForlogs() + " to cut this");
resetWoodcuttingEvent();
return;
}
p.requestAnim(getAnimation(), 0);
setlogsDelay(selectRandomDelay());
p.frames.sendMessage(p, "You swing your axe at the tree..");
}
/**
* If player's logs delay reached zero, The player receives an logs and anim resets. Woodcutting resets to.
*/
public void receivelogs() {
if (p == null || !playerIsWoodcutting()) {
resetWoodcuttingEvent();
return;
}
if (getlogsDelay() == 0) {
p.requestAnim(-1, 0);
Engine.playerItems.addItem(p, getlogsType(), 1);
p.addSkillXP(getXP(), 8);
p.frames.sendMessage(p, "You succes fully cut an " + Engine.items.getItemName(getlogsType()));
resetWoodcuttingEvent();
}
}
/**
* Get the requested animation for the axeaxe.
* @return the axeaxe's animation id.
*/
public boolean hasItem(int id) {
PlayerItems pi = new PlayerItems();
return pi.invItemCount(p, id) > 0;
}
int getaxe() {
if (hasItem(1265)) return 1265;
if (hasItem(1275)) return 1275;
if (p.equipment[3] == 1265) return 1265;
if (p.equipment[3] == 1275) return 1275;
return -1;
}
int getAnimation() {
switch (getaxe()) {
case 1265: //Bronze axe
return 625;
case 1275: // Rune axe
return 624;
default:
return -1;
}
}
/**
* Return the rock type.
* @return the rock type to receive the correct logs.
*/
int getlogsType() {
switch (p.logsType) {
case 1: //Tin
return 438;
case 2: //Copper
return 436;
case 3: //Iron
return 440;
case 4: //Silver
return 442;
case 5: //Coal
return 453;
case 6: //Gold
return 444;
case 7: //Mithrill
return 447;
case 8: //Adamantite
return 449;
case 9: //Runite
return 451;
default:
return -1;
}
}
/**
* Return the Xp gained of rock type.
* @return the right amount of XP.
*/
int getXP() {
switch(p.logsType) {
case 1: //Tin
return 300;
case 2: //Copper
return 500;
case 3: //Iron
return 750;
case 4: //Silver
return 1150;
case 5: //Coal
return 2100;
case 6: //Gold
return 4350;
case 7: //Mithrill
return 6550;
case 8: //Adamantite
return 7750;
case 9: //Runite
return 8900;
default:
return -1;
}
}
/**
* Return the level required to mine.
* @return the right level.
*/
int getLevelForlogs() {
switch(p.logsType) {
case 1: //Tin
return 1;
case 2: //Copper
return 1;
case 3: //Iron
return 15;
case 4: //Silver
return 20;
case 5: //Coal
return 30;
case 6: //Gold
return 40;
case 7: //Mithrill
return 55;
case 8: //Adamantite
return 70;
case 9: //Runite
return 85;
default:
return -1;
}
}
/**
* Return the level required to use the axe with.
* @return the right level.
*/
int getlevelaxe(int pick) {
switch (pick) {
case 1265:
return 1;
case 1275:
return 41;
}
return -1;
}
/**
* Get the player's logs delay.
* @return the logs delay.
*/
int getlogsDelay() {
return p.logsDelay;
}
/**
* If player is Woodcutting an rock.
* @return if player is Woodcutting.
*/
boolean playerIsWoodcutting() {
return p.isWoodcutting;
}
/**
* Select a random delay
* @return the delay thats going to be setted for the logs delay.
*/
int selectRandomDelay() {
int highestDelay = 14, lowestDelay = 6;
int delay = Misc.random(14);
int Woodcutting = p.skillLvl[14];
if (Woodcutting >= delay && delay <= highestDelay && delay >= lowestDelay)
return delay;
else
return delay - lowestDelay + 4;
}
/**
* Set player Woodcutting.
* @param isWoodcutting if player is Woodcutting.
*/
void setWoodcutting(boolean isWoodcutting) {
p.isWoodcutting = isWoodcutting;
}
/**
* Set logs delay.
* @param logsDelay the delay thats going to be setted.
*/
void setlogsDelay(int logsDelay) {
p.logsDelay = logsDelay;
}
/**
* Set the player's tree type to receive after Woodcutting the correct logs.
* @param logsType the tree type of the logs thats cuted later etc.
*/
void setlogsType(int logsType) {
p.logsType = logsType;
}
/**
* Reset the Woodcutting process.
*/
public void resetWoodcuttingEvent() {
setlogsType(0);
setWoodcutting(false);
setlogsDelay(-1);
}
}