Commit 001e8b96 authored by Kenix Whisperwind's avatar Kenix Whisperwind

Merge branch '2.0.0' of gitlab.openrsc.com:open-rsc/Game into 2.0.0

# Conflicts:
#	server/plugins/com/openrsc/server/plugins/quests/members/LostCity.java
#	server/plugins/com/openrsc/server/plugins/quests/members/touristtrap/TouristTrap.java
#	server/src/com/openrsc/server/net/rsc/ActionSender.java
parents 8d727eae 8354cedc
......@@ -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,6 @@ public final class mudclient implements Runnable {
this.drawMenu();
}
}
this.mouseButtonClick = 0;
} catch (RuntimeException var4) {
throw GenUtil.makeThrowable(var4, "client.DC(" + var1 + ')');
......@@ -10026,8 +10026,13 @@ public final class mudclient implements Runnable {
heightMargin += 12;
this.getSurface().drawString("Combat level: " + this.localPlayer.level, 5 + x, heightMargin, textColour, 1);
heightMargin += 12;
//if there is a skill hovered over
} else {
//exp freeze notification
if (experienceOff)
this.getSurface().drawString("XP GAIN OFF", 122+x, yOffset + 8, 0x00FF0000, 1);
else
this.getSurface().drawString("XP GAIN ON", 124+x, yOffset + 8, 0x0000FF00, 1);
} else {//if there is a skill hovered over
this.getSurface().drawString(this.skillNameLong[currentlyHoveredSkill] + " skill", 5 + x, heightMargin, textColourHeading, 1);
heightMargin += 12;
int nextLevelExp = this.experienceArray[0];
......@@ -14561,6 +14566,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;
}
......
......@@ -38112,7 +38112,8 @@ INSERT INTO `openrsc_objects` (`x`, `y`, `id`, `direction`, `type`, `d_id`) VALU
(79, 505, 59, 0, 0, 29320),
(857, 53, 1205, 0, 0, 29321),
(855, 52, 1221, 0, 0, 29322),
(373, 3352, 1236, 2, 0, 29323);
(373, 3352, 1236, 2, 0, 29323),
(605, 505, 942, 2, 0, 29324);
DROP TABLE IF EXISTS `openrsc_recovery_questions`;
CREATE TABLE IF NOT EXISTS `openrsc_recovery_questions` (
......@@ -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;
......@@ -7020,7 +7021,6 @@ public final class mudclient implements Runnable {
this.drawMenu();
}
}
this.mouseButtonClick = 0;
} catch (RuntimeException var4) {
throw GenUtil.makeThrowable(var4, "client.DC(" + var1 + ')');
......@@ -7514,7 +7514,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);
}
}
......@@ -9855,7 +9855,6 @@ public final class mudclient implements Runnable {
this.getSurface().drawString("Fatigue: @yel@" + this.statFatigue + "%", xOffset, yOffset,
textColour, 1);
}
yOffset += 20;
this.getSurface().drawString("Equipment Status", 5 + x, yOffset, textColourHeading, 3);
yOffset += 13;
......@@ -9894,8 +9893,13 @@ public final class mudclient implements Runnable {
heightMargin += 12;
this.getSurface().drawString("Combat level: " + this.localPlayer.level, 5 + x, heightMargin, textColour, 1);
heightMargin += 12;
//if there is a skill hovered over
} else {
//exp freeze notification
if (experienceOff)
this.getSurface().drawString("XP GAIN OFF", 122+x, yOffset + 8, 0x00FF0000, 1);
else
this.getSurface().drawString("XP GAIN ON", 124+x, yOffset + 8, 0x0000FF00, 1);
} else {//if there is a skill hovered over
this.getSurface().drawString(this.skillNameLong[currentlyHoveredSkill] + " skill", 5 + x, heightMargin, textColourHeading, 1);
heightMargin += 12;
int nextLevelExp = this.experienceArray[0];
......@@ -14429,6 +14433,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;
}
......
......@@ -109,6 +109,7 @@ public class RandomObjects implements ObjectActionExecutiveListener, ObjectActio
});
} else {
owner.message("but nothing happens");
owner.setBusy(false);
}
break;
case 417: // CAVE ENTRANCE HAZEEL CULT
......
......@@ -5,7 +5,7 @@ import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.NpcId;
import com.openrsc.server.constants.Quests;
import com.openrsc.server.constants.Skills;
import com.openrsc.server.event.DelayedEvent;
import com.openrsc.server.event.SingleEvent;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.GameObject;
import com.openrsc.server.model.entity.npc.Npc;
......@@ -93,9 +93,9 @@ public class LostCity implements QuestInterface, TalkToNpcListener,
p.setBusyTimer(1800);
lepr.walk(173, 661);
try {
Server.getServer().getGameEventHandler().add(new DelayedEvent(null, 600, "Lost City Leprechaun") {
Server.getServer().getGameEventHandler().add(new SingleEvent(null, 600, "Lost City Leprechaun", true) {
@Override
public void run() {
public void action() {
lepr.walk(177, 661 + DataConversions.random(0, 10) - 5);
}
});
......
......@@ -71,7 +71,7 @@ public class Woodcutting implements ObjectActionListener,
final int axeID = axeId;
owner.message("You swing your " + EntityHandler.getItemDef(axeId).getName().toLowerCase() + " at the tree...");
showBubble(owner, new Item(axeId));
owner.setBatchEvent(new BatchEvent(owner, 1800, "Woodcutting", 5, true) {
owner.setBatchEvent(new BatchEvent(owner, 1800, "Woodcutting", Formulae.getRepeatTimes(owner,Skills.WOODCUT), true) {
@Override
public void action() {
final Item log = new Item(def.getLogId());
......
package com.openrsc.server.model.container;
import com.openrsc.server.external.ItemDefinition;
import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.net.rsc.ActionSender;
import java.util.ArrayList;
......@@ -119,5 +121,37 @@ public class Equipment {
}
}
public int remove(int id, int amount) {
synchronized (list) {
for (int i = 0; i < slots; i++) {
Item curEquip = list[i];
if (curEquip == null || curEquip.getDef() == null)
continue;
ItemDefinition curEquipDef = curEquip.getDef();
if (curEquip.getID() == id) {
int curAmount = curEquip.getAmount();
if (!curEquipDef.isStackable() && amount > 1)
return -1;
if (curAmount > amount) {
list[i].setAmount(curAmount - amount);
} else if(curAmount < amount) {
return -1;
} else {
list[i] = null;
player.updateWornItems(curEquipDef.getWieldPosition(),
player.getSettings().getAppearance().getSprite(curEquipDef.getWieldPosition()));
}
ActionSender.sendEquipmentStats(player);
return i;
}
}
return -1;
}
}
}
......@@ -277,7 +277,10 @@ public class Inventory {
}
}
}
return -1;
if (player.getWorld().getServer().getConfig().WANT_EQUIPMENT_TAB)
return player.getEquipment().remove(id, amount);
else
return -1;
}
public int remove(int id, int amount) {
......
......@@ -466,9 +466,9 @@ public class Npc extends Mob {
}
public int getWeaponPowerPoints() {
if (this.getID() == 236) {
/*if (this.getID() == 236) {
return 81;
} else
} else*/
return weaponPowerPoints;
}
......@@ -500,7 +500,7 @@ public class Npc extends Mob {
}
//owner = handleLootAndXpDistribution((Player) mob);
owner = handleLootAndXpDistribution(((Player) mob));
//Determine if the RDT is hit first
boolean rdtHit = false;
......@@ -954,8 +954,6 @@ public class Npc extends Mob {
//return playerWithMostDamage;
Mob npcWithMostDamage = attacker;
for (Player p282828 : World.getWorld().getPlayers()) {
}
// Melee damagers
for (int npcID : getCombatDamagers()) {
int newXP = 0;
......@@ -969,17 +967,6 @@ public class Npc extends Mob {
npcWithMostDamage = n;
currentHighestDamage = dmgDoneByNpc;
}
/*
if(attacker.getPetNpc() > 0) {
newXP = (int) (((double) (totalCombatXP) / (double) (this.getDef().hits)) * (double) (dmgDoneByNpc));
p28x.incPet1Exp(Skills.PETRANGED, newXP * 4, true);
//ActionSender.sendStat(p28x, Skills.PETRANGED);
for (Player p282828 : World.getWorld().getPlayers()) {
p282828.message("TEST 28");
}
}
*/
}
......@@ -995,17 +982,6 @@ public class Npc extends Mob {
npcWithMostDamage = n;
currentHighestDamage = dmgDoneByNpc;
}
/*
if(attacker.getPetNpc() > 0) {
newXP = (int) (((double) (totalCombatXP) / (double) (this.getDef().hits)) * (double) (dmgDoneByNpc));
p28x.incPet1Exp(Skills.PETRANGED, newXP * 4, true);
//ActionSender.sendStat(p28x, Skills.PETRANGED);
for (Player p282828 : World.getWorld().getPlayers()) {
p282828.message("TEST 28282828");
}
}
*/
}
// Magic damagers
......@@ -1016,19 +992,82 @@ public class Npc extends Mob {
int dmgDoneByNpc = getMageDamageDoneBy(n);
if (n == null)
continue;
/*
if(attacker.getPetNpc() > 0) {
newXP = (int) (((double) (totalCombatXP) / (double) (this.getDef().hits)) * (double) (dmgDoneByNpc));
p28x.incPet1Exp(Skills.PETRANGED, newXP * 4, true);
//ActionSender.sendStat(p28x, Skills.PETRANGED);
for (Player p282828 : World.getWorld().getPlayers()) {
p282828.message("TEST 28111128");
}
return npcWithMostDamage;
}
private Player handleLootAndXpDistribution(Player attacker) {
Player playerWithMostDamage = attacker;
int currentHighestDamage = 0;
int totalCombatXP = Formulae.combatExperience(this);
// Melee damagers
for (int playerID : getCombatDamagers()) {
final Player p = World.getWorld().getPlayerID(playerID);
if (p == null)
continue;
final int damageDoneByPlayer = getCombatDamageDoneBy(p);
if (damageDoneByPlayer > currentHighestDamage) {
playerWithMostDamage = p;
currentHighestDamage = damageDoneByPlayer;
}
// Give the player their share of the experience.
int totalXP = (int) (((double) (totalCombatXP) / (double) (getDef().hits)) * (double) (damageDoneByPlayer));
switch (p.getCombatStyle()) {
case 0: //CONTROLLED
for (int x = 0; x < 3; x++) {
p.incExp(x, totalXP, true);
}
break;
case 1: //AGGRESSIVE
p.incExp(Skills.STRENGTH, totalXP * 3, true);
break;
case 2: //ACCURATE
p.incExp(Skills.ATTACK, totalXP * 3, true);
break;
case 3: //DEFENSIVE
p.incExp(Skills.DEFENSE, totalXP * 3, true);
break;
}
p.incExp(Skills.HITS, totalXP, true);
}
// Ranged damagers
for (int playerID : getRangeDamagers()) {
int newXP = 0;
Player p = World.getWorld().getPlayerID(playerID);
int dmgDoneByPlayer = getRangeDamageDoneBy(p);
if (p == null)
continue;
if (dmgDoneByPlayer > currentHighestDamage) {
playerWithMostDamage = p;
currentHighestDamage = dmgDoneByPlayer;
}
newXP = (int) (((double) (totalCombatXP) / (double) (this.getDef().hits)) * (double) (dmgDoneByPlayer));
p.incExp(Skills.RANGED, newXP * 4, true);
ActionSender.sendStat(p, Skills.RANGED);
}
// Magic damagers
for (int playerID : getMageDamagers()) {
Player p = World.getWorld().getPlayerID(playerID);
*/
int dmgDoneByPlayer = getMageDamageDoneBy(p);
if (p == null)
continue;
if (dmgDoneByPlayer > currentHighestDamage) {
playerWithMostDamage = p;
currentHighestDamage = dmgDoneByPlayer;
}
}
return npcWithMostDamage;
return playerWithMostDamage;
}
private Npc handleLootAndXpDistribution(Npc attacker) {
......
......@@ -1425,6 +1425,8 @@ public final class Player extends Mob {
ActionSender.sendMessage(this, "You can not gain experience right now!");
return;
}
} else if (isExperienceFrozen()) {
return;
}
if (Server.getServer().getConfig().WANT_FATIGUE) {
......@@ -2729,7 +2731,7 @@ public final class Player extends Mob {
return setCacheInvulnerable(!cacheIsInvulnerable());
}
private boolean isExperienceFrozen() {
public boolean isExperienceFrozen() {
if (!getCache().hasKey("freezexp"))
return false;
......
......@@ -898,6 +898,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
*/
......@@ -1477,6 +1484,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),
......
......@@ -37,6 +37,11 @@ public final class SleepHandler implements PacketHandler {
// Advance the fatigue expert part of tutorial island
if(player.getCache().hasKey("tutorial") && player.getCache().getInt("tutorial") == 85)
player.getCache().set("tutorial", 86);
//Handle exp toggle for servers without fatigue
if (!player.getWorld().getServer().getConfig().WANT_FATIGUE) {
handleExpToggle(player);
}
} else {
ActionSender.sendIncorrectSleepword(player);
player.incrementSleepTries();
......@@ -56,4 +61,13 @@ public final class SleepHandler implements PacketHandler {
}
}
}
private void handleExpToggle(Player player) {
player.toggleFreezeXp();
ActionSender.sendExperienceToggle(player, player.isExperienceFrozen());
if (player.isExperienceFrozen())
player.message("You have @red@DISABLED@whi@ experience gain!");
else
player.message("You have @gre@ENABLED@whi@ experience gain!");
}
}
......@@ -1245,7 +1245,14 @@ public class Functions {
* @return
*/
public static boolean hasItem(final Player p, final int id, final int amt) {
return p.getInventory().countId(id) >= amt;
int amount = p.getInventory().countId(id);
int equipslot = -1;
if (p.getWorld().getServer().getConfig().WANT_EQUIPMENT_TAB) {
if ((equipslot = p.getEquipment().hasEquipped(id))!=-1) {
amount += p.getEquipment().get(equipslot).getAmount();
}
}
return amount >= amt;
}
/**
......
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