mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Players can no longer walk where there is no map data
Fixed an issue that prevented teleblock from being used in PvP Removed redundant code that prevented PvP looting in some instances Improved strictness of grave generation rules in regards to PvP Added nothing drop to the RDT (50% chance) Implemented ring of wealth effect on rare drops (removes nothing drop) Improved handling of nothing drops, preventing dwarf remains being awarded instead of nothing in some instances Added impling IDs to the ImplingNPC definition so all implings behave like implings Crystal shield and crystal bow now degrade Made cyclops room kickout on disconnect more reliable Fixed MTA Enchantment Zone items not adhering to the zone's rules
This commit is contained in:
parent
a100affda2
commit
b2f90d3dcc
31 changed files with 212 additions and 1048 deletions
|
|
@ -26,4 +26,5 @@
|
|||
<item id="1247" minAmt="1" maxAmt="1" weight="1"/>
|
||||
<item id="2366" minAmt="1" maxAmt="1" weight="1"/>
|
||||
<item id="1249" minAmt="1" maxAmt="1" weight="1"/>
|
||||
<item id="0" minAmt="1" maxAmt="1" weight="171"/>
|
||||
</RDT>
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
package content.data.tables;
|
||||
|
||||
import core.api.StartupListener;
|
||||
import core.ServerConstants;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.item.WeightedChanceItem;
|
||||
import core.tools.SystemLogger;
|
||||
import core.tools.RandomFunction;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static core.tools.SystemLogger.logInfo;
|
||||
|
||||
/**
|
||||
* Handles the rare drop table.
|
||||
* @author Ceikry
|
||||
*/
|
||||
public final class RareDropTable implements StartupListener {
|
||||
|
||||
/**
|
||||
* The item id of the item representing the rare drop table slot in a drop
|
||||
* table.
|
||||
*/
|
||||
public static final int SLOT_ITEM_ID = 31;
|
||||
|
||||
/**
|
||||
* The rare drop table.
|
||||
*/
|
||||
private static final List<WeightedChanceItem> TABLE = new ArrayList<>(20);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize needed objects for xml reading/writing
|
||||
*/
|
||||
static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
static DocumentBuilder builder;
|
||||
|
||||
static {
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public RareDropTable() throws ParserConfigurationException {}
|
||||
|
||||
@Override
|
||||
public void startup() {
|
||||
if(ServerConstants.RDT_DATA_PATH != null && !new File(ServerConstants.RDT_DATA_PATH).exists()){
|
||||
SystemLogger.logErr(this.getClass(), "Can't locate RDT file at " + ServerConstants.RDT_DATA_PATH);
|
||||
return;
|
||||
}
|
||||
parse(ServerConstants.RDT_DATA_PATH);
|
||||
logInfo(this.getClass(), "Initialized Rare Drop Table from " + ServerConstants.RDT_DATA_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml file for the RDT.
|
||||
* @param file the .xml file containing the RDT.
|
||||
*/
|
||||
public static void parse(String file){
|
||||
try {
|
||||
Document doc = builder.parse(file);
|
||||
|
||||
NodeList itemNodes = doc.getElementsByTagName("item");
|
||||
for(int i = 0; i < itemNodes.getLength(); i++){
|
||||
Node itemNode = itemNodes.item(i);
|
||||
if(itemNode.getNodeType() == Node.ELEMENT_NODE){
|
||||
Element item = (Element) itemNode;
|
||||
int itemId = Integer.parseInt(item.getAttribute("id"));
|
||||
int minAmt = Integer.parseInt(item.getAttribute("minAmt"));
|
||||
int maxAmt = Integer.parseInt(item.getAttribute("maxAmt"));
|
||||
int weight = Integer.parseInt(item.getAttribute("weight"));
|
||||
|
||||
TABLE.add(new WeightedChanceItem(itemId,minAmt,maxAmt,weight));
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Item retrieve(){
|
||||
return RandomFunction.rollWeightedChanceTable(TABLE);
|
||||
}
|
||||
}
|
||||
114
Server/src/main/content/data/tables/RareDropTable.kt
Normal file
114
Server/src/main/content/data/tables/RareDropTable.kt
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
package content.data.tables
|
||||
|
||||
import core.ServerConstants
|
||||
import core.api.StartupListener
|
||||
import core.api.shouldRemoveNothings
|
||||
import core.api.utils.WeightBasedTable
|
||||
import core.api.utils.WeightedItem
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.tools.RandomFunction
|
||||
import core.tools.SystemLogger.logErr
|
||||
import core.tools.SystemLogger.logInfo
|
||||
import org.rs09.consts.Items
|
||||
import org.w3c.dom.Element
|
||||
import org.w3c.dom.Node
|
||||
import java.io.File
|
||||
import javax.xml.parsers.DocumentBuilder
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import javax.xml.parsers.ParserConfigurationException
|
||||
|
||||
/**
|
||||
* Handles the rare drop table.
|
||||
* @author Ceikry
|
||||
*/
|
||||
class RareDropTable : StartupListener {
|
||||
override fun startup() {
|
||||
if (ServerConstants.RDT_DATA_PATH != null && !File(ServerConstants.RDT_DATA_PATH).exists()) {
|
||||
logErr(this.javaClass, "Can't locate RDT file at " + ServerConstants.RDT_DATA_PATH)
|
||||
return
|
||||
}
|
||||
parse(ServerConstants.RDT_DATA_PATH)
|
||||
logInfo(this.javaClass, "Initialized Rare Drop Table from " + ServerConstants.RDT_DATA_PATH)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TABLE: WeightBasedTable = object : WeightBasedTable() {
|
||||
override fun roll(receiver: Entity?): ArrayList<Item> {
|
||||
val items = ArrayList(guaranteedItems)
|
||||
var effectiveWeight = totalWeight
|
||||
val p = if (receiver is Player) receiver else null
|
||||
if (p != null && shouldRemoveNothings(p))
|
||||
effectiveWeight -= nothingWeight
|
||||
|
||||
if (this.size == 1) {
|
||||
items.add(get(0))
|
||||
} else if (!this.isEmpty()) {
|
||||
var rngWeight = RandomFunction.randomDouble(effectiveWeight)
|
||||
for (item in this.shuffled()) {
|
||||
if (item.id == Items.DWARF_REMAINS_0) continue
|
||||
rngWeight -= item.weight
|
||||
if (rngWeight <= 0) {
|
||||
items.add(item)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return convertWeightedItems(items, receiver)
|
||||
}
|
||||
|
||||
private val nothingWeight: Double
|
||||
get() {
|
||||
var sum = 0.0
|
||||
for (i in this) {
|
||||
if (i.id == Items.DWARF_REMAINS_0)
|
||||
sum += i.weight
|
||||
}
|
||||
return sum
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize needed objects for xml reading/writing
|
||||
*/
|
||||
var factory = DocumentBuilderFactory.newInstance()
|
||||
var builder: DocumentBuilder? = null
|
||||
|
||||
init {
|
||||
try {
|
||||
builder = factory.newDocumentBuilder()
|
||||
} catch (e: ParserConfigurationException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml file for the RDT.
|
||||
* @param file the .xml file containing the RDT.
|
||||
*/
|
||||
fun parse(file: String?) {
|
||||
try {
|
||||
val doc = builder!!.parse(file)
|
||||
val itemNodes = doc.getElementsByTagName("item")
|
||||
for (i in 0 until itemNodes.length) {
|
||||
val itemNode = itemNodes.item(i)
|
||||
if (itemNode.nodeType == Node.ELEMENT_NODE) {
|
||||
val item = itemNode as Element
|
||||
val itemId = item.getAttribute("id").toInt()
|
||||
val minAmt = item.getAttribute("minAmt").toInt()
|
||||
val maxAmt = item.getAttribute("maxAmt").toInt()
|
||||
val weight = item.getAttribute("weight").toInt()
|
||||
TABLE.add(WeightedItem(itemId, minAmt, maxAmt, weight.toDouble(), false))
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun retrieve(receiver: Entity?): Item? {
|
||||
return TABLE.roll(receiver).getOrNull(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -128,19 +128,19 @@ public enum ClueLevel {
|
|||
for (; itemCount > 0; itemCount--) {
|
||||
switch (level) {
|
||||
case EASY:
|
||||
loot.addAll(ClueRewardParser.getEasyTable().roll());
|
||||
loot.addAll(ClueRewardParser.getEasyTable().roll(player));
|
||||
break;
|
||||
case MEDIUM:
|
||||
loot.addAll(ClueRewardParser.getMedTable().roll());
|
||||
loot.addAll(ClueRewardParser.getMedTable().roll(player));
|
||||
break;
|
||||
case HARD:
|
||||
loot.addAll(ClueRewardParser.getHardTable().roll());
|
||||
loot.addAll(ClueRewardParser.getHardTable().roll(player));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (level == ClueLevel.HARD && RandomFunction.random(100) == 50) {
|
||||
loot.addAll(ClueRewardParser.getRareTable().roll());
|
||||
loot.addAll(ClueRewardParser.getRareTable().roll(player));
|
||||
}
|
||||
|
||||
return loot;
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
package content.global.handlers.iface;
|
||||
|
||||
import core.game.component.Component;
|
||||
import core.game.component.ComponentDefinition;
|
||||
import core.game.component.ComponentPlugin;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
import core.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* Package -> core.game.interaction.inter
|
||||
* Created on -> 9/6/2016 @8:12 PM for 530
|
||||
*
|
||||
* @author Ethan Kyle Millard
|
||||
*/
|
||||
@Initializable
|
||||
public class PlayerExamineInterfacePlugin extends ComponentPlugin {
|
||||
|
||||
private Player node;
|
||||
|
||||
public PlayerExamineInterfacePlugin() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
ComponentDefinition.put(31, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
|
||||
switch (button) {
|
||||
case 2:
|
||||
component.close(player);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void prepareInterface(Player player, Player examined) {
|
||||
Component component = new Component(31);
|
||||
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 7, true);
|
||||
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 8, true);
|
||||
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 15, true);
|
||||
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 18, true);
|
||||
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 2, true);
|
||||
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 14, true);
|
||||
player.getPacketDispatch().sendInterfaceConfig(component.getId(), 13, true);
|
||||
player.getInterfaceManager().open(component);
|
||||
player.getPacketDispatch().sendString("<col=" + examined.getSavedData().getSpawnData().getTitle().getTitleColor() + ">" + examined.getSavedData().getSpawnData().getTitle().getName() + "</col> " + StringUtils.formatDisplayName(examined.getName()) + " - Combat Level: " + player.getProperties().getCurrentCombatLevel(), 31, 3);
|
||||
player.getPacketDispatch().sendString("Total Level -> ", 31, 9);
|
||||
player.getPacketDispatch().sendString("Inventory items -> ", 31, 10);
|
||||
player.getPacketDispatch().sendString("Inventory value -> ", 31, 16);
|
||||
player.getPacketDispatch().sendString("Custom state-> ", 31, 19);
|
||||
player.getPacketDispatch().sendString("" + examined.getSkills().getTotalLevel(), 31, 11);
|
||||
player.getPacketDispatch().sendString("" + examined.getInventory().itemCount(), 31, 12);
|
||||
player.getPacketDispatch().sendString("" + examined.getInventory().getWealth(), 31, 17);
|
||||
player.getPacketDispatch().sendString("" + examined.getCustomState(), 31, 20);
|
||||
player.getPacketDispatch().sendString("Close", 31, 5);
|
||||
|
||||
for (int i = 0; i < 11; i++) {
|
||||
Item item = examined.getEquipment().get(i);
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
System.out.println(item.getName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ public final class CasketPlugin extends OptionHandler {
|
|||
|
||||
@Override
|
||||
public boolean handle(Player player, Node node, String option) {
|
||||
final Item reward = table.roll().get(0);
|
||||
final Item reward = table.roll(player).get(0);
|
||||
player.getInventory().remove((Item) node);
|
||||
player.getDialogueInterpreter().sendItemMessage(reward, "You open the casket. Inside you find " + (reward.getAmount() > 1 ? "some" : (StringUtils.isPlusN(reward.getName()) ? "an" : "a")) + " " + reward.getName().toLowerCase() + ".");
|
||||
addItemOrDrop(player, reward.getId(), reward.getAmount());
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class ImplingJarListener : InteractionListener {
|
|||
on(JARS, IntType.ITEM, "loot"){ player, node ->
|
||||
val jar = node.asItem()
|
||||
|
||||
val loot = ImplingLoot.forId(jar.id)?.roll()?.first() ?: return@on false
|
||||
val loot = ImplingLoot.forId(jar.id)?.roll()?.firstOrNull() ?: return@on false
|
||||
|
||||
if(removeItem(player, jar, Container.INVENTORY)) {
|
||||
addItemOrDrop(player, loot.id, loot.amount)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package content.global.handlers.item.equipment
|
||||
|
||||
import core.api.StartupListener
|
||||
import org.rs09.consts.Items
|
||||
|
||||
class CrystalEquipmentRegister : StartupListener {
|
||||
val shield: Array<Int> = arrayOf(Items.NEW_CRYSTAL_SHIELD_4224, Items.CRYSTAL_SHIELD_FULL_4225, Items.CRYSTAL_SHIELD_9_10_4226, Items.CRYSTAL_SHIELD_8_10_4227, Items.CRYSTAL_SHIELD_7_10_4228, Items.CRYSTAL_SHIELD_6_10_4229, Items.CRYSTAL_SHIELD_5_10_4230, Items.CRYSTAL_SHIELD_4_10_4231, Items.CRYSTAL_SHIELD_3_10_4232, Items.CRYSTAL_SHIELD_2_10_4233, Items.CRYSTAL_SHIELD_1_10_4234, Items.CRYSTAL_SEED_4207)
|
||||
val bow: Array<Int> = arrayOf(Items.NEW_CRYSTAL_BOW_4212, Items.CRYSTAL_BOW_FULL_4214, Items.CRYSTAL_BOW_9_10_4215, Items.CRYSTAL_BOW_8_10_4216, Items.CRYSTAL_BOW_7_10_4217, Items.CRYSTAL_BOW_6_10_4218, Items.CRYSTAL_BOW_5_10_4219, Items.CRYSTAL_BOW_4_10_4220, Items.CRYSTAL_BOW_3_10_4221, Items.CRYSTAL_BOW_2_10_4222, Items.CRYSTAL_BOW_1_10_4223, Items.CRYSTAL_SEED_4207)
|
||||
override fun startup() {
|
||||
EquipmentDegrader.registerSet(250, shield)
|
||||
EquipmentDegrader.registerSet(250, bow)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package content.global.handlers.item.equipment
|
||||
|
||||
import core.api.addItemOrDrop
|
||||
import core.api.getNext
|
||||
import core.api.isLast
|
||||
import core.api.isNextLast
|
||||
|
|
@ -51,6 +52,9 @@ class EquipmentDegrader{
|
|||
|
||||
fun Item.degrade(slot: Int){ //extension function that degrades items
|
||||
val set = getDegradableSet(this.id)
|
||||
val charges = itemCharges.getOrElse(this.id) {1000}
|
||||
if (this.charge > charges)
|
||||
charge = charges
|
||||
this.charge--
|
||||
if(set?.indexOf(this.id) == 0 && !this.name.contains("100")){
|
||||
charge = 0
|
||||
|
|
@ -60,8 +64,8 @@ class EquipmentDegrader{
|
|||
if (set?.size!! > 2) {
|
||||
p?.equipment?.remove(this)
|
||||
p?.sendMessage("Your $name has degraded.")
|
||||
if (set.isNextLast(set.indexOf(this.id))) {
|
||||
p?.inventory?.add(Item(set.getNext(this.id)))
|
||||
if (set.isNextLast(this.id)) {
|
||||
p?.let { addItemOrDrop(it, set.getNext(this.id)) }
|
||||
p?.sendMessage("Your $name has broken.")
|
||||
} else {
|
||||
p?.equipment?.add(Item(set.getNext(this.id), 1, charges), slot, false, false)
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
package content.global.handlers.player;
|
||||
|
||||
import core.game.interaction.Option;
|
||||
import core.game.interaction.OptionHandler;
|
||||
import core.game.node.Node;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
import content.global.handlers.iface.PlayerExamineInterfacePlugin;
|
||||
|
||||
/**
|
||||
* Package -> core.game.interaction.player
|
||||
* Created on -> 9/13/2016 @7:53 AM for 530
|
||||
*
|
||||
* @author Ethan Kyle Millard
|
||||
*/
|
||||
@Initializable
|
||||
public class ExamineOptionPlugin extends OptionHandler {
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
Option._P_EXAMINE.setHandler(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(Player player, Node node, String option) {
|
||||
PlayerExamineInterfacePlugin component = new PlayerExamineInterfacePlugin();
|
||||
component.prepareInterface(player, (Player) node);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ import core.game.system.task.Pulse;
|
|||
import core.game.world.map.Location;
|
||||
import core.game.world.map.path.Pathfinder;
|
||||
import core.game.world.update.flag.context.Graphics;
|
||||
import core.plugin.Initializable;
|
||||
import core.tools.RandomFunction;
|
||||
import core.game.system.config.NPCConfigParser;
|
||||
import core.game.world.GameWorld;
|
||||
|
|
@ -18,6 +19,7 @@ import core.game.world.GameWorld;
|
|||
* Handles an impling npc.
|
||||
* @author Vexia
|
||||
*/
|
||||
@Initializable
|
||||
public final class ImplingNPC extends AbstractNPC {
|
||||
|
||||
/**
|
||||
|
|
@ -104,7 +106,7 @@ public final class ImplingNPC extends AbstractNPC {
|
|||
|
||||
@Override
|
||||
public int[] getIds() {
|
||||
return new int[] {};
|
||||
return new int[] { 1028, 6055, 1029, 6056, 1030, 6057, 1031, 6058, 1032, 6059, 1033, 6060, 1034, 6061, 1035, 6062, 6053, 6063};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public final class TeleblockSpell extends CombatSpell {
|
|||
|
||||
@Override
|
||||
public void fireEffect(Entity entity, Entity victim, BattleState state) {
|
||||
if(!victim.isTeleBlocked() && victim instanceof Player && state.getStyle().getSwingHandler().isAccurateImpact(entity, victim) && state.getEstimatedHit() > 0){
|
||||
if(!victim.isTeleBlocked() && victim instanceof Player && state.getStyle().getSwingHandler().isAccurateImpact(entity, victim)){
|
||||
int ticks = 500;
|
||||
if(((Player) victim).getPrayer().get(PrayerType.PROTECT_FROM_MAGIC)){
|
||||
ticks /= 2;
|
||||
|
|
|
|||
|
|
@ -178,6 +178,9 @@ public class EnchantingZone extends MTAZone {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemainPrivate() {return true;}
|
||||
|
||||
@Override
|
||||
public void respawn() {
|
||||
GameWorld.getPulser().submit(getRespawnPulse(this));
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@ import core.game.world.map.zone.ZoneRestriction;
|
|||
import core.plugin.Plugin;
|
||||
import core.plugin.ClassScanner;
|
||||
import core.tools.RandomFunction;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
import static core.api.ContentAPIKt.clearLogoutListener;
|
||||
import static core.api.ContentAPIKt.registerLogoutListener;
|
||||
|
||||
/**
|
||||
* The cyclopes room.
|
||||
|
|
@ -103,6 +108,7 @@ public final class CyclopesRoom extends MapZone implements Plugin<Object> {
|
|||
if (logout) {
|
||||
e.setLocation(Location.create(2846, 3540, 2));
|
||||
}
|
||||
clearLogoutListener((Player) e, "cyclopes");
|
||||
}
|
||||
return super.leave(e, logout);
|
||||
}
|
||||
|
|
@ -199,6 +205,10 @@ public final class CyclopesRoom extends MapZone implements Plugin<Object> {
|
|||
PULSE.start();
|
||||
GameWorld.getPulser().submit(PULSE);
|
||||
}
|
||||
registerLogoutListener(player, "cyclopes", player1 -> {
|
||||
player1.setLocation(Location.create(2844, 3540, 2));
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -198,6 +198,16 @@ fun hasGodItem(player: Player, god: God): Boolean {
|
|||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given player should have the "remove nothing" RoW effect active.
|
||||
* @param player the player we are checking
|
||||
* @return whether we should ignore nothings
|
||||
*/
|
||||
fun shouldRemoveNothings(player: Player) : Boolean {
|
||||
val ring = getItemFromEquipment(player, EquipmentSlot.RING)
|
||||
return ring != null && ring.id in Items.RING_OF_WEALTH_14638..Items.RING_OF_WEALTH4_14646
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from a player's inventory
|
||||
* @param player the player whose inventory to remove the item from
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package core.api.utils
|
||||
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.item.Item
|
||||
|
||||
class NPCDropTable : WeightBasedTable() {
|
||||
|
|
@ -9,12 +10,12 @@ class NPCDropTable : WeightBasedTable() {
|
|||
return charmDrops.add(element)
|
||||
}
|
||||
|
||||
override fun roll(): ArrayList<Item> {
|
||||
override fun roll(receiver: Entity?): ArrayList<Item> {
|
||||
val items = ArrayList<Item>()
|
||||
// Charms table is always rolled, and should contain explicit "Nothing"
|
||||
// entries at the data level to account for the chance to not drop a charm.
|
||||
items.addAll(charmDrops.roll())
|
||||
items.addAll(super.roll())
|
||||
items.addAll(super.roll(receiver))
|
||||
return items
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,14 +10,15 @@ import content.data.tables.HerbDropTable
|
|||
import content.data.tables.GemDropTable
|
||||
import content.data.tables.RareSeedDropTable
|
||||
import content.data.tables.AllotmentSeedDropTable
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.Items
|
||||
|
||||
open class WeightBasedTable : ArrayList<WeightedItem>() {
|
||||
private var totalWeight = 0.0
|
||||
private val guaranteedItems = ArrayList<WeightedItem>()
|
||||
var totalWeight = 0.0
|
||||
val guaranteedItems = ArrayList<WeightedItem>()
|
||||
|
||||
override fun add(element: WeightedItem): Boolean {
|
||||
return if (element.guaranteed) {
|
||||
|
|
@ -28,7 +29,7 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
|
|||
}
|
||||
}
|
||||
|
||||
open fun roll(): ArrayList<Item>{
|
||||
open fun roll(receiver: Entity? = null): ArrayList<Item>{
|
||||
val items = ArrayList<WeightedItem>()
|
||||
items.addAll(guaranteedItems)
|
||||
|
||||
|
|
@ -46,26 +47,27 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
|
|||
}
|
||||
}
|
||||
|
||||
return convertWeightedItems(items)
|
||||
return convertWeightedItems(items, receiver)
|
||||
}
|
||||
|
||||
private fun convertWeightedItems(weightedItems: ArrayList<WeightedItem>): ArrayList<Item> {
|
||||
val safeItems = ArrayList<Item>(weightedItems.size)
|
||||
weightedItems.forEach { e ->
|
||||
fun convertWeightedItems(weightedItems: ArrayList<WeightedItem>, receiver: Entity?): ArrayList<Item> {
|
||||
val safeItems = ArrayList<Item>()
|
||||
for (e in weightedItems) {
|
||||
val safeItem = when (e.id) {
|
||||
SLOT_CLUE_EASY -> ClueScrollPlugin.getClue(ClueLevel.EASY)
|
||||
SLOT_CLUE_MEDIUM -> ClueScrollPlugin.getClue(ClueLevel.MEDIUM)
|
||||
SLOT_CLUE_HARD -> ClueScrollPlugin.getClue(ClueLevel.HARD)
|
||||
SLOT_RDT -> RareDropTable.retrieve()
|
||||
SLOT_RDT -> RareDropTable.retrieve(receiver)
|
||||
SLOT_CELEDT -> CELEMinorTable.retrieve()
|
||||
SLOT_USDT -> UncommonSeedDropTable.retrieve()
|
||||
SLOT_HDT -> HerbDropTable.retrieve()
|
||||
SLOT_GDT -> GemDropTable.retrieve()
|
||||
SLOT_RSDT -> RareSeedDropTable.retrieve()
|
||||
SLOT_ASDT -> AllotmentSeedDropTable.retrieve()
|
||||
Items.DWARF_REMAINS_0 -> continue
|
||||
else -> e.getItem()
|
||||
}
|
||||
safeItems.add(safeItem)
|
||||
safeItems.add(safeItem ?: continue)
|
||||
}
|
||||
return safeItems
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package core.auth
|
|||
import core.game.node.entity.player.Player
|
||||
import core.game.system.SystemManager
|
||||
import core.ServerConstants
|
||||
import core.game.world.repository.Repository
|
||||
import core.storage.AccountStorageProvider
|
||||
import core.storage.SQLStorageProvider
|
||||
import java.sql.SQLDataException
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import core.game.interaction.InteractionListener
|
|||
import core.game.interaction.IntType
|
||||
import core.game.system.command.Privilege
|
||||
import core.game.world.GameWorld
|
||||
import core.game.world.map.zone.impl.WildernessZone
|
||||
import core.game.world.repository.Repository
|
||||
import core.tools.secondsToTicks
|
||||
import core.tools.colorize
|
||||
|
|
@ -219,6 +220,8 @@ class GraveController : PersistWorld, TickListener, InteractionListener, Command
|
|||
return false
|
||||
if (player.skullManager.isWilderness)
|
||||
return false
|
||||
if (WildernessZone.isInZone(player))
|
||||
return false
|
||||
if (player.ironmanManager.mode == IronmanMode.HARDCORE)
|
||||
return false
|
||||
if (player.zoneMonitor.isRestricted(ZoneRestriction.GRAVES))
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public final class NPCDropTables {
|
|||
*/
|
||||
public void drop(NPC npc, Entity looter) {
|
||||
Player p = looter instanceof Player ? (Player) looter : null;
|
||||
table.roll().forEach(item -> createDrop(item,p,npc,npc.getDropLocation()));
|
||||
table.roll(looter).forEach(item -> createDrop(item,p,npc,npc.getDropLocation()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -91,30 +91,6 @@ public final class NPCDropTables {
|
|||
if (handleBoneCrusher(player, item)) {
|
||||
return;
|
||||
}
|
||||
if (item.getId() == RareDropTable.SLOT_ITEM_ID){
|
||||
item = RareDropTable.retrieve();
|
||||
}
|
||||
if (item.getId() == UncommonSeedDropTable.SLOT_ITEM_ID){
|
||||
item = UncommonSeedDropTable.retrieve();
|
||||
}
|
||||
if (item.getId() == HerbDropTable.SLOT_ITEM_ID){
|
||||
item = HerbDropTable.retrieve();
|
||||
}
|
||||
if (item.getId() == GemDropTable.SLOT_ITEM_ID){
|
||||
item = GemDropTable.retrieve();
|
||||
}
|
||||
if (item.getId() == RareSeedDropTable.SLOT_ITEM_ID){
|
||||
item = RareSeedDropTable.retrieve();
|
||||
}
|
||||
if (item.getId() == AllotmentSeedDropTable.SLOT_ITEM_ID){
|
||||
item = AllotmentSeedDropTable.retrieve();
|
||||
}
|
||||
if (item.getId() == 995 && player.getBank().hasSpaceFor(item) && ( player.getGlobalData().isEnableCoinMachine() )) {
|
||||
item = new Item(995, (int) (item.getAmount() + (item.getAmount() * 0.25)));
|
||||
player.getBank().add(item);
|
||||
player.sendMessage("<col=3498db> " + item.getAmount() + " coins were sent to your bank.");
|
||||
return;
|
||||
}
|
||||
if (item.hasItemPlugin() && player != null) {
|
||||
if (!item.getPlugin().createDrop(item, player, npc, l)) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -665,12 +665,6 @@ public class Player extends Entity {
|
|||
getPrayer().reset();
|
||||
super.finalizeDeath(killer);
|
||||
appearance.sync();
|
||||
if (killer instanceof Player && !GameWorld.isEconomyWorld() && getSkullManager().isWilderness() && killer.asPlayer().getSkullManager().isWilderness()) {
|
||||
killer.asPlayer().getSavedData().getSpawnData().onDeath(killer.asPlayer(), this);
|
||||
}
|
||||
if (GameWorld.isEconomyWorld() && !getSavedData().getGlobalData().isDeathScreenDisabled()) {
|
||||
getInterfaceManager().open(new Component(153));
|
||||
}
|
||||
if (!getSavedData().getGlobalData().isDeathScreenDisabled()) {
|
||||
getInterfaceManager().open(new Component(153));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,9 +31,6 @@ class LoginParser(val details: PlayerDetails) {
|
|||
{
|
||||
e.printStackTrace()
|
||||
Repository.removePlayer(player)
|
||||
Repository.LOGGED_IN_PLAYERS.remove(player.username)
|
||||
Repository.lobbyPlayers.remove(player)
|
||||
Repository.playerNames.remove(player.name)
|
||||
flag(AuthResponse.ErrorLoadingProfile)
|
||||
}
|
||||
GameWorld.Pulser.submit(object : Pulse(1) {
|
||||
|
|
@ -50,14 +47,11 @@ class LoginParser(val details: PlayerDetails) {
|
|||
player.init()
|
||||
}
|
||||
} else {
|
||||
Repository.playerNames.remove(player.name)
|
||||
Repository.removePlayer(player)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
Repository.removePlayer(player)
|
||||
Repository.LOGGED_IN_PLAYERS.remove(player.username)
|
||||
Repository.lobbyPlayers.remove(player)
|
||||
Repository.playerNames.remove(player.name)
|
||||
flag(AuthResponse.ErrorLoadingProfile)
|
||||
}
|
||||
return true
|
||||
|
|
@ -78,9 +72,6 @@ class LoginParser(val details: PlayerDetails) {
|
|||
player.updateSceneGraph(true)
|
||||
player.configManager.init()
|
||||
LoginConfiguration.configureGameWorld(player)
|
||||
if (!Repository.players.contains(player)) {
|
||||
Repository.addPlayer(player)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ package core.game.node.entity.player.link;
|
|||
|
||||
import core.game.node.entity.player.Player;
|
||||
|
||||
import core.game.node.entity.player.link.spawn.SpawnData;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
|
|
@ -28,11 +26,6 @@ public class SavedData {
|
|||
*/
|
||||
private final QuestData questData = new QuestData();
|
||||
|
||||
/**
|
||||
* The spawn data to save.
|
||||
*/
|
||||
private final SpawnData spawnData = new SpawnData();
|
||||
|
||||
/**
|
||||
* The player.
|
||||
*/
|
||||
|
|
@ -134,13 +127,4 @@ public class SavedData {
|
|||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the spawnData.
|
||||
* @return the spawnData
|
||||
*/
|
||||
public SpawnData getSpawnData() {
|
||||
return spawnData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,120 +0,0 @@
|
|||
package core.game.node.entity.player.link.spawn;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.world.repository.Repository;
|
||||
import core.tools.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A PK title received from a certain amount of kills.
|
||||
* @author Vexia
|
||||
*
|
||||
*/
|
||||
public enum PKTitle {
|
||||
NOOB(0),
|
||||
PEASANT(5),
|
||||
SKIRMISHER(20),
|
||||
KNIGHT(50),
|
||||
WARRIOR(80),
|
||||
BOUNTY_HUNTER(100),
|
||||
HERO(150),
|
||||
SKULLCRACKER(250),
|
||||
DESTROYER(400),
|
||||
DOMINATOR(600),
|
||||
REAPER(800, "DF7401"),
|
||||
ASSASSIN(1000, "21610B"),
|
||||
MASTER(1500, "0431B4"),
|
||||
GODLY(2000, "FF0000");
|
||||
|
||||
/**
|
||||
* The kills needed for the title.
|
||||
*/
|
||||
private final int kills;
|
||||
|
||||
/**
|
||||
* The color for this title.
|
||||
*/
|
||||
private final String titleColor;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code PKTitle} {@Code Object}
|
||||
* @param kills the points.
|
||||
* @param titleColor the title color.
|
||||
*/
|
||||
private PKTitle(int kills, String titleColor) {
|
||||
this.kills = kills;
|
||||
this.titleColor = titleColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code PKTitle} {@Code Object}
|
||||
* @param points the points.
|
||||
*/
|
||||
private PKTitle(int points) {
|
||||
this(points, "874b93");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the title for a player.
|
||||
*/
|
||||
public static void checkTitle(Player player) {
|
||||
PKTitle title = null;
|
||||
int kills = player.getSavedData().getSpawnData().getKills();
|
||||
for (PKTitle t : values()) {
|
||||
if (kills >= t.getKills()) {
|
||||
title = t;
|
||||
}
|
||||
}
|
||||
if (title.ordinal() > player.getSavedData().getSpawnData().getTitle().ordinal() && player.getSavedData().getSpawnData().getKills() <= title.getKills()) {
|
||||
player.getSavedData().getSpawnData().setTitle(title);
|
||||
if (!title.getTitleColor().equals("874b93")) {
|
||||
Repository.sendNews("<img=10><col=CC6600>News: " + player.getUsername() + " has just unlocked the title: " + title.getName() + "!");
|
||||
}
|
||||
player.getAppearance().sync();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the titles.
|
||||
* @param player the player.
|
||||
* @return the titles.
|
||||
*/
|
||||
public static PKTitle[] getTitles(Player player) {
|
||||
int kills = player.getSavedData().getSpawnData().getKills();
|
||||
List<PKTitle> titles = new ArrayList<>(20);
|
||||
for (PKTitle t : values()) {
|
||||
if (kills >= t.getKills()) {
|
||||
titles.add(t);
|
||||
}
|
||||
}
|
||||
return titles.toArray(new PKTitle[] {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the title.
|
||||
* @return the name.
|
||||
*/
|
||||
public String getName() {
|
||||
return StringUtils.formatDisplayName(name().toLowerCase().replace("_", ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the points.
|
||||
* @return the points
|
||||
*/
|
||||
public int getKills() {
|
||||
return kills;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the titleColor.
|
||||
* @return the titleColor
|
||||
*/
|
||||
public String getTitleColor() {
|
||||
return titleColor;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,639 +0,0 @@
|
|||
package core.game.node.entity.player.link.spawn;
|
||||
|
||||
import core.game.component.Component;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.player.Player;
|
||||
|
||||
import core.game.node.entity.player.link.SpellBookManager;
|
||||
import core.game.world.GameWorld;
|
||||
import core.game.world.repository.Repository;
|
||||
import core.net.packet.PacketRepository;
|
||||
import core.net.packet.context.ChildPositionContext;
|
||||
import core.net.packet.out.RepositionChild;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* Handles the spawn data for the spawn world.
|
||||
* @author Vexia
|
||||
*
|
||||
*/
|
||||
public class SpawnData {
|
||||
|
||||
/**
|
||||
* The kill streak messages.
|
||||
*/
|
||||
private static final String[] KILLSTREAKS = new String[] {"rampage", "massacre", "frenzy", "annihilation", "decimation", "butchery", "extermination", "genocide", "carnage", "slaughter", "bloodshed", "assassination", "obliteration"};
|
||||
|
||||
/**
|
||||
* The current title.
|
||||
*/
|
||||
private PKTitle title = PKTitle.NOOB;
|
||||
|
||||
/**
|
||||
* The tutorial stage for the spawn server.
|
||||
*/
|
||||
private int tutorialStage;
|
||||
|
||||
/**
|
||||
* The pk points.
|
||||
*/
|
||||
private int pkPoints;
|
||||
|
||||
/**
|
||||
* The amount of kills.
|
||||
*/
|
||||
private int kills;
|
||||
|
||||
/**
|
||||
* The ammount of deaths.
|
||||
*/
|
||||
private int deaths;
|
||||
|
||||
/**
|
||||
* The skill streak.
|
||||
*/
|
||||
private int killStreak;
|
||||
|
||||
private int purchased;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code SpawnData} {@Code Object}
|
||||
*/
|
||||
public SpawnData() {
|
||||
/**
|
||||
* empty.
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the stats tab.
|
||||
* @param player the player.
|
||||
*/
|
||||
public void drawStatsTab(Player player) {
|
||||
if (GameWorld.isEconomyWorld()) {
|
||||
return;
|
||||
}
|
||||
player.getPacketDispatch().sendInterfaceConfig(274, 3, true);
|
||||
player.getPacketDispatch().sendInterfaceConfig(274, 8, true);
|
||||
sendString(player, "Players online: " + Repository.getPlayers().size(), 5);
|
||||
sendString(player, "Starter Packages Below...", 23);
|
||||
sendString(player, "Information:", 12, null, -1);
|
||||
sendString(player, "PK Points: " + player.getSavedData().getSpawnData().getPkPoints(), 13);
|
||||
sendString(player, "Kills: " + getKills(), 14);
|
||||
sendString(player, "Deaths: " + getDeaths(), 15);
|
||||
sendString(player, "KDR: " + getKdr(), 16);
|
||||
sendString(player, "Title: " + "<col=" + getTitle().getTitleColor() + ">" + getTitle().getName(), 17);
|
||||
sendString(player, " ", 20);
|
||||
sendString(player, "Starter Packages:", 31);
|
||||
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 274, 60, 10, 298));/*
|
||||
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 274, 33, 10, 300));
|
||||
PacketRepository.send(RepositionChild.class, new ChildPositionContext(player, 274, 34, 11, 314));*/
|
||||
//Sets & consumables
|
||||
|
||||
sendString(player, PKPackage.values()[0].getName(), 156);
|
||||
sendString(player, PKPackage.values()[1].getName(), 32);
|
||||
sendString(player, PKPackage.values()[2].getName(), 137);
|
||||
sendString(player, PKPackage.values()[3].getName(), 146);
|
||||
sendString(player, PKPackage.values()[4].getName(), 142);
|
||||
// sendString(player, PKPackage.values()[5].getName(), 33);
|
||||
/*sendString(player, PKPackage.values()[6].getName(), 34);
|
||||
sendString(player, PKPackage.values()[7].getName(), 35);
|
||||
sendString(player, PKPackage.values()[8].getName(), 36);
|
||||
sendString(player, PKPackage.values()[9].getName(), 147);
|
||||
sendString(player, PKPackage.values()[10].getName(), 37);
|
||||
sendString(player, PKPackage.values()[11].getName(), 131);
|
||||
sendString(player, PKPackage.values()[12].getName(), 38);*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the string.
|
||||
* @param player the player.
|
||||
* @param string the string.
|
||||
* @param child the child.
|
||||
* @param color the color.
|
||||
*/
|
||||
private void sendString(Player player, String string, int child, String color, int purchased) {
|
||||
player.getPacketDispatch().sendInterfaceConfig(274, child, false);
|
||||
player.getPacketDispatch().sendString((color != null && purchased == -1 ? color : "") + string, 274, child);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the string.
|
||||
* @param player the player.
|
||||
* @param string the string.
|
||||
* @param child the child.
|
||||
*/
|
||||
private void sendString(Player player, String string, int child, int purchased) {
|
||||
sendString(player, string, child, "<col=FE9A2E>", purchased);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the string.
|
||||
* @param player the player.
|
||||
* @param string the string.
|
||||
* @param child the child.
|
||||
*/
|
||||
private void sendString(Player player, String string, int child) {
|
||||
sendString(player, string, child, "<col=FE9A2E>", -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shouts spawn info of the player.
|
||||
* @param p the player.
|
||||
* @param button the button.
|
||||
*/
|
||||
public void handleButton(Player p, int button) {
|
||||
if (GameWorld.isEconomyWorld()) {
|
||||
return;
|
||||
}
|
||||
drawStatsTab(p);
|
||||
switch(button) {
|
||||
case -1:
|
||||
break;
|
||||
case 16:
|
||||
p.sendChat("<col=FF0000>My KDR is: " + p.getSavedData().getSpawnData().getKdr() + "!");
|
||||
break;
|
||||
case 14:
|
||||
p.sendChat("<col=FF0000>I have killed " + p.getSavedData().getSpawnData().getKills() + " player" + (p.getSavedData().getSpawnData().getKills() != 1 ? "s" : "") + "!");
|
||||
break;
|
||||
case 15:
|
||||
p.sendChat("<col=FF0000>I have been killed " + p.getSavedData().getSpawnData().getDeaths() + " time" + (p.getSavedData().getSpawnData().getDeaths() != 1 ? "s" : "") + "!");
|
||||
break;
|
||||
case 13:
|
||||
p.sendChat("<col=FF0000>PK Points: " + p.getSavedData().getSpawnData().getPkPoints() + "!");
|
||||
break;
|
||||
case 17:
|
||||
PKTitle[] titles = PKTitle.getTitles(p);
|
||||
PKTitle t;
|
||||
if (title.ordinal() >= titles.length-1) {
|
||||
t = titles[0];
|
||||
} else {
|
||||
t = titles[title.ordinal() + 1];
|
||||
}
|
||||
this.title = t;
|
||||
p.getAppearance().sync();
|
||||
drawStatsTab(p);
|
||||
break;
|
||||
/*sendString(player, PKPackage.values()[0].getName(), 156);
|
||||
sendString(player, PKPackage.values()[1].getName(), 32);
|
||||
sendString(player, PKPackage.values()[2].getName(), 137);
|
||||
sendString(player, PKPackage.values()[3].getName(), 146);
|
||||
sendString(player, PKPackage.values()[4].getName(), 142);
|
||||
sendString(player, PKPackage.values()[5].getName(), 33);
|
||||
sendString(player, PKPackage.values()[6].getName(), 34);
|
||||
sendString(player, PKPackage.values()[7].getName(), 35);
|
||||
sendString(player, PKPackage.values()[8].getName(), 36);
|
||||
sendString(player, PKPackage.values()[9].getName(), 147);
|
||||
sendString(player, PKPackage.values()[10].getName(), 37);
|
||||
sendString(player, PKPackage.values()[11].getName(), 131);
|
||||
sendString(player, PKPackage.values()[12].getName(), 38);*/
|
||||
case 156:
|
||||
Player player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
p.getSkills().setLevel(Skills.ATTACK, 99);
|
||||
p.getSkills().setStaticLevel(Skills.ATTACK, 99);
|
||||
p.getSkills().setLevel(Skills.STRENGTH, 99);
|
||||
p.getSkills().setStaticLevel(Skills.STRENGTH, 99);
|
||||
p.getSkills().setLevel(Skills.DEFENCE, 99);
|
||||
p.getSkills().setStaticLevel(Skills.DEFENCE, 99);
|
||||
p.getSkills().setLevel(Skills.HITPOINTS, 99);
|
||||
p.getSkills().setStaticLevel(Skills.HITPOINTS, 99);
|
||||
p.getSkills().setLevel(Skills.RANGE, 99);
|
||||
p.getSkills().setStaticLevel(Skills.RANGE, 99);
|
||||
p.getSkills().setLevel(Skills.MAGIC, 99);
|
||||
p.getSkills().setStaticLevel(Skills.MAGIC, 99);
|
||||
p.getSkills().setLevel(Skills.PRAYER, 99);
|
||||
p.getSkills().setStaticLevel(Skills.PRAYER, 99);
|
||||
loadGear(p, 0);
|
||||
break;
|
||||
case 32:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
p.getSkills().setLevel(Skills.ATTACK, 50);
|
||||
p.getSkills().setStaticLevel(Skills.ATTACK, 50);
|
||||
p.getSkills().setLevel(Skills.STRENGTH, 99);
|
||||
p.getSkills().setStaticLevel(Skills.STRENGTH, 99);
|
||||
p.getSkills().setLevel(Skills.DEFENCE, 45);
|
||||
p.getSkills().setStaticLevel(Skills.DEFENCE, 45);
|
||||
p.getSkills().setLevel(Skills.HITPOINTS, 99);
|
||||
p.getSkills().setStaticLevel(Skills.HITPOINTS, 99);
|
||||
p.getSkills().setLevel(Skills.RANGE, 99);
|
||||
p.getSkills().setStaticLevel(Skills.RANGE, 99);
|
||||
p.getSkills().setLevel(Skills.MAGIC, 94);
|
||||
p.getSkills().setStaticLevel(Skills.MAGIC, 94);
|
||||
p.getSkills().setLevel(Skills.PRAYER, 52);
|
||||
p.getSkills().setStaticLevel(Skills.PRAYER, 52);
|
||||
loadGear(p, 1);
|
||||
break;
|
||||
case 137:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
p.getSkills().setLevel(Skills.ATTACK, 90);
|
||||
p.getSkills().setStaticLevel(Skills.ATTACK, 90);
|
||||
p.getSkills().setLevel(Skills.STRENGTH, 99);
|
||||
p.getSkills().setStaticLevel(Skills.STRENGTH, 99);
|
||||
p.getSkills().setLevel(Skills.DEFENCE, 80);
|
||||
p.getSkills().setStaticLevel(Skills.DEFENCE, 80);
|
||||
p.getSkills().setLevel(Skills.HITPOINTS, 99);
|
||||
p.getSkills().setStaticLevel(Skills.HITPOINTS, 99);
|
||||
p.getSkills().setLevel(Skills.RANGE, 99);
|
||||
p.getSkills().setStaticLevel(Skills.RANGE, 99);
|
||||
p.getSkills().setLevel(Skills.MAGIC, 99);
|
||||
p.getSkills().setStaticLevel(Skills.MAGIC, 99);
|
||||
p.getSkills().setLevel(Skills.PRAYER, 80);
|
||||
p.getSkills().setStaticLevel(Skills.PRAYER, 80);
|
||||
loadGear(p, 2);
|
||||
break;
|
||||
case 146:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
p.getSkills().setLevel(Skills.ATTACK, 80);
|
||||
p.getSkills().setStaticLevel(Skills.ATTACK, 80);
|
||||
p.getSkills().setLevel(Skills.STRENGTH, 99);
|
||||
p.getSkills().setStaticLevel(Skills.STRENGTH, 99);
|
||||
p.getSkills().setLevel(Skills.DEFENCE, 1);
|
||||
p.getSkills().setStaticLevel(Skills.DEFENCE, 1);
|
||||
p.getSkills().setLevel(Skills.HITPOINTS, 99);
|
||||
p.getSkills().setStaticLevel(Skills.HITPOINTS, 99);
|
||||
p.getSkills().setLevel(Skills.RANGE, 99);
|
||||
p.getSkills().setStaticLevel(Skills.RANGE, 99);
|
||||
p.getSkills().setLevel(Skills.MAGIC, 99);
|
||||
p.getSkills().setStaticLevel(Skills.MAGIC, 99);
|
||||
p.getSkills().setLevel(Skills.PRAYER, 52);
|
||||
p.getSkills().setStaticLevel(Skills.PRAYER, 52);
|
||||
loadGear(p, 3);
|
||||
break;
|
||||
case 142:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
p.getSkills().setLevel(Skills.ATTACK, 60);
|
||||
p.getSkills().setStaticLevel(Skills.ATTACK, 60);
|
||||
p.getSkills().setLevel(Skills.STRENGTH, 92);
|
||||
p.getSkills().setStaticLevel(Skills.STRENGTH, 92);
|
||||
p.getSkills().setLevel(Skills.DEFENCE, 45);
|
||||
p.getSkills().setStaticLevel(Skills.DEFENCE, 45);
|
||||
p.getSkills().setLevel(Skills.HITPOINTS, 91);
|
||||
p.getSkills().setStaticLevel(Skills.HITPOINTS, 91);
|
||||
p.getSkills().setLevel(Skills.RANGE, 99);
|
||||
p.getSkills().setStaticLevel(Skills.RANGE, 99);
|
||||
p.getSkills().setLevel(Skills.MAGIC, 99);
|
||||
p.getSkills().setStaticLevel(Skills.MAGIC, 99);
|
||||
p.getSkills().setLevel(Skills.PRAYER, 52);
|
||||
p.getSkills().setStaticLevel(Skills.PRAYER, 52);
|
||||
loadGear(p, 4);
|
||||
break;
|
||||
case 33:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
loadGear(p, 5);
|
||||
break;
|
||||
case 34:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
loadGear(p, 6);
|
||||
break;
|
||||
case 35:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
loadGear(p, 7);
|
||||
break;
|
||||
case 36:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
loadGear(p, 8);
|
||||
break;
|
||||
case 147:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
loadGear(p, 9);
|
||||
break;
|
||||
case 37:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
loadGear(p, 10);
|
||||
break;
|
||||
case 131:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
loadGear(p, 11);
|
||||
break;
|
||||
case 38:
|
||||
player = p;
|
||||
if (player.canSpawn()) {
|
||||
return;
|
||||
}
|
||||
loadGear(p, 12);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void loadGear(Player p, int index) {
|
||||
PKPackage pkPackage = PKPackage.values()[index];
|
||||
if (pkPackage != null) {
|
||||
if (pkPackage.getType() == 0 && (!p.getBank().hasSpaceFor(p.getEquipment()) || !p.getBank().hasSpaceFor(p.getInventory()))) {
|
||||
p.sendMessage("You don't have enough bank space to do that.");
|
||||
return;
|
||||
}
|
||||
if (pkPackage == pkPackage.PURE) {
|
||||
p.getSkills().setLevel(Skills.DEFENCE, 1);
|
||||
p.getSkills().setStaticLevel(Skills.DEFENCE, 1);
|
||||
p.getSkills().setLevel(Skills.PRAYER, 52);
|
||||
p.getSkills().setStaticLevel(Skills.PRAYER, 52);
|
||||
} /*else if (pkPackage.getType() == 0) {
|
||||
for (int i = 0; i < Skills.SKILL_NAME.length; i++) {
|
||||
p.getSkills().setLevel(i, 99);
|
||||
p.getSkills().setStaticLevel(i, 99);
|
||||
}
|
||||
}*/
|
||||
if (pkPackage.getType() == 0/* && purchased == -1*/) {
|
||||
p.getBank().addAll(p.getEquipment());
|
||||
p.getBank().addAll(p.getInventory());
|
||||
p.getEquipment().clear();
|
||||
p.getInventory().clear();
|
||||
/*for (Item item : pkPackage.getItems()) {
|
||||
if ((item.getDefinition().hasAction("wear") || item.getDefinition().hasAction("wield")) && p.getEquipment().get(item.getDefinition().getConfiguration(ItemConfigParser.EQUIP_SLOT, -1)) == null) {
|
||||
p.getEquipment().add(item, true, false);
|
||||
} else {
|
||||
p.getInventory().add(item);
|
||||
}
|
||||
}
|
||||
} else {*/
|
||||
p.getInventory().add(pkPackage.getItems());
|
||||
purchased = PKPackage.values()[index].ordinal();
|
||||
}
|
||||
if (pkPackage.getSpellBook() != -1 && purchased == -1) {
|
||||
p.getSpellBookManager().setSpellBook(SpellBookManager.SpellBook.values()[pkPackage.getSpellBook()]);
|
||||
p.getSpellBookManager().update(p);
|
||||
}
|
||||
if (pkPackage == pkPackage.VENGEANCE_RUNE || pkPackage == pkPackage.BARRAGE_RUNE || pkPackage == pkPackage.ENTANGE_RUNE) {
|
||||
p.getSpellBookManager().setSpellBook(SpellBookManager.SpellBook.LUNAR);
|
||||
p.getSpellBookManager().update(p);
|
||||
}
|
||||
p.getSkills().updateCombatLevel();
|
||||
p.getAppearance().sync();
|
||||
if (purchased != -1) {
|
||||
p.sendMessage("You have already purchased your one set, please use the shops");
|
||||
p.sendMessage("for any gear needed.");
|
||||
} else {
|
||||
p.sendMessage("You load the " + pkPackage.getName() + " package, your items have been banked!");
|
||||
}
|
||||
p.getInterfaceManager().openTab(3, new Component(149)); // inventory
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the player killer has killed another player.
|
||||
* @param killer
|
||||
* @param killed
|
||||
*/
|
||||
public void onDeath(Player killer, Player killed) {
|
||||
if (GameWorld.isEconomyWorld()) {
|
||||
return;
|
||||
}
|
||||
if (killer.isArtificial() || killed.isArtificial() || killer.getDetails().getInfo().getIp().equals(killed.getDetails().getInfo().getIp()) || killed.getDetails().getInfo().getMac().equals(killer.getDetails().getInfo().getMac())) {
|
||||
killer.sendMessage("You can't kill someone from your own computer address.");
|
||||
return;
|
||||
}
|
||||
SpawnData killedInfo = killed.getSavedData().getSpawnData();
|
||||
int increment = getStreakPoints(killer);
|
||||
if (killedInfo.getKillStreak() > 4) {
|
||||
increment += getStreakPoints(killed);
|
||||
Repository.sendNews("<img=10><col=CC6600>News: " + killer.getUsername() + " has ended " + killed.getUsername() + "'s killstreak of " + killedInfo.getKillStreak() + "!");
|
||||
}
|
||||
incrementKills();
|
||||
incrementStreak();
|
||||
killedInfo.setKillStreak(0);
|
||||
killedInfo.incrementDeaths();
|
||||
incrementPkPoints(increment);
|
||||
PKTitle.checkTitle(killer);
|
||||
drawStatsTab(killer);
|
||||
killedInfo.drawStatsTab(killed);
|
||||
killer.sendMessage("<col=FF0000>You have killed " + killed.getUsername() + "! Your PK Points have increased by " + increment + ".");
|
||||
killer.sendMessage("<col=FF0000>You are now on a " + killStreak + " killstreak!");
|
||||
if (killStreak > 4) {
|
||||
Repository.sendNews("<img=10><col=CC6600>News: " + getStreakMessage(killer, killed));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the streak points.
|
||||
* @param killed the killed player.
|
||||
* @return the points.
|
||||
*/
|
||||
private int getStreakPoints(Player killed) {
|
||||
int streak = killed.getSavedData().getSpawnData().getKillStreak();
|
||||
int points = 1;
|
||||
if (streak > 3) {
|
||||
return streak;
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a kill streak message.
|
||||
* @param killer the killer.
|
||||
* @param killed the killed.
|
||||
* @return the kill streak message.no1 readd him
|
||||
*/
|
||||
private String getStreakMessage(Player killer, Player killed) {
|
||||
int streak = getKillStreak();
|
||||
String message = "killstreak";
|
||||
if (streak > 5) {
|
||||
int index = streak - 6;
|
||||
if (index > KILLSTREAKS.length-1) {
|
||||
return killer.getUsername() + " is unstoppable! " + (killer.getAppearance().isMale() ? "He" : "She") + " is on a killstreak of " + streak + "!";
|
||||
} else {
|
||||
message = "kill " + KILLSTREAKS[index];
|
||||
}
|
||||
}
|
||||
return killer.getUsername() + " is on a " + streak + " " + message + "! Kill " + (killer.getAppearance().isMale() ? "him" : "her") + " to gain " + streak + " PKP!";
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the kill streak.
|
||||
*/
|
||||
public void incrementStreak() {
|
||||
killStreak++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the deaths.
|
||||
*/
|
||||
public void incrementDeaths() {
|
||||
deaths++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the kills.
|
||||
*/
|
||||
public void incrementKills() {
|
||||
kills++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the pk points.
|
||||
* @param increment the increment.
|
||||
*/
|
||||
public void incrementPkPoints(int increment) {
|
||||
setPkPoints(getPkPoints() + increment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the tutorial is completed.
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
public boolean hasCompletedTutorial() {
|
||||
return getTutorialStage() > 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the tutorial stage.
|
||||
*/
|
||||
public void incrementTutorialStage() {
|
||||
setTutorialStage(getTutorialStage() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the kdr.
|
||||
* @return the kdr.
|
||||
*/
|
||||
public String getKdr() {
|
||||
return new DecimalFormat().format(deaths == 0 ? kills : (double) ((double) kills / (double) deaths));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tutorialStage.
|
||||
* @return the tutorialStage
|
||||
*/
|
||||
public int getTutorialStage() {
|
||||
return tutorialStage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the batutorialStage.
|
||||
* @param tutorialStage the tutorialStage to set.
|
||||
*/
|
||||
public void setTutorialStage(int tutorialStage) {
|
||||
this.tutorialStage = tutorialStage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pkPoints.
|
||||
* @return the pkPoints
|
||||
*/
|
||||
public int getPkPoints() {
|
||||
return pkPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bapkPoints.
|
||||
* @param pkPoints the pkPoints to set.
|
||||
*/
|
||||
public void setPkPoints(int pkPoints) {
|
||||
this.pkPoints = pkPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the title.
|
||||
* @return the title
|
||||
*/
|
||||
public PKTitle getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the batitle.
|
||||
* @param title the title to set.
|
||||
*/
|
||||
public void setTitle(PKTitle title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the kills.
|
||||
* @return the kills
|
||||
*/
|
||||
public int getKills() {
|
||||
return kills;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bakills.
|
||||
* @param kills the kills to set.
|
||||
*/
|
||||
public void setKills(int kills) {
|
||||
this.kills = kills;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the deaths.
|
||||
* @return the deaths
|
||||
*/
|
||||
public int getDeaths() {
|
||||
return deaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrements the points.
|
||||
*/
|
||||
public void decrementPoints(int decrement) {
|
||||
pkPoints-= decrement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the badeaths.
|
||||
* @param deaths the deaths to set.
|
||||
*/
|
||||
public void setDeaths(int deaths) {
|
||||
this.deaths = deaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the killStreak.
|
||||
* @return the killStreak
|
||||
*/
|
||||
public int getKillStreak() {
|
||||
return killStreak;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bakillStreak.
|
||||
* @param killStreak the killStreak to set.
|
||||
*/
|
||||
public void setKillStreak(int killStreak) {
|
||||
this.killStreak = killStreak;
|
||||
}
|
||||
|
||||
public void setPurchased(int purchased) {
|
||||
this.purchased = purchased;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ class DevelopmentCommandSet : CommandSet(Privilege.ADMIN) {
|
|||
|
||||
for(i in 0..amount)
|
||||
{
|
||||
val drops = NPCDefinition.forId(npcId).dropTables.table.roll()
|
||||
val drops = NPCDefinition.forId(npcId).dropTables.table.roll(player)
|
||||
for(drop in drops) container.add(drop)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -301,6 +301,11 @@ public class Region {
|
|||
int regionX = regionId >> 8 & 0xFF;
|
||||
int regionY = regionId & 0xFF;
|
||||
int mapscapeId = Cache.getIndexes()[5].getArchiveId("m" + regionX + "_"+ regionY);
|
||||
|
||||
if (mapscapeId < 0 && !dynamic) {
|
||||
return;
|
||||
}
|
||||
|
||||
byte[][][] mapscapeData = new byte[4][SIZE][SIZE];
|
||||
for (RegionPlane plane : r.planes) {
|
||||
plane.getFlags().setLandscape(new boolean[SIZE][SIZE]);
|
||||
|
|
|
|||
|
|
@ -53,10 +53,7 @@ class DisconnectionQueue {
|
|||
SystemLogger.logInfo(this::class.java, "Clearing player...")
|
||||
player.clear()
|
||||
}
|
||||
Repository.playerNames.remove(player.name)
|
||||
Repository.lobbyPlayers.remove(player)
|
||||
Repository.removePlayer(player)
|
||||
Repository.LOGGED_IN_PLAYERS.remove(player.details.username)
|
||||
SystemLogger.logInfo(this::class.java, "Player cleared. Removed ${player.details.username}")
|
||||
try {
|
||||
if(player.communication.clan != null)
|
||||
|
|
|
|||
|
|
@ -136,6 +136,18 @@ object Repository {
|
|||
|
||||
@JvmStatic
|
||||
fun addPlayer(player: Player){
|
||||
if (players.isNotEmpty()) {
|
||||
for (i in 1 until players.size) {
|
||||
players[i] ?: continue
|
||||
if (players[i].details.uid == player.details.uid) {
|
||||
val oldPl = players[i]
|
||||
players.remove(oldPl)
|
||||
oldPl.clear(true)
|
||||
oldPl.session.disconnect()
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
players.add(player)
|
||||
uid_map[player.details.uid] = player
|
||||
playerNames[player.name] = player
|
||||
|
|
@ -147,6 +159,8 @@ object Repository {
|
|||
uid_map.remove(player.details.uid)
|
||||
playerNames.remove(player.name)
|
||||
UpdateSequence.renderablePlayers.remove(player)
|
||||
player.session.disconnect()
|
||||
player.clear(true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -117,8 +117,10 @@ object Login {
|
|||
private fun noop(buffer: ByteBuffer, amount: Int = 1) {buffer.get(ByteArray(amount))}
|
||||
|
||||
fun proceedWith(session: IoSession, details: PlayerDetails, opcode: Int) {
|
||||
if (!Repository.LOGGED_IN_PLAYERS.contains(details.username))
|
||||
Repository.LOGGED_IN_PLAYERS.add(details.username)
|
||||
if (Repository.uid_map.contains(details.uid)) {
|
||||
session.write(AuthResponse.AlreadyOnline)
|
||||
return;
|
||||
}
|
||||
details.session = session
|
||||
details.info.translate(UIDInfo(details.ipAddress, "DEPRECATED", "DEPRECATED", "DEPRECATED"))
|
||||
|
||||
|
|
@ -146,9 +148,7 @@ object Login {
|
|||
}
|
||||
|
||||
private fun proceedWithAcceptableLogin(session: IoSession, player: Player, opcode: Int) {
|
||||
if (Repository.getPlayerByName(player.name) == null) {
|
||||
Repository.addPlayer(player)
|
||||
}
|
||||
session.lastPing = System.currentTimeMillis()
|
||||
try {
|
||||
LoginParser(player.details).initialize(player, opcode == RECONNECT_LOGIN_OP)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ class MajorUpdateWorker {
|
|||
player?.details?.session?.disconnect()
|
||||
player?.session?.lastPing = Long.MAX_VALUE
|
||||
player?.clear(true)
|
||||
Repository.removePlayer(player)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue