Fixed some issues with incorrectly reading varbit values
Fixed Dwarf Cannon quest Improved varp/varbit interface and handling
This commit is contained in:
@@ -1005,61 +1005,52 @@ fun heal(entity: Entity, amount: Int) {
|
||||
entity.skills.heal(amount)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given varbit for the given player
|
||||
* @param player the player to set the varbit for
|
||||
* @param varpIndex the index of the VARP that contains the desired varbit.
|
||||
* @param offset the offset of the desired varbit inside the varp.
|
||||
* @param value the value to set the varbit to
|
||||
*/
|
||||
fun setVarbit(player: Player, varpIndex: Int, offset: Int, value: Int, save: Boolean = false) {
|
||||
player.varpManager.get(varpIndex).setVarbit(offset, value).send(player)
|
||||
if (save) player.varpManager.flagSave(varpIndex)
|
||||
fun getVarp (player: Player, varpIndex: Int) : Int {
|
||||
return player.varpMap[varpIndex] ?: 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given varbit for the given player.
|
||||
* @param player the player to set the varbit for.
|
||||
* @param varbitId the ID of the varbit to set.
|
||||
* @param value the value to set the varbit to.
|
||||
* @param save whether or not we should save this setting (default false)
|
||||
*/
|
||||
fun setVarbit(player: Player, varbitId: Int, value: Int, save: Boolean = false) {
|
||||
player.varpManager.setVarbit(varbitId, value)
|
||||
if (save) {
|
||||
val def = VarbitDefinition.forId(varbitId)
|
||||
player.varpManager.flagSave(def.varpId)
|
||||
fun getVarbit (player: Player, def: VarbitDefinition) : Int {
|
||||
val mask = def.mask
|
||||
val current = getVarp (player, def.varpId)
|
||||
return (current and mask) shr def.startBit
|
||||
}
|
||||
|
||||
fun getVarbit (player: Player, varbitId: Int) : Int {
|
||||
val def = VarbitDefinition.forId(varbitId)
|
||||
return getVarbit (player, def)
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun setVarp (player: Player, varpIndex: Int, value: Int, save: Boolean = false) {
|
||||
player.varpMap[varpIndex] = value
|
||||
player.saveVarp[varpIndex] = save
|
||||
player.packetDispatch.sendVarp(varpIndex, value)
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun setVarbit (player: Player, def: VarbitDefinition, value: Int, save: Boolean = false) {
|
||||
val mask = def.mask
|
||||
val current = getVarp (player, def.varpId) and mask.inv()
|
||||
val newValue = (value shl def.startBit) and mask
|
||||
setVarp (player, def.varpId, current or newValue, save)
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun setVarbit (player: Player, varbitId: Int, value: Int, save: Boolean = false) {
|
||||
val def = VarbitDefinition.forId(varbitId)
|
||||
|
||||
if (def == null) {
|
||||
logWithStack (ContentAPI::class.java, Log.ERR, "Trying to setVarbit $varbitId, which doesn't seem to exist.")
|
||||
return
|
||||
}
|
||||
|
||||
setVarbit (player, def, value, save)
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all bits for a given varp index
|
||||
* @param player the player to clear for
|
||||
* @param varpIndex the index of the varp to clear
|
||||
*/
|
||||
fun clearVarp(player: Player, varpIndex: Int) {
|
||||
player.varpManager.get(varpIndex).clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of all bits collected together from a given varp
|
||||
* @param player the player to get the varp for
|
||||
* @param varpIndex the index of the varp to calculate the value of
|
||||
* @return the value of the varp
|
||||
*/
|
||||
fun getVarpValue(player: Player, varpIndex: Int): Int {
|
||||
return player.varpManager.get(varpIndex).getValue()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of a specific varbit
|
||||
* @param player the player to get the value for
|
||||
* @param varpIndex the index of th varp containinig the desired varbit
|
||||
* @param offset the offset of the varbit inside the varp
|
||||
* @return the value of the given varbit
|
||||
*/
|
||||
fun getVarbitValue(player: Player, varpIndex: Int, offset: Int): Int {
|
||||
return player.varpManager.get(varpIndex).getVarbitValue(offset) ?: 0
|
||||
fun reinitVarps (player: Player) {
|
||||
for ((index, value) in player.varpMap) {
|
||||
setVarp(player, index, value, player.saveVarp[index] ?: false)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-2
@@ -17,6 +17,8 @@ import java.nio.ByteBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
/**
|
||||
* Debug NPC Opcodes Line 483, Uncomment
|
||||
*/
|
||||
@@ -239,7 +241,7 @@ public final class NPCDefinition extends Definition<NPC> {
|
||||
if (configFileId != -1) {
|
||||
configValue = VarbitDefinition.forNPCID(configFileId).getValue(player);
|
||||
} else if (configId != -1) {
|
||||
configValue = player.getConfigManager().get(configId);
|
||||
configValue = getVarp(player, configId);
|
||||
}
|
||||
} else {
|
||||
configValue = 0;
|
||||
@@ -1114,4 +1116,4 @@ public final class NPCDefinition extends Definition<NPC> {
|
||||
public void setRenderAnimationId(int renderAnimationId) {
|
||||
this.renderAnimationId = renderAnimationId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static core.api.ContentAPIKt.log;
|
||||
import static core.api.ContentAPIKt.getVarp;
|
||||
|
||||
/**
|
||||
* Represents an object's definition.
|
||||
@@ -890,7 +891,7 @@ public class SceneryDefinition extends Definition<Scenery> {
|
||||
configValue = def.getValue(player);
|
||||
}
|
||||
} else if (configId != -1) {
|
||||
configValue = player.getConfigManager().get(configId);
|
||||
configValue = getVarp(player, configId);
|
||||
}
|
||||
} else {
|
||||
configValue = 0;
|
||||
|
||||
+11
-7
@@ -7,6 +7,8 @@ import java.nio.ByteBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
/**
|
||||
* Handles config definition reading.
|
||||
* @author Emperor
|
||||
@@ -126,12 +128,7 @@ public final class VarbitDefinition {
|
||||
* @return The config value.
|
||||
*/
|
||||
public int getValue(Player player) {
|
||||
int size = BITS[endBit - startBit];
|
||||
int bitValue = player.varpManager.get(getVarpId()).getBitRangeValue(getStartBit(), getStartBit() + (endBit - startBit));
|
||||
if(bitValue != 0){
|
||||
return size & (bitValue >>> startBit);
|
||||
}
|
||||
return size & (player.getConfigManager().get(varpId) >>> startBit);
|
||||
return getVarbit(player, id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,8 +159,15 @@ public final class VarbitDefinition {
|
||||
return endBit;
|
||||
}
|
||||
|
||||
public int getMask() {
|
||||
int mask = 0;
|
||||
for (int i = startBit; i <= endBit; i++)
|
||||
mask |= (1 << i);
|
||||
return mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConfigFileDefinition [id=" + id + ", configId=" + varpId + ", bitShift=" + startBit + ", bitSize=" + endBit + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ import core.net.packet.out.ContainerPacket;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the bank container.
|
||||
* @author Emperor
|
||||
@@ -128,7 +131,7 @@ public final class BankContainer extends Container {
|
||||
super.refresh();
|
||||
player.getInventory().getListeners().add(listener);
|
||||
player.getInventory().refresh();
|
||||
player.varpManager.get(1249).setVarbit(0,lastAmountX).send(player);
|
||||
setVarp(player, 1249, lastAmountX);
|
||||
int settings = new IfaceSettingsBuilder().enableOptions(new IntRange(0, 5)).enableExamine().enableSlotSwitch().build();
|
||||
player.getPacketDispatch().sendIfaceSettings(settings, 0, 763, 0, 27);
|
||||
player.getPacketDispatch().sendRunScript(1451, "");
|
||||
@@ -156,7 +159,7 @@ public final class BankContainer extends Container {
|
||||
player.getInterfaceManager().openSingleTab(new Component(763));
|
||||
player.getInventory().getListeners().add(player.getBank().listener);
|
||||
player.getInventory().refresh();
|
||||
player.varpManager.get(1249).setVarbit(0,lastAmountX).send(player);
|
||||
setVarp(player, 1249, lastAmountX);
|
||||
player.getPacketDispatch().sendIfaceSettings(1278, 73, 762, 0, SIZE);
|
||||
int settings = new IfaceSettingsBuilder().enableOptions(new IntRange(0,5)).enableExamine().enableSlotSwitch().build();
|
||||
player.getPacketDispatch().sendIfaceSettings(settings, 0, 763, 0, 27);
|
||||
@@ -316,7 +319,7 @@ public final class BankContainer extends Container {
|
||||
*/
|
||||
public void updateLastAmountX(int amount) {
|
||||
this.lastAmountX = amount;
|
||||
player.varpManager.get(1249).setVarbit(0,amount).send(player);
|
||||
setVarp(player, 1249, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -418,16 +421,16 @@ public final class BankContainer extends Container {
|
||||
int value = getItemsInTab(1);
|
||||
value += getItemsInTab(2) << 10;
|
||||
value += getItemsInTab(3) << 20;
|
||||
player.getConfigManager().set(1246, value);
|
||||
setVarp(player, 1246, value);
|
||||
value = getItemsInTab(4);
|
||||
value += getItemsInTab(5) << 10;
|
||||
value += getItemsInTab(6) << 20;
|
||||
player.getConfigManager().set(1247, value);
|
||||
setVarp(player, 1247, value);
|
||||
value = -2013265920;
|
||||
value += (134217728 * (tabIndex == 10 ? 0 : tabIndex));
|
||||
value += getItemsInTab(7);
|
||||
value += getItemsInTab(8) << 10;
|
||||
player.getConfigManager().set(1248, value);
|
||||
setVarp(player, 1248, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,16 +440,16 @@ public final class BankContainer extends Container {
|
||||
int value = getItemsInTab(1);
|
||||
value += getItemsInTab(2) << 10;
|
||||
value += getItemsInTab(3) << 20;
|
||||
player.getConfigManager().set(1246, value);
|
||||
setVarp(player, 1246, value);
|
||||
value = getItemsInTab(4);
|
||||
value += getItemsInTab(5) << 10;
|
||||
value += getItemsInTab(6) << 20;
|
||||
player.getConfigManager().set(1247, value);
|
||||
setVarp(player, 1247, value);
|
||||
value = -2013265920;
|
||||
value += (134217728 * (tabIndex == 10 ? 0 : tabIndex));
|
||||
value += getItemsInTab(7);
|
||||
value += getItemsInTab(8) << 10;
|
||||
player.getConfigManager().set(1248, value);
|
||||
setVarp(player, 1248, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -480,7 +483,7 @@ public final class BankContainer extends Container {
|
||||
* @return If items have to be noted {@code true}.
|
||||
*/
|
||||
public boolean isNoteItems() {
|
||||
return player.varpManager.getVarbit(Vars.VARBIT_IFACE_BANK_NOTE_MODE) == 1;
|
||||
return getVarbit(player, Vars.VARBIT_IFACE_BANK_NOTE_MODE) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -488,8 +491,7 @@ public final class BankContainer extends Container {
|
||||
* @param noteItems If items have to be noted {@code true}.
|
||||
*/
|
||||
public void setNoteItems(boolean noteItems) {
|
||||
player.varpManager.flagSave(Vars.VARBIT_IFACE_BANK_NOTE_MODE, true);
|
||||
player.varpManager.setVarbit(Vars.VARBIT_IFACE_BANK_NOTE_MODE, noteItems ? 1 : 0);
|
||||
setVarbit(player, Vars.VARBIT_IFACE_BANK_NOTE_MODE, noteItems ? 1 : 0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -528,8 +530,7 @@ public final class BankContainer extends Container {
|
||||
* @param insertItems The insert items value.
|
||||
*/
|
||||
public void setInsertItems(boolean insertItems) {
|
||||
player.varpManager.setVarbit(Vars.VARBIT_IFACE_BANK_INSERT_MODE, insertItems ? 1 : 0);
|
||||
player.varpManager.flagSave(Vars.VARBIT_IFACE_BANK_INSERT_MODE, true);
|
||||
setVarbit(player, Vars.VARBIT_IFACE_BANK_INSERT_MODE, insertItems ? 1 : 0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -537,7 +538,7 @@ public final class BankContainer extends Container {
|
||||
* @return {@code True} if inserting items mode is enabled.
|
||||
*/
|
||||
public boolean isInsertItems() {
|
||||
return player.varpManager.getVarbit(Vars.VARBIT_IFACE_BANK_INSERT_MODE) == 1;
|
||||
return getVarbit(player, Vars.VARBIT_IFACE_BANK_INSERT_MODE) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,8 @@ import core.game.system.config.ItemConfigParser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
/**
|
||||
* Represents the equipment container.
|
||||
* @author Emperor
|
||||
@@ -301,7 +303,7 @@ public final class EquipmentContainer extends Container {
|
||||
player.removeAttribute("dfs_spec");
|
||||
player.getProperties().getCombatPulse().setHandler(null);
|
||||
if (!player.getSettings().isSpecialToggled()) {
|
||||
player.getConfigManager().set(301, 0);
|
||||
setVarp(player, 301, 0);
|
||||
}
|
||||
}
|
||||
player.getAppearance().setAnimations();
|
||||
|
||||
@@ -20,6 +20,9 @@ import core.net.packet.out.StringPacket;
|
||||
import org.rs09.consts.Components;
|
||||
import core.game.system.config.ItemConfigParser;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Represents the weapon interface component.
|
||||
@@ -318,9 +321,9 @@ public final class WeaponInterface extends Component {
|
||||
return;
|
||||
}
|
||||
boolean defensive = slot == 3;
|
||||
player.getConfigManager().set(439, defensive ? -5 : 0);
|
||||
setVarp(player, 439, defensive ? -5 : 0);
|
||||
if (slot > 2) {
|
||||
player.getConfigManager().set(43, defensive ? -1 : 3);
|
||||
setVarp(player, 43, defensive ? -1 : 3);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -729,4 +732,4 @@ public final class WeaponInterface extends Component {
|
||||
return specialBar;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,9 @@ public class Player extends Entity {
|
||||
|
||||
public VarpManager varpManager = new VarpManager(this);
|
||||
|
||||
public HashMap<Integer, Integer> varpMap = new HashMap<>();
|
||||
public HashMap<Integer, Boolean> saveVarp = new HashMap<>();
|
||||
|
||||
public HashMap<String,State> states = new HashMap<>();
|
||||
|
||||
public HashMap<String,Function1<Player, Unit>> logoutListeners = new HashMap<>();
|
||||
@@ -229,11 +232,6 @@ public class Player extends Entity {
|
||||
*/
|
||||
private final FamiliarManager familiarManager = new FamiliarManager(this);
|
||||
|
||||
/**
|
||||
* The config manager.
|
||||
*/
|
||||
private final ConfigurationManager configManager = new ConfigurationManager(this);
|
||||
|
||||
/**
|
||||
* The saved data.
|
||||
*/
|
||||
@@ -620,6 +618,8 @@ public class Player extends Entity {
|
||||
savedData = new SavedData(this);
|
||||
questRepository = new QuestRepository(this);
|
||||
varpManager = new VarpManager(this);
|
||||
varpMap.clear();
|
||||
saveVarp.clear();
|
||||
new PlayerSaver(this).save();
|
||||
clear();
|
||||
return;
|
||||
@@ -761,7 +761,6 @@ public class Player extends Entity {
|
||||
getPulseManager().clear();
|
||||
getZoneMonitor().getZones().clear();
|
||||
getViewport().setCurrentPlane(RegionManager.forId(66666).getPlanes()[3]);
|
||||
configManager.reset();
|
||||
playerFlags.setLastSceneGraph(null);
|
||||
playerFlags.setUpdateSceneGraph(false);
|
||||
playerFlags.setLastViewport(new RegionChunk[Viewport.CHUNK_SIZE][Viewport.CHUNK_SIZE]);
|
||||
@@ -1176,14 +1175,6 @@ public class Player extends Entity {
|
||||
return familiarManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configManager.
|
||||
* @return The configManager.
|
||||
*/
|
||||
public ConfigurationManager getConfigManager() {
|
||||
return configManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the communication.
|
||||
* @return The communication.
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
package core.game.node.entity.player
|
||||
|
||||
/**
|
||||
* A class that represents Varps and aids in modifying/calculating them
|
||||
* @author Ceikry
|
||||
*/
|
||||
class Varp(val index: Int) {
|
||||
val varbits = HashMap<Int, Int>()
|
||||
var save = false
|
||||
|
||||
fun setVarbit(offset: Int, value: Int): Varp {
|
||||
varbits[offset] = value
|
||||
return this
|
||||
}
|
||||
|
||||
fun getValue(): Int{
|
||||
var config = 0
|
||||
for((index,value) in varbits.entries){
|
||||
config = config or (value shl index)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
fun getVarbit(offset: Int): Int {
|
||||
return getVarbitValue(offset)
|
||||
}
|
||||
|
||||
fun getVarbitValue(offset: Int): Int {
|
||||
return varbits[offset] ?: 0
|
||||
}
|
||||
|
||||
fun send(player: Player){
|
||||
player.packetDispatch.sendVarp(this)
|
||||
}
|
||||
|
||||
fun clear(): Varp {
|
||||
varbits.clear()
|
||||
return this
|
||||
}
|
||||
|
||||
fun clearBitRange(first : Int, last : Int){
|
||||
for(i in first..last) varbits.remove(i)
|
||||
}
|
||||
|
||||
fun getBitRangeValue(first: Int, last: Int): Int{
|
||||
var product = 0
|
||||
for (i in first..last)
|
||||
{
|
||||
val value = varbits[i] ?: 0
|
||||
product = product or (value shl i)
|
||||
}
|
||||
return product
|
||||
}
|
||||
}
|
||||
@@ -12,111 +12,23 @@ import org.json.simple.JSONObject
|
||||
* @author Ceikry
|
||||
*/
|
||||
class VarpManager(val player: Player) {
|
||||
val varps = Array(3500) { Varp(it) }
|
||||
|
||||
fun get(index: Int): Varp {
|
||||
return varps[index]
|
||||
}
|
||||
|
||||
fun send(index: Int){
|
||||
player.packetDispatch.sendVarp(get(index))
|
||||
}
|
||||
|
||||
fun set(index: Int, value: Int){
|
||||
get(index).varbits.clear()
|
||||
get(index).varbits[0] = value
|
||||
get(index).send(player)
|
||||
}
|
||||
|
||||
fun setVarbit(def: VarbitDefinition, value: Int){
|
||||
get(def.varpId).setVarbit(def.startBit,value).send(player)
|
||||
|
||||
player.dispatch(VarbitUpdateEvent(def.id, value))
|
||||
}
|
||||
|
||||
fun setVarbit(varbitIndex: Int, value: Int){
|
||||
val def = VarbitDefinition.forId(varbitIndex)
|
||||
get(def.varpId).setVarbit(def.startBit, value)
|
||||
get(def.varpId).send(player)
|
||||
|
||||
player.dispatch(VarbitUpdateEvent(varbitIndex, value))
|
||||
}
|
||||
|
||||
fun getVarbit(varbitIndex: Int): Int{
|
||||
val def = VarbitDefinition.forId(varbitIndex)
|
||||
return get(def.varpId).getVarbit(def.startBit)
|
||||
}
|
||||
|
||||
fun flagSave(index: Int, isVarbit: Boolean = false){
|
||||
if (isVarbit) {
|
||||
val def = VarbitDefinition.forId(index)
|
||||
flagSave(def.varpId, false)
|
||||
} else {
|
||||
get(index).save = true
|
||||
}
|
||||
}
|
||||
|
||||
fun unflagSave(index: Int, isVarbit: Boolean = false){
|
||||
if (isVarbit) {
|
||||
val def = VarbitDefinition.forId(index)
|
||||
unflagSave(def.varpId, false)
|
||||
}
|
||||
else {
|
||||
get(index).save = false
|
||||
}
|
||||
}
|
||||
|
||||
fun sendAllVarps(){
|
||||
for(varp in varps){
|
||||
if(varp.getValue() != 0){
|
||||
player.packetDispatch.sendVarp(varp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getSavedVarps(): ArrayList<Varp>{
|
||||
val list = ArrayList<Varp>()
|
||||
for(varp in varps){
|
||||
if(varp.save) list.add(varp)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
fun save(root: JSONObject){
|
||||
val varps = JSONArray()
|
||||
for(varp in getSavedVarps()){
|
||||
val varpobj = JSONObject()
|
||||
varpobj.put("index",varp.index.toString())
|
||||
val bitArray = JSONArray()
|
||||
for(varbit in varp.varbits){
|
||||
val varbitobj = JSONObject()
|
||||
varbitobj.put("offset",varbit.key.toString())
|
||||
varbitobj.put("value",varbit.value.toString())
|
||||
bitArray.add(varbitobj)
|
||||
}
|
||||
varpobj.put("bitArray",bitArray)
|
||||
varps.add(varpobj)
|
||||
}
|
||||
root.put("varps",varps)
|
||||
}
|
||||
|
||||
fun parse(data: JSONArray){
|
||||
val patch_varps = FarmingPatch.values().map { it.varpIndex }.toIntArray()
|
||||
val bin_varps = FarmingPatch.values().map { it.varpIndex }.toIntArray()
|
||||
for(varpobj in data){
|
||||
val vobj = varpobj as JSONObject
|
||||
val index = vobj["index"].toString().toInt()
|
||||
if(patch_varps.contains(index)) continue
|
||||
if(bin_varps.contains(index)) continue
|
||||
val varp = get(index)
|
||||
val bits = vobj["bitArray"] as JSONArray
|
||||
var total = 0
|
||||
for(vbit in bits){
|
||||
val varbit = vbit as JSONObject
|
||||
val offset = varbit["offset"].toString().toInt()
|
||||
val value = varbit["value"].toString().toInt()
|
||||
varp.setVarbit(offset,value)
|
||||
varp.save = true
|
||||
total = total or (value shl offset)
|
||||
}
|
||||
player.varpMap[index] = total
|
||||
player.saveVarp[index] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static core.api.ContentAPIKt.log;
|
||||
import static core.api.ContentAPIKt.hasRequirement;
|
||||
import static core.api.ContentAPIKt.*;
|
||||
import static core.tools.GlobalsKt.colorize;
|
||||
|
||||
|
||||
@@ -132,7 +131,6 @@ public final class LoginConfiguration {
|
||||
* @param player The player.
|
||||
*/
|
||||
public static void configureGameWorld(final Player player) {
|
||||
player.getConfigManager().reset();
|
||||
sendGameConfiguration(player);
|
||||
Repository.getLobbyPlayers().remove(player);
|
||||
player.setPlaying(true);
|
||||
@@ -146,7 +144,6 @@ public final class LoginConfiguration {
|
||||
if(player.getGlobalData().getTestStage() == 3 && !player.getEmoteManager().isUnlocked(Emotes.SAFETY_FIRST)){
|
||||
player.getEmoteManager().unlock(Emotes.SAFETY_FIRST);
|
||||
}
|
||||
player.varpManager.sendAllVarps();
|
||||
for (Item item : player.getEquipment().toArray()) {
|
||||
//Run equip hooks for all items equipped on login.
|
||||
//We should have already been doing this.
|
||||
@@ -177,6 +174,9 @@ public final class LoginConfiguration {
|
||||
player.getSpellBookManager().setSpellBook(SpellBookManager.SpellBook.MODERN);
|
||||
}
|
||||
player.getSpellBookManager().update(player);
|
||||
// 1050 is checked client-side for making piety/chivalry disallowed sfx, likely due to the minigame requirement.
|
||||
// Set it here unconditionally until the minigame is implemented.
|
||||
setVarbit(player, 3909, 8, false);
|
||||
if(ServerConstants.RULES_AND_INFO_ENABLED)
|
||||
RulesAndInfo.openFor(player);
|
||||
/*if (GameWorld.getSettings().isPvp()) {
|
||||
@@ -249,7 +249,6 @@ public final class LoginConfiguration {
|
||||
player.getFamiliarManager().login();
|
||||
player.getInterfaceManager().openDefaultTabs();
|
||||
player.getPacketDispatch().sendString("Friends List - World " + GameWorld.getSettings().getWorldId(), 550, 3);
|
||||
player.getConfigManager().init();
|
||||
player.getQuestRepository().syncronizeTab(player);
|
||||
player.getInterfaceManager().close();
|
||||
player.getEmoteManager().refresh();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package core.game.node.entity.player.info.login
|
||||
|
||||
import core.api.LoginListener
|
||||
import core.api.*
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.info.PlayerDetails
|
||||
import core.game.system.SystemManager
|
||||
@@ -45,6 +45,7 @@ class LoginParser(val details: PlayerDetails) {
|
||||
} else {
|
||||
flag(AuthResponse.Success)
|
||||
player.init()
|
||||
reinitVarps(player)
|
||||
}
|
||||
} else {
|
||||
Repository.removePlayer(player)
|
||||
@@ -70,7 +71,7 @@ class LoginParser(val details: PlayerDetails) {
|
||||
player.isActive = true
|
||||
flag(AuthResponse.Success)
|
||||
player.updateSceneGraph(true)
|
||||
player.configManager.init()
|
||||
reinitVarps(player)
|
||||
LoginConfiguration.configureGameWorld(player)
|
||||
}
|
||||
|
||||
@@ -99,4 +100,4 @@ class LoginParser(val details: PlayerDetails) {
|
||||
details.session.write(response, true)
|
||||
return response == AuthResponse.Success
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,9 +39,6 @@ class PlayerSaveParser(val player: Player) {
|
||||
var saveFile: JSONObject? = null
|
||||
var read = true
|
||||
|
||||
val patch_varps = FarmingPatch.values().map { it.varpIndex }.toIntArray()
|
||||
val bin_varps = CompostBins.values().map { it.varpIndex }.toIntArray()
|
||||
|
||||
init {
|
||||
val JSON = File(ServerConstants.PLAYER_SAVE_PATH + player.name + ".json")
|
||||
if(JSON.exists())
|
||||
@@ -215,15 +212,13 @@ class PlayerSaveParser(val player: Player) {
|
||||
}
|
||||
|
||||
fun parseConfigs() {
|
||||
val configs = saveFile!!["configs"] as JSONArray
|
||||
val configs = saveFile!!["configs"] as? JSONArray ?: return
|
||||
for (config in configs) {
|
||||
val c = config as JSONObject
|
||||
val index = (c.get("index") as String).toInt()
|
||||
if(index == 1048) continue
|
||||
if(patch_varps.contains(index)) continue
|
||||
if(bin_varps.contains(index)) continue
|
||||
val value = (c.get("value") as String).toInt()
|
||||
player.configManager.savedConfigurations[index] = value
|
||||
player.varpMap[index] = value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,6 +298,7 @@ class PlayerSaveParser(val player: Player) {
|
||||
val bBars = coreData["blastBars"] as? JSONArray
|
||||
val bOre = coreData["blastOre"] as? JSONArray
|
||||
val bCoal = coreData["blastCoal"] as? JSONArray
|
||||
val varpData = coreData["varp"] as? JSONArray
|
||||
val location = coreData["location"] as String
|
||||
val bankTabData = coreData["bankTabs"]
|
||||
if (bankTabData != null) {
|
||||
@@ -335,6 +331,17 @@ class PlayerSaveParser(val player: Player) {
|
||||
bOre?.let{player.blastOre.parse(bOre)}
|
||||
bCoal?.let{player.blastCoal.parse(bCoal)}
|
||||
player.location = JSONUtils.parseLocation(location)
|
||||
|
||||
if (varpData != null) {
|
||||
for (e in varpData) {
|
||||
e ?: continue
|
||||
val varp = e as JSONObject
|
||||
val index = varp["index"]?.toString()?.toInt() ?: continue
|
||||
val value = varp["value"]?.toString()?.toInt() ?: continue
|
||||
player.varpMap[index] = value
|
||||
player.saveVarp[index] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun parseSkills() {
|
||||
|
||||
@@ -42,10 +42,8 @@ class PlayerSaver (val player: Player){
|
||||
saveQuests(saveFile)
|
||||
saveAppearance(saveFile)
|
||||
saveSpellbook(saveFile)
|
||||
saveVarps(saveFile)
|
||||
saveSavedData(saveFile)
|
||||
saveAutocast(saveFile)
|
||||
saveConfigs(saveFile)
|
||||
savePlayerMonitor(saveFile)
|
||||
saveMusicPlayer(saveFile)
|
||||
saveFamiliarManager(saveFile)
|
||||
@@ -93,10 +91,6 @@ class PlayerSaver (val player: Player){
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
fun saveVarps(root: JSONObject){
|
||||
|
||||
player.varpManager.save(root)
|
||||
}
|
||||
|
||||
fun savePouches(root: JSONObject){
|
||||
player.pouchManager.save(root)
|
||||
@@ -319,21 +313,6 @@ class PlayerSaver (val player: Player){
|
||||
|
||||
}
|
||||
|
||||
fun saveConfigs(root: JSONObject){
|
||||
val configs = JSONArray()
|
||||
var idx = 0
|
||||
player.configManager.savedConfigurations.map {
|
||||
if(it != 0){
|
||||
val config = JSONObject()
|
||||
config.put("index",idx.toString())
|
||||
config.put("value",it.toString())
|
||||
configs.add(config)
|
||||
}
|
||||
idx++
|
||||
}
|
||||
root.put("configs",configs)
|
||||
}
|
||||
|
||||
fun saveAutocast(root: JSONObject){
|
||||
player.properties.autocastSpell ?: return
|
||||
val spell = JSONObject()
|
||||
@@ -662,6 +641,15 @@ class PlayerSaver (val player: Player){
|
||||
val locStr = "${loctemp.x},${loctemp.y},${loctemp.z}"
|
||||
coreData.put("location",locStr)
|
||||
|
||||
val varpData = JSONArray()
|
||||
for ((index, value) in player.varpMap) {
|
||||
val varpObj = JSONObject()
|
||||
varpObj["index"] = index.toString()
|
||||
varpObj["value"] = value.toString()
|
||||
varpData.add(varpObj)
|
||||
}
|
||||
coreData.put("varp", varpData)
|
||||
|
||||
root.put("core_data",coreData)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Manages the players bank pin.
|
||||
* @author Vexia
|
||||
@@ -436,8 +439,8 @@ public class BankPinManager {
|
||||
if (stage >= 4) {
|
||||
stage = stage - 4;
|
||||
}
|
||||
player.getConfigManager().set(562, bitValue);
|
||||
player.getConfigManager().set(563, digits.get(8) | digits.get(9) << 4 | stage << 26);
|
||||
setVarp(player, 562, bitValue);
|
||||
setVarp(player, 563, digits.get(8) | digits.get(9) << 4 | stage << 26);
|
||||
for (int i = 0; i < 9; i++) {
|
||||
int child = (i > 2 ? i + 1 : i) + 11;
|
||||
int positionX = 37 + ((i % 3) * 95) + RandomFunction.random(2, 45);
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
package core.game.node.entity.player.link;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
|
||||
import core.game.system.task.Pulse;
|
||||
import core.game.world.GameWorld;
|
||||
import core.net.packet.PacketRepository;
|
||||
import core.net.packet.context.ConfigContext;
|
||||
import core.net.packet.out.Config;
|
||||
|
||||
/**
|
||||
* Manages a player's configurations.
|
||||
* @author Emperor
|
||||
*/
|
||||
@Deprecated
|
||||
public final class ConfigurationManager {
|
||||
|
||||
/**
|
||||
* The amount of configurations.
|
||||
*/
|
||||
public static final int SIZE = 3500;
|
||||
|
||||
/**
|
||||
* The player.
|
||||
*/
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* The configurations.
|
||||
*/
|
||||
private final int[] configurations = new int[SIZE];
|
||||
|
||||
/**
|
||||
* The configurations.
|
||||
*/
|
||||
private final int[] savedConfigurations = new int[SIZE];
|
||||
|
||||
/**
|
||||
* Constructs a new {@code ConfigurationManager} {@code Object}.
|
||||
* @param player The player.
|
||||
*/
|
||||
public ConfigurationManager(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the configurations.
|
||||
*/
|
||||
public void init() {
|
||||
for (int i = 0; i < savedConfigurations.length; i++) {
|
||||
int value = savedConfigurations[i];
|
||||
if (value != 0) {
|
||||
set(i, value, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the configurations.
|
||||
*/
|
||||
public void reset() {
|
||||
for (int i = 0; i < configurations.length; i++) {
|
||||
configurations[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a configuration.
|
||||
* @param config The configuration.
|
||||
* @param value The value.
|
||||
*/
|
||||
public void set(Configuration config, boolean value) {
|
||||
set(config.id, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a configuration.
|
||||
* @param id The configuration id.
|
||||
* @param value The value.
|
||||
*/
|
||||
@Deprecated
|
||||
public void set(int id, boolean value) {
|
||||
|
||||
player.varpManager.get(id).setVarbit(0, value ? 1 : 0).send(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a configuration.
|
||||
* @param config The configuration.
|
||||
* @param value The value.
|
||||
*/
|
||||
@Deprecated
|
||||
public void set(Configuration config, int value) {
|
||||
player.varpManager.get(config.id).setVarbit(0,value).send(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the configuration.
|
||||
* @param config The configuration id.
|
||||
* @param value The value.
|
||||
* @param saved If the configuration should be saved.
|
||||
*/
|
||||
public void set(Configuration config, int value, boolean saved) {
|
||||
set(config.id, value, saved);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a configuration.
|
||||
* @param id The configuration id.
|
||||
* @param value The value.
|
||||
*/
|
||||
public void set(int id, int value) {
|
||||
set(id, value, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a configuration for a set amount of time.
|
||||
* @param id the id.
|
||||
* @param value the value.
|
||||
* @param delay the delay.
|
||||
*/
|
||||
@Deprecated
|
||||
public void set(final int id, final int value, int delay) {
|
||||
set(id, value);
|
||||
player.varpManager.get(id).setVarbit(0,value).send(player);
|
||||
GameWorld.getPulser().submit(new Pulse(delay, player) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
player.varpManager.get(id).setVarbit(0,0).send(player);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a configuration.
|
||||
* @param id The configuration id.
|
||||
* @param value The value.
|
||||
*/
|
||||
@Deprecated
|
||||
public void set(int id, int value, boolean saved) {
|
||||
player.varpManager.get(id).setVarbit(0,value).send(player);
|
||||
if (saved) {
|
||||
player.varpManager.flagSave(id, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void forceSet(int id, int value, boolean saved){
|
||||
PacketRepository.send(Config.class, new ConfigContext(player,id,value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the configuration without caching.
|
||||
*/
|
||||
@Deprecated
|
||||
public void send(int id, int value) {
|
||||
PacketRepository.send(Config.class, new ConfigContext(player, id, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration value.
|
||||
* @param id The config id.
|
||||
* @return The value.
|
||||
*/
|
||||
@Deprecated
|
||||
public int get(int id) {
|
||||
if(player.varpManager.get(id).getValue() != 0){
|
||||
return player.varpManager.get(id).getValue();
|
||||
}
|
||||
return configurations[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds the configurations.
|
||||
* @author Emperor
|
||||
*/
|
||||
public enum Configuration {
|
||||
|
||||
BRIGHTNESS(166), MUSIC_VOLUME(168), EFFECT_VOLUME(169), MOUSE_BUTTON(170), CHAT_EFFECT(171), RETALIATE(172), RUNNING(173), SPLIT_PRIVATE(287), ACCEPT_AID(427), PC_PORTALS(719), SURROUNDING_VOLUME(872), CLAN_WAR_DATA(1147), ;
|
||||
|
||||
/**
|
||||
* The config id.
|
||||
*/
|
||||
private final int id;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code Configuration} {@code Object}.
|
||||
* @param id The config id.
|
||||
*/
|
||||
private Configuration(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
* @return The id.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int[] getSavedConfigurations() {
|
||||
return savedConfigurations;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import content.region.misc.tutisland.handlers.TutorialStage;
|
||||
import core.tools.SystemLogger;
|
||||
|
||||
import static core.api.ContentAPIKt.log;
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
@@ -498,7 +499,7 @@ public final class InterfaceManager {
|
||||
PacketRepository.send(Interface.class, new InterfaceContext(player, InterfaceType.CHATBOX.getFixedPaneId(), InterfaceType.CHATBOX.getFixedChildId(), Components.CHATDEFAULT_137, true));
|
||||
}
|
||||
chatbox = component;
|
||||
player.getConfigManager().set(334, 1);
|
||||
setVarp(player, 334, 1);
|
||||
} else {
|
||||
chatbox = component;
|
||||
if (chatbox.getDefinition().getType() != InterfaceType.DIALOGUE && chatbox.getDefinition().getType() != InterfaceType.CHATBOX && chatbox.getDefinition().getType() != InterfaceType.CS_CHATBOX) {
|
||||
@@ -785,4 +786,4 @@ public final class InterfaceManager {
|
||||
packetCount += increment;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package core.game.node.entity.player.link;
|
||||
|
||||
import core.game.node.entity.player.Varp;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.scenery.Scenery;
|
||||
import core.tools.Log;
|
||||
@@ -19,6 +18,8 @@ import core.net.packet.context.DisplayModelContext.ModelType;
|
||||
import core.net.packet.out.*;
|
||||
|
||||
import static core.api.ContentAPIKt.log;
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the class used to dispatching packets.
|
||||
@@ -46,8 +47,8 @@ public final class PacketDispatch {
|
||||
this.context = new PlayerContext(player);
|
||||
}
|
||||
|
||||
public void sendVarp(Varp varp){
|
||||
PacketRepository.send(Config.class, new ConfigContext(player, varp.getIndex(), varp.getValue()));
|
||||
public void sendVarp (int index, int value) {
|
||||
PacketRepository.send(Config.class, new ConfigContext(player, index, value));
|
||||
}
|
||||
|
||||
public void sendVarcUpdate(short index, int value) {
|
||||
@@ -389,11 +390,11 @@ public final class PacketDispatch {
|
||||
}
|
||||
|
||||
public void sendLeftShiftedVarbit(int varpIndex, int offset, int value){
|
||||
player.getConfigManager().set(varpIndex, (value << offset));
|
||||
setVarp(player, varpIndex, (value << offset));
|
||||
}
|
||||
|
||||
public void sendRightShiftedVarbit(int varpIndex, int offset, int value){
|
||||
player.getConfigManager().set(varpIndex, (value >> offset));
|
||||
setVarp(player, varpIndex, (value >> offset));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ import core.net.packet.IoBuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Holds a player's settings.
|
||||
* @author Emperor
|
||||
@@ -128,20 +131,20 @@ public final class Settings {
|
||||
* Updates the settings.
|
||||
*/
|
||||
public void update() {
|
||||
player.getConfigManager().set(ConfigurationManager.Configuration.BRIGHTNESS, brightness + 1);
|
||||
player.getConfigManager().set(ConfigurationManager.Configuration.MUSIC_VOLUME, musicVolume);
|
||||
player.getConfigManager().set(ConfigurationManager.Configuration.EFFECT_VOLUME, soundEffectVolume);
|
||||
player.getConfigManager().set(ConfigurationManager.Configuration.SURROUNDING_VOLUME, areaSoundVolume);
|
||||
player.getConfigManager().set(ConfigurationManager.Configuration.MOUSE_BUTTON, singleMouseButton);
|
||||
player.getConfigManager().set(ConfigurationManager.Configuration.CHAT_EFFECT, disableChatEffects);
|
||||
player.getConfigManager().set(ConfigurationManager.Configuration.SPLIT_PRIVATE, splitPrivateChat);
|
||||
player.getConfigManager().set(ConfigurationManager.Configuration.ACCEPT_AID, acceptAid);
|
||||
player.getConfigManager().set(ConfigurationManager.Configuration.RETALIATE, !player.getProperties().isRetaliating());
|
||||
player.getConfigManager().set(ConfigurationManager.Configuration.RUNNING, runToggled);
|
||||
player.getConfigManager().set(1054, clanChatSetting);
|
||||
player.getConfigManager().set(1055, assistSetting);
|
||||
player.getConfigManager().set(300, specialEnergy * 10);
|
||||
player.getConfigManager().set(43, attackStyleIndex);
|
||||
setVarp(player, 166, brightness + 1);
|
||||
setVarp(player, 168, musicVolume);
|
||||
setVarp(player, 169, soundEffectVolume);
|
||||
setVarp(player, 872, areaSoundVolume);
|
||||
setVarp(player, 170, singleMouseButton ? 1 : 0);
|
||||
setVarp(player, 171, disableChatEffects ? 1 : 0);
|
||||
setVarp(player, 287, splitPrivateChat ? 1 : 0);
|
||||
setVarp(player, 427, acceptAid ? 1 : 0);
|
||||
setVarp(player, 172, !player.getProperties().isRetaliating() ? 1 : 0);
|
||||
setVarp(player, 173, runToggled ? 1 : 0);
|
||||
setVarp(player, 1054, clanChatSetting);
|
||||
setVarp(player, 1055, assistSetting);
|
||||
setVarp(player, 300, specialEnergy * 10);
|
||||
setVarp(player, 43, attackStyleIndex);
|
||||
player.getPacketDispatch().sendRunEnergy();
|
||||
updateChatSettings();
|
||||
Pulse pulse = player.getAttribute("energy-restore", null);
|
||||
@@ -168,7 +171,7 @@ public final class Settings {
|
||||
*/
|
||||
public void toggleAttackStyleIndex(int index) {
|
||||
this.attackStyleIndex = index;
|
||||
player.getConfigManager().set(43, attackStyleIndex);
|
||||
setVarp(player, 43, attackStyleIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,7 +304,7 @@ public final class Settings {
|
||||
*/
|
||||
public void setSpecialToggled(boolean enable) {
|
||||
specialToggled = !specialToggled;
|
||||
player.getConfigManager().set(301, specialToggled ? 1 : 0);
|
||||
setVarp(player, 301, specialToggled ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,7 +340,7 @@ public final class Settings {
|
||||
*/
|
||||
public void setSpecialEnergy(int value) {
|
||||
specialEnergy = value;
|
||||
player.getConfigManager().set(300, specialEnergy * 10);
|
||||
setVarp(player, 300, specialEnergy * 10);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,7 +356,7 @@ public final class Settings {
|
||||
*/
|
||||
public void toggleRetaliating() {
|
||||
player.getProperties().setRetaliating(!player.getProperties().isRetaliating());
|
||||
player.getConfigManager().set(172, !player.getProperties().isRetaliating() ? 1 : 0);
|
||||
setVarp(player, 172, !player.getProperties().isRetaliating() ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -361,7 +364,7 @@ public final class Settings {
|
||||
*/
|
||||
public void toggleMouseButton() {
|
||||
singleMouseButton = !singleMouseButton;
|
||||
player.getConfigManager().set(170, singleMouseButton ? 1 : 0);
|
||||
setVarp(player, 170, singleMouseButton ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -369,7 +372,7 @@ public final class Settings {
|
||||
*/
|
||||
public void toggleChatEffects() {
|
||||
disableChatEffects = !disableChatEffects;
|
||||
player.getConfigManager().set(171, disableChatEffects ? 1 : 0);
|
||||
setVarp(player, 171, disableChatEffects ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -377,7 +380,7 @@ public final class Settings {
|
||||
*/
|
||||
public void toggleSplitPrivateChat() {
|
||||
splitPrivateChat = !splitPrivateChat;
|
||||
player.getConfigManager().set(287, splitPrivateChat ? 1 : 0);
|
||||
setVarp(player, 287, splitPrivateChat ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -385,7 +388,7 @@ public final class Settings {
|
||||
*/
|
||||
public void toggleAcceptAid() {
|
||||
acceptAid = !acceptAid;
|
||||
player.getConfigManager().set(427, acceptAid ? 1 : 0);
|
||||
setVarp(player, 427, acceptAid ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,7 +404,7 @@ public final class Settings {
|
||||
*/
|
||||
public void setRunToggled(boolean enabled) {
|
||||
runToggled = enabled;
|
||||
player.getConfigManager().set(173, runToggled ? 1 : 0);
|
||||
setVarp(player, 173, runToggled ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -465,7 +468,7 @@ public final class Settings {
|
||||
*/
|
||||
public void setBrightness(int brightness) {
|
||||
this.brightness = brightness;
|
||||
player.getConfigManager().set(166, brightness + 1);
|
||||
setVarp(player, 166, brightness + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,7 +485,7 @@ public final class Settings {
|
||||
*/
|
||||
public void setMusicVolume(int musicVolume) {
|
||||
this.musicVolume = musicVolume;
|
||||
player.getConfigManager().set(168, musicVolume);
|
||||
setVarp(player, 168, musicVolume);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -499,7 +502,7 @@ public final class Settings {
|
||||
*/
|
||||
public void setSoundEffectVolume(int soundEffectVolume) {
|
||||
this.soundEffectVolume = soundEffectVolume;
|
||||
player.getConfigManager().set(169, soundEffectVolume);
|
||||
setVarp(player, 169, soundEffectVolume);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -516,7 +519,7 @@ public final class Settings {
|
||||
*/
|
||||
public void setAreaSoundVolume(int areaSoundVolume) {
|
||||
this.areaSoundVolume = areaSoundVolume;
|
||||
player.getConfigManager().set(872, areaSoundVolume);
|
||||
setVarp(player, 872, areaSoundVolume);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -610,7 +613,7 @@ public final class Settings {
|
||||
*/
|
||||
public void setClanChatSetting(int clanChatSetting) {
|
||||
this.clanChatSetting = clanChatSetting;
|
||||
player.getConfigManager().set(1054, clanChatSetting);
|
||||
setVarp(player, 1054, clanChatSetting);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -644,7 +647,7 @@ public final class Settings {
|
||||
*/
|
||||
public void setAssistSetting(int assistSetting) {
|
||||
this.assistSetting = assistSetting;
|
||||
player.getConfigManager().set(1055, assistSetting);
|
||||
setVarp(player, 1055, assistSetting);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -677,4 +680,4 @@ public final class Settings {
|
||||
this.attackStyleIndex = attackStyleIndex;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Handles the warning messages of a player.
|
||||
* @author Vexia
|
||||
@@ -38,7 +41,7 @@ public final class WarningMessages {
|
||||
* @param player the player.
|
||||
*/
|
||||
private void refresh(final Player player) {
|
||||
player.getConfigManager().set(CONFIG, getConfigValue(), true);
|
||||
setVarp(player, CONFIG, getConfigValue(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,8 @@ import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static core.api.ContentAPIKt.setVarp;
|
||||
|
||||
/**
|
||||
* Manages the players unlocked/locked emotes.
|
||||
* @author Vexia
|
||||
@@ -52,7 +54,7 @@ public class EmoteManager {
|
||||
if (isUnlocked(Emotes.SLAP_HEAD)) {
|
||||
value1 += 2;
|
||||
}
|
||||
player.getConfigManager().set(802, value1); // stronghold of // security
|
||||
setVarp(player, 802, value1, false);
|
||||
int value2 = 0;
|
||||
if (isUnlocked(Emotes.GLASS_BOX)) {
|
||||
value2 += 2;
|
||||
@@ -103,12 +105,12 @@ public class EmoteManager {
|
||||
if (isUnlocked(Emotes.GIVE_THANKS)) {
|
||||
value2 += 16384;
|
||||
}
|
||||
player.getConfigManager().set(313, value2); // events emotes
|
||||
setVarp(player, 313, value2, false);
|
||||
int value3 = 0;
|
||||
if (isUnlocked(Emotes.ZOMBIE_HAND)) {
|
||||
value3 = 12;
|
||||
}
|
||||
player.getConfigManager().set(1085, value3);//zombie hand.
|
||||
setVarp(player, 1085, value3, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Handles a music playing for a player.
|
||||
* @author Emperor
|
||||
@@ -74,7 +77,7 @@ public final class MusicPlayer {
|
||||
*/
|
||||
public void init() {
|
||||
refreshList();
|
||||
player.getConfigManager().set(19, looping ? 1 : 0);
|
||||
setVarp(player, 19, looping ? 1 : 0);
|
||||
int value = 0;
|
||||
for (int i = 0; i < CONFIG_IDS.length; i++) {
|
||||
value |= 2 << i;
|
||||
@@ -137,7 +140,7 @@ public final class MusicPlayer {
|
||||
values[index] |= 1 << (listIndex - (index * 32));
|
||||
}
|
||||
for (int i = 0; i < CONFIG_IDS.length; i++) {
|
||||
player.getConfigManager().set(CONFIG_IDS[i], values[i]);
|
||||
setVarp(player, CONFIG_IDS[i], values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +227,7 @@ public final class MusicPlayer {
|
||||
*/
|
||||
public void toggleLooping() {
|
||||
looping = !looping;
|
||||
player.getConfigManager().set(19, looping ? 1 : 0);
|
||||
setVarp(player, 19, looping ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,6 +292,6 @@ public final class MusicPlayer {
|
||||
*/
|
||||
public void setLooping(boolean looping) {
|
||||
this.looping = looping;
|
||||
player.getConfigManager().set(19, looping ? 1 : 0);
|
||||
setVarp(player, 19, looping ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ import core.game.world.GameWorld;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static core.api.ContentAPIKt.setVarp;
|
||||
import static core.api.ContentAPIKt.setVarbit;
|
||||
|
||||
/**
|
||||
* Represents a managing class of a players prayers.
|
||||
* @author Vexia
|
||||
@@ -43,10 +46,6 @@ public final class Prayer {
|
||||
*/
|
||||
public Prayer(Player player) {
|
||||
this.player = player;
|
||||
|
||||
// 1050 is checked client-side for making piety/chivalry disallowed sfx, likely due to the minigame requirement.
|
||||
// Set it here unconditionally until the minigame is implemented.
|
||||
player.varpManager.get(1050).setVarbit(1, 8);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +64,7 @@ public final class Prayer {
|
||||
*/
|
||||
public void reset() {
|
||||
for (PrayerType type : getActive()) {
|
||||
player.getConfigManager().set(type.getConfig(), 0);
|
||||
setVarp(player, type.getConfig(), 0, false);
|
||||
}
|
||||
getActive().clear();
|
||||
// Clear the overhead prayer icon a tick later
|
||||
|
||||
@@ -11,6 +11,9 @@ import core.tools.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a prayer type.
|
||||
* @author Vexia
|
||||
@@ -231,7 +234,7 @@ public enum PrayerType {
|
||||
* @return <code>True</code> if toggled.
|
||||
*/
|
||||
public boolean toggle(final Player player, final boolean on) {
|
||||
player.getConfigManager().set(getConfig(), on ? 1 : 0);
|
||||
setVarp(player, getConfig(), on ? 1 : 0);
|
||||
if (on) {
|
||||
flag(player, this);
|
||||
player.getPrayer().getActive().add(this);
|
||||
|
||||
@@ -129,7 +129,6 @@ public abstract class Quest implements Plugin<Object> {
|
||||
player.getQuestRepository().setStage(this, 100);
|
||||
player.getQuestRepository().incrementPoints(getQuestPoints());
|
||||
player.getQuestRepository().syncronizeTab(player);
|
||||
player.getConfigManager().set(101, player.getQuestRepository().getPoints());
|
||||
player.getInterfaceManager().open(new Component(277));
|
||||
player.getPacketDispatch().sendString("" + player.getQuestRepository().getPoints() + "", 277, 7);
|
||||
player.getPacketDispatch().sendString("You have completed the " + getName() + " Quest!", 277, 4);
|
||||
|
||||
@@ -12,6 +12,8 @@ import java.util.TreeMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static core.api.ContentAPIKt.log;
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Manages the systems/players quest repository.
|
||||
@@ -68,25 +70,13 @@ public final class QuestRepository {
|
||||
* @param player The player.
|
||||
*/
|
||||
public void syncronizeTab(Player player) {
|
||||
player.getConfigManager().set(101, points);
|
||||
setVarp(player, 101, points);
|
||||
int[] config = null;
|
||||
if(!player.getAttribute("quest-varps-converted",false)) {
|
||||
for (Quest quest : QUESTS.values()) {
|
||||
config = quest.getConfig(player, getStage(quest));
|
||||
player.varpManager.get(config[0]).setVarbit(0,config[1]).send(player);
|
||||
player.varpManager.flagSave(config[0], false);
|
||||
player.setAttribute("/save:quest-varps-converted",true);
|
||||
|
||||
}
|
||||
} else {
|
||||
for(Quest quest : QUESTS.values()){
|
||||
if(quest.getIndex() == 81 && quest.isCompleted(player)){
|
||||
player.varpManager.get(534).setVarbit(15,2).setVarbit(18,2).setVarbit(21,2).setVarbit(24,2).setVarbit(12,2).send(player);
|
||||
}
|
||||
config = quest.getConfig(player,getStage(quest));
|
||||
player.varpManager.get(config[0]).setVarbit(0,config[1]).send(player);
|
||||
quest.updateVarps(player);
|
||||
}
|
||||
for(Quest quest : QUESTS.values()){
|
||||
config = quest.getConfig(player,getStage(quest));
|
||||
|
||||
setVarp(player, config[0], config[1]);
|
||||
quest.updateVarps(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ import core.game.world.update.flag.context.Graphics;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the class used to handle the assist requesting of a {@link Player}
|
||||
* .
|
||||
@@ -243,8 +246,8 @@ public final class AssistSession extends Pulse implements RequestModule {
|
||||
message = "You've earned the maximum XP from the Assist System within a 24-hour period. You can assist again in " + getTimeLeft() + ".";
|
||||
}
|
||||
player.getPacketDispatch().sendString(message, 301, 10);
|
||||
player.getConfigManager().set(1087, value);
|
||||
player.getConfigManager().set(1088, (int) totalXp * 10);
|
||||
setVarp(player, 1087, value);
|
||||
setVarp(player, 1088, (int) totalXp * 10);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -466,4 +469,4 @@ public final class AssistSession extends Pulse implements RequestModule {
|
||||
this.partener = partener;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -8,6 +8,9 @@ import core.net.packet.PacketRepository;
|
||||
import core.net.packet.context.ContainerContext;
|
||||
import core.net.packet.out.ContainerPacket;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the close event invoked at the closing of a trade interface.
|
||||
* @author Vexia
|
||||
@@ -59,8 +62,8 @@ public final class TradeCloseEvent implements CloseEvent {
|
||||
* @param player the player.
|
||||
*/
|
||||
private void end(final Player player) {
|
||||
player.getConfigManager().set(1043, 0);
|
||||
player.getConfigManager().set(1042, 0);
|
||||
setVarp(player, 1043, 0);
|
||||
setVarp(player, 1042, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,4 +79,4 @@ public final class TradeCloseEvent implements CloseEvent {
|
||||
player.getInventory().addAll(module.getContainer());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import core.game.node.item.Item
|
||||
import core.game.bots.AIRepository
|
||||
import content.global.bots.DoublingMoney
|
||||
import core.game.node.entity.player.info.PlayerMonitor
|
||||
import core.api.*
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
|
||||
@@ -166,10 +167,10 @@ class TradeModule
|
||||
if (stage == 0) {
|
||||
// Main interface
|
||||
if (otherModified) {
|
||||
player!!.configManager[1043] = 1
|
||||
setVarp(player!!, 1043, 1)
|
||||
}
|
||||
if (isModified) {
|
||||
player!!.configManager[1042] = 1
|
||||
setVarp(player!!, 1042, 1)
|
||||
}
|
||||
} else {
|
||||
// Accept interface
|
||||
@@ -511,4 +512,4 @@ class TradeModule
|
||||
init {
|
||||
container = TradeContainer(player)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ import core.net.packet.PacketRepository;
|
||||
import core.net.packet.context.MusicContext;
|
||||
import core.net.packet.out.MusicPacket;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a leveling up reward.
|
||||
* @author Emperor
|
||||
@@ -165,7 +168,7 @@ public final class LevelUp {
|
||||
}
|
||||
value |= player.getSkills().getCombatMilestone() << 23; //Combat level milestone index.
|
||||
value |= player.getSkills().getSkillMilestone() << 27; //Total level milestone index
|
||||
player.getConfigManager().set(1230, value);
|
||||
setVarp(player, 1230, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +187,7 @@ public final class LevelUp {
|
||||
value |= SKILL_ICON[slot];
|
||||
player.getInterfaceManager().openChatbox(new Component(740));
|
||||
}
|
||||
player.getConfigManager().set(1179, value);
|
||||
setVarp(player, 1179, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,4 +196,4 @@ public final class LevelUp {
|
||||
public static int[] getSkillcapes() {
|
||||
return SKILLCAPES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
/**
|
||||
* Represents a scenery.
|
||||
@@ -232,10 +233,10 @@ public class Scenery extends Node {
|
||||
if (def.getVarbitID() > -1) {
|
||||
VarbitDefinition config = def.getConfigFile();
|
||||
if (config != null) {
|
||||
player.varpManager.get(config.getVarpId()).setVarbit(config.getStartBit(),index).send(player);
|
||||
setVarbit(player, def.getVarbitID(), index);
|
||||
}
|
||||
} else if (def.getConfigId() > -1) {
|
||||
player.varpManager.get(def.getConfigId()).setVarbit(0,index);
|
||||
setVarp(player, def.getConfigId(), index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ class VisualCommand : CommandPlugin() {
|
||||
var shift = 0
|
||||
override fun pulse(): Boolean {
|
||||
for(i in 0..1999){
|
||||
player?.configManager?.forceSet(i, pos shl shift, false)
|
||||
setVarp(player!!, i, pos shl shift)
|
||||
}
|
||||
player?.sendMessage("$pos shl $shift")
|
||||
if(pos++ >= 63){
|
||||
@@ -246,34 +246,13 @@ class VisualCommand : CommandPlugin() {
|
||||
submitWorldPulse(object : Pulse(3, player) {
|
||||
var pos = 0
|
||||
override fun pulse(): Boolean {
|
||||
player?.configManager?.forceSet(cfg_index, value shl pos, false)
|
||||
setVarp(player!!, cfg_index, value shl pos)
|
||||
player?.sendMessage("$pos")
|
||||
return pos++ >= 32
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
"setbit" -> {
|
||||
if (args!!.size < 2) {
|
||||
player!!.debug("syntax error: bit value")
|
||||
return true
|
||||
}
|
||||
var bit = toInteger(args[0]!!)
|
||||
var value = toInteger(args[1]!!)
|
||||
var val2 = toInteger(args[2]!!)
|
||||
player!!.debug("$value $val2")
|
||||
PacketRepository.send(Varbit::class.java, VarbitContext(player, value, val2))
|
||||
return true
|
||||
}
|
||||
"setbits" -> {
|
||||
args ?: return false
|
||||
val start = toInteger(args[1]!!)
|
||||
val end = toInteger(args[2]!!)
|
||||
val value = toInteger(args[3]!!)
|
||||
for(i in start until end){
|
||||
player?.varpManager?.setVarbit(i, value)
|
||||
}
|
||||
}
|
||||
"loop_anim_on_i" -> {
|
||||
var anim = toInteger(args!![1]!!)
|
||||
submitWorldPulse(object : Pulse(3){
|
||||
@@ -342,7 +321,7 @@ class VisualCommand : CommandPlugin() {
|
||||
val value = toInteger(args[3]!!)
|
||||
var i = toInteger(args[1]!!)
|
||||
while (i < toInteger(args[2]!!)) {
|
||||
player!!.configManager[i] = value
|
||||
setVarp(player!!, i, value)
|
||||
i++
|
||||
}
|
||||
return true
|
||||
@@ -519,4 +498,4 @@ class VisualCommand : CommandPlugin() {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package core.game.system.command.sets
|
||||
import core.plugin.Initializable
|
||||
import core.game.system.command.Command
|
||||
import core.game.system.command.Privilege
|
||||
import core.api.*
|
||||
|
||||
@Initializable
|
||||
class ConfigCommandSet : CommandSet(Privilege.ADMIN){
|
||||
@@ -18,7 +19,7 @@ class ConfigCommandSet : CommandSet(Privilege.ADMIN){
|
||||
val idlo = args[1].toIntOrNull() ?: reject(player, "INCORRECT ID LOW")
|
||||
val idhi = args[2].toIntOrNull() ?: reject(player, "INCORRECT ID HIGH")
|
||||
for (idsend in (idlo as Int) until (idhi as Int)) {
|
||||
player.configManager.set(idsend, Integer.MAX_VALUE)
|
||||
setVarp(player, idsend, Integer.MAX_VALUE)
|
||||
notify(player,"Config: $idsend value: " + Integer.MAX_VALUE)
|
||||
}
|
||||
}
|
||||
@@ -33,7 +34,7 @@ class ConfigCommandSet : CommandSet(Privilege.ADMIN){
|
||||
val idlo = args[1].toIntOrNull() ?: reject(player, "INCORRECT ID LOW")
|
||||
val idhi = args[2].toIntOrNull() ?: reject(player, "INCORRECT ID HIGH")
|
||||
for (idsend in (idlo as Int) until (idhi as Int)) {
|
||||
player.configManager.set(idsend, 0)
|
||||
setVarp(player, idsend, 0)
|
||||
notify(player,"Config: $idsend value: 0")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){
|
||||
}
|
||||
val configID = args[1].toString().toInt()
|
||||
val configValue = args[2].toString().toInt()
|
||||
player.configManager.forceSet(configID,configValue,false)
|
||||
setVarp(player, configID, configValue)
|
||||
}
|
||||
|
||||
define("getobjectvarp"){player,args ->
|
||||
@@ -474,77 +474,7 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){
|
||||
val varbitID = args[1].toInt()
|
||||
notify(player, "${varbitID}: ${VarbitDefinition.forId(varbitID)}")
|
||||
}
|
||||
define("togglexp", Privilege.STANDARD){ player, args ->
|
||||
val enabled = player.varpManager.get(2501).getVarbit(0) == 1
|
||||
player.varpManager.get(2501).setVarbit(0,if(enabled) 0 else 1).send(player)
|
||||
notify(player, "XP drops are now " + colorize("%R" + if(!enabled) "ON." else "OFF."))
|
||||
player.varpManager.flagSave(2501)
|
||||
}
|
||||
|
||||
define("xpconfig", Privilege.STANDARD){ player, args ->
|
||||
if(args.size < 3){
|
||||
reject(player,"Usage: ::xpconfig track|mode type",
|
||||
"Track types: total|recent",
|
||||
"Mode types: instant|increment",
|
||||
"Defaults: track - total, mode - increment")
|
||||
}
|
||||
|
||||
when(args[1]){
|
||||
"track" -> when(args[2]){
|
||||
"total" -> {
|
||||
player.varpManager.get(2501).setVarbit(2,0).send(player)
|
||||
notify(player,"You are now tracking " + colorize("%RTOTAL") + " experience.")
|
||||
}
|
||||
"recent" -> {
|
||||
player.varpManager.get(2501).setVarbit(2,1).send(player)
|
||||
notify(player,"You are now tracking the " + colorize("%RMOST RECENT") + " skill's experience.")
|
||||
}
|
||||
else -> {
|
||||
reject(player,"Usage: ::xpconfig track|mode type")
|
||||
reject(player,"Track types: total|recent")
|
||||
reject(player, "Mode types: instant|increment")
|
||||
reject(player,"Defaults: track - total, mode - increment")
|
||||
}
|
||||
}
|
||||
|
||||
"mode" -> {
|
||||
when(args[2]){
|
||||
"instant" -> {
|
||||
player.varpManager.get(2501).setVarbit(1,1).send(player)
|
||||
notify(player,"Your xp tracker now updates " + colorize("%RINSTANTLY") + ".")
|
||||
}
|
||||
"increment" -> {
|
||||
player.varpManager.get(2501).setVarbit(1,0).send(player)
|
||||
notify(player,"Your xp tracker now updates " + colorize("%RINCREMENTALLY") + ".")
|
||||
}
|
||||
else -> {
|
||||
reject(player,"Usage: ::xpconfig track|mode type")
|
||||
reject(player,"Track types: total|recent")
|
||||
reject(player, "Mode types: instant|increment")
|
||||
reject(player,"Defaults: track - total, mode - increment")
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
reject(player,"Usage: ::xpconfig track|mode type")
|
||||
reject(player,"Track types: total|recent")
|
||||
reject(player, "Mode types: instant|increment")
|
||||
reject(player,"Defaults: track - total, mode - increment")
|
||||
}
|
||||
}
|
||||
player.varpManager.flagSave(2501)
|
||||
}
|
||||
|
||||
define("toggleslayer", Privilege.STANDARD){ player, _ ->
|
||||
val disabled = player.varpManager.get(2502).getVarbit(0) == 1
|
||||
player.varpManager.get(2502).setVarbit(0,if(disabled) 0 else 1).send(player)
|
||||
if(!disabled){
|
||||
player.varpManager.flagSave(2502)
|
||||
} else {
|
||||
player.varpManager.get(2502).save = false
|
||||
}
|
||||
notify(player,"Slayer task tracker is now " + (if(disabled) colorize("%RON") else colorize("%ROFF")) + ".")
|
||||
}
|
||||
|
||||
define("setvarbit", Privilege.ADMIN, "::setvarbit <lt>VARBIT ID<gt> <lt>VALUE<gt>", ""){
|
||||
player,args ->
|
||||
@@ -558,7 +488,15 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){
|
||||
reject(player,"Usage ::setvarbit index offset value")
|
||||
}
|
||||
|
||||
player.varpManager.setVarbit(index!!, value!!)
|
||||
setVarbit(player, index!!, value!!)
|
||||
}
|
||||
|
||||
define("getvarbit", Privilege.ADMIN, "::getvarbit <lt>VARBIT ID<gt>", "") {
|
||||
player, args ->
|
||||
if (args.size != 2)
|
||||
reject(player, "Usage: ::getvarbit id")
|
||||
val index = args[1].toIntOrNull() ?: return@define
|
||||
notify(player, "Varbit $index: Currently ${getVarbit(player, index)}")
|
||||
}
|
||||
|
||||
define("setvarp", Privilege.ADMIN, "::setvarp <lt>VARP ID<gt> <lt>BIT OFFSET<gt> <lt>VALUE<gt>", "Sets the value starting at the BIT OFFSET of the varp."){
|
||||
@@ -574,7 +512,7 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){
|
||||
reject(player,"Usage ::setvarp index offset value")
|
||||
}
|
||||
|
||||
player.varpManager.get(index!!).setVarbit(offset!!, value!!).send(player)
|
||||
setVarp(player, index!!, value!! shl offset!!)
|
||||
}
|
||||
|
||||
define("setvarc", Privilege.ADMIN, "::setvarc <lt>VARC ID<gt> <lt>VALUE<gt>") { player, args ->
|
||||
@@ -621,15 +559,6 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){
|
||||
player.details.credits += 100
|
||||
}
|
||||
|
||||
define("resetgwdropes", Privilege.STANDARD, "", "OLD: Was used for fixing broken data."){ player, _ ->
|
||||
player.varpManager.get(1048).clearBitRange(0,31)
|
||||
player.varpManager.get(1048).send(player)
|
||||
}
|
||||
|
||||
define("resetmistag", Privilege.STANDARD, "", "OLD: Was used for fixing broken data."){ player, _ ->
|
||||
player.removeAttribute("mistag-greeted")
|
||||
}
|
||||
|
||||
define("getnpcparent"){player,args ->
|
||||
if(args.size < 2){
|
||||
reject(player,"Usage: ::getnpcparent npcid")
|
||||
|
||||
@@ -7,6 +7,7 @@ import content.global.skill.slayer.Tasks
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.system.command.Privilege
|
||||
import core.plugin.Initializable
|
||||
import core.api.*
|
||||
|
||||
@Initializable
|
||||
class SlayerCommandSet : CommandSet(Privilege.ADMIN){
|
||||
@@ -50,7 +51,7 @@ class SlayerCommandSet : CommandSet(Privilege.ADMIN){
|
||||
val slayer = SlayerManager.getInstance(player)
|
||||
if (slayer.hasTask()) slayer.task = task else SlayerUtils.assign(player, task, Master.values().random())
|
||||
if (amount != null) slayer.amount = amount
|
||||
player.varpManager.get(2502).setVarbit(0, slayer.flags.taskFlags shr 4).send(player)
|
||||
setVarp(player, 2502, slayer.flags.taskFlags shr 4)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static core.api.ContentAPIKt.log;
|
||||
import static core.api.ContentAPIKt.setVarp;
|
||||
|
||||
/**
|
||||
* Holds communication information.
|
||||
@@ -194,19 +195,19 @@ public final class CommunicationInfo {
|
||||
public void toggleLootshare(final Player player) {
|
||||
if (lootShare) {
|
||||
lootShare = false;
|
||||
player.getConfigManager().set(1083, 0);
|
||||
setVarp(player, 1083, 0);
|
||||
} else if (lootSharePulse != null) {
|
||||
lootSharePulse.stop();
|
||||
lootSharePulse = null;
|
||||
player.getConfigManager().set(1083, 0);
|
||||
setVarp(player, 1083, 0);
|
||||
} else if (!lootShare) {
|
||||
player.getConfigManager().set(1083, 2);
|
||||
setVarp(player, 1083, 2);
|
||||
lootSharePulse = new Pulse(GameWorld.getSettings().isDevMode() ? 5 : 200, player) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
lootShare = true;
|
||||
lootSharePulse = null;
|
||||
player.getConfigManager().set(1083, 1);
|
||||
setVarp(player, 1083, 1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -667,4 +668,4 @@ public final class CommunicationInfo {
|
||||
+ "," + kickRequirement.ordinal()
|
||||
+ "," + lootRequirement.ordinal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import core.game.bots.AIPlayer;
|
||||
|
||||
import static core.api.ContentAPIKt.log;
|
||||
|
||||
@@ -85,6 +86,7 @@ public final class PacketRepository {
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static void send(Class<? extends OutgoingPacket> clazz, Context context) {
|
||||
if(context.getPlayer() instanceof AIPlayer) return;
|
||||
if(context.getPlayer().getSession() == null) return;
|
||||
OutgoingPacket p = OUTGOING_PACKETS.get(clazz);
|
||||
if (p == null) {
|
||||
|
||||
Reference in New Issue
Block a user