Search in sources :

Example 1 with RelativeLifeMovement

use of server.movement.RelativeLifeMovement in project HeavenMS by ronancpl.

the class AbstractMovementPacketHandler method parseMovement.

protected List<LifeMovementFragment> parseMovement(LittleEndianAccessor lea) {
    List<LifeMovementFragment> res = new ArrayList<>();
    byte numCommands = lea.readByte();
    for (byte i = 0; i < numCommands; i++) {
        byte command = lea.readByte();
        switch(command) {
            // normal move
            case 0:
            case 5:
            case 17:
                {
                    // Float
                    short xpos = lea.readShort();
                    short ypos = lea.readShort();
                    short xwobble = lea.readShort();
                    short ywobble = lea.readShort();
                    short unk = lea.readShort();
                    byte newstate = lea.readByte();
                    short duration = lea.readShort();
                    AbsoluteLifeMovement alm = new AbsoluteLifeMovement(command, new Point(xpos, ypos), duration, newstate);
                    alm.setUnk(unk);
                    alm.setPixelsPerSecond(new Point(xwobble, ywobble));
                    res.add(alm);
                    break;
                }
            case 1:
            case 2:
            // fj
            case 6:
            case 12:
            // Shot-jump-back thing
            case 13:
            // Float
            case 16:
            case 18:
            // Springs on maps
            case 19:
            // Aran Combat Step
            case 20:
            case 22:
                {
                    short xpos = lea.readShort();
                    short ypos = lea.readShort();
                    byte newstate = lea.readByte();
                    short duration = lea.readShort();
                    RelativeLifeMovement rlm = new RelativeLifeMovement(command, new Point(xpos, ypos), duration, newstate);
                    res.add(rlm);
                    break;
                }
            case 3:
            // tele... -.-
            case 4:
            // assaulter
            case 7:
            // assassinate
            case 8:
            // rush
            case 9:
            case // chair
            11:
                {
                    // case 14: {
                    short xpos = lea.readShort();
                    short ypos = lea.readShort();
                    short xwobble = lea.readShort();
                    short ywobble = lea.readShort();
                    byte newstate = lea.readByte();
                    TeleportMovement tm = new TeleportMovement(command, new Point(xpos, ypos), newstate);
                    tm.setPixelsPerSecond(new Point(xwobble, ywobble));
                    res.add(tm);
                    break;
                }
            case 14:
                // jump down (?)
                lea.skip(9);
                break;
            case // Change Equip
            10:
                res.add(new ChangeEquip(lea.readByte()));
                break;
            /*case 11: { // Chair
                    short xpos = lea.readShort();
                    short ypos = lea.readShort();
                    short unk = lea.readShort();
                    byte newstate = lea.readByte();
                    short duration = lea.readShort();
                    ChairMovement cm = new ChairMovement(command, new Point(xpos, ypos), duration, newstate);
                    cm.setUnk(unk);
                    res.add(cm);
                    break;
                }*/
            case 15:
                {
                    short xpos = lea.readShort();
                    short ypos = lea.readShort();
                    short xwobble = lea.readShort();
                    short ywobble = lea.readShort();
                    short unk = lea.readShort();
                    short fh = lea.readShort();
                    byte newstate = lea.readByte();
                    short duration = lea.readShort();
                    JumpDownMovement jdm = new JumpDownMovement(command, new Point(xpos, ypos), duration, newstate);
                    jdm.setUnk(unk);
                    jdm.setPixelsPerSecond(new Point(xwobble, ywobble));
                    jdm.setFH(fh);
                    res.add(jdm);
                    break;
                }
            case 21:
                {
                    // Causes aran to do weird stuff when attacking o.o
                    /*byte newstate = lea.readByte();
                     short unk = lea.readShort();
                     AranMovement am = new AranMovement(command, null, unk, newstate);
                     res.add(am);*/
                    lea.skip(3);
                    break;
                }
            default:
                System.out.println("Unhandled Case:" + command);
                return null;
        }
    }
    return res;
}
Also used : RelativeLifeMovement(server.movement.RelativeLifeMovement) LifeMovementFragment(server.movement.LifeMovementFragment) ArrayList(java.util.ArrayList) Point(java.awt.Point) JumpDownMovement(server.movement.JumpDownMovement) ChangeEquip(server.movement.ChangeEquip) AbsoluteLifeMovement(server.movement.AbsoluteLifeMovement) TeleportMovement(server.movement.TeleportMovement)

Aggregations

Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 AbsoluteLifeMovement (server.movement.AbsoluteLifeMovement)1 ChangeEquip (server.movement.ChangeEquip)1 JumpDownMovement (server.movement.JumpDownMovement)1 LifeMovementFragment (server.movement.LifeMovementFragment)1 RelativeLifeMovement (server.movement.RelativeLifeMovement)1 TeleportMovement (server.movement.TeleportMovement)1