Search in sources :

Example 1 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class DistributeAPHandler method addMP.

private static int addMP(MapleClient c, boolean usedAPReset) {
    MapleCharacter player = c.getPlayer();
    int MaxMP = player.getMaxMp();
    MapleJob job = player.getJob();
    if (player.getHpMpApUsed() > 9999 || player.getMaxMp() >= 30000) {
        return MaxMP;
    }
    return MaxMP + calcMpChange(player, job, usedAPReset);
}
Also used : MapleCharacter(client.MapleCharacter) MapleJob(client.MapleJob)

Example 2 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class DistributeSPHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    slea.readInt();
    int skillid = slea.readInt();
    if (skillid == Aran.HIDDEN_FULL_DOUBLE || skillid == Aran.HIDDEN_FULL_TRIPLE || skillid == Aran.HIDDEN_OVER_DOUBLE || skillid == Aran.HIDDEN_OVER_TRIPLE) {
        c.getSession().write(MaplePacketCreator.enableActions());
        return;
    }
    MapleCharacter player = c.getPlayer();
    int remainingSp = player.getRemainingSpBySkill(GameConstants.getSkillBook(skillid / 10000));
    boolean isBeginnerSkill = false;
    if ((!GameConstants.isPqSkillMap(player.getMapId()) && GameConstants.isPqSkill(skillid)) || (!player.isGM() && GameConstants.isGMSkills(skillid)) || (!GameConstants.isInJobTree(skillid, player.getJob().getId()) && !player.isGM())) {
        AutobanFactory.PACKET_EDIT.alert(player, "tried to packet edit in distributing sp.");
        FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to use skill " + skillid + " without it being in their job.\r\n");
        c.disconnect(true, false);
        return;
    }
    if (skillid % 10000000 > 999 && skillid % 10000000 < 1003) {
        int total = 0;
        for (int i = 0; i < 3; i++) {
            total += player.getSkillLevel(SkillFactory.getSkill(player.getJobType() * 10000000 + 1000 + i));
        }
        remainingSp = Math.min((player.getLevel() - 1), 6) - total;
        isBeginnerSkill = true;
    }
    Skill skill = SkillFactory.getSkill(skillid);
    int curLevel = player.getSkillLevel(skill);
    if ((remainingSp > 0 && curLevel + 1 <= (skill.isFourthJob() ? player.getMasterLevel(skill) : skill.getMaxLevel()))) {
        if (!isBeginnerSkill) {
            player.setRemainingSp(player.getRemainingSpBySkill(GameConstants.getSkillBook(skillid / 10000)) - 1, GameConstants.getSkillBook(skillid / 10000));
        }
        player.updateSingleStat(MapleStat.AVAILABLESP, player.getRemainingSpBySkill(GameConstants.getSkillBook(skillid / 10000)));
        if (skill.getId() == Aran.FULL_SWING) {
            player.changeSkillLevel(skill, (byte) (curLevel + 1), player.getMasterLevel(skill), player.getSkillExpiration(skill));
            player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_FULL_DOUBLE), (byte) player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
            player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_FULL_TRIPLE), (byte) player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
        } else if (skill.getId() == Aran.OVER_SWING) {
            player.changeSkillLevel(skill, (byte) (curLevel + 1), player.getMasterLevel(skill), player.getSkillExpiration(skill));
            player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_OVER_DOUBLE), (byte) player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
            player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_OVER_TRIPLE), (byte) player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
        } else {
            player.changeSkillLevel(skill, (byte) (curLevel + 1), player.getMasterLevel(skill), player.getSkillExpiration(skill));
        }
    }
}
Also used : MapleCharacter(client.MapleCharacter) Skill(client.Skill)

Example 3 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class EnterCashShopHandler method handlePacket.

