Skip to content

Instantly share code, notes, and snippets.

@pjmagee
Created December 22, 2012 00:48
Show Gist options
  • Select an option

  • Save pjmagee/4356836 to your computer and use it in GitHub Desktop.

Select an option

Save pjmagee/4356836 to your computer and use it in GitHub Desktop.
Creo6
protected static byte[] buildBaselineCREO6(Player player)
throws IOException {
int[] iCurrentHam = player.getCurrentHam();
int[] iMaxHam = player.getMaxHam();
int[] hamMods = player.getHamModifiers();
if (hamMods == null) {
hamMods = new int[iMaxHam.length];
for (int i = 0; i < hamMods.length; i++) {
hamMods[i] = 0;
}
player.setHamModifiers(hamMods);
}
String sMoodString = player.getMoodString();
String sPerformanceString = player.getPerformanceString();
int PacketSize = 100 + iCurrentHam.length * 4 + iMaxHam.length * 4;
if (sMoodString != null) {
PacketSize += sMoodString.length();
}
if (sPerformanceString != null) {
PacketSize += sPerformanceString.length();
}
Vector<TangibleItem> vEquippedItems = player.getEquippedItems();
if (vEquippedItems != null) {
for (int i = 0; i < vEquippedItems.size(); i++) {
TangibleItem t = vEquippedItems.elementAt(i);
if (t == null) {
vEquippedItems.remove(i);
} else {
byte[] customData = t.getCustomData();
if (customData != null) {
PacketSize += customData.length;
}
PacketSize += 18;
}
}
}
SOEOutputStream dOut = new SOEOutputStream(new ByteArrayOutputStream());
dOut.setOpcode(Constants.SOE_CHL_DATA_A);
dOut.setSequence(0);
dOut.setUpdateType(Constants.OBJECT_UPDATE);
dOut.writeInt(Constants.BaselinesMessage);
dOut.writeLong(player.getID());
dOut.writeInt(Constants.BaselinesTypes[Constants.BASELINES_CREO]);
dOut.writeByte(6);
dOut.writeInt(PacketSize);
dOut.writeShort(0x16); // Operand count
// Note: The vID count in the Creo6 baseline is wrong, since there's
// only 0x11 variables, yet we tell it there's 0x16.
// vID 0
dOut.writeInt(0x3D); // Unknown -- Core 3 == 0x3D
// TODO: Implement Defender List!!!
// opreand 1 0x01
dOut.writeInt(0); // Defender list. Probably just a list of longs?
dOut.writeInt(0);
// operand 2 0x02
if (player instanceof Player && !(player instanceof NPC)) {
dOut.writeShort(100);
} else {
dOut.writeShort(player.getConLevel());
}
// operand 3 0x03
dOut.writeUTF(player.getPerformanceString()); // This should be null if
// not performing any
// music/song.
// operand 4 0x04
dOut.writeUTF(player.getMoodString()); // This should be "none" if not
// having a mood.
// operand 5 0x05
Weapon w = player.getWeapon();
if (w != null) {
dOut.writeLong(w.getID());
} else {
dOut.writeLong(0);
}
// operand 5 0x05
dOut.writeLong(player.getGroupID()); // group id
// operand 6 0x06
dOut.writeLong(player.getGroupHost()); // Invite Sender's ID.
// operand 7 0x07
dOut.writeLong(player.getGroupInviteCounter(false)); // New group invite
// counter.
// operand 8 0x08
dOut.writeInt(0); // Guild ID.
// operand 9 0x09
dOut.writeLong(player.getTargetID()); // Target ID.
// operand 10 0x0A
dOut.writeByte(player.getMoodID());
// operand 11 0x0B
dOut.writeInt(player.getIPerformanceID()); // Performance ID
// operand 12 0x0C
dOut.writeInt(player.getSongID()); // song ID
// operand 13 0x0D
dOut.writeInt(iCurrentHam.length);
dOut.writeInt(player.getCurrentHamUpdateCounter(false));
for (int i = 0; i < iCurrentHam.length; i++) {
dOut.writeInt(iCurrentHam[i]);
}
// operand 14 0x0E
dOut.writeInt(iMaxHam.length);
dOut.writeInt(player.getHamModifiersUpdateCount(false));
for (int i = 0; i < iMaxHam.length; i++) {
dOut.writeInt(iMaxHam[i] + hamMods[i]);
} // 0x0E
// operand 15 0x0F
if (vEquippedItems == null) {
dOut.writeLong(0);
} else {
dOut.writeInt(vEquippedItems.size());
dOut.writeInt(player.getEquippedItemUpdateCount(false));
// EQUIPMENT LIST
for (int i = 0; i < vEquippedItems.size(); i++) {
TangibleItem item = vEquippedItems.elementAt(i);
byte[] customizationData = item.getCustomData();
if (customizationData != null) {
dOut.writeShort(customizationData.length);
dOut.write(customizationData);
} else {
dOut.writeShort(0);
}
dOut.writeInt(item.getEquippedStatus());
dOut.writeLong(item.getID());
dOut.writeInt(item.getCRC());
}
}
// operand 16 0x10
dOut.writeUTF(""); // ModModelIFF
// operand 17 0x11
dOut.writeBoolean(player.getC60X11()); // is performing bool ????
return dOut.getBuffer();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment