Search in sources :

Example 16 with MapleStatEffect

use of server.MapleStatEffect in project HeavenMS by ronancpl.

the class MapleCharacter method unregisterChairBuff.

public void unregisterChairBuff() {
    if (!ServerConstants.USE_CHAIR_EXTRAHEAL)
        return;
    int skillId = getJobMapChair(job);
    int skillLv = getSkillLevel(skillId);
    if (skillLv > 0) {
        MapleStatEffect mapChairSkill = SkillFactory.getSkill(skillId).getEffect(skillLv);
        cancelEffect(mapChairSkill, false, -1);
    }
}
Also used : MapleStatEffect(server.MapleStatEffect) Point(java.awt.Point)

Example 17 with MapleStatEffect

use of server.MapleStatEffect in project HeavenMS by ronancpl.

the class MCField method onItemPickup.

/**
 * Handles a player looting an item.
 *   [MENTION=2000183830]para[/MENTION]m player Player that picked up the object.
 *   [MENTION=2000183830]para[/MENTION]m mapitem Object picked up.
 *
 *   [MENTION=850422]return[/MENTION] True if pickup was successful, false otherwise.
 */
public boolean onItemPickup(Player player, FieldItem mapitem) {
    if (mapitem == null) {
        MCTracker.log("[MCPQ] Attempting to loot null object.");
        return false;
    }
    int itemid = mapitem.getItem().getItemId();
    if (!MonsterCarnival.isCPQConsumeItem(itemid)) {
        return false;
    }
    MCParty pty = player.getMCPQParty();
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    MapleStatEffect itemEffect = ii.getItemEffect(itemid);
    if (!itemEffect.isConsumeOnPickup()) {
        return false;
    }
    if (itemEffect.isParty()) {
        for (Player chr : pty.getMembers()) {
            if (chr.getStat().getCurrentHp() > 0) {
                itemEffect.applyTo(chr);
            }
        }
    } else {
        // Single Target Item
        itemEffect.applyTo(player);
    }
    // Status items
    if (itemEffect.getNuffSkill() != -1) {
        MCSkill debuff = MCSkillFactory.getMCSkill(itemEffect.getNuffSkill());
        if (debuff == null) {
            MCTracker.log("[MCPQ] debuff skill is null " + itemEffect.getNuffSkill());
            return false;
        }
        pty.getEnemy().applyMCSkill(debuff);
    }
    if (itemEffect.getCP() > 0) {
        this.gainCP(player, itemEffect.getCP());
    }
    return true;
}
Also used : Player(client.player.Player) MapleStatEffect(server.MapleStatEffect) MapleItemInformationProvider(server.itens.MapleItemInformationProvider)

Example 18 with MapleStatEffect

use of server.MapleStatEffect in project HeavenMS by ronancpl.

