Untitled
raw download clone
TEXT
views 35
,
size 9886 b
public static byte[] giveBuff(int buffid, int bufflength, Map < MapleBuffStat, Integer > statups, MapleStatEffect effect, MapleCharacter chr) {
            MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
            
            mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
            PacketHelper.writeBuffMask(mplew, statups); //48
            boolean stacked = false;
            boolean isAura = false;
            boolean iscombo = false;
            
            for (Map.Entry < MapleBuffStat, Integer > stat: statups.entrySet()) {
                isAura = GameConstants.isAuraBuff(stat.getKey());
                if (stat.getKey() == MapleBuffStat.COMBO) {
                    iscombo = true;
                }
                if (!stat.getKey().canStack()) {
                    boolean specialBuff = GameConstants.isSpecialBuff(stat.getKey());
                    if (specialBuff) {
                        mplew.writeInt(stat.getValue());
                    } else {
                        mplew.writeShort(stat.getValue());
                    }

                    mplew.writeInt(buffid);
                    if(buffid == 1200014 && stat.getKey() == MapleBuffStat.ElementalCharge){
                       mplew.writeLong(bufflength);
                    }else{
                        mplew.writeInt(bufflength);
                    }
                    if (stat.getKey() == MapleBuffStat.HOLY_SHIELD) {
                        mplew.writeInt(0);
                    }
                    if (stat.getKey() == MapleBuffStat.TEMPEST_BLADES) {
                        System.out.println("Buff Id is " + buffid + "Effect Weapon is " + effect.getWeapon());
                        if (buffid != 61101002 && buffid != 61110211) {
                            mplew.writeZeroBytes(5); //idk
                            mplew.writeInt(buffid == 61121217 ? 4 : 2); //Effect of the Packet (Visual)
                            mplew.writeInt(5); //Number of Swords
                            mplew.writeInt(effect.getWeapon()); //Weapon Looks added to the Packet obviously
                            mplew.writeInt(5); // AttackCount
                            mplew.writeZeroBytes(24);
                        } else {
                            mplew.writeZeroBytes(5); //idk
                            mplew.writeInt(buffid == 61110211 ? 3 : 1); //Effect of the Packet (Visual)
                            mplew.writeInt(3); //Number of Swords
                            mplew.writeInt(effect.getWeapon()); //Weapon Looks added to the Packet obviously
                            mplew.writeInt(3); // AttackCount
                            mplew.writeZeroBytes(16);
                        }
                    }
                }
            }
            for (Map.Entry < MapleBuffStat, Integer > stat: statups.entrySet()) {
                if (stat.getKey().canStack()) {
                    if (!stacked) {
                        mplew.writeZeroBytes(5);
                        mplew.writeZeroBytes(4); //new v143?
                        if (GameConstants.isSpecialStackBuff(stat.getKey())) {
                            mplew.writeZeroBytes(1); //not sure where this part comes
                        }
                        stacked = true;
                    }
                    mplew.writeInt(1); //amount of the same buffstat
                    //for each of the same buffstats:
                    mplew.writeInt(buffid);
                    mplew.writeInt(stat.getValue());
                    mplew.writeInt(Integer.MAX_VALUE); //some kind of time
                    mplew.writeInt(0);
                    mplew.writeInt(bufflength);
                    if (stat.getKey() == MapleBuffStat.DAMAGE_CAP_INCREASE) {
                        mplew.writeInt(1000);
                    }
                }
            }
            
            if (buffid == 24121004) { // Priere D'Aria
                mplew.writeZeroBytes(3);
                mplew.writeShort(0);
                mplew.write(0);
            }
            if (buffid == 2321054 || buffid == 2121054  || buffid == 2221054 || buffid == 41121002) {
                mplew.writeInt(1);
            }
            if(buffid == 15001022){
                mplew.writeInt(0);
                mplew.writeInt(chr.LightningElementalStack * 300);
            }

            /*if(buffid == 4221013){
                mplew.writeInt(0);
                mplew.writeInt(5);
                mplew.writeZeroBytes(69);
            }*/
            if (buffid == 32001003 || buffid == 32120013 /*|| buffid == 32101003*/ || buffid == 32120014 /*|| buffid == 32111012*/ || buffid == 32120015 || buffid == 36121003 || buffid == 11101022 || buffid == 11111022 || buffid == 2311012 || buffid == 100001263 || buffid == 100001264) {
                mplew.write(1);
            }
            /*if (buffid == 1200014) {
                MapleStatEffect AdvancedCharge = chr.getEffect(1220010);
                MapleStatEffect RealEffect = AdvancedCharge != null ? chr.getEffect(1220010) : chr.getEffect(1200014);
                mplew.write(chr.GetCount()); // m
                mplew.writeShort(chr.GetCount() * RealEffect.getW() / 2); // w
                mplew.write(chr.GetCount() * RealEffect.getY()); // u
                mplew.write(chr.GetCount() * RealEffect.getU()); // z
                //return mplew.getPacket();
            } */
            if (buffid == 1200014) {
                MapleStatEffect AdvancedCharge = chr.getEffect(1220010);
                MapleStatEffect RealEffect = AdvancedCharge != null ? chr.getEffect(1220010) : chr.getEffect(1200014);
                mplew.write(1);
                mplew.write(chr.GetCount());
                mplew.writeShort(chr.GetCount() * RealEffect.getY());
                mplew.writeZeroBytes(69);
                return mplew.getPacket();
                } 

            if (!isAura) {
                mplew.writeShort(0);
                if (effect != null) {
                    if (effect.isDivineShield()) {
                        mplew.writeInt(effect.getEnhancedWatk());
                    } else if (effect.getCharColor() > 0) {
                        mplew.writeInt(effect.getCharColor());
                    } else if (effect.isInflation()) {
                        mplew.writeInt(effect.getInflation());
                    }
                }
            }
            int CrescendoCount = GameConstants.getDarkCrescendoCount(chr.acaneAim);
            mplew.writeShort(0);

            if (buffid == 32110000 || buffid == 32111012 || buffid == 2221054 || buffid == 11101022 || buffid == 11111022 || buffid == 2311012) {
                mplew.write(1);
            } 
            //if (buffid == 27121005) {
                //MapleStatEffect DarkCrescendo = chr.getEffect(27121005);
                //mplew.writeInt(0);
                //mplew.write(DarkCrescendo.getX());
            //} 
            if (buffid == 31211004) { // Recovery
                mplew.writeInt(effect.getDuration());
                JobPacket.AvengerPacket.cancelExceed();
                CWvsContext.enableActions();
            }
            if (buffid == 27110007) {
                mplew.write(0);
                mplew.writeShort(25);
            }
            if (buffid == 27101202) {
                mplew.writeZeroBytes(10);
            }
            if (iscombo) {
                mplew.writeShort(258);
                mplew.writeShort(600);
            } else {
                mplew.write(0);
                mplew.write((effect != null) && (effect.isShadow()) ? 1 : 2);
            }
            if (isAura) {
                mplew.writeInt(0);
            }
            if ((statups.containsKey(MapleBuffStat.JUMP)) || (statups.containsKey(MapleBuffStat.SPEED)) || (statups.containsKey(MapleBuffStat.MORPH)) || (statups.containsKey(MapleBuffStat.GHOST_MORPH)) /*|| (statups.containsKey(MapleBuffStat.MAPLE_WARRIOR))*/ || (statups.containsKey(MapleBuffStat.MONSTER_RIDING)) || (statups.containsKey(MapleBuffStat.DASH_SPEED)) || (statups.containsKey(MapleBuffStat.DASH_JUMP)) || (statups.containsKey(MapleBuffStat.SOARING)) || (statups.containsKey(MapleBuffStat.YELLOW_AURA)) || (statups.containsKey(MapleBuffStat.SNATCH)) || (statups.containsKey(MapleBuffStat.IndieSpeed)) || (statups.containsKey(MapleBuffStat.IndieJump)) || (statups.containsKey(MapleBuffStat.ENERGY_CHARGE)) || (statups.containsKey(MapleBuffStat.MECH_CHANGE))) {
                mplew.write(4);
            }
            if (buffid == 23111004) { //ignis roar
                mplew.write(0);
                mplew.writeShort(1000);
            } else {
                mplew.writeShort(0);

            }
            if (statups.containsKey(MapleBuffStat.MAPLE_WARRIOR)) {
                mplew.write(HexTool.getByteArrayFromHexString("00 E8 03 00 00 00 13 00 00 00 00"));
                return mplew.getPacket();
            }
            if (statups.containsKey(MapleBuffStat.KAISER_COMBO)) { //this too
                mplew.writeZeroBytes(8);
            }
            if(buffid == 27121005){
                System.out.println("tools.packet.CWvsContext.BuffPacket.giveBuff() " + CrescendoCount);
                mplew.writeInt(CrescendoCount);
            }   
            mplew.writeZeroBytes(69); //make sure no dc incase not enough length

            //new v142
            mplew.writeShort(1);
            mplew.write(0);
            mplew.write(0);
            mplew.write(0);
            //System.err.println("sent Buff with buffid: " + buffid + "  as packet: " + mplew.toString());
            return mplew.getPacket();
        }
close fullscreen
Login or Register to edit or fork this paste. It's free.