Author Topic: [PI] Woodcutting (Around 80-90%)  (Read 616 times)

Offline Alex_Kilroy

  • Adamant Member
  • *
  • Posts: 91
  • Rep 2
  • Java programmer
  • Location: United Kingdom, England.
    • View Profile
[PI] Woodcutting (Around 80-90%)
« on: March 14, 2011, 07:07:21 pm »
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:
Code: (java) [Select]
**/
*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:
Code: (java) [Select]
/**
* @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.)

   
Code: (java) [Select]
public static final int WOODCUT_KNOWLEDGE = 40;This is the exp multiplier.

Ok now add this into your Skill Instances in Client.Java:
   
Code: (java) [Select]
private Woodcut woodcut = new Woodcut(this);


Still in client Java add this:
      
Code: (java) [Select]
//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:
   
Code: (java) [Select]
public Woodcutting getWoodcutting() {
return woodcutting;
                } // Thank you to Roonspace for pointing the '}' out.


If this does not exist, add it under your woodcut constructor:
   
Code: (java) [Select]
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:
   
Code: (java) [Select]
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.
I'm a MEXICAN
#facepalm
My various other names are, Byte3, Kaex and Limbo.
I am now known as Alex_Kilroy.

Share on Bluesky Share on Facebook


Offline Cinodor

  • I'm Awesome
  • Veteran
  • Pernix Member
  • *
  • Posts: 494
  • Rep 15
  • I Do Graphics To.
  • Location: GMT -6 (Oklahoma)
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #1 on: March 14, 2011, 07:34:34 pm »
This will help some players :) thanks for sharing!
Signature Loading.. Please Wait..

Offline Alex_Kilroy

  • Adamant Member
  • *
  • Posts: 91
  • Rep 2
  • Java programmer
  • Location: United Kingdom, England.
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #2 on: March 14, 2011, 07:37:41 pm »
This will help some players :) thanks for sharing!

I guess, Project Insanity's original woodcutting is horrible. Sanity really did horrible, and Project Insanity in general is horrible, the combat is ridiculously out-formed.
I'm a MEXICAN
#facepalm
My various other names are, Byte3, Kaex and Limbo.
I am now known as Alex_Kilroy.

Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #3 on: March 14, 2011, 11:45:14 pm »
I made one of these a while back, made a new class to handle the tree by its location, if the tree wasnt added to the arraylist, once you started chopping it it was automatically added. The tree's even disappear for 1 minute after being cut down ;D

Offline Alex_Kilroy

  • Adamant Member
  • *
  • Posts: 91
  • Rep 2
  • Java programmer
  • Location: United Kingdom, England.
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #4 on: March 15, 2011, 07:37:53 am »
I made one of these a while back, made a new class to handle the tree by its location, if the tree wasnt added to the arraylist, once you started chopping it it was automatically added. The tree's even disappear for 1 minute after being cut down ;D

I made a better one than this, if tree id is this, time down is this, else if tree id is this etc.
Handling the tree stump in action handler made more sense, blaintly because its an action.
I'm a MEXICAN
#facepalm
My various other names are, Byte3, Kaex and Limbo.
I am now known as Alex_Kilroy.

Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #5 on: March 15, 2011, 07:46:52 am »
I made a better one than this, if tree id is this, time down is this, else if tree id is this etc.
Handling the tree stump in action handler made more sense, blaintly because its an action.
If you made a better one why post this one? lol
and yeah how else do you expect it to start chopping? lol
i just handled the tree class in the objectmanager xP

Offline Alex_Kilroy

  • Adamant Member
  • *
  • Posts: 91
  • Rep 2
  • Java programmer
  • Location: United Kingdom, England.
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #6 on: March 15, 2011, 07:49:19 am »
I made a better one than this, if tree id is this, time down is this, else if tree id is this etc.
Handling the tree stump in action handler made more sense, blaintly because its an action.
If you made a better one why post this one? lol
and yeah how else do you expect it to start chopping? lol
i just handled the tree class in the objectmanager xP

Why handle it in the objectmanager lol. And I released this over a year ago, this community needs some releases and not leeches. The majority of the community don't know Java and leech atm, so...

I also don't release any more because people don't give a ****.
I'm a MEXICAN
#facepalm
My various other names are, Byte3, Kaex and Limbo.
I am now known as Alex_Kilroy.

Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #7 on: March 15, 2011, 07:58:36 am »
Why handle it in the objectmanager lol. And I released this over a year ago, this community needs some releases and not leeches. The majority of the community don't know Java and leech atm, so...

I also don't release any more because people don't give a ****.

like the tree, once its chopped down, in 60 seconds a new tree appears.
its handled there because tats where most object ticks are handled in my source.
so if the tree is ready to respawn, it will spawn the same tree back to its original position with full health(20 logs).
anyways, yeah, nice release tho :P

Offline Alex_Kilroy

  • Adamant Member
  • *
  • Posts: 91
  • Rep 2
  • Java programmer
  • Location: United Kingdom, England.
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #8 on: March 15, 2011, 07:59:45 am »
Why handle it in the objectmanager lol. And I released this over a year ago, this community needs some releases and not leeches. The majority of the community don't know Java and leech atm, so...

I also don't release any more because people don't give a ****.

like the tree, once its chopped down, in 60 seconds a new tree appears.
its handled there because tats where most object ticks are handled in my source.
so if the tree is ready to respawn, it will spawn the same tree back to its original position with full health(20 logs).
anyways, yeah, nice release tho :P

I'm still going to bumfuck action handler.
I'm a MEXICAN
#facepalm
My various other names are, Byte3, Kaex and Limbo.
I am now known as Alex_Kilroy.

Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #9 on: March 15, 2011, 08:05:20 am »
Sounds fine to me xD

Offline Alex_Kilroy

  • Adamant Member
  • *
  • Posts: 91
  • Rep 2
  • Java programmer
  • Location: United Kingdom, England.
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #10 on: March 15, 2011, 11:37:55 am »
Sounds fine to me xD

Good lol, I'm working on 100% clue scrolls atm, doing the interfaces.
I'm a MEXICAN
#facepalm
My various other names are, Byte3, Kaex and Limbo.
I am now known as Alex_Kilroy.

Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #11 on: March 15, 2011, 11:56:51 pm »
nicee :D

Offline Alex_Kilroy

  • Adamant Member
  • *
  • Posts: 91
  • Rep 2
  • Java programmer
  • Location: United Kingdom, England.
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #12 on: March 16, 2011, 12:08:26 am »
nicee :D

Go in projects section for 317, check my new project 'Summerbright'.
I'm a MEXICAN
#facepalm
My various other names are, Byte3, Kaex and Limbo.
I am now known as Alex_Kilroy.

Offline Cinodor

  • I'm Awesome
  • Veteran
  • Pernix Member
  • *
  • Posts: 494
  • Rep 15
  • I Do Graphics To.
  • Location: GMT -6 (Oklahoma)
    • View Profile
Re: [PI] Woodcutting (Around 80-90%)
« Reply #13 on: March 29, 2011, 11:56:14 pm »
Locked, Please use the format stated here.
http://www.rune-kingdom.org/index.php?topic=285.0
Signature Loading.. Please Wait..