Initial commit
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
@Packet name MainPlayer
|
||||
@Packet identifier 128
|
||||
@Description Sends the connected main player's data
|
||||
@Data pId,
|
||||
@Structure -
|
||||
*/
|
||||
|
||||
module.exports = function (data) {
|
||||
// const guildTag = data.guildTag;
|
||||
const packetLength = 52 + 1; // (guildTag ? 51 : 48) + 1;
|
||||
const buffer = new ArrayBuffer(packetLength);
|
||||
const view = new DataView(buffer);
|
||||
|
||||
view.setUint8(0, 128);
|
||||
view.setUint8(1, packetLength);
|
||||
view.setUint32(2, data.id);
|
||||
view.setUint32(6, data.hp.current);
|
||||
view.setUint32(10, data.hp.maximum);
|
||||
view.setUint16(14, data.position.x);
|
||||
view.setUint16(16, data.position.y);
|
||||
view.setUint16(18, data.speed);
|
||||
view.setUint8(20, data.mapID);
|
||||
view.setUint16(21, data.textureID);
|
||||
view.setUint16(23, data.harpoonerRange);
|
||||
view.setUint16(25, data.cannonRange)
|
||||
view.setUint8(27, +data.isSpeedLowered)
|
||||
view.setUint8(28, +data.isRepairing)
|
||||
view.setUint16(29, data.pirateLevel);
|
||||
view.setUint16(31, data.eliteLevel);
|
||||
view.setUint16(33, data.fishingLevel);
|
||||
view.setUint8(35, data.globalRank);
|
||||
view.setUint8(36, data.levelRank);
|
||||
|
||||
const nameBuffer = Buffer.from(data.name);
|
||||
for (const pair of nameBuffer.entries()) {
|
||||
const index = pair[0];
|
||||
view.setUint8(37 + index, pair[1]);
|
||||
};
|
||||
|
||||
/*
|
||||
if (guildTag) {
|
||||
const guildBuffer = Buffer.from(guildTag);
|
||||
for (const pair of guildBuffer.entries()) {
|
||||
const index = pair[0];
|
||||
view.setUint8(49 + index, pair[1]);
|
||||
};
|
||||
};
|
||||
*/
|
||||
|
||||
return buffer;
|
||||
};
|
||||
Reference in New Issue
Block a user