Author Topic: [PI] Enhanced mining.  (Read 126 times)

Offline Alex_Kilroy

  • Adamant Member
  • *
  • Posts: 91
  • Rep 2
  • Java programmer
  • Location: United Kingdom, England.
    • View Profile
[PI] Enhanced mining.
« on: March 14, 2011, 06:58:58 pm »
Just a better mining for project insanity. And yes, this time I've tested it. All you do is copy and paste it with your current/ make a new Java file named "Mining".

Also depending on how your PI is packaged you may need to change imports and the package, if you never changed the packaging you'll have no problems.

The index for the player is now direct for face to the object using xy.
The ore variables and now given correctly.
It basically just works 100%.

Enjoy.

Code: [Select]
package server.model.players.skills;

import server.model.players.*;
import server.Config;
import server.util.Misc;

/**
 * The mining skill.
 *
 * @author Byte3 / Kaex.
 */

public class Mining {

Client c;

/**
* Int represents the experience given.
*/
private int expGiven;

/**
* Int represents the type of pick axe.
*/
private int pickAxe;

/**
* Int represents the level specification.
*/
private int levSpec;

/**
* Int represents the type of ore.
*/
private int oreType;

/**
* Int represents the anim ID.
*/
private final int ANIM = 625;

/**
* Int represents the pick axe ID'S.
*/
private final int PICK_AXES[] = {1265,1267,1269,1273,1271,1275};

/**
* Int represents the specification to equip the axe.
*/
private final int PICK_SPECS[] = {1,1,6,6,21,31,41,61};



public Mining(Client c) {
this.c = c;
}


/**
* Resets all variables by taking them below zero.
*/
public void resetMining() {
this.oreType = -1;
this.expGiven = -1;
this.levSpec = -1;
this.pickAxe = -1;
}

/**
* Represents if the pick axe is happy, and good to go.
*/
public int happyPick() {
for (int j = PICK_AXES.length - 1; j >= 0; j--) {
if (c.playerEquipment[c.playerWeapon] == PICK_AXES[j]) {
if (c.playerLevel[c.playerMining] >= PICK_SPECS[j])
return PICK_AXES[j];
}
}
for (int i = 0; i < c.playerItems.length; i++) {
for (int j = PICK_AXES.length - 1; j >= 0; j--) {
if (c.playerItems[i] == PICK_AXES[j] + 1) {
if (c.playerLevel[c.playerMining] >= PICK_SPECS[j])
return PICK_AXES[j];
     }
       }
         }
            return - 1;
}

/**
* Creates a timer via the Misc class.
*/
public int getMiningTimer(int ore) {
int time = Misc.random(5);
if (ore == 451) {
time += 4;
}
       return time;
}


/**
* Begins the mining.
* @param
The ore type.
* The level specification.
* The experience given.
*/
public void beginMining(int oreType, int levSpec, int expGiven) {
c.turnPlayerTo(c.objectX, c.objectY);
if (happyPick() > 0) {
if (c.playerLevel[c.playerMining] >= levSpec) {

/**
* Creates the handle, then moves below.
*/
this.oreType = oreType;
this.expGiven = expGiven;
this.levSpec = levSpec;
this.pickAxe = happyPick();

/**
* Once here, sends message.
* Starts the emote, and resets timer.
*/
c.miningTimer = getMiningTimer(oreType);
c.startAnimation(ANIM);
c.sendMessage("You switch your pickaxe at the rock.");
} else {
resetMining();
c.sendMessage("You need a mining level of " + levSpec + " to mine this rock.");
} else {

resetMining();
c.sendMessage("You need a pickaxe to mine this rock.");

     /**
      * Resets #ALL variables.
      */
     c.getPA().resetVariables();
    }
}

/**
* Gets the item ID and gives experience per each '1'.
*/
public void mineOre() {
if (c.getItems().addItem(oreType,1)) {
c.startAnimation(ANIM);
c.sendMessage("You mine some ore.");
c.getPA().addSkillXP(exp * Config.MINING_EXPERIENCE, c.playerMining);
c.getPA().refreshSkill(c.playerMining);
c.miningTimer = getMiningTimer(oreType);
}
} else {
c.getPA().resetVariables();

}
}

/**
* Enhanced mining
* For: Project insanity.
* Corrections: None.
* Author: Byte3 / Kaex
*/
}

If you don't like the documentation, then what ever. Its how I code.
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 EpicScape

  • Bronze Member
  • *
  • Posts: 8
  • Rep 0
    • View Profile
Re: [PI] Enhanced mining.
« Reply #1 on: March 19, 2011, 11:23:47 pm »
If you don't like the documentation, then what ever. Its how I code.

Without documentation coding is too hard for you, right?  :fp:

Offline Tampon Abuse

  • Dragon Member
  • *
  • Posts: 193
  • Rep 1
  • All vote for Rune-Kingdom!
  • Location: Oklahoma, Oklahoma City
    • View Profile
Re: [PI] Enhanced mining.
« Reply #2 on: April 03, 2011, 08:59:41 pm »
yea, this is a abit better then the one i used before i used this one, thanks.

Everyone Vote For RUNE-KINGDOM at http://www.mmorpgtop200.com/in.php?site=6792