Shaun
July 14th, 2010, 16:51
Well, I'll go ahead and release the base I wrote up a while ago. This was all completely written from scratch. I'm only handing you guys the WoodCutting class and I won't spoonfeed you on how to implement it. It does need some work and a little bit of cleaning up. Not everything is complete.
(not completed).
Features:
Cutting delay formula - Differences between Axe/Level (Trees soon)
Basic looping
Credits:
Mr Dillusion
Shaun
//Dillusion Woodcutting Project - v0.1
public class woodCutting {
private client c; //Player
public boolean isCutting;
private int woodExp, //Experience given
woodLog, //Given cut log
woodAxe, //Which axe being used
whatTree, //Will be improved upon
cutTime, //Resets cutting emote
woodDelay; //Delay when cutting : Axe differences
//woodCutting Class Constructor
public woodCutting(client c) {
this.c = c;
isCutting = false;
whatTree = 0;
cutTime = 0;
woodExp = 0;
woodLog = 0;
woodAxe = 0;
woodDelay = 0;
}
//woodCutting delay when cutting
public void woodAxeDelay(int axe) {
double mathDelay = (double) (20-(c.playerLevel[c.playerWoodcutting]/10)) - axe;
woodDelay = misc.random((int)mathDelay);
}
//woodCutting Loop
public void loopCut() {
if (woodDelay > 0) {
woodDelay--;
if (cutTime == 0 && isCutting) {
c.pEmote = 0x284;
cutTime = 4;
} else {
cutTime--;
}
if (woodDelay == 0) {
//Recieve the log
if (c.freeSlots() > 0) {
c.addItem(woodLog, 1)
c.addSkillXP(woodExp, c.playerWoodcutting);
c.sendMessage("You get some logs.");
beginWC(whatTree);
} else { //If no room, end WC
isCutting = false;
c.sendMessage("You do not have enough room!");
}
}
}
}
public void beginWC(int tree) {
int axes = c.playerEquipment[c.playerWeapon];
recievedLog(tree);
whatTree = tree;
if (hasAxe(axes)) {
if (c.freeSlots() > 0) {
isCutting = true;
c.sendMessage("You swing your axe at the tree.");
woodAxeDelay(axes);
} else {
c.sendMessage("You don't have enough room!");
}
} else {
c.sendMessage("You need to equip a woodcutting axe before cutting trees!");
}
}
//Returns weather or not an axe is equiped and which one is equiped
public boolean hasAxe() {
int hand;
hand = c.playerEquipment[c.playerWeapon];
switch (wAxe) {
case 1351:
// Bronze woodAxe
woodAxe = 1;
return true;
case 1349:
// Iron woodAxe
woodAxe = 1;
return true;
case 1353:
// Steel woodAxe
woodAxe = 3;
return true;
case 1361:
// Black woodAxe
woodAxe = 4;
return true;
case 1355:
// Mithril woodAxe
woodAxe = 5;
return true;
case 1357:
// Adamant woodAxe
woodAxe = 6;
return true;
case 1359:
// Rune woodAxe
woodAxe = 7;
return true;
case 6739:
// dragon woodAxe
woodAxe = 8;
return true;
default:
return false;
}
}
//Determains which log to give per tree
public int recievedLog(int cut) {
switch (cut) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return 1;
} else {
return -1;
}
}
public void cutTree(int tree) {
int exp[] = {1, 2, 3, 4, 5, 6};
int log = recievedLog(tree);
switch (tree) {
//Normal Trees
case 1276:
woodExp = 4*exp[1];
woodLog = log;
beginWC(tree);
break;
//Oak Trees
case 1281:
woodExp = 4*exp[2];
woodLog = log;
beginWC(tree);
break;
//Willow Trees
case 1308:
woodExp = 4*exp[3];
woodLog = log;
beginWC(tree);
break;
//Maple Trees
case 1307:
woodExp = 4*exp[4];
woodLog = log;
beginWC(tree);
break;
//Yew Trees
case 1309:
woodExp = 4*exp[5];
woodLog = log;
beginWC(tree);
break;
//Magic Trees
case 1306:
woodExp = 4*exp[6];
woodLog = log;
beginWC(tree);
break;
}
}
(not completed).
Features:
Cutting delay formula - Differences between Axe/Level (Trees soon)
Basic looping
Credits:
Mr Dillusion
Shaun
//Dillusion Woodcutting Project - v0.1
public class woodCutting {
private client c; //Player
public boolean isCutting;
private int woodExp, //Experience given
woodLog, //Given cut log
woodAxe, //Which axe being used
whatTree, //Will be improved upon
cutTime, //Resets cutting emote
woodDelay; //Delay when cutting : Axe differences
//woodCutting Class Constructor
public woodCutting(client c) {
this.c = c;
isCutting = false;
whatTree = 0;
cutTime = 0;
woodExp = 0;
woodLog = 0;
woodAxe = 0;
woodDelay = 0;
}
//woodCutting delay when cutting
public void woodAxeDelay(int axe) {
double mathDelay = (double) (20-(c.playerLevel[c.playerWoodcutting]/10)) - axe;
woodDelay = misc.random((int)mathDelay);
}
//woodCutting Loop
public void loopCut() {
if (woodDelay > 0) {
woodDelay--;
if (cutTime == 0 && isCutting) {
c.pEmote = 0x284;
cutTime = 4;
} else {
cutTime--;
}
if (woodDelay == 0) {
//Recieve the log
if (c.freeSlots() > 0) {
c.addItem(woodLog, 1)
c.addSkillXP(woodExp, c.playerWoodcutting);
c.sendMessage("You get some logs.");
beginWC(whatTree);
} else { //If no room, end WC
isCutting = false;
c.sendMessage("You do not have enough room!");
}
}
}
}
public void beginWC(int tree) {
int axes = c.playerEquipment[c.playerWeapon];
recievedLog(tree);
whatTree = tree;
if (hasAxe(axes)) {
if (c.freeSlots() > 0) {
isCutting = true;
c.sendMessage("You swing your axe at the tree.");
woodAxeDelay(axes);
} else {
c.sendMessage("You don't have enough room!");
}
} else {
c.sendMessage("You need to equip a woodcutting axe before cutting trees!");
}
}
//Returns weather or not an axe is equiped and which one is equiped
public boolean hasAxe() {
int hand;
hand = c.playerEquipment[c.playerWeapon];
switch (wAxe) {
case 1351:
// Bronze woodAxe
woodAxe = 1;
return true;
case 1349:
// Iron woodAxe
woodAxe = 1;
return true;
case 1353:
// Steel woodAxe
woodAxe = 3;
return true;
case 1361:
// Black woodAxe
woodAxe = 4;
return true;
case 1355:
// Mithril woodAxe
woodAxe = 5;
return true;
case 1357:
// Adamant woodAxe
woodAxe = 6;
return true;
case 1359:
// Rune woodAxe
woodAxe = 7;
return true;
case 6739:
// dragon woodAxe
woodAxe = 8;
return true;
default:
return false;
}
}
//Determains which log to give per tree
public int recievedLog(int cut) {
switch (cut) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return 1;
} else {
return -1;
}
}
public void cutTree(int tree) {
int exp[] = {1, 2, 3, 4, 5, 6};
int log = recievedLog(tree);
switch (tree) {
//Normal Trees
case 1276:
woodExp = 4*exp[1];
woodLog = log;
beginWC(tree);
break;
//Oak Trees
case 1281:
woodExp = 4*exp[2];
woodLog = log;
beginWC(tree);
break;
//Willow Trees
case 1308:
woodExp = 4*exp[3];
woodLog = log;
beginWC(tree);
break;
//Maple Trees
case 1307:
woodExp = 4*exp[4];
woodLog = log;
beginWC(tree);
break;
//Yew Trees
case 1309:
woodExp = 4*exp[5];
woodLog = log;
beginWC(tree);
break;
//Magic Trees
case 1306:
woodExp = 4*exp[6];
woodLog = log;
beginWC(tree);
break;
}
}