Search in sources :

Example 6 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class MesoDropHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter player = c.getPlayer();
    if (!player.isAlive()) {
        c.announce(MaplePacketCreator.enableActions());
        return;
    }
    if (!player.canDropMeso()) {
        player.announce(MaplePacketCreator.serverNotice(5, "Fast meso drop has been patched, cut that out. ;)"));
        return;
    }
    slea.skip(4);
    int meso = slea.readInt();
    if (meso <= player.getMeso() && meso > 9 && meso < 50001) {
        player.gainMeso(-meso, false, true, false);
        player.getMap().spawnMesoDrop(meso, player.getPosition(), player, player, true, (byte) 2);
    }
}
Also used : MapleCharacter(client.MapleCharacter)

Example 7 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class PetCommandHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter chr = c.getPlayer();
    int petId = slea.readInt();
    byte petIndex = chr.getPetIndex(petId);
    MaplePet pet;
    if (petIndex == -1) {
        return;
    } else {
        pet = chr.getPet(petIndex);
    }
    slea.readInt();
    slea.readByte();
    byte command = slea.readByte();
    PetCommand petCommand = PetDataFactory.getPetCommand(pet.getItemId(), (int) command);
    if (petCommand == null) {
        return;
    }
    if (Randomizer.nextInt(101) <= petCommand.getProbability()) {
        pet.gainClosenessFullness(chr, petCommand.getIncrease(), 0, command);
    } else {
        chr.getMap().broadcastMessage(MaplePacketCreator.commandResponse(chr.getId(), petIndex, command, false));
        if (chr.getMount() != null)
            chr.getMap().broadcastMessage(MaplePacketCreator.updateMount(chr.getId(), chr.getMount(), false));
    }
}
Also used : MapleCharacter(client.MapleCharacter) PetCommand(client.inventory.PetCommand) MaplePet(client.inventory.MaplePet)

Example 8 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class PetExcludeItemsHandler method handlePacket.

public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    final int petId = slea.readInt();
    slea.skip(4);
    MapleCharacter chr = c.getPlayer();
    byte petIndex = (byte) chr.getPetIndex(petId);
    if (petIndex < 0)
        return;
    final MaplePet pet = chr.getPet(petIndex);
    if (pet == null) {
        return;
    }
    chr.resetExcluded(petId);
    byte amount = slea.readByte();
    for (int i = 0; i < amount; i++) {
        chr.addExcluded(petId, slea.readInt());
    }
    chr.commitExcludedItems();
}
Also used : MapleCharacter(client.MapleCharacter) MaplePet(client.inventory.MaplePet)

Example 9 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class PetFoodHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter chr = c.getPlayer();
    AutobanManager abm = chr.getAutobanManager();
    if (abm.getLastSpam(2) + 500 > System.currentTimeMillis()) {
        c.announce(MaplePacketCreator.enableActions());
        return;
    }
    abm.spam(2);
    abm.setTimestamp(1, slea.readInt(), 3);
    if (chr.getNoPets() == 0) {
        c.announce(MaplePacketCreator.enableActions());
        return;
    }
    int previousFullness = 100;
    byte slot = 0;
    MaplePet[] pets = chr.getPets();
    for (byte i = 0; i < 3; i++) {
        if (pets[i] != null) {
            if (pets[i].getFullness() < previousFullness) {
                slot = i;
                previousFullness = pets[i].getFullness();
            }
        }
    }
    MaplePet pet = chr.getPet(slot);
    if (pet == null)
        return;
    short pos = slea.readShort();
    int itemId = slea.readInt();
    Item use = chr.getInventory(MapleInventoryType.USE).getItem(pos);
    if (use == null || (itemId / 10000) != 212 || use.getItemId() != itemId) {
        return;
    }
    // 50% chance to get +1 closeness
    pet.gainClosenessFullness(chr, (Randomizer.nextInt(101) <= 50) ? 1 : 0, 30, 1);
    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, pos, (short) 1, false);
}
Also used : Item(client.inventory.Item) MapleCharacter(client.MapleCharacter) AutobanManager(client.autoban.AutobanManager) MaplePet(client.inventory.MaplePet)

Example 10 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class RangedAttackHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter chr = c.getPlayer();
    chr.setPetLootCd(System.currentTimeMillis());
    /*long timeElapsed = System.currentTimeMillis() - chr.getAutobanManager().getLastSpam(8);
        if(timeElapsed < 300) {
            AutobanFactory.FAST_ATTACK.alert(chr, "Time: " + timeElapsed);
        }
        chr.getAutobanManager().spam(8);*/
    AttackInfo attack = parseDamage(slea, chr, true, false);
    if (chr.getBuffEffect(MapleBuffStat.MORPH) != null) {
        if (chr.getBuffEffect(MapleBuffStat.MORPH).isMorphWithoutAttack()) {
            // How are they attacking when the client won't let them?
            chr.getClient().disconnect(false, false);
            return;
        }
    }
    if (chr.getMap().isDojoMap() && attack.numAttacked > 0) {
        chr.setDojoEnergy(chr.getDojoEnergy() + ServerConstants.DOJO_ENERGY_ATK);
        c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
    }
    if (attack.skill == Buccaneer.ENERGY_ORB || attack.skill == ThunderBreaker.SPARK || attack.skill == Shadower.TAUNT || attack.skill == NightLord.TAUNT) {
        chr.getMap().broadcastMessage(chr, MaplePacketCreator.rangedAttack(chr, attack.skill, attack.skilllevel, attack.stance, attack.numAttackedAndDamage, 0, attack.allDamage, attack.speed, attack.direction, attack.display), false);
        applyAttack(attack, chr, 1);
    } else if (attack.skill == Aran.COMBO_SMASH || attack.skill == Aran.COMBO_FENRIR || attack.skill == Aran.COMBO_TEMPEST) {
        chr.getMap().broadcastMessage(chr, MaplePacketCreator.rangedAttack(chr, attack.skill, attack.skilllevel, attack.stance, attack.numAttackedAndDamage, 0, attack.allDamage, attack.speed, attack.direction, attack.display), false);
        if (attack.skill == Aran.COMBO_SMASH && chr.getCombo() >= 30) {
            chr.setCombo((short) 0);
            applyAttack(attack, chr, 1);
        } else if (attack.skill == Aran.COMBO_FENRIR && chr.getCombo() >= 100) {
            chr.setCombo((short) 0);
            applyAttack(attack, chr, 2);
        } else if (attack.skill == Aran.COMBO_TEMPEST && chr.getCombo() >= 200) {
            chr.setCombo((short) 0);
            applyAttack(attack, chr, 4);
        }
    } else {
        Item weapon = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -11);
        MapleWeaponType type = MapleItemInformationProvider.getInstance().getWeaponType(weapon.getItemId());
        if (type == MapleWeaponType.NOT_A_WEAPON) {
            return;
        }
        short slot = -1;
        int projectile = 0;
        byte bulletCount = 1;
        MapleStatEffect effect = null;
        if (attack.skill != 0) {
            effect = attack.getAttackEffect(chr, null);
            bulletCount = effect.getBulletCount();
            if (effect.getCooldown() > 0) {
                c.announce(MaplePacketCreator.skillCooldown(attack.skill, effect.getCooldown()));
            }
        }
        boolean hasShadowPartner = chr.getBuffedValue(MapleBuffStat.SHADOWPARTNER) != null;
        if (hasShadowPartner) {
            bulletCount *= 2;
        }
        MapleInventory inv = chr.getInventory(MapleInventoryType.USE);
        for (short i = 1; i <= inv.getSlotLimit(); i++) {
            Item item = inv.getItem(i);
            if (item != null) {
                int id = item.getItemId();
                slot = item.getPosition();
                boolean bow = ItemConstants.isArrowForBow(id);
                boolean cbow = ItemConstants.isArrowForCrossBow(id);
                if (item.getQuantity() >= bulletCount) {
                    // Fixes the bug where you can't use your last arrow.
                    if (type == MapleWeaponType.CLAW && ItemConstants.isThrowingStar(id) && weapon.getItemId() != 1472063) {
                        if (((id == 2070007 || id == 2070018) && chr.getLevel() < 70) || (id == 2070016 && chr.getLevel() < 50)) {
                        } else {
                            projectile = id;
                            break;
                        }
                    } else if ((type == MapleWeaponType.GUN && ItemConstants.isBullet(id))) {
                        if (id == 2331000 && id == 2332000) {
                            if (chr.getLevel() > 69) {
                                projectile = id;
                                break;
                            }
                        } else if (chr.getLevel() > (id % 10) * 20 + 9) {
                            projectile = id;
                            break;
                        }
                    } else if ((type == MapleWeaponType.BOW && bow) || (type == MapleWeaponType.CROSSBOW && cbow) || (weapon.getItemId() == 1472063 && (bow || cbow))) {
                        projectile = id;
                        break;
                    }
                }
            }
        }
        boolean soulArrow = chr.getBuffedValue(MapleBuffStat.SOULARROW) != null;
        boolean shadowClaw = chr.getBuffedValue(MapleBuffStat.SHADOW_CLAW) != null;
        if (projectile != 0) {
            if (!soulArrow && !shadowClaw && attack.skill != 11101004 && attack.skill != 15111007 && attack.skill != 14101006) {
                byte bulletConsume = bulletCount;
                if (effect != null && effect.getBulletConsume() != 0) {
                    bulletConsume = (byte) (effect.getBulletConsume() * (hasShadowPartner ? 2 : 1));
                }
                if (slot < 0)
                    System.out.println("<ERROR> Projectile to use was unable to be found.");
                else
                    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, bulletConsume, false, true);
            }
        }
        if (projectile != 0 || soulArrow || attack.skill == 11101004 || attack.skill == 15111007 || attack.skill == 14101006) {
            // visible projectile sent to players
            int visProjectile = projectile;
            if (ItemConstants.isThrowingStar(projectile)) {
                MapleInventory cash = chr.getInventory(MapleInventoryType.CASH);
                for (int i = 1; i <= cash.getSlotLimit(); i++) {
                    // impose order...
                    Item item = cash.getItem((short) i);
                    if (item != null) {
                        if (item.getItemId() / 1000 == 5021) {
                            visProjectile = item.getItemId();
                            break;
                        }
                    }
                }
            } else // bow, crossbow
            if (soulArrow || attack.skill == 3111004 || attack.skill == 3211004 || attack.skill == 11101004 || attack.skill == 15111007 || attack.skill == 14101006) {
                visProjectile = 0;
            }
            byte[] packet;
            switch(attack.skill) {
                // Hurricane
                case 3121004:
                // Pierce
                case 3221001:
                // Rapid Fire
                case 5221004:
                case // KoC Hurricane
                13111002:
                    packet = MaplePacketCreator.rangedAttack(chr, attack.skill, attack.skilllevel, attack.rangedirection, attack.numAttackedAndDamage, visProjectile, attack.allDamage, attack.speed, attack.direction, attack.display);
                    break;
                default:
                    packet = MaplePacketCreator.rangedAttack(chr, attack.skill, attack.skilllevel, attack.stance, attack.numAttackedAndDamage, visProjectile, attack.allDamage, attack.speed, attack.direction, attack.display);
                    break;
            }
            chr.getMap().broadcastMessage(chr, packet, false, true);
            if (effect != null) {
                int money = effect.getMoneyCon();
                if (money != 0) {
                    int moneyMod = money / 2;
                    money += Randomizer.nextInt(moneyMod);
                    if (money > chr.getMeso()) {
                        money = chr.getMeso();
                    }
                    chr.gainMeso(-money, false);
                }
            }
            if (attack.skill != 0) {
                Skill skill = SkillFactory.getSkill(attack.skill);
                MapleStatEffect effect_ = skill.getEffect(chr.getSkillLevel(skill));
                if (effect_.getCooldown() > 0) {
                    if (chr.skillIsCooling(attack.skill)) {
                        return;
                    } else {
                        c.announce(MaplePacketCreator.skillCooldown(attack.skill, effect_.getCooldown()));
                        chr.addCooldown(attack.skill, System.currentTimeMillis(), effect_.getCooldown() * 1000);
                    }
                }
            }
            if (chr.getSkillLevel(SkillFactory.getSkill(NightWalker.VANISH)) > 0 && chr.getBuffedValue(MapleBuffStat.DARKSIGHT) != null && attack.numAttacked > 0 && chr.getBuffSource(MapleBuffStat.DARKSIGHT) != 9101004) {
                chr.cancelEffectFromBuffStat(MapleBuffStat.DARKSIGHT);
                chr.cancelBuffStats(MapleBuffStat.DARKSIGHT);
            } else if (chr.getSkillLevel(SkillFactory.getSkill(WindArcher.WIND_WALK)) > 0 && chr.getBuffedValue(MapleBuffStat.WIND_WALK) != null && attack.numAttacked > 0) {
                chr.cancelEffectFromBuffStat(MapleBuffStat.WIND_WALK);
                chr.cancelBuffStats(MapleBuffStat.WIND_WALK);
            }
            applyAttack(attack, chr, bulletCount);
        }
    }
}
Also used : Item(client.inventory.Item) MapleCharacter(client.MapleCharacter) Skill(client.Skill) MapleWeaponType(client.inventory.MapleWeaponType) MapleStatEffect(server.MapleStatEffect) MapleInventory(client.inventory.MapleInventory)

Aggregations

MapleCharacter (client.MapleCharacter)163 Point (java.awt.Point)32 SQLException (java.sql.SQLException)22 Item (client.inventory.Item)21 Connection (java.sql.Connection)15 PreparedStatement (java.sql.PreparedStatement)15 MapleMonster (server.life.MapleMonster)15 MapleMapObject (server.maps.MapleMapObject)15 DatabaseConnection (tools.DatabaseConnection)15 MapleMap (server.maps.MapleMap)14 ArrayList (java.util.ArrayList)13 Skill (client.Skill)12 SpawnPoint (server.life.SpawnPoint)12 LinkedList (java.util.LinkedList)11 MapleInventory (client.inventory.MapleInventory)10 World (net.server.world.World)10 MapleStatEffect (server.MapleStatEffect)10 MapleInventoryType (client.inventory.MapleInventoryType)9 ResultSet (java.sql.ResultSet)9 MapleItemInformationProvider (server.MapleItemInformationProvider)9