Description: Fletching System.
Difficulty: 3/10
Assumed Knowledge: Basic Java and knowing how to use RS2E.
Tested Server: Pk Predatory (RS2E)
Files/Classes Modified: Fletching.java
Procedure:
Step 1: The fletching class. Open up Skills folder and create new class called Fletching.java:
Code:
/*
* @author Encouragin
* Class Name: Fletching
* Information: Handles Fletching Skill.
*/
package RS2E.Skills;
import RS2E.Main;
import RS2E.Players.*;
import RS2E.NPCs.*;
public class Fletching {
Player p;
public Fletching(Player _p) {
p = _p;
}
int getWood() {
switch (p.getFletchType()) {
case 1: return 1511;
}
return 0;
}
int getBow() {
switch (p.getFletchType()) {
case 1: return 52;
}
return 0;
}
int getExperience() {
switch (p.getFletchType()) {
case 1: return 15;
}
return 0;
}
public void fletchSystem() {
if (p == null)
{
return;
}
PlayerItems pi = new PlayerItems();
if (pi.freeSlots(p) >= 0) {
if (p.IsFletching()) {
p.requestAnim(1248, 0);
pi.deleteItem(p, getWood(), pi.getItemSlot(p, getWood()), 1);
pi.addItem(p, getBow(), 15);
p.addSkillXP(getExperience(), 9);
p.frame.sendMessage(p, "You fletched a bow.");
p.setFletchDelay(4);
}
if (!pi.playerHasItem(p, getWood())) {
p.setFletching(false);
p.setFletchDelay(-1);
p.frame.sendMessage(p, "You ran out of logs.");
}
} else {
p.setFletching(false);
p.setFletchDelay(-1);
p.frame.sendMessage(p, "Not enough space in your inventory.");
}
}
}
Step 2: Close Skills folder and head to Players folder -> PlayerItems.java. declare this method:
Code:
public boolean playerHasItem(Player p, int ItemId)
{
for (int i=0; i <p.items.length; i++)
{
if (p.items[i] == ItemId+1)
{
return true;
}
}
return false;
}
Step 3: Close PlayerItems.java and open up PlayerInstance.java. The methods below are there for you to declare:
Code:
/**
* Fletching Variables
*/
int fletchDelay;
int fletchType;
boolean isFletching;
public void setFletchDelay(int fletchDelay) {
this.fletchDelay = fletchDelay;
}
public boolean IsFletching() {
return isFletching;
}
public void setFletchType(int fletchType) {
this.fletchType = fletchType;
}
public void setFletching(boolean isFletching) {
this.isFletching = isFletching;
}
public int getFletchType() {
return fletchType;
}
Step 4: The fletchin auto system. Head to Player.java and add these to process:
Code:
if (fletchDelay > 0)
{
fletchDelay--;
}
if (fletchDelay == 0 && IsFletching())
{
Fletching fl = new Fletching(this);
fl.fletchSystem();
fl = null;
}
the import:
Code:
import RS2E.Skills.Fletching;
Step 5: Walking away = Stop fletching. -> Walk.java Packets folder. Method:
MainWalkReset.
Code:
p.setFletching(false);
p.setFletchDelay(-1);
Step 6: Item on Item. This requires My Item on Item tutorial. If you dont have it. I suggest you do it. or else you cant do this. Open up ItemOnItem.java and add this:
Code:
if (usedItem == 946 && itemTarget == 1511 || usedItem == 1511 && itemTarget == 946) {
p.setFletchType(1);
p.setFletchDelay(1);
p.setFletching(true);
}
Note:
This fletching System do NOT Include Interfaces. If you want Interfaces you have to go search for yourself. Have a nice day.
Credits:
Palidino76 - Creating RS2E
Ownage Bone/Encouragin - For making Fletching System.
wL - for a simple item method.