Initial commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
@Packet name Harpoons
|
||||
@Packet identifier 154
|
||||
@Description Sends the
|
||||
@Data pId, (harpoonId, damage, amount), selectedHarpoon
|
||||
@Structure -
|
||||
*/
|
||||
|
||||
module.exports = function (data) {
|
||||
const { harpoon, selected } = data;
|
||||
|
||||
const packetLength = harpoon.length * 6 + 2 + 1;
|
||||
const buffer = new ArrayBuffer(packetLength);
|
||||
const view = new DataView(buffer);
|
||||
|
||||
view.setUint8(0, 154);
|
||||
view.setUint8(1, packetLength);
|
||||
|
||||
for (let i = 0; i < harpoon.length; i++) {
|
||||
const harp = harpoon[i];
|
||||
|
||||
view.setUint8(i * 6 + 2, harp.id);
|
||||
view.setUint8(i * 6 + 3, 0);
|
||||
view.setUint32(i * 6 + 4, harp.amount);
|
||||
};
|
||||
|
||||
view.setUint8(2 + harpoon.length * 6, selected);
|
||||
|
||||
return buffer;
|
||||
};
|
||||
Reference in New Issue
Block a user