Add xpRate Var & Include With XPRate Calculations

This commit is contained in:
Dark98
2021-11-23 01:08:13 +00:00
parent 8ab31771b3
commit bdd5297a94
3 changed files with 48 additions and 37 deletions
@@ -1,5 +1,7 @@
package com.rs2; package com.rs2;
import com.rs2.game.players.Player;
public class GameConstants { public class GameConstants {
/** /**
@@ -31,7 +33,7 @@ public class GameConstants {
public static boolean FILE_SERVER = true, SERVER_DEBUG = false, MEMBERS_ONLY = false, TUTORIAL_ISLAND = false, public static boolean FILE_SERVER = true, SERVER_DEBUG = false, MEMBERS_ONLY = false, TUTORIAL_ISLAND = false,
PARTY_ROOM_DISABLED = false, CLUES_ENABLED = true, ITEM_REQUIREMENTS = true, PARTY_ROOM_DISABLED = false, CLUES_ENABLED = true, ITEM_REQUIREMENTS = true,
ADMIN_CAN_TRADE = false, ADMIN_DROP_ITEMS = false, ADMIN_CAN_SELL_ITEMS = false; ADMIN_CAN_TRADE = false, ADMIN_DROP_ITEMS = false, ADMIN_CAN_SELL_ITEMS = false;
public static double XP_RATE = 1; public static double XP_RATE = 1 * Player.xpRate;
/** /**
@@ -98,7 +98,8 @@ public abstract class Player {
public byte buffer[] = null; public byte buffer[] = null;
public String lastConnectedFrom; public String lastConnectedFrom;
private Compost compost = new Compost(this); public static int xpRate;
private Compost compost = new Compost(this);
private Allotments allotment = new Allotments(this); private Allotments allotment = new Allotments(this);
private Flowers flower = new Flowers(this); private Flowers flower = new Flowers(this);
private Herbs herb = new Herbs(this); private Herbs herb = new Herbs(this);
@@ -166,6 +167,10 @@ public abstract class Player {
private DoubleGates doubleGates = new DoubleGates(); private DoubleGates doubleGates = new DoubleGates();
public int lastMainFrameInterface = -1; //Possibly used in future to prevent packet exploits public int lastMainFrameInterface = -1; //Possibly used in future to prevent packet exploits
public int getXPRate() { return xpRate; }
public void setXPRate(int xpRate) { this.xpRate = xpRate; }
public boolean isPreaching() { public boolean isPreaching() {
return preaching; return preaching;
} }
@@ -173,9 +178,9 @@ public abstract class Player {
public void setPreaching(boolean preaching) { public void setPreaching(boolean preaching) {
this.preaching = preaching; this.preaching = preaching;
} }
public boolean preaching; public boolean preaching;
public Compost getCompost() { public Compost getCompost() {
return compost; return compost;
} }
@@ -223,12 +228,12 @@ public abstract class Player {
public ToolLeprechaun getFarmingTools() { public ToolLeprechaun getFarmingTools() {
return toolLeprechaun; return toolLeprechaun;
} }
public LogCuttingInterface getFletching() { public LogCuttingInterface getFletching() {
return fletching; return fletching;
} }
public SingleGates getSingleGates() { public SingleGates getSingleGates() {
return singleGates; return singleGates;
} }
@@ -404,7 +409,7 @@ public abstract class Player {
public MageTrainingArena getMageTrainingArena() { public MageTrainingArena getMageTrainingArena() {
return mageArena; return mageArena;
} }
public Trading getTrading() { public Trading getTrading() {
return trading; return trading;
} }
@@ -444,13 +449,13 @@ public abstract class Player {
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;
} }
private Inventory inventory = new Inventory(this); private Inventory inventory = new Inventory(this);
private int tempInteger; private int tempInteger;
public boolean tempBoolean; public boolean tempBoolean;
public void setTempInteger(int tempInteger) { public void setTempInteger(int tempInteger) {
this.tempInteger = tempInteger; this.tempInteger = tempInteger;
} }
@@ -460,17 +465,17 @@ public abstract class Player {
} }
public int totalShopItems; public int totalShopItems;
public boolean stopPlayer(boolean stop) { public boolean stopPlayer(boolean stop) {
return (stop ? stopPlayerPacket == true : stopPlayerPacket == false); return (stop ? stopPlayerPacket == true : stopPlayerPacket == false);
} }
public long objectDelay; public long objectDelay;
public long getObjectDelay() { public long getObjectDelay() {
return (objectDelay); return (objectDelay);
} }
public long setObjectDelay(long delay) { public long setObjectDelay(long delay) {
return (objectDelay = delay); return (objectDelay = delay);
} }
@@ -981,7 +986,7 @@ public abstract class Player {
if (System.currentTimeMillis() - singleCombatDelay2 > 3300) { if (System.currentTimeMillis() - singleCombatDelay2 > 3300) {
underAttackBy2 = 0; underAttackBy2 = 0;
} }
if (System.currentTimeMillis() - restoreStatsDelay > 60000) { if (System.currentTimeMillis() - restoreStatsDelay > 60000) {
restoreStatsDelay = System.currentTimeMillis(); restoreStatsDelay = System.currentTimeMillis();
for (int skill = 0; skill < playerLevel.length; skill++) { for (int skill = 0; skill < playerLevel.length; skill++) {
@@ -1398,20 +1403,20 @@ public abstract class Player {
restoreStatsDelay, logoutDelay, buryDelay, foodDelay, potDelay, restoreStatsDelay, logoutDelay, buryDelay, foodDelay, potDelay,
doorDelay, doubleDoorDelay, buySlayerTimer, lastIncrease, doorDelay, doubleDoorDelay, buySlayerTimer, lastIncrease,
boneDelay, leverDelay = 0, searchObjectDelay = 0, clickDelay = 0; boneDelay, leverDelay = 0, searchObjectDelay = 0, clickDelay = 0;
public boolean hideYell; public boolean hideYell;
private Npc specialTarget = null; private Npc specialTarget = null;
public void setSpecialTarget(Npc target) { public void setSpecialTarget(Npc target) {
this.specialTarget = target; this.specialTarget = target;
} }
public Npc getSpecialTarget() { public Npc getSpecialTarget() {
return specialTarget; return specialTarget;
} }
public int miningAxe = -1, woodcuttingAxe = -1; public int miningAxe = -1, woodcuttingAxe = -1;
public boolean initialized, musicOn = true, luthas, public boolean initialized, musicOn = true, luthas,
@@ -1695,7 +1700,7 @@ public abstract class Player {
4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 2097152, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 2097152,
8388608, 16777216, 67108864, 134217728 }; 8388608, 16777216, 67108864, 134217728 };
/** /**
* Combat variables * Combat variables
*/ */
@@ -1713,7 +1718,7 @@ public abstract class Player {
/** /**
* End * End
*/ */
public int clickNpcType, clickObjectType, objectId, objectX, public int clickNpcType, clickObjectType, objectId, objectX,
objectY, npcIndex, npcClickIndex, npcType; objectY, npcIndex, npcClickIndex, npcType;
public int pItemX, pItemY, pItemId; public int pItemX, pItemY, pItemId;
@@ -2130,11 +2135,11 @@ public abstract class Player {
walkingQueueY[wQueueWritePtr] = y; walkingQueueY[wQueueWritePtr] = y;
wQueueWritePtr = next; wQueueWritePtr = next;
} }
public boolean checkRangeDistance() { public boolean checkRangeDistance() {
return (usingRangeWeapon || usingBow); return (usingRangeWeapon || usingBow);
} }
public int gatherRangeDistance(int distance) { public int gatherRangeDistance(int distance) {
//dart (non long range) //dart (non long range)
if (usingRangeWeapon && RangeData.usingDart(this) && fightMode != 3) { if (usingRangeWeapon && RangeData.usingDart(this) && fightMode != 3) {
@@ -2148,7 +2153,7 @@ public abstract class Player {
//dart, knife, throwing axe (long range) //dart, knife, throwing axe (long range)
} else if (usingRangeWeapon && fightMode == 3) { } else if (usingRangeWeapon && fightMode == 3) {
distance = RangeData.usingDart(this) ? 5 : 6; distance = RangeData.usingDart(this) ? 5 : 6;
//short bow //short bow
} else if (usingBow && !RangeData.usingLongbow(this)) { } else if (usingBow && !RangeData.usingLongbow(this)) {
distance = fightMode == 3 ? 7 : 9; distance = fightMode == 3 ? 7 : 9;
} }
@@ -2507,74 +2512,74 @@ public abstract class Player {
} else { } else {
playerProps.writeByte(0); playerProps.writeByte(0);
} }
if (playerEquipment[ItemConstants.CAPE] > 1) { if (playerEquipment[ItemConstants.CAPE] > 1) {
playerProps.writeWord(0x200 + playerEquipment[ItemConstants.CAPE]); playerProps.writeWord(0x200 + playerEquipment[ItemConstants.CAPE]);
} else { } else {
playerProps.writeByte(0); playerProps.writeByte(0);
} }
if (playerEquipment[ItemConstants.AMULET] > 1) { if (playerEquipment[ItemConstants.AMULET] > 1) {
playerProps.writeWord(0x200 + playerEquipment[ItemConstants.AMULET]); playerProps.writeWord(0x200 + playerEquipment[ItemConstants.AMULET]);
} else { } else {
playerProps.writeByte(0); playerProps.writeByte(0);
} }
if (playerEquipment[ItemConstants.WEAPON] > 1) { if (playerEquipment[ItemConstants.WEAPON] > 1) {
playerProps.writeWord(0x200 + playerEquipment[ItemConstants.WEAPON]); playerProps.writeWord(0x200 + playerEquipment[ItemConstants.WEAPON]);
} else { } else {
playerProps.writeByte(0); playerProps.writeByte(0);
} }
if (playerEquipment[ItemConstants.CHEST] > 1) { if (playerEquipment[ItemConstants.CHEST] > 1) {
playerProps.writeWord(0x200 + playerEquipment[ItemConstants.CHEST]); playerProps.writeWord(0x200 + playerEquipment[ItemConstants.CHEST]);
} else { } else {
playerProps.writeWord(0x100 + playerAppearance[2]); playerProps.writeWord(0x100 + playerAppearance[2]);
} }
if (playerEquipment[ItemConstants.SHIELD] > 1) { if (playerEquipment[ItemConstants.SHIELD] > 1) {
playerProps.writeWord(0x200 + playerEquipment[ItemConstants.SHIELD]); playerProps.writeWord(0x200 + playerEquipment[ItemConstants.SHIELD]);
} else { } else {
playerProps.writeByte(0); playerProps.writeByte(0);
} }
if (!ItemData.isFullBody(playerEquipment[ItemConstants.CHEST])) { if (!ItemData.isFullBody(playerEquipment[ItemConstants.CHEST])) {
playerProps.writeWord(0x100 + playerAppearance[3]); playerProps.writeWord(0x100 + playerAppearance[3]);
} else { } else {
playerProps.writeByte(0); playerProps.writeByte(0);
} }
if (playerEquipment[ItemConstants.LEGS] > 1) { if (playerEquipment[ItemConstants.LEGS] > 1) {
playerProps.writeWord(0x200 + playerEquipment[ItemConstants.LEGS]); playerProps.writeWord(0x200 + playerEquipment[ItemConstants.LEGS]);
} else { } else {
playerProps.writeWord(0x100 + playerAppearance[5]); playerProps.writeWord(0x100 + playerAppearance[5]);
} }
if (!ItemData.isFullHelm(playerEquipment[ItemConstants.HAT]) if (!ItemData.isFullHelm(playerEquipment[ItemConstants.HAT])
&& !ItemData.isFullMask(playerEquipment[ItemConstants.HAT])) { && !ItemData.isFullMask(playerEquipment[ItemConstants.HAT])) {
playerProps.writeWord(0x100 + playerAppearance[1]); playerProps.writeWord(0x100 + playerAppearance[1]);
} else { } else {
playerProps.writeByte(0); playerProps.writeByte(0);
} }
if (playerEquipment[ItemConstants.HANDS] > 1) { if (playerEquipment[ItemConstants.HANDS] > 1) {
playerProps.writeWord(0x200 + playerEquipment[ItemConstants.HANDS]); playerProps.writeWord(0x200 + playerEquipment[ItemConstants.HANDS]);
} else { } else {
playerProps.writeWord(0x100 + playerAppearance[4]); playerProps.writeWord(0x100 + playerAppearance[4]);
} }
if (playerEquipment[ItemConstants.FEET] > 1) { if (playerEquipment[ItemConstants.FEET] > 1) {
playerProps.writeWord(0x200 + playerEquipment[ItemConstants.FEET]); playerProps.writeWord(0x200 + playerEquipment[ItemConstants.FEET]);
} else { } else {
playerProps.writeWord(0x100 + playerAppearance[6]); playerProps.writeWord(0x100 + playerAppearance[6]);
} }
if (playerAppearance[0] != 1 && !ItemData.isFullMask(playerEquipment[ItemConstants.HAT])) { if (playerAppearance[0] != 1 && !ItemData.isFullMask(playerEquipment[ItemConstants.HAT])) {
playerProps.writeWord(0x100 + playerAppearance[7]); playerProps.writeWord(0x100 + playerAppearance[7]);
} else { } else {
playerProps.writeByte(0); playerProps.writeByte(0);
} }
} else {//send npc data } else {//send npc data
playerProps.writeWord(-1);//Tells client that were being a npc playerProps.writeWord(-1);//Tells client that were being a npc
playerProps.writeWord(npcId2);//send NpcID playerProps.writeWord(npcId2);//send NpcID
@@ -92,6 +92,8 @@ public class PlayerSave {
case "character-rights": case "character-rights":
player.playerRights = Integer.parseInt(token2); player.playerRights = Integer.parseInt(token2);
break; break;
case "xp-rate":
player.xpRate = Integer.parseInt(token2);
case "last-ip": case "last-ip":
player.lastConnectedFrom = token2; player.lastConnectedFrom = token2;
break; break;
@@ -593,6 +595,8 @@ public class PlayerSave {
characterfile.newLine(); characterfile.newLine();
characterfile.write("character-rights = " + player.playerRights); characterfile.write("character-rights = " + player.playerRights);
characterfile.newLine(); characterfile.newLine();
characterfile.write("xp-rate = " + player.xpRate);
characterfile.newLine();
characterfile.write("last-ip = " + player.connectedFrom); characterfile.write("last-ip = " + player.connectedFrom);
characterfile.newLine(); characterfile.newLine();
characterfile.write("isBot = " + player.isBot); characterfile.write("isBot = " + player.isBot);