the class SpecialMoveHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter chr = c.getPlayer();
    chr.getAutobanManager().setTimestamp(4, slea.readInt(), 3);
    int skillid = slea.readInt();
    /*
        if ((!GameConstants.isPqSkillMap(chr.getMapId()) && GameConstants.isPqSkill(skillid)) || (!chr.isGM() && GameConstants.isGMSkills(skillid)) || (!GameConstants.isInJobTree(skillid, chr.getJob().getId()) && !chr.isGM())) {
        	AutobanFactory.PACKET_EDIT.alert(chr, chr.getName() + " tried to packet edit skills.");
        	FilePrinter.printError(FilePrinter.EXPLOITS + chr.getName() + ".txt", chr.getName() + " tried to use skill " + skillid + " without it being in their job.\r\n");
    		c.disconnect(true, false);
            return;
        }
        */
    Point pos = null;
    int __skillLevel = slea.readByte();
    Skill skill = SkillFactory.getSkill(skillid);
    int skillLevel = chr.getSkillLevel(skill);
    if (skillid % 10000000 == 1010 || skillid % 10000000 == 1011) {
        if (chr.getDojoEnergy() < 10000) {
            // PE hacking or maybe just lagging
            return;
        }
        skillLevel = 1;
        chr.setDojoEnergy(0);
        c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
        c.announce(MaplePacketCreator.serverNotice(5, "As you used the secret skill, your energy bar has been reset."));
    }
    if (skillLevel == 0 || skillLevel != __skillLevel)
        return;
    MapleStatEffect effect = skill.getEffect(skillLevel);
    if (effect.getCooldown() > 0) {
        if (chr.skillIsCooling(skillid)) {
            return;
        } else if (skillid != Corsair.BATTLE_SHIP) {
            c.announce(MaplePacketCreator.skillCooldown(skillid, effect.getCooldown()));
            chr.addCooldown(skillid, System.currentTimeMillis(), effect.getCooldown() * 1000);
        }
    }
    if (skillid == Hero.MONSTER_MAGNET || skillid == Paladin.MONSTER_MAGNET || skillid == DarkKnight.MONSTER_MAGNET) {
        // Monster Magnet
        int num = slea.readInt();
        int mobId;
        byte success;
        for (int i = 0; i < num; i++) {
            mobId = slea.readInt();
            success = slea.readByte();
            chr.getMap().broadcastMessage(chr, MaplePacketCreator.showMagnet(mobId, success), false);
            MapleMonster monster = chr.getMap().getMonsterByOid(mobId);
            if (monster != null) {
                if (!monster.isBoss()) {
                    monster.switchController(chr, monster.isControllerHasAggro());
                }
            }
        }
        byte direction = slea.readByte();
        chr.getMap().broadcastMessage(chr, MaplePacketCreator.showBuffeffect(chr.getId(), skillid, chr.getSkillLevel(skillid), direction), false);
        c.announce(MaplePacketCreator.enableActions());
        return;
    } else if (skillid == Brawler.MP_RECOVERY) {
        // MP Recovery
        Skill s = SkillFactory.getSkill(skillid);
        MapleStatEffect ef = s.getEffect(chr.getSkillLevel(s));
        int lose = chr.getMaxHp() / ef.getX();
        chr.setHp(chr.getHp() - lose);
        chr.updateSingleStat(MapleStat.HP, chr.getHp());
        int gain = lose * (ef.getY() / 100);
        chr.setMp(chr.getMp() + gain);
        chr.updateSingleStat(MapleStat.MP, chr.getMp());
    } else if (skillid == Priest.DISPEL || skillid == SuperGM.HEAL_PLUS_DISPEL) {
        slea.skip((skillid == Priest.DISPEL) ? 10 : 11);
        chr.getMap().broadcastMessage(chr, MaplePacketCreator.showBuffeffect(chr.getId(), skillid, chr.getSkillLevel(skillid)), false);
    } else if (skillid % 10000000 == 1004) {
        slea.readShort();
    }
    if (slea.available() == 5) {
        pos = new Point(slea.readShort(), slea.readShort());
    }
    if (chr.isAlive()) {
        if (skill.getId() != Priest.MYSTIC_DOOR) {
            skill.getEffect(skillLevel).applyTo(chr, pos);
        } else if (chr.canDoor()) {
            // update door lists
            chr.cancelMagicDoor();
            skill.getEffect(skillLevel).applyTo(chr, pos);
        } else {
            chr.message("Please wait 5 seconds before casting Mystic Door again.");
            c.announce(MaplePacketCreator.enableActions());
        }
    } else {
        c.announce(MaplePacketCreator.enableActions());
    }
}
Also used : MapleCharacter(client.MapleCharacter) Skill(client.Skill) MapleStatEffect(server.MapleStatEffect) Point(java.awt.Point) Point(java.awt.Point) MapleMonster(server.life.MapleMonster)

Example 19 with MapleStatEffect

use of server.MapleStatEffect in project HeavenMS by ronancpl.

the class SummonDamageHandler method handlePacket.

