Search in sources :

Example 1 with Skill

use of client.Skill 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 2 with Skill

use of client.Skill in project HeavenMS by ronancpl.

the class KeymapChangeHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    if (slea.available() >= 8) {
        int mode = slea.readInt();
        if (mode == 0) {
            int numChanges = slea.readInt();
            for (int i = 0; i < numChanges; i++) {
                int key = slea.readInt();
                int type = slea.readByte();
                int action = slea.readInt();
                if (type == 1) {
                    Skill skill = SkillFactory.getSkill(action);
                    boolean isBanndedSkill;
                    if (skill != null) {
                        isBanndedSkill = GameConstants.bannedBindSkills(skill.getId());
                        if (isBanndedSkill || (!c.getPlayer().isGM() && GameConstants.isGMSkills(skill.getId())) || (!GameConstants.isInJobTree(skill.getId(), c.getPlayer().getJob().getId()) && !c.getPlayer().isGM())) {
                            // fk that
                            continue;
                        }
                    /* if (c.getPlayer().getSkillLevel(skill) < 1) {    HOW WOULD A SKILL EVEN BE AVAILABLE TO KEYBINDING
                                                                continue;                                   IF THERE IS NOT EVEN A SINGLE POINT USED INTO IT??
                                                        } */
                    }
                }
                c.getPlayer().changeKeybinding(key, new MapleKeyBinding(type, action));
            }
        } else if (mode == 1) {
            // Auto HP Potion
            int itemID = slea.readInt();
            if (itemID != 0 && c.getPlayer().getInventory(MapleInventoryType.USE).findById(itemID) == null) {
                // Don't let them send a packet with a use item they dont have.
                c.disconnect(false, false);
                return;
            }
            c.getPlayer().changeKeybinding(91, new MapleKeyBinding(7, itemID));
        } else if (mode == 2) {
            // Auto MP Potion
            int itemID = slea.readInt();
            if (itemID != 0 && c.getPlayer().getInventory(MapleInventoryType.USE).findById(itemID) == null) {
                // Don't let them send a packet with a use item they dont have.
                c.disconnect(false, false);
                return;
            }
            c.getPlayer().changeKeybinding(92, new MapleKeyBinding(7, itemID));
        }
    }
}
Also used : Skill(client.Skill) MapleKeyBinding(client.MapleKeyBinding)

Example 3 with Skill

use of client.Skill 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)

Example 4 with Skill

use of client.Skill 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)

Example 5 with Skill

use of client.Skill in project HeavenMS by ronancpl.

the class SkillBookHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    if (!c.getPlayer().isAlive()) {
        c.announce(MaplePacketCreator.enableActions());
        return;
    }
    slea.readInt();
    short slot = (short) slea.readShort();
    int itemId = slea.readInt();
    MapleCharacter player = c.getPlayer();
    Item toUse = c.getPlayer().getInventory(MapleInventoryType.USE).getItem(slot);
    if (toUse != null && toUse.getQuantity() == 1) {
        if (toUse.getItemId() != itemId) {
            return;
        }
        Map<String, Integer> skilldata = MapleItemInformationProvider.getInstance().getSkillStats(toUse.getItemId(), c.getPlayer().getJob().getId());
        boolean canuse;
        boolean success = false;
        int skill = 0;
        int maxlevel = 0;
        if (skilldata == null) {
            return;
        }
        Skill skill2 = SkillFactory.getSkill(skilldata.get("skillid"));
        if (skilldata.get("skillid") == 0) {
            canuse = false;
        } else if ((player.getSkillLevel(skill2) >= skilldata.get("reqSkillLevel") || skilldata.get("reqSkillLevel") == 0) && player.getMasterLevel(skill2) < skilldata.get("masterLevel")) {
            canuse = true;
            if (MapleItemInformationProvider.rollSuccessChance(skilldata.get("success"))) {
                success = true;
                player.changeSkillLevel(skill2, player.getSkillLevel(skill2), Math.max(skilldata.get("masterLevel"), player.getMasterLevel(skill2)), -1);
            } else {
                success = false;
            // player.dropMessage("The skill book lights up, but the skill winds up as if nothing happened.");
            }
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, (short) 1, false);
        } else {
            canuse = false;
        }
        player.getClient().announce(MaplePacketCreator.skillBookSuccess(player, skill, maxlevel, canuse, success));
    }
}
Also used : Item(client.inventory.Item) MapleCharacter(client.MapleCharacter) Skill(client.Skill)

Aggregations

Skill (client.Skill)23 MapleCharacter (client.MapleCharacter)12 Point (java.awt.Point)9 MapleStatEffect (server.MapleStatEffect)9 Item (client.inventory.Item)6 ArrayList (java.util.ArrayList)6 MapleMonster (server.life.MapleMonster)6 MonsterStatusEffect (client.status.MonsterStatusEffect)5 MobSkill (server.life.MobSkill)4 MapleMap (server.maps.MapleMap)4 MapleItemInformationProvider (server.MapleItemInformationProvider)3 Equip (client.inventory.Equip)2 ScrollResult (client.inventory.Equip.ScrollResult)2 MapleInventory (client.inventory.MapleInventory)2 MapleInventoryType (client.inventory.MapleInventoryType)2 ModifyInventory (client.inventory.ModifyInventory)2 File (java.io.File)2 SQLException (java.sql.SQLException)2 List (java.util.List)2 Client (org.powerbot.bot.rt6.client.Client)2