Okay so I got bored of Python, and R-server are being
****.
You may also notice it says author Limbo / Kaex, my user name on Moparscape is Kaex. And on Rune-server byte3, used to be Limbo. That explains that.
Here is what you'll be adding:
80-90% Woodcutting
Tested On: Project C-11 || Project Insanity || Emulous
Length: 2/10
Hard: 0/10
Copy&Paste
Okay, go to action handler, and add this:
**/
*Woodcutting case Id's
*@Author Limbo/Kaex.
/**
case 1286: // dead tree
case 1276: // normal tree 'example'
case 1278: // normal tree
case 1281: //oak tree
case 1308: // willow tree
case 1307: // maple tree
case 1309: //yew trree
case 1306: //magic tree
c.sendMessage("You chop the tree.");
Objects stump = new Objects(1343, c.objectX, c.objectY, 0, -1, 10, 0); // edit 10 to what ever you want.
Server.objectHandler.addObject(stump);
Server.objectHandler.placeObject(stump);
Objects tree = new Objects(c.objectId, c.objectX, c.objectY, 0, -1, 10, 10); // edit 10 to what ever you want
Server.objectHandler.addObject(tree);
break;The cases are the tree object Id's.
sendMessage is to inform you that the tree has been cut.
Objects stump = new objects just switches the object case id into the given id for 10ms.
Okay now go to the "Skills" folder: SRC > Server > Model > Players.
Make a new class named "Woodcut" and put this into it:
/**
* @Author Limbo/Kaex.
* Sets reqs axe intergers animation and exp.
*/
package server.model.players.skills; //Please add these imports.
import server.Config;
import server.util.Misc;
import server.model.players.*;
public class Woodcutting {
Client c;
private final int AXE_VAL[] = {1351,1349,1353,1361,1355,1357,1359,6739}; // Array keeps code clean.
private final int[] AXE_REQUIRE = {1,1,6,6,21,31,41,61};
private final int EMOTE = 875;
private int logType;
private int exp;
private int levelReq;
private int axeType;
public Woodcutting(Client c) {
this.c = c;
}
public void startWoodcut(int logType, int levelReq, int exp) {
if (goodAxe() > 0) {
c.turnPlayerTo(c.objectX, c.objectY);
if (c.playerLevel[c.playerWoodcutting] >= levelReq) {
this.logType = logType;
this.exp = exp;
this.levelReq = levelReq;
this.axeType = goodAxe();
c.wcTimer = getWcTimer();
c.startAnimation(EMOTE);
} else {
c.getPA().resetVariables();
c.startAnimation(65535);
c.sendMessage("You need a Woodcutting level of " + levelReq + " to cut this tree.");
}
} else {
c.startAnimation(65535);
c.sendMessage("You need an axe to cut this tree.");
c.getPA().resetVariables();
}
}
public void resetWoodcut() {
this.logType = -1;
this.exp = -1;
this.levelReq = -1;
this.axeType = -1;
c.wcTimer = -1;
}
public void cutWood() {
if (c.getItems().addItem(logType,1)) {
c.startAnimation(EMOTE);
c.sendMessage("You get some wooden logs.");
c.getPA().addSkillXP(exp * Config.WOODCUT_KNOWLEDGE, c.playerWoodcut);
c.getPA().refreshSkill(c.playerWoodcut);
c.wcTimer = getWcTimer();
} else {
c.getPA().resetVariables();
}
}
public int goodAxe() {
for (int j = VALID_AXE.length - 1; j >= 0; j--) {
if (c.playerEquipment[c.playerWeapon] == VALID_AXE[j]) {
if (c.playerLevel[c.playerWoodcut] >= AXE_REQS[j])
return VALID_AXE[j];
}
}
for (int i = 0; i < c.playerItems.length; i++) {
for (int j = VALID_AXE.length - 1; j >= 0; j--) {
if (c.playerItems[i] == VALID_AXE[j] + 1) {
if (c.playerLevel[c.playerWoodcut] >= AXE_REQS[j])
return VALID_AXE[j];
}
}
}
return - 1;
}
public int getWcTimer() {
int time = Misc.random(5);
return time;
}
}
This is needed so that your server knows axe id's and req's, it also starts the animations when you cut and uses a Misc random for a random timer when your cutting tree. This also handles the exp given.
Okay now go to Config.Java
Plonk this into it (With your other skill multipliers.)
public static final int WOODCUT_KNOWLEDGE = 40;This is the exp multiplier.
Ok now add this into your Skill Instances in Client.Java:
private Woodcut woodcut = new Woodcut(this);Still in client Java add this:
//Timer for the wuddi cutti.
if (wcTimer > 0 && woodcut[0] > 0) {
wcTimer--;This is the if statement for the wctimer.'
Now add this to your Skill constructors, that is if you have some otherwise make a list for them:
public Woodcutting getWoodcutting() {
return woodcutting;
} // Thank you to Roonspace for pointing the '}' out.If this does not exist, add it under your woodcut constructor:
public void queueMessage(Packet arg1) {
synchronized(queuedPackets) {
}
}
public synchronized boolean processQueuedPackets() {
Packet p = null;
synchronized(queuedPackets) {
p = queuedPackets.poll();
}
if(p == null) {
return false;
}
inStream.currentOffset = 0;
packetType = p.getId();
packetSize = p.getLength();
inStream.buffer = p.getData();
if(packetType > 0) {
PacketHandler.processPacket(this, packetType, packetSize);
}
timeOutCounter = 0;
return true;
}
Packet stream.Synchronizes the packet stream.
Now in player assistant add this void:
public void refreshSkill(int i) {
switch (i) {
case 8:
sendFrame126("" + c.playerLevel[8] + "", 4038);
sendFrame126("" + getLevelForXP(c.playerXP[8]) + "", 4039);
sendFrame126("" + c.playerXP[8] + "", 4146);
sendFrame126("" + getXPForLevel(getLevelForXP(c.playerXP[8]) + 1) + "", 4147);
break;(YOU MAY HAVE IT ALREADY)
And thats it, congratulations, you now have a some what good woodcutting.