@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    int oid = slea.readInt();
    MapleCharacter player = c.getPlayer();
    if (!player.isAlive()) {
        return;
    }
    MapleSummon summon = null;
    for (MapleSummon sum : player.getSummonsValues()) {
        if (sum.getObjectId() == oid) {
            summon = sum;
        }
    }
    if (summon == null) {
        return;
    }
    Skill summonSkill = SkillFactory.getSkill(summon.getSkill());
    MapleStatEffect summonEffect = summonSkill.getEffect(summon.getSkillLevel());
    slea.skip(4);
    List<SummonAttackEntry> allDamage = new ArrayList<>();
    byte direction = slea.readByte();
    int numAttacked = slea.readByte();
    // Thanks Gerald :D, I failed lol (mob x,y and summon x,y)
    slea.skip(8);
    for (int x = 0; x < numAttacked; x++) {
        // attacked oid
        int monsterOid = slea.readInt();
        slea.skip(18);
        int damage = slea.readInt();
        allDamage.add(new SummonAttackEntry(monsterOid, damage));
    }
    player.getMap().broadcastMessage(player, MaplePacketCreator.summonAttack(player.getId(), summon.getObjectId(), direction, allDamage), summon.getPosition());
    for (SummonAttackEntry attackEntry : allDamage) {
        int damage = attackEntry.getDamage();
        MapleMonster target = player.getMap().getMonsterByOid(attackEntry.getMonsterOid());
        if (target != null) {
            if (damage > 0 && summonEffect.getMonsterStati().size() > 0) {
                if (summonEffect.makeChanceResult()) {
                    target.applyStatus(player, new MonsterStatusEffect(summonEffect.getMonsterStati(), summonSkill, null, false), summonEffect.isPoison(), 4000);
                }
            }
            player.getMap().damageMonster(player, target, damage);
        }
    }
}
Also used : MapleCharacter(client.MapleCharacter) Skill(client.Skill) MapleStatEffect(server.MapleStatEffect) MonsterStatusEffect(client.status.MonsterStatusEffect) ArrayList(java.util.ArrayList) MapleSummon(server.maps.MapleSummon) MapleMonster(server.life.MapleMonster)

Example 20 with MapleStatEffect

use of server.MapleStatEffect in project HeavenMS by ronancpl.

the class TakeDamageHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    List<MapleCharacter> banishPlayers = new ArrayList<>();
    MapleCharacter chr = c.getPlayer();
    slea.readInt();
    byte damagefrom = slea.readByte();
    // Element
    slea.readByte();
    int damage = slea.readInt();
    int oid = 0, monsteridfrom = 0, pgmr = 0, direction = 0;
    int pos_x = 0, pos_y = 0, fake = 0;
    boolean is_pgmr = false, is_pg = true, is_deadly = false;
    int mpattack = 0;
    MapleMonster attacker = null;
    final MapleMap map = chr.getMap();
    if (damagefrom != -3 && damagefrom != -4) {
        monsteridfrom = slea.readInt();
        oid = slea.readInt();
        try {
            MapleMapObject mmo = map.getMapObject(oid);
            if (mmo instanceof MapleMonster) {
                attacker = (MapleMonster) mmo;
                if (attacker.getId() != monsteridfrom) {
                    attacker = null;
                }
            }
            if (attacker != null) {
                List<loseItem> loseItems;
                if (attacker.isBuffed(MonsterStatus.NEUTRALISE)) {
                    return;
                }
                if (damage > 0) {
                    MapleMonster assaulter = map.getMonsterById(monsteridfrom);
                    if (assaulter != null) {
                        loseItems = assaulter.getStats().loseItem();
                        if (loseItems != null) {
                            MapleInventoryType type;
                            final int playerpos = chr.getPosition().x;
                            byte d = 1;
                            Point pos = new Point(0, chr.getPosition().y);
                            for (loseItem loseItem : loseItems) {
                                type = ItemConstants.getInventoryType(loseItem.getId());
                                for (byte b = 0; b < loseItem.getX(); b++) {
                                    // LOL?
                                    if (Randomizer.nextInt(101) >= loseItem.getChance()) {
                                        if (chr.haveItem(loseItem.getId())) {
                                            pos.x = (int) (playerpos + ((d % 2 == 0) ? (25 * (d + 1) / 2) : -(25 * (d / 2))));
                                            MapleInventoryManipulator.removeById(c, type, loseItem.getId(), 1, false, false);
                                            map.spawnItemDrop(chr, chr, new Item(loseItem.getId(), (short) 0, (short) 1), map.calcDropPos(pos, chr.getPosition()), true, true);
                                            d++;
                                        } else {
                                            break;
                                        }
                                    }
                                }
                            }
                            map.removeMapObject(attacker);
                        }
                    }
                }
            } else {
                return;
            }
        } catch (ClassCastException e) {
            // this happens due to mob on last map damaging player just before changing maps
            e.printStackTrace();
            FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, "Attacker is not a mob-type, rather is a " + map.getMapObject(oid).getClass().getName() + " entity.");
            return;
        }
        direction = slea.readByte();
    }
    if (damagefrom != -1 && damagefrom != -2 && attacker != null) {
        MobAttackInfo attackInfo = MobAttackInfoFactory.getMobAttackInfo(attacker, damagefrom);
        if (attackInfo != null) {
            if (attackInfo.isDeadlyAttack()) {
                mpattack = chr.getMp() - 1;
                is_deadly = true;
            }
            mpattack += attackInfo.getMpBurn();
            MobSkill mobSkill = MobSkillFactory.getMobSkill(attackInfo.getDiseaseSkill(), attackInfo.getDiseaseLevel());
            if (mobSkill != null && damage > 0) {
                mobSkill.applyEffect(chr, attacker, false, banishPlayers);
            }
            attacker.setMp(attacker.getMp() - attackInfo.getMpCon());
            if (chr.getBuffedValue(MapleBuffStat.MANA_REFLECTION) != null && damage > 0 && !attacker.isBoss()) {
                int jobid = chr.getJob().getId();
                if (jobid == 212 || jobid == 222 || jobid == 232) {
                    int id = jobid * 10000 + 1002;
                    Skill manaReflectSkill = SkillFactory.getSkill(id);
                    if (chr.isBuffFrom(MapleBuffStat.MANA_REFLECTION, manaReflectSkill) && chr.getSkillLevel(manaReflectSkill) > 0 && manaReflectSkill.getEffect(chr.getSkillLevel(manaReflectSkill)).makeChanceResult()) {
                        int bouncedamage = (damage * manaReflectSkill.getEffect(chr.getSkillLevel(manaReflectSkill)).getX() / 100);
                        if (bouncedamage > attacker.getMaxHp() / 5) {
                            bouncedamage = attacker.getMaxHp() / 5;
                        }
                        map.damageMonster(chr, attacker, bouncedamage);
                        map.broadcastMessage(chr, MaplePacketCreator.damageMonster(oid, bouncedamage), true);
                        chr.getClient().announce(MaplePacketCreator.showOwnBuffEffect(id, 5));
                        map.broadcastMessage(chr, MaplePacketCreator.showBuffeffect(chr.getId(), id, 5), false);
                    }
                }
            }
        }
    }
    if (damage == -1) {
        fake = 4020002 + (chr.getJob().getId() / 10 - 40) * 100000;
    }
    // in dojo player cannot use pot, so deadly attacks should be turned off as well
    if (is_deadly && chr.getMap().isDojoMap() && !ServerConstants.USE_DEADLY_DOJO) {
        damage = 0;
        mpattack = 0;
    }
    if (damage == 0) {
        chr.getAutobanManager().addMiss();
    } else {
        chr.getAutobanManager().resetMisses();
    }
    if (damage > 0 && !chr.isHidden()) {
        if (attacker != null && damagefrom == -1 && chr.getBuffedValue(MapleBuffStat.POWERGUARD) != null) {
            // PG works on bosses, but only at half of the rate.
            int bouncedamage = (int) (damage * (chr.getBuffedValue(MapleBuffStat.POWERGUARD).doubleValue() / (attacker.isBoss() ? 200 : 100)));
            bouncedamage = Math.min(bouncedamage, attacker.getMaxHp() / 10);
            damage -= bouncedamage;
            map.damageMonster(chr, attacker, bouncedamage);
            map.broadcastMessage(chr, MaplePacketCreator.damageMonster(oid, bouncedamage), false, true);
            chr.checkMonsterAggro(attacker);
        }
        if (attacker != null && damagefrom == -1 && chr.getBuffedValue(MapleBuffStat.BODY_PRESSURE) != null) {
            Skill skill = SkillFactory.getSkill(Aran.BODY_PRESSURE);
            final MapleStatEffect eff = skill.getEffect(chr.getSkillLevel(skill));
            if (!attacker.alreadyBuffedStats().contains(MonsterStatus.NEUTRALISE)) {
                if (!attacker.isBoss() && eff.makeChanceResult()) {
                    attacker.applyStatus(chr, new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.NEUTRALISE, 1), skill, null, false), false, (eff.getDuration() / 10) * 2, false);
                }
            }
        }
        if (damagefrom != -3 && damagefrom != -4) {
            int achilles = 0;
            Skill achilles1 = null;
            int jobid = chr.getJob().getId();
            if (jobid < 200 && jobid % 10 == 2) {
                achilles1 = SkillFactory.getSkill(jobid * 10000 + (jobid == 112 ? 4 : 5));
                achilles = chr.getSkillLevel(achilles1);
            }
            if (achilles != 0 && achilles1 != null) {
                damage *= (achilles1.getEffect(achilles).getX() / 1000.0);
            }
        }
        Integer mesoguard = chr.getBuffedValue(MapleBuffStat.MESOGUARD);
        if (chr.getBuffedValue(MapleBuffStat.MAGIC_GUARD) != null && mpattack == 0) {
            int mploss = (int) (damage * (chr.getBuffedValue(MapleBuffStat.MAGIC_GUARD).doubleValue() / 100.0));
            int hploss = damage - mploss;
            int curmp = chr.getMp();
            if (mploss > curmp) {
                hploss += mploss - curmp;
                mploss = curmp;
            }
            chr.addMPHP(-hploss, -mploss);
        } else if (mesoguard != null) {
            damage = Math.round(damage / 2);
            int mesoloss = (int) (damage * (mesoguard.doubleValue() / 100.0));
            if (chr.getMeso() < mesoloss) {
                chr.gainMeso(-chr.getMeso(), false);
                chr.cancelBuffStats(MapleBuffStat.MESOGUARD);
            } else {
                chr.gainMeso(-mesoloss, false);
            }
            chr.addMPHP(-damage, -mpattack);
        } else {
            if (chr.getBuffedValue(MapleBuffStat.MONSTER_RIDING) != null) {
                if (chr.getBuffedValue(MapleBuffStat.MONSTER_RIDING).intValue() == Corsair.BATTLE_SHIP) {
                    chr.decreaseBattleshipHp(damage);
                }
            }
            chr.addMPHP(-damage, -mpattack);
        }
    }
    if (!chr.isHidden()) {
        map.broadcastMessage(chr, MaplePacketCreator.damagePlayer(damagefrom, monsteridfrom, chr.getId(), damage, fake, direction, is_pgmr, pgmr, is_pg, oid, pos_x, pos_y), false);
        chr.checkBerserk(true);
    } else {
        map.broadcastGMMessage(chr, MaplePacketCreator.damagePlayer(damagefrom, monsteridfrom, chr.getId(), damage, fake, direction, is_pgmr, pgmr, is_pg, oid, pos_x, pos_y), false);
        chr.checkBerserk(false);
    }
    if (GameConstants.isDojo(map.getId())) {
        chr.setDojoEnergy(chr.getDojoEnergy() + ServerConstants.DOJO_ENERGY_DMG);
        c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
    }
    for (MapleCharacter player : banishPlayers) {
        // chill, if this list ever gets non-empty an attacker does exist, trust me :)
        player.changeMapBanish(attacker.getBanish().getMap(), attacker.getBanish().getPortal(), attacker.getBanish().getMsg());
    }
}
Also used : MapleCharacter(client.MapleCharacter) MonsterStatusEffect(client.status.MonsterStatusEffect) ArrayList(java.util.ArrayList) MapleMapObject(server.maps.MapleMapObject) MobAttackInfo(server.life.MobAttackInfo) MapleLifeFactory.loseItem(server.life.MapleLifeFactory.loseItem) Point(java.awt.Point) Point(java.awt.Point) MapleMap(server.maps.MapleMap) Item(client.inventory.Item) MapleLifeFactory.loseItem(server.life.MapleLifeFactory.loseItem) MapleInventoryType(client.inventory.MapleInventoryType) Skill(client.Skill) MobSkill(server.life.MobSkill) MapleStatEffect(server.MapleStatEffect) MobSkill(server.life.MobSkill) MapleMonster(server.life.MapleMonster)

Aggregations

MapleStatEffect (server.MapleStatEffect)21 MapleCharacter (client.MapleCharacter)10 Point (java.awt.Point)10 Skill (client.Skill)9 ArrayList (java.util.ArrayList)6 MapleMonster (server.life.MapleMonster)6 MobSkill (server.life.MobSkill)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 Pair (tools.Pair)5 Item (client.inventory.Item)3 MonsterStatusEffect (client.status.MonsterStatusEffect)3 MapleMap (server.maps.MapleMap)3 MapleBuffStat (client.MapleBuffStat)2 MapleInventory (client.inventory.MapleInventory)2 MapleWeaponType (client.inventory.MapleWeaponType)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 SpawnPoint (server.life.SpawnPoint)2 MapleMapItem (server.maps.MapleMapItem)2 MapleMapObject (server.maps.MapleMapObject)2