public static byte[] giveBuff(int buffid, int bufflength, Map statups, MapleStatEffect effect) { MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue()); // 17 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 07 00 AE E1 3E 00 68 B9 01 00 00 00 00 00 //lhc patch adds an extra int here PacketHelper.writeBuffMask(mplew, statups); boolean stacked = false; boolean skipStacked = false; for (Entry stat : statups.entrySet()) { if (!stat.getKey().canStack()) { //System.out.println("buff : " +stat.getKey() + " position " + stat.getKey().getPosition()); if (stat.getKey() == MapleBuffStat.SPIRIT_LINK || stat.getKey() == MapleBuffStat.SPIRIT_SURGE || stat.getKey() == MapleBuffStat.SHADOWPARTNER || stat.getKey() == MapleBuffStat.CRITICAL_INCREASE) { mplew.writeInt(stat.getValue().intValue()); } else { mplew.writeShort(stat.getValue().intValue()); } mplew.writeInt(buffid); mplew.writeInt(bufflength); } } if (buffid == 13120008) { mplew.writeInt(0); } for (Entry stat : statups.entrySet()) { if (stat.getKey().canStack()) { if (!stacked) { mplew.writeZeroBytes(5); // dark metamorphosis end with byte 5 if (statups.containsKey(MapleBuffStat.DARK_AURA) || statups.containsKey(MapleBuffStat.BLUE_AURA) || statups.containsKey(MapleBuffStat.YELLOW_AURA)) { mplew.write(1); } if (statups.containsKey(MapleBuffStat.BLUE_AURA)) { // position problem :O skipStacked = true; addBuffStatIfNotNull(mplew, statups, buffid, 8000, MapleBuffStat.HP_BOOST); addBuffStatIfNotNull(mplew, statups, buffid, 8000, MapleBuffStat.INDIE_PDD); addBuffStatIfNotNull(mplew, statups, buffid, 8000, MapleBuffStat.INDIE_MDD); } stacked = true; } if (skipStacked) { break; } if (buffid == 36121003 && statups.containsKey(MapleBuffStat.DAMAGE_PERCENT_INCREASE)) { mplew.write(1); } mplew.writeInt(1); mplew.writeInt(buffid); mplew.writeLong(stat.getValue().intValue()); mplew.writeInt(bufflength); } } if (buffid == 27111004 || buffid == 27121005 || buffid == 36111003) { mplew.writeZeroBytes(5); if (buffid == 27111004) { mplew.writeShort(1000); mplew.writeShort(0); } else if (buffid == 27121005) { mplew.writeInt(effect.getX()); mplew.write(0); } else if (buffid == 36111003) { mplew.write(effect.getX()); mplew.writeShort(600); // something mplew.writeShort(0); } mplew.writeShort(1); // delay? } else if (buffid == 13101024 || buffid == 13111023 || buffid == 15111024 || buffid == 13001022 || buffid == 15121004 || buffid == 31121005 || buffid == 41101003 || buffid == 65121004) { if (buffid == 15121004 || buffid == 41101003 || buffid == 65121004) { mplew.writeZeroBytes(5); } mplew.writeInt(0); mplew.write(1); if (buffid == 41101003) { mplew.write(5); } mplew.writeInt(0); } else if (buffid == 15001022) { if (buffid == 15001022 && effect.getY() > 0) { mplew.writeZeroBytes(5); mplew.writeInt(effect.getY()); mplew.writeInt(0); mplew.write(0); mplew.writeInt(0); } } mplew.writeShort(0); if (effect != null && effect.isDivineShield()) { mplew.writeInt(effect.getEnhancedWatk()); } else if (effect != null && effect.getCharColor() > 0) { mplew.writeInt(effect.getCharColor()); } else if (effect != null && effect.isInflation()) { //mplew.writeInt(effect.getInflation()); } mplew.writeShort(0); // delay mplew.writeZeroBytes(50); // hehe mplew.write(1); if (isMovementAffectingStat(statups)) { mplew.write(4); // updatePlayerStats } System.out.println(mplew.toString()); return mplew.getPacket(); }