BenniScape Forums
Client download: http://www.mediafire.com/?565sq757qosw6yf
BenniScape Forums
Client download: http://www.mediafire.com/?565sq757qosw6yf
BenniScape Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomePortalLatest imagesSearchRegisterLog in
BENNISCAPE 562 IS ONLINE!

 

 farming code

Go down 
3 posters
AuthorMessage
mage
Moderator
Moderator



Posts : 32
Reputation : 0
Join date : 2010-07-12

farming code Empty
PostSubject: farming code   farming code EmptyMon Jul 12, 2010 1:30 am

for benni =[]

My farming is a little different to runescape farming. I will explain the differences right now Auto planting and also we have that the seed does not grow sometimes. well enough of this. time for the code =]

Step 1- Farming.Java

Make a new file called Farming.java (with the capital F) in your skills folder

Code:
package com.rs2hd.skills.farming;
Code:
package com.rs2hd.skills.farming;import com.rs2hd.event.Event;import com.rs2hd.model.Item;import com.rs2hd.model.Player;import com.rs2hd.model.Skills;import com.rs2hd.model.World;import com.rs2hd.util.Misc;public class Farming {        private int counter;        private Player p;        private boolean isFarming;        private int farmIndex;        /* {seedId, levelReq, farmedItem,XPGained} */        private final static int[][] farmingData =        {{5318, 1, 1942, 100},                        {5322, 5, 1942, 200},                {5324, 10, 1982, 300},                {5323, 15, 1965, 400},                {5321, 20, 5504, 500},                {5291, 25, 5982, 600},                {5293, 30, 249, 700},                {5295, 35, 253, 800},                {5294, 40, 257, 900},                {5296, 45, 251, 1000},                {5297, 50, 255, 1100},                {5298, 55, 2998, 1200},                {5299, 60, 259, 1300},                {5300, 65, 261, 1400},                {5301, 70, 263, 1500},                {5302, 75, 3000, 1600},                {5303, 80, 265, 1700},                {5304, 85, 2481, 1800},                {5292, 90, 267, 1900}};        private final static int[] patches = {7965};        public Farming(Player player) {                this.p = player;        }        private int getFarmed(int item) {                return farmingData[farmIndex][2];        }        private int getReq(int item) {                return farmingData[farmIndex][1];        }        private int getXP(int item) {                return farmingData[farmIndex][3];        }        private int getSeed(final int item) {                return farmingData[farmIndex][0];        }        private int patch(int object) {                for (int i = 0; patches.length > i;i++) {                        if(patches[i] == object) {                                return patches[i];                        }                }                return -1;        }        private boolean isSeed(int item) {                for (int i = 0; farmingData.length > i; i++) {                        if(farmingData[i][0] == item) {                                farmIndex = i;                                return true;                        }                }                return false;        }        public void handleItemOnObject(int itemId, int objectId) {                if(objectId == patch(objectId)) {                        if (!isSeed(itemId)) {                                p.getActionSender().sendMessage("Your Seed Failed To Grow");                                return;                        }                        if (patch(objectId) != -1 || objectId != -1) {                                handleFarming(itemId, 1);                        }                }                if(objectId == patch(objectId)) {                        if (!isSeed(itemId)) {                                p.getActionSender().sendMessage("Your Seed Faied To Grow");                                return;                        }                        if (patch(objectId) != -1 || objectId != -1) {                                handleFarming(itemId, 2);                        }                }        }        private void handleFarming(int itemId, int object) {                int emote = 2282;                if (object == 1) {                        emote = 2282;                }                if(object == 2) {                        emote = 2282;                }                final int seedId = getSeed(itemId);                setFarming(true);                if(p.getSkills().getLevel(Skills.FARMING) >= getReq(seedId)) {                        executeEvent(itemId, emote);                } else {                        p.getActionSender().sendMessage("You need level " + getReq(seedId) + " Farming to Farm this.");                }        }        private void executeEvent(final int item, final int emote) {                World.getInstance().registerEvent(new Event(500) {                        @Override                        public void execute() {                                if (p == null) {                                        this.stop();                                        return;                                }                                if (!isFarming && item != -1) {                                        this.stop();                                        return;                                }                                if(p.getInventory().numberOf(item) == 0) {                                        this.stop();                                        resetFarming();                                        p.getActionSender().sendMessage("You ran out of Seeds To Plant");                                        return;                                }                                if (counter == 0) {                                        p.animate(emote);                                        p.getInventory().deleteItem(item, 1);                                                                                if(sucess(item)) {                                                p.getSkills().addXp(19,getXP(item));                                                p.getActionSender().sendMessage("You Planted The Seed And You Got Something!");                                                p.getInventory().addItem(getFarmed(item), 1);                                                counter = 7;                                        } else {                                                p.getActionSender().sendMessage("Your seed failed To grow");                                                counter = 7;                                        }                                }                                counter--;                        }                });        }        private void resetFarming() {                isFarming = false;        }        private boolean sucess(int seedId) {                if (p.getSkills().getLevel(Skills.FARMING) > 98) {                        return true;                }                int level = p.getSkills().getLevel(Skills.FARMING);                int seedLevel = getReq(seedId);                int random = Misc.random(level*2);                if(random > seedLevel) {                        return true;                }                return false;        }        public void setFarming(boolean isFarming) {                this.isFarming = isFarming;        }        public boolean isFarming() {                return isFarming;        }}




Step 2-Player.Java Stuff:



Right. Next is adding just a few things to player.java



1st Add This Import:





Code:
import com.rs2hd.skills.farming.Farming;




Then Add This With All Your Other Thingys





Code:
private transient Farming farming;




Then Search For





Code:
public Object readResolve() {




Under That Add Where all the other skills are:





Code:
farming = new Farming(this);




A little bit under you should see:





Code:
public void resetSkills() {




Under That Add:





Code:
getFarming().setFarming(false);




Ok just A Little Bit More Now:





Code:
public void destroy() {




^^ Find That.





Underneath that you should see things about cooking and smithing etc.





Put these In With Them:





Code:
public void setFarming(Farming farming) {












Code:
this.farming = farming;}



AND:



Code:
public Farming getFarming() {




Code:
return farming;} 




Step 3-ItemPacketHandler.java:



This is The Last Part.



Find All Of This:



Code:
private void itemOnObject(final Player player, final IoSession session, final Packet packet) {












Code:
@SuppressWarnings("unused")final int objectY = packet.readLEShort() & 0xFFFF;final int objectId = packet.readLEShort() & 0xFFFF;@SuppressWarnings("unused") final int unknown = packet.readShortA() & 0xFFFF;//Value : 128 ? 200;final int interfaceId = packet.readShort() & 0xFFFF;final int itemId = packet.readShortA() & 0xFFFF;@SuppressWarnings("unused") final int itemSlot = packet.readShortA() & 0xFFFF;@SuppressWarnings("unused")final int objectX = packet.readLEShort() & 0xFFFF;@SuppressWarnings("unused") final int slot = player.getInventory().lookupSlot(itemId);if (interfaceId != 149) {//Player is not in invy screenreturn;}



Underneath that Add:



Code:
player.getFarming().handleItemOnObject(itemId, objectId);

that's it hopefully it works, just trying to add more skills to server =]

Back to top Go down
https://benniscape.darkbb.com
Knightmare15

Knightmare15


Posts : 20
Reputation : 0
Join date : 2010-07-12
Age : 112
Location : United K

farming code Empty
PostSubject: Re: farming code   farming code EmptyFri Jul 16, 2010 3:34 am

ok idk wot all that meant... are we getting a farming skill? Very Happy
Back to top Go down
De2th
Owner
Owner
De2th


Posts : 19
Reputation : 0
Join date : 2010-06-16
Location : Saudi Arabia

farming code Empty
PostSubject: Thanks   farming code EmptyFri Jul 16, 2010 2:54 pm

Very Very Nice

I Hope Benni Check This Out And Code It

I Well Try To Tell Him.

~~De2th.
Back to top Go down
mage
Moderator
Moderator



Posts : 32
Reputation : 0
Join date : 2010-07-12

farming code Empty
PostSubject: Re: farming code   farming code EmptyFri Jul 16, 2010 7:03 pm

De2th wrote:
Very Very Nice

I Hope Benni Check This Out And Code It

I Well Try To Tell Him.

~~De2th.

Ok thanks.
Back to top Go down
https://benniscape.darkbb.com
mage
Moderator
Moderator



Posts : 32
Reputation : 0
Join date : 2010-07-12

farming code Empty
PostSubject: Re: farming code   farming code EmptySat Jul 17, 2010 6:06 pm

Knightmare15 wrote:
ok idk wot all that meant... are we getting a farming skill? Very Happy

Yes now we officially will, since i'm the new benniscape coder, I will personly code it in my self.

Thanks, Mage
Back to top Go down
https://benniscape.darkbb.com
De2th
Owner
Owner
De2th


Posts : 19
Reputation : 0
Join date : 2010-06-16
Location : Saudi Arabia

farming code Empty
PostSubject: good luck   farming code EmptySat Jul 17, 2010 8:05 pm

Good Luck Mage.

~~De2th.
Back to top Go down
Sponsored content





farming code Empty
PostSubject: Re: farming code   farming code Empty

Back to top Go down
 
farming code
Back to top 
Page 1 of 1
 Similar topics
-
» WORKING IP BAN CODE- REQUESTED BY BENNI

Permissions in this forum:You cannot reply to topics in this forum
BenniScape Forums :: Forum :: Your Codes-
Jump to: