90% because for temp use i made all stump ids set to regular tree stumps as default.
*uses arrays so this will handle UNLIMITED trees at any given time
*oak trees + have a random amount of logs before they'll get cut down.
*After the tree's logs have been cut the stomp will appear and after a while the tree will come back, the tree that comes back will be the exact tree object id you cut down to begin with.
Additional notes: Made by me of course, basic layout was from whitefang's firemaking which he ****ed up badly by making his arrays a one time load. Unlike regular object spawning, this WILL NOT 'lag' your server because it only spawns the object once when it is needed, it will not spawn after that.
First, make a new file called Woodcutting.java and put this in it.
Code:
public class Woodcutting {
public static boolean woodcutting(int PlayerId) {
client p = (client) server.playerHandler.players[PlayerId];
for(int i = 0; i < server.objectHandler.MaxObjects; i++) {
int WCAxe = 0;
if (p.IsCutting == true) {
WCAxe = 1; //If Cutting -> Go trough loop, passby WCCheckAxe to prevent originalweapon loss, 1 to tell you got axe, no function left for WCAxe if cutting, so 1 is enough.
} else {
WCAxe = WCCheckAxe(PlayerId);
}
if (WCAxe > 0) {
if (p.playerLevel[p.playerWoodcutting] >= p.woodcutting[1]) {
if (p.freeSlots() > 0) {
if (p.WCTimer == 0 && p.IsCutting == false) {
p.actionAmount++;
p.sendMessage("You swing your axe at the tree...");
p.WCTimer = (int)((p.woodcutting[0] + 10) - WCAxe);
if (p.WCTimer <= 0) {
p.WCTimer = 2;
}
if (p.TreeHealth2 <= 0) {
p.TreeHealth2 = 1;
}
p.OriginalWeapon = p.playerEquipment[p.playerWeapon];
p.TreeHealth[i] = p.TreeHealth2;
p.ContinuedAnim(0x284);
p.IsCutting = true;
}
if (p.WCTimer == 1 && p.IsCutting == true) {
p.addSkillXP((p.woodcutting[2] * p.woodcutting[3]), p.playerWoodcutting);
p.addItem(p.woodcutting[4], 1);
p.sendMessage("You get some logs.");
p.TreeHealth[i] -= 1;
if (p.TreeHealth[i] >= 1){
p.WCTimer = (int)((p.woodcutting[0] + 10) - WCAxe);
}
else if (p.TreeHealth[i] == 0){
p.playerEquipment[p.playerWeapon] = p.OriginalWeapon;
p.OriginalWeapon = -1;
CutTree(PlayerId);
p.resetAnimation();
p.IsCutting = false;
resetWC(PlayerId);
}
}
} else {
p.sendMessage("Not enough space in your inventory.");
resetWC(PlayerId);
p.resetAnimation();
p.IsCutting = false;
return false;
}
} else {
p.sendMessage("You need "+p.woodcutting[1]+" "+p.statName[p.playerWoodcutting]+" to cut those logs.");
resetWC(PlayerId);
return false;
}
} else {
p.sendMessage("You need an Axe to cut logs.");
resetWC(PlayerId);
return false;
}
}
return true;
}
public static boolean resetWC(int PlayerId) {
client p = (client) server.playerHandler.players[PlayerId];
p.woodcutting[0] = 0;
p.woodcutting[1] = 0;
p.woodcutting[2] = 0;
p.woodcutting[4] = 0;
p.woodcutting[5] = 2;
p.woodcutting[6] = 0;
p.skillX = -1;
p.skillY = -1;
p.IsCutting = false;
p.IsUsingSkill = false;
return true;
}
public static int WCCheckAxe(int PlayerId) {
client p = (client) server.playerHandler.players[PlayerId];
int Hand;
int Shield;
int Bag;
int Axe;
Hand = p.playerEquipment[p.playerWeapon];
Shield = p.playerEquipment[p.playerShield];
Axe = 0;
switch (Hand) {
case 1351: //Bronze Axe
Axe = 1; break;
case 1349: //Iron Axe
Axe = 2; break;
case 1353: //Steel Axe
Axe = 3; break;
case 1361: //Black Axe
Axe = 4; break;
case 1355: //Mithril Axe
Axe = 5; break;
case 1357: //Adamant Axe
Axe = 6; break;
case 1359: //Rune Axe
Axe = 7; break;
case 6739: //Dragon Axe
Axe = 8; break;
}
if (Axe > 0) {
p.OriginalWeapon = Hand;
p.OriginalShield = Shield;
p.playerEquipment[p.playerShield] = -1;
return Axe;
}
Bag = -1;
for (int i = 0; i < p.playerItems.length; i++) {
Bag = p.playerItems[i];
Bag -=1; //Only to fix the ID !
if (Bag == 1351 || Bag == 1349 || Bag == 1353 || Bag == 1361 || Bag == 1355 || Bag == 1357 || Bag == 1359 || Bag == 6739) {
break;
}
}
switch (Bag) {
case 1351: //Bronze Axe
Axe = 1; break;
case 1349: //Iron Axe
Axe = 2; break;
case 1353: //Steel Axe
Axe = 3; break;
case 1361: //Black Axe
Axe = 4; break;
case 1355: //Mithril Axe
Axe = 5; break;
case 1357: //Adamant Axe
Axe = 6; break;
case 1359: //Rune Axe
Axe = 7; break;
case 6739: //Dragon Axe
Axe = 8; break;
}
if (Axe > 0) {
p.OriginalWeapon = Hand;
p.OriginalShield = Shield;
p.playerEquipment[p.playerShield] = -1;
p.playerEquipment[p.playerWeapon] = Bag;
}
return Axe;
}
public static void CutTree(int PlayerId) {
client p = (client) server.playerHandler.players[PlayerId];
for(int i = 0; i < server.objectHandler.MaxObjects; i++) {
if (server.objectHandler.ObjectCutID[i] == -1) {
p.TreeId = p.TreeId1;
server.objectHandler.ObjectCutID[i] = 1341;
server.objectHandler.ObjectTreeID[i] = p.TreeId;
server.objectHandler.ObjectTreeX[i] = p.skillX;
server.objectHandler.ObjectTreeY[i] = p.skillY;
server.objectHandler.ObjectTreeH[i] = p.heightLevel;
server.objectHandler.ObjectTreeMaxDelay[i] = server.objectHandler.TreeDelay + ((p.woodcutting[6] * 2));
break;
}
}
}
public static void AddObjectTree(int PlayerId) {
client p = (client) server.playerHandler.players[PlayerId];
if (p.IsChopping == false) {
p.IsChopping = true;
int tmpX = 0;
int tmpY = 0;
int calcX = 0;
int calcY = 0;
for (int i = 0; i < server.objectHandler.MaxObjects; i++) {
if (server.objectHandler.ObjectCutID[i] > -1) {
tmpX = server.objectHandler.ObjectTreeX[i];
tmpY = server.objectHandler.ObjectTreeY[i];
calcX = tmpX - p.absX;
calcY = tmpY - p.absY;
if (calcX >= -16 && calcX <= 15 && calcY >= -16 && calcY <= 15 && p.TreeSpawn[i] == false && server.objectHandler.ObjectTreeH[i] == p.heightLevel) {
if (p.IsTreeCut[i] == false) {
p.IsTreeCut[i] = true;
p.AddGlobalObj(server.objectHandler.ObjectTreeX[i], server.objectHandler.ObjectTreeY[i], server.objectHandler.ObjectCutID[i], 0);
}
} else if (p.IsTreeCut[i] == true && p.TreeSpawn[i] == true) {
p.AddGlobalObj(server.objectHandler.ObjectTreeX[i], server.objectHandler.ObjectTreeY[i], server.objectHandler.ObjectTreeID[i], 0);
p.TreeSpawn[i] = false;
p.IsTreeCut[i] = false;
}
}
}
p.IsChopping = false;
}
}
}
now go into client.java and delete the following methods:
Code:
public boolean woodcutting()
public boolean resetWC()
public int WCCheckAxe()
^Delete all those methods, now declare these somewhere in client:
Code:
public static boolean UsingSkill = false;
public void ContinuedAnim(int i) {
pEmote = i;
UsingSkill = true;
updateRequired = true;
appearanceUpdateRequired = true;
}
go down into the process and find this:
Code:
if(drunkTimer < 1) {
change that to
Code:
if(drunkTimer < 1 && !UsingSkill) {
^ That's so if you cutting a tree ect.. and using a continued animation it won't stop every half second.
Next find this:
Code:
if (GoodDistance(skillX, skillY, absX, absY, woodcutting[5]) == true) {
woodcutting();
}
replace with this:
Code:
if (GoodDistance(skillX, skillY, absX, absY, woodcutting[5]) == true) {
Woodcutting.woodcutting(playerId);
}
Find this:
Code:
//woodcutting check
if (woodcutting[0] > 0) {
playerEquipment[playerWeapon] = OriginalWeapon;
OriginalWeapon = -1;
resetAnimation();
resetWC();
}
replace with:
Code:
//woodcutting check
if (woodcutting[0] > 0) {
playerEquipment[playerWeapon] = OriginalWeapon;
OriginalWeapon = -1;
resetAnimation();
Woodcutting.resetWC(playerId);
}
Also put this inside your client process:
Code:
Woodcutting.AddObjectTree(playerId);
Find:
Code:
private int woodcutting[] = {0,0,0,1,-1,2};
replace with:
Code:
public static int woodcutting[] = {0,0,0,1,-1,2,0};
Find:
Code:
if (IsUsingSkill == false) {
if (CheckObjectSkill(objectID) == true) {
IsUsingSkill = true;
skillX = objectX;
skillY = objectY;
}
}
Underneath the "skillY = objectY;" put this:
Code:
if (objectID != -1){
TreeId1 = objectID;
}
now replace all your woodcutting cases with these:
Code:
case 1276: //Normal Tree start
case 1277:
woodcutting[0] = 1;
woodcutting[1] = 1;
woodcutting[2] = 25;
woodcutting[4] = 1511;
woodcutting[6] = 0;
TreeHealth2 = 1;
break;
case 1278:
woodcutting[0] = 1;
woodcutting[1] = 1;
woodcutting[2] = 25;
woodcutting[4] = 1511;
woodcutting[6] = 0;
TreeHealth2 = 1;
break;
case 1279:
case 1280:
case 1330: //Evergreen
case 1332: //Evergreen
case 2409:
woodcutting[0] = 1;
woodcutting[1] = 1;
woodcutting[2] = 25;
woodcutting[4] = 1511;
woodcutting[6] = 0;
TreeHealth2 = 1;
break;
case 3033:
woodcutting[0] = 1;
woodcutting[1] = 1;
woodcutting[2] = 25;
woodcutting[4] = 1511;
woodcutting[6] = 0;
TreeHealth2 = 1;
break;
case 3034:
woodcutting[0] = 1;
woodcutting[1] = 1;
woodcutting[2] = 25;
woodcutting[4] = 1511;
woodcutting[6] = 0;
TreeHealth2 = 1;
break;
case 3035:
case 3036:
case 3879:
case 3881:
case 3882: //Empty christmas tree?
case 3883: //Normal Tree finish
case 1315: //Evergreen (Small)
case 1316: //Evergreen
case 1318: //Evergreen
case 1319: //Evergreen
woodcutting[0] = 1;
woodcutting[1] = 1;
woodcutting[2] = 25;
woodcutting[4] = 1511;
woodcutting[6] = 0;
TreeHealth2 = 1;
break;
case 1282: //Dead Tree start
case 1283:
case 1284:
case 1285:
case 1286:
case 1287:
case 1289:
case 1290:
case 1291:
case 1365:
case 1383:
case 1384:
case 5902:
case 5903:
case 5904: //Dead Tree finish
woodcutting[0] = 1;
woodcutting[1] = 1;
woodcutting[2] = 25;
woodcutting[4] = 1511;
woodcutting[6] = 0;
TreeHealth2 = 1;
break;
case 2023: //Achey Tree
woodcutting[0] = 2;
woodcutting[1] = 1;
woodcutting[2] = 25;
woodcutting[4] = 2862;
woodcutting[6] = 0;
TreeHealth2 = 1;
break;
case 1281:
case 3037: //Oak Tree
woodcutting[0] = 3;
woodcutting[1] = 15;
if (misc.random(2) == 1) {
woodcutting[2] = 37;
} else {
woodcutting[2] = 38;
}
woodcutting[4] = 1521;
woodcutting[6] = 4;
TreeHealth2 = misc.random(7);
break;
case 1308:
woodcutting[0] =4;
woodcutting[1] = 30;
if (misc.random(2) == 1) {
woodcutting[2] = 67;
} else {
woodcutting[2] = 68;
}
woodcutting[4] = 1519;
woodcutting[6] = 10;
TreeHealth2 = misc.random(8);
case 5551:
woodcutting[0] =4;
woodcutting[1] = 30;
if (misc.random(2) == 1) {
woodcutting[2] = 67;
} else {
woodcutting[2] = 68;
}
woodcutting[4] = 1519;
woodcutting[6] = 10;
TreeHealth2 = misc.random(8);
case 5552:
woodcutting[0] =4;
woodcutting[1] = 30;
if (misc.random(2) == 1) {
woodcutting[2] = 67;
} else {
woodcutting[2] = 68;
}
woodcutting[4] = 1519;
woodcutting[6] = 10;
TreeHealth2 = misc.random(8);
case 5553: //Willow Tree
woodcutting[0] =4;
woodcutting[1] = 30;
if (misc.random(2) == 1) {
woodcutting[2] = 67;
} else {
woodcutting[2] = 68;
}
woodcutting[4] = 1519;
woodcutting[6] = 10;
TreeHealth2 = misc.random(8);
break;
case 9036: //Teak Tree
woodcutting[0] = 5;
woodcutting[1] = 35;
woodcutting[2] = 85;
woodcutting[4] = 6333;
woodcutting[6] = 4;
TreeHealth2 = misc.random(5);
break;
case 1292: //Dramen Tree
woodcutting[0] = 5;
woodcutting[1] = 36;
woodcutting[2] = 0;
woodcutting[4] = 771;
woodcutting[6] = 20;
TreeHealth2 = misc.random(100); //Because of the branches
EntId = 1733;
break;
case 1307:
case 4674: //Maple Tree
woodcutting[0] = 6;
woodcutting[1] = 45;
woodcutting[2] = 100;
woodcutting[4] = 1517;
woodcutting[6] = 24;
TreeHealth2 = misc.random(9);
break;
case 2289:
case 4060: //Hollow Tree
woodcutting[0] = 7;
woodcutting[1] = 45;
if (misc.random(2) == 1) {
woodcutting[2] = 82;
} else {
woodcutting[2] = 83;
}
woodcutting[4] = 3239;
woodcutting[6] = 8;
TreeHealth2 =1;
break;
case 9034: //Mahogany Tree
woodcutting[0] = 8;
woodcutting[1] = 50;
woodcutting[2] = 125;
woodcutting[4] = 4445;
woodcutting[6] = 12;
TreeHealth2 = misc.random(3);
break;
case 1309: //Yew Tree
woodcutting[0] = 9;
woodcutting[1] = 60;
woodcutting[2] = 175;
woodcutting[4] = 1515;
woodcutting[5] = 3;
woodcutting[6] = 30;
TreeHealth2 = misc.random(12);
break;
case 1306: //Magic Tree
woodcutting[0] = 10;
woodcutting[1] = 75;
woodcutting[2] = 250;
woodcutting[4] = 1513;
woodcutting[6] = 50;
TreeHealth2 = misc.random(15);
break;
Declare these to:
Code:
public static int TreeId;
public static int TreeId1;
Close client and head over to objecthandler.java and declare these:
Code:
/*WOODCUTTING*/
public static int TreeDelay = 20;
public static int[] ObjectTreeID = new int[MaxObjects];
public static int[] ObjectCutID = new int[MaxObjects];
public static int[] ObjectTreeX = new int[MaxObjects];
public static int[] ObjectTreeY = new int[MaxObjects];
public static int[] ObjectTreeH = new int[MaxObjects];
public static int[] ObjectTreeDelay = new int[MaxObjects];
public static int[] ObjectTreeMaxDelay = new int[MaxObjects];
public static int[] ObjectTreeSpawncount = new int[MaxObjects];
Find this:
below it put this:
now declare these to in objecthandler as well:
Code:
/*WOODCUTTING*/
public void woodcutting_process() {
for(int i = 0; i < MaxObjects; i++) {
if (ObjectCutID[i] > -1 && ObjectTreeID[i] > -1) {
if (ObjectTreeDelay[i] < ObjectTreeMaxDelay[i]) {
ObjectTreeDelay[i]++;
} else {
for (int j = 1; j < server.playerHandler.maxPlayers; j++) {
if (server.playerHandler.players[j] != null) {
server.playerHandler.players[j].TreeSpawn[i] = true;
}
}
}
}
}
}
public void ResetTree(int ArrayID) {
ObjectCutID[ArrayID] = -1;
ObjectTreeID[ArrayID] = -1;
ObjectTreeX[ArrayID] = -1;
ObjectTreeY[ArrayID] = -1;
ObjectTreeH[ArrayID] = -1;
ObjectTreeDelay[ArrayID] = 0;
ObjectTreeMaxDelay[ArrayID] = 0;
}
Close\Save, head into server.java and find this:
Code:
objectHandler.process();
below it put this:
Code:
objectHandler.woodcutting_process();
Save\Close, head into player.java and declare all this: (Don't know if it's all needed but it won't hurt if it's not)
Code:
public boolean[] IsTreeCut = new boolean[server.objectHandler.MaxObjects];
public boolean[] TreeSpawn = new boolean[server.objectHandler.MaxObjects];
public int[] TreeHealth = new int[server.objectHandler.MaxObjects];
public int TreeHealth2 = 1;
public int WCTimer = 0;
public boolean IsChopping = false;
Now 'I think' that's all, it's hard to keep track of all that + full mining + full firemaking.
Ill make a tut for full mining and full firemaking in just a sec.
~Wolf