@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    try {
        MapleCharacter mc = c.getPlayer();
        if (mc.cannotEnterCashShop()) {
            c.announce(MaplePacketCreator.enableActions());
            return;
        }
        if (MapleMiniDungeonInfo.isDungeonMap(c.getPlayer().getMapId())) {
            c.announce(MaplePacketCreator.serverNotice(5, "Changing channels or entering Cash Shop or MTS are disabled when inside a Mini-Dungeon."));
            c.announce(MaplePacketCreator.enableActions());
            return;
        }
        if (mc.getCashShop().isOpened()) {
            return;
        }
        mc.closePlayerInteractions();
        mc.unregisterChairBuff();
        Server.getInstance().getPlayerBuffStorage().addBuffsToStorage(mc.getId(), mc.getAllBuffs());
        mc.setAwayFromWorld(true);
        mc.cancelAllBuffs(true);
        mc.cancelBuffExpireTask();
        mc.cancelDiseaseExpireTask();
        mc.cancelSkillCooldownTask();
        mc.cancelExpirationTask();
        mc.forfeitExpirableQuests();
        mc.cancelQuestExpirationTask();
        c.announce(MaplePacketCreator.openCashShop(c, false));
        c.announce(MaplePacketCreator.showCashInventory(c));
        c.announce(MaplePacketCreator.showGifts(mc.getCashShop().loadGifts()));
        c.announce(MaplePacketCreator.showWishList(mc, false));
        c.announce(MaplePacketCreator.showCash(mc));
        c.getChannelServer().removePlayer(mc);
        mc.getMap().removePlayer(mc);
        mc.getCashShop().open(true);
        mc.saveToDB();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : MapleCharacter(client.MapleCharacter)

Example 4 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class FredrickHandler method handlePacket.

@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter chr = c.getPlayer();
    byte operation = slea.readByte();
    switch(operation) {
        case // Will never come...
        0x19:
            // c.announce(MaplePacketCreator.getFredrick((byte) 0x24));
            break;
        case 0x1A:
            List<Pair<Item, MapleInventoryType>> items;
            try {
                items = ItemFactory.MERCHANT.loadItems(chr.getId(), false);
                if (!check(chr, items)) {
                    c.announce(MaplePacketCreator.fredrickMessage((byte) 0x21));
                    return;
                }
                chr.gainMeso(chr.getMerchantMeso(), false);
                chr.setMerchantMeso(0);
                if (deleteItems(chr)) {
                    if (chr.getHiredMerchant() != null)
                        chr.getHiredMerchant().clearItems();
                    for (int i = 0; i < items.size(); i++) {
                        Item item = items.get(i).getLeft();
                        MapleInventoryManipulator.addFromDrop(c, item, false);
                        String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
                        FilePrinter.print(FilePrinter.FREDRICK + chr.getName() + ".txt", chr.getName() + " gained " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
                    }
                    c.announce(MaplePacketCreator.fredrickMessage((byte) 0x1E));
                } else {
                    chr.message("An unknown error has occured.");
                }
                break;
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
            break;
        case // Exit
        0x1C:
            break;
        default:
    }
}
Also used : Item(client.inventory.Item) MapleCharacter(client.MapleCharacter) SQLException(java.sql.SQLException) Pair(tools.Pair)

Example 5 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class MagicDamageHandler 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, false, true);
    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()));
    }
    int charge = (attack.skill == Evan.FIRE_BREATH || attack.skill == Evan.ICE_BREATH || attack.skill == FPArchMage.BIG_BANG || attack.skill == ILArchMage.BIG_BANG || attack.skill == Bishop.BIG_BANG) ? attack.charge : -1;
    byte[] packet = MaplePacketCreator.magicAttack(chr, attack.skill, attack.skilllevel, attack.stance, attack.numAttackedAndDamage, attack.allDamage, charge, attack.speed, attack.direction, attack.display);
    chr.getMap().broadcastMessage(chr, packet, false, true);
    MapleStatEffect effect = attack.getAttackEffect(chr, null);
    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);
        }
    }
    applyAttack(attack, chr, effect.getAttackCount());
    // MP Eater, works with right job
    Skill eaterSkill = SkillFactory.getSkill((chr.getJob().getId() - (chr.getJob().getId() % 10)) * 10000);
    int eaterLevel = chr.getSkillLevel(eaterSkill);
    if (eaterLevel > 0) {
        for (Integer singleDamage : attack.allDamage.keySet()) {
            eaterSkill.getEffect(eaterLevel).applyPassive(chr, chr.getMap().getMapObject(singleDamage), 0);
        }
    }
}
Also used : MapleCharacter(client.MapleCharacter) Skill(client.Skill) MapleStatEffect(server.MapleStatEffect)

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