Commit 36e91d5d authored by Scott T's avatar Scott T

Sleeping bag experience freeze toggle for servers without fatigue

parent 7ee121b4
......@@ -3404,7 +3404,7 @@ public class EntityHandler {
items.add(new ItemDef("Mithril Pickaxe", "Requires level 21 mining to use", "", 1300, 72, "items:72", false, false, 0, 10072780, false, false, 2077, -1, 1260));
items.add(new ItemDef("Adamantite Pickaxe", "Requires level 31 mining to use", "", 3200, 72, "items:72", false, false, 0, 11717785, false, false, 2078, -1, 1261));
items.add(new ItemDef("Rune Pickaxe", "Requires level 41 mining to use", "", 32000, 72, "items:72", false, false, 0, 65535, false, false, 2079, -1, 1262));
items.add(new ItemDef("Sleeping Bag", "Not as comfy as a bed but better than nothing", "sleep", 30, 422, "items:422", false, false, 0, 0, false, false, 2080, -1, 1263));
items.add(new ItemDef("Sleeping Bag", "Not as comfy as a bed but better than nothing", Config.S_WANT_FATIGUE ? "sleep" : "toggle exp", 30, 422, "items:422", false, false, 0, 0, false, false, 2080, -1, 1263));
items.add(new ItemDef("A blue wizards hat", "An ancient wizards hat.", "", 2, 86, "items:86", false, true, 32, 255, true, true, -1, -1, 1264));
items.add(new ItemDef("Gilded Totem Pole", "A well crafted totem pole - given to you as a gift from Gujuo", "Inspect", 20, 403, "items:403", false, false, 0, 65280, true, true, -1, -1, 1265));
items.add(new ItemDef("Blessed Golden Bowl", "A specially made bowl constructed out of pure gold - it looks magical somehow", "", 1000, 404, "items:404", false, false, 0, 0, true, true, -1, -1, 1266));
......
......@@ -375,6 +375,9 @@ public class PacketHandler {
// Draw Ground Items
else if (opcode == 99) drawGroundItems(length);
//toggle experience freeze
else if (opcode == 34) mc.toggleExperienceFreeze(packetsIncoming.getByte());
else mc.closeConnection(true);
} catch (RuntimeException var17) {
......
......@@ -266,6 +266,7 @@ public final class mudclient implements Runnable {
private final int[] playerSkinColors = new int[]{15523536, 13415270, 11766848, 10056486, 9461792};
private int[] playerStatBase;
private int[] playerExperience;
private boolean experienceOff = false;
public final int[] playerStatEquipment = new int[5];
private final boolean[] prayerOn = new boolean[50];
private final int projectileMaxRange = 40;
......@@ -7152,7 +7153,17 @@ public final class mudclient implements Runnable {
this.drawMenu();
}
}
//draw experience freeze message
if (this.experienceOff) {
this.getSurface().drawColoredString(
this.getSurface().width2 - 218 - getSurface().stringWidth(1,"YOUR EXPERIENCE GAIN IS DISABLED"),
25,
"YOUR EXPERIENCE GAIN IS DISABLED",
1,
0x00FF0000,
-1
);
}
this.mouseButtonClick = 0;
} catch (RuntimeException var4) {
throw GenUtil.makeThrowable(var4, "client.DC(" + var1 + ')');
......@@ -14561,6 +14572,14 @@ public final class mudclient implements Runnable {
return this.playerExperience[stat];
}
public void toggleExperienceFreeze(byte expOff) {
if (expOff == 1) {
experienceOff = true;
} else if (expOff == 0) {
experienceOff = false;
}
}
public void setQuestPoints(int p) {
this.questPoints = p;
}
......
......@@ -3397,7 +3397,7 @@ public class EntityHandler {
items.add(new ItemDef("Mithril Pickaxe", "Requires level 21 mining to use", "", 1300, 72, "items:72", false, false, 0, 10072780, false, false, 2077, -1, 1260));
items.add(new ItemDef("Adamantite Pickaxe", "Requires level 31 mining to use", "", 3200, 72, "items:72", false, false, 0, 11717785, false, false, 2078, -1, 1261));
items.add(new ItemDef("Rune Pickaxe", "Requires level 41 mining to use", "", 32000, 72, "items:72", false, false, 0, 65535, false, false, 2079, -1, 1262));
items.add(new ItemDef("Sleeping Bag", "Not as comfy as a bed but better than nothing", "sleep", 30, 422, "items:422", false, false, 0, 0, false, false, 2080, -1, 1263));
items.add(new ItemDef("Sleeping Bag", "Not as comfy as a bed but better than nothing", Config.S_WANT_FATIGUE ? "sleep" : "toggle exp", 30, 422, "items:422", false, false, 0, 0, false, false, 2080, -1, 1263));
items.add(new ItemDef("A blue wizards hat", "An ancient wizards hat.", "", 2, 86, "items:86", false, true, 32, 255, true, true, -1, -1, 1264));
items.add(new ItemDef("Gilded Totem Pole", "A well crafted totem pole - given to you as a gift from Gujuo", "Inspect", 20, 403, "items:403", false, false, 0, 65280, true, true, -1, -1, 1265));
items.add(new ItemDef("Blessed Golden Bowl", "A specially made bowl constructed out of pure gold - it looks magical somehow", "", 1000, 404, "items:404", false, false, 0, 0, true, true, -1, -1, 1266));
......
......@@ -374,6 +374,9 @@ public class PacketHandler {
// Draw Ground Items
else if (opcode == 99) drawGroundItems(length);
//toggle experience freeze
else if (opcode == 34) mc.toggleExperienceFreeze(packetsIncoming.getByte());
else mc.closeConnection(true);
} catch (RuntimeException var17) {
......
......@@ -134,6 +134,7 @@ public final class mudclient implements Runnable {
private final int[] playerSkinColors = new int[]{15523536, 13415270, 11766848, 10056486, 9461792};
private int[] playerStatBase;
private int[] playerExperience;
private boolean experienceOff = false;
public final int[] playerStatEquipment = new int[5];
private final boolean[] prayerOn = new boolean[50];
private final int projectileMaxRange = 40;
......@@ -7021,6 +7022,17 @@ public final class mudclient implements Runnable {
}
}
//draw experience freeze message
if (this.experienceOff) {
this.getSurface().drawColoredString(
this.getSurface().width2 - 218 - getSurface().stringWidth(1,"YOUR EXPERIENCE GAIN IS DISABLED"),
25,
"YOUR EXPERIENCE GAIN IS DISABLED",
1,
0x00FF0000,
-1
);
}
this.mouseButtonClick = 0;
} catch (RuntimeException var4) {
throw GenUtil.makeThrowable(var4, "client.DC(" + var1 + ')');
......@@ -7514,7 +7526,7 @@ public final class mudclient implements Runnable {
if (EntityHandler.getItemDef(id).getCommand() != null
&& EntityHandler.getItemDef(id).getNotedFormOf() == -1) {
for (int p = 0; p < EntityHandler.getItemDef(id).getCommand().length; p++) {
for (int p = EntityHandler.getItemDef(id).getCommand().length-1; p >= 0; p--) {
this.menuCommon.addItem(0, EntityHandler.getItemDef(id).getCommand()[p], p, 0, "@lre@" + EntityHandler.getItemDef(id).getName(), var5, (String) null, MenuItemAction.ITEM_COMMAND, 0, (String) null, (String) null);
}
}
......@@ -14429,6 +14441,14 @@ public final class mudclient implements Runnable {
return this.playerExperience[stat];
}
public void toggleExperienceFreeze(byte expOff) {
if (expOff == 1) {
experienceOff = true;
} else if (expOff == 0) {
experienceOff = false;
}
}
public void setQuestPoints(int p) {
this.questPoints = p;
}
......
......@@ -28,7 +28,8 @@ public class InvAction extends Functions implements InvActionListener, InvAction
ItemId.SHAMAN_ROBE.id(), ItemId.SPELL_SCROLL.id(), ItemId.BOOK_OF_EXPERIMENTAL_CHEMISTRY.id(),
ItemId.LEVEL_1_CERTIFICATE.id(), ItemId.LEVEL_2_CERTIFICATE.id(), ItemId.LEVEL_3_CERTIFICATE.id(),
ItemId.DIGSITE_SCROLL.id(), ItemId.ASTROLOGY_BOOK.id(), ItemId.STONE_TABLET.id(),
ItemId.OYSTER.id(), ItemId.SCRUMPLED_PIECE_OF_PAPER.id());
ItemId.OYSTER.id(), ItemId.SCRUMPLED_PIECE_OF_PAPER.id())
|| (item.getID() == ItemId.SLEEPING_BAG.id() && !Constants.GameServer.WANT_FATIGUE);
}
@Override
......@@ -130,8 +131,20 @@ public class InvAction extends Functions implements InvActionListener, InvAction
else if (id == ItemId.STONE_TABLET.id())
handleStoneTablet(player);
else if (id == ItemId.SLEEPING_BAG.id())
handleSleepingBag(player);
}
private void handleSleepingBag(Player player) {
ActionSender.sendEnterSleep(player);
player.startSleepEvent(false);
player.toggleFreezeXp();
ActionSender.sendExperienceToggle(player, player.isExperienceFrozen());
if (player.isExperienceFrozen())
player.message("@red@You have DISABLED experience gain!");
else
player.message("@gre@You have ENABLED experience gain!");
}
private void handleOyster(Player player, int oyster) {
player.message("you open the oyster shell");
if (DataConversions.random(0, 10) == 1) {
......
......@@ -1426,6 +1426,8 @@ public final class Player extends Mob {
ActionSender.sendMessage(this, "You can not gain experience right now!");
return;
}
} else if (isExperienceFrozen()) {
return;
}
if (Constants.GameServer.WANT_FATIGUE) {
......@@ -2730,7 +2732,7 @@ public final class Player extends Mob {
return setCacheInvulnerable(!cacheIsInvulnerable());
}
private boolean isExperienceFrozen() {
public boolean isExperienceFrozen() {
if (!getCache().hasKey("freezexp"))
return false;
......
......@@ -901,6 +901,13 @@ public class ActionSender {
p.write(s.toPacket());
}
public static void sendExperienceToggle(Player p, boolean expOff) {
com.openrsc.server.net.PacketBuilder s = new com.openrsc.server.net.PacketBuilder();
s.setID(Opcode.SEND_EXPERIENCE_TOGGLE.opcode);
s.writeByte((byte) (expOff ? 1 : 0));
p.write(s.toPacket());
}
/**
* Updates the users stats
*/
......@@ -1236,6 +1243,8 @@ public class ActionSender {
if (WANT_BANK_PRESETS)
sendBankPresets(p);
if (!WANT_FATIGUE)
sendExperienceToggle(p, p.isExperienceFrozen());
/*if (!Constants.GameServer.MEMBER_WORLD) {
p.unwieldMembersItems();
}*/
......@@ -1480,6 +1489,7 @@ public class ActionSender {
SEND_WORLD_INFO(25),
SEND_DUEL_SETTINGS(30),
SEND_EXPERIENCE(33),
SEND_EXPERIENCE_TOGGLE(34),
SEND_BUBBLE(36),
SEND_BANK_OPEN(42),
SEND_SYSTEM_UPDATE(52),
......
......@@ -75,7 +75,7 @@ public class ItemActionHandler implements PacketHandler {
return;
}
if (item.getID() == ItemId.SLEEPING_BAG.id() && !player.isSleeping()) {
if (item.getID() == ItemId.SLEEPING_BAG.id() && Constants.GameServer.WANT_FATIGUE && !player.isSleeping()) {
ActionSender.sendEnterSleep(player);
player.startSleepEvent(false);
// player.resetPath(); - real rsc.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment