[Add-On]Auto-Assign Button Fix

Newbie Spellweaver
Joined
Aug 13, 2009
Messages
76
Reaction score
20
For the people who's Auto-Assign button is not working:

net.channel.handler "AutoAssignHandler.java"
Code:
package net.channel.handler;

import client.MapleCharacter;
import client.MapleClient;
import client.MapleStat;
import net.AbstractMaplePacketHandler;
import tools.MaplePacketCreator;
import tools.data.input.SeekableLittleEndianAccessor;

public class AutoAssignHandler extends AbstractMaplePacketHandler {

    public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
        MapleCharacter chr = c.getPlayer();
        slea.skip(8);
        if (chr.getRemainingAp() < 1) {
            return;
        }
        int total = 0;
        int extras = 0;
        for (int i = 0; i < 2; i++) {
            int type = slea.readInt();
            int tempVal = slea.readInt();
            if (tempVal < 0 || tempVal > c.getPlayer().getRemainingAp()) {
                return;
            }
            total += tempVal;
            extras += gainStatByType(chr, MapleStat.getBy5ByteEncoding(type), tempVal);
        }
        int remainingAp = (chr.getRemainingAp() - total) + extras;
        chr.setRemainingAp(remainingAp);
        chr.updateSingleStat(MapleStat.AVAILABLEAP, remainingAp);
        c.announce(MaplePacketCreator.enableActions());
    }

    private int gainStatByType(MapleCharacter chr, MapleStat type, int gain) {
        int newVal = 0;
        if (type.equals(MapleStat.STR)) {
            newVal = chr.getStr() + gain;
            if (newVal > 999) {
                chr.setStr(999);
            } else {
                chr.setStr(newVal);
            }
        } else if (type.equals(MapleStat.INT)) {
            newVal = chr.getInt() + gain;
            if (newVal > 999) {
                chr.setInt(999);
            } else {
                chr.setInt(newVal);
            }
        } else if (type.equals(MapleStat.LUK)) {
            newVal = chr.getLuk() + gain;
            if (newVal > 999) {
                chr.setLuk(999);
            } else {
                chr.setLuk(newVal);
            }
        } else if (type.equals(MapleStat.DEX)) {
            newVal = chr.getDex() + gain;
            if (newVal > 999) {
                chr.setDex(999);
            } else {
                chr.setDex(newVal);
            }
        }
        if (newVal > 999) {
            chr.updateSingleStat(type, 999);
            return newVal - 999;
        }
        chr.updateSingleStat(type, newVal);
        return 0;
    }
}
client "MapleStat.java" add:
Code:
    public static MapleStat getBy5ByteEncoding(int encoded) {
        switch (encoded) {
            case 64:
                return STR;
            case 128:
                return DEX;
            case 256:
                return INT;
            case 512:
                return LUK;
        }
        return null;
    }
client "MapleStat.java" add:
Code:
    public void announce(MaplePacket packet) {
        session.write(packet);
    }
Credits goes to "Kevin" from "MoopleDev" and Me
 
Last edited:
Please use proper tags when posting a thread. The acceptable tags can be found in the section guidelines. Also, prefixes are not needed and should not be used. They clash with the tags and makes the section look sloppy. Other than that, thanks for the contribution.
 
if you are not using moople you use c.getSession().write(MaplePacketCreator.enableActions()); instead of
c.announce(MaplePacketCreator.enableActions());
right?
 
he has no problem he is stating the fact that hasnt been publicly released because some sources/repacks already have it and your just releasing what the community already has.
 
he has no problem he is stating the fact that hasnt been publicly released because some sources/repacks already have it and your just releasing what the community already has.

He's not.. not saying that clever guy:glare:
Anyways i think iy would be really handy for a few sources (like mapleblade)
 
Last edited:
Back