Added + handled varbit packet
This commit is contained in:
@@ -77,6 +77,7 @@ public final class PacketRepository {
|
||||
OUTGOING_PACKETS.put(UpdateRandomFile.class, new UpdateRandomFile()); //
|
||||
OUTGOING_PACKETS.put(InstancedLocationUpdate.class, new InstancedLocationUpdate()); //
|
||||
OUTGOING_PACKETS.put(CSConfigPacket.class, new CSConfigPacket()); //
|
||||
OUTGOING_PACKETS.put(Varbit.class, new Varbit());
|
||||
INCOMING_PACKETS.put(22, new ClientFocusPacket());
|
||||
INCOMING_PACKETS.put(93, new PingPacketHandler());
|
||||
INCOMING_PACKETS.put(44, new CommandPacket());
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package core.net.packet.context;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.net.packet.Context;
|
||||
|
||||
public class VarbitContext implements Context {
|
||||
|
||||
Player player;
|
||||
public int varbitId;
|
||||
public int value;
|
||||
|
||||
public VarbitContext(Player player, int varbitId, int value){
|
||||
this.player = player;
|
||||
this.varbitId = varbitId;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
@@ -266,6 +266,7 @@ public final class InteractionPacket implements IncomingPacket {
|
||||
player.debug("dir=" + object.getDirection());
|
||||
VarbitDefinition def = VarbitDefinition.forObjectID(SceneryDefinition.forId(objectId).getVarbitID());
|
||||
player.debug("Varp ID=" + def.getConfigId() + " Offset=" + def.getBitShift() + " Size=" + def.getBitSize());
|
||||
player.debug("Varbit: " + def.getId());
|
||||
if (option.getHandler() != null) {
|
||||
player.debug("Object handler: " + option.getHandler().getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package core.net.packet.out;
|
||||
|
||||
import core.net.packet.IoBuffer;
|
||||
import core.net.packet.OutgoingPacket;
|
||||
import core.net.packet.context.VarbitContext;
|
||||
|
||||
public class Varbit implements OutgoingPacket<VarbitContext> {
|
||||
@Override
|
||||
public void send(VarbitContext varbitContext) {
|
||||
IoBuffer buffer = new IoBuffer(37);
|
||||
buffer.put((byte) varbitContext.value);
|
||||
buffer.putLEShort(varbitContext.varbitId);
|
||||
varbitContext.getPlayer().getSession().write(buffer);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package rs09.game
|
||||
|
||||
import core.cache.def.impl.VarbitDefinition
|
||||
import core.game.node.entity.player.Player
|
||||
import core.net.packet.PacketRepository
|
||||
import core.net.packet.context.VarbitContext
|
||||
import org.json.simple.JSONArray
|
||||
import org.json.simple.JSONObject
|
||||
import rs09.game.node.entity.skill.farming.FarmingPatch
|
||||
@@ -32,6 +34,10 @@ class VarpManager(val player: Player) {
|
||||
get(def.configId).setVarbit(def.bitShift,value).send(player)
|
||||
}
|
||||
|
||||
fun setVarbit(varbitIndex: Int, value: Int){
|
||||
PacketRepository.send(core.net.packet.out.Varbit::class.java, VarbitContext(player, varbitIndex, value))
|
||||
}
|
||||
|
||||
fun flagSave(index: Int){
|
||||
get(index).save = true
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ import core.game.world.map.Location
|
||||
import core.game.world.map.RegionManager
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import core.net.packet.PacketRepository
|
||||
import core.net.packet.context.VarbitContext
|
||||
import core.net.packet.out.Varbit
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import rs09.game.system.command.CommandPlugin
|
||||
@@ -221,14 +224,14 @@ class VisualCommand : CommandPlugin() {
|
||||
val cfg_index = (args.getOrNull(2)?.toString()?.toInt() ?: -1)
|
||||
if(cfg_index == -1){
|
||||
ContentAPI.submitWorldPulse(object : Pulse(3, player){
|
||||
var pos = 0
|
||||
var pos = 32
|
||||
var shift = 0
|
||||
override fun pulse(): Boolean {
|
||||
for(i in 0..1999){
|
||||
player?.configManager?.forceSet(i, pos shl shift, false)
|
||||
}
|
||||
player?.sendMessage("$pos << $shift")
|
||||
if(pos++ >= 32){
|
||||
player?.sendMessage("$pos shl $shift")
|
||||
if(pos++ >= 63){
|
||||
shift += 4
|
||||
pos = 0
|
||||
}
|
||||
@@ -246,6 +249,18 @@ class VisualCommand : CommandPlugin() {
|
||||
})
|
||||
}
|
||||
}
|
||||
"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
|
||||
}
|
||||
"loop_anim_on_i" -> {
|
||||
var anim = toInteger(args!![1]!!)
|
||||
ContentAPI.submitWorldPulse(object : Pulse(3){
|
||||
|
||||
Reference in New Issue
Block a user