Search in sources :

Example 21 with MapleItemInformationProvider

use of server.MapleItemInformationProvider in project HeavenMS by ronancpl.

the class ScrollHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    // whatever...
    slea.readInt();
    short slot = slea.readShort();
    short dst = slea.readShort();
    byte ws = (byte) slea.readShort();
    // white scroll being used?
    boolean whiteScroll = false;
    // legendary spirit skill
    boolean legendarySpirit = false;
    if ((ws & 2) == 2) {
        whiteScroll = true;
    }
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    Equip toScroll = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem(dst);
    Skill LegendarySpirit = SkillFactory.getSkill(1003);
    if (c.getPlayer().getSkillLevel(LegendarySpirit) > 0 && dst >= 0) {
        legendarySpirit = true;
        toScroll = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(dst);
    }
    byte oldLevel = toScroll.getLevel();
    byte oldSlots = toScroll.getUpgradeSlots();
    MapleInventory useInventory = c.getPlayer().getInventory(MapleInventoryType.USE);
    Item scroll = useInventory.getItem(slot);
    Item wscroll = null;
    if (((Equip) toScroll).getUpgradeSlots() < 1 && !ItemConstants.isCleanSlate(scroll.getItemId())) {
        c.announce(MaplePacketCreator.getInventoryFull());
        return;
    }
    List<Integer> scrollReqs = ii.getScrollReqs(scroll.getItemId());
    if (scrollReqs.size() > 0 && !scrollReqs.contains(toScroll.getItemId())) {
        c.announce(MaplePacketCreator.getInventoryFull());
        return;
    }
    if (whiteScroll) {
        wscroll = useInventory.findById(2340000);
        if (wscroll == null || wscroll.getItemId() != 2340000) {
            whiteScroll = false;
        }
    }
    if (!ItemConstants.isChaosScroll(scroll.getItemId()) && !ItemConstants.isCleanSlate(scroll.getItemId())) {
        if (!canScroll(scroll.getItemId(), toScroll.getItemId())) {
            return;
        }
    }
    if (ItemConstants.isCleanSlate(scroll.getItemId()) && !(toScroll.getLevel() + toScroll.getUpgradeSlots() < ii.getEquipStats(toScroll.getItemId()).get("tuc"))) {
        // upgrade slots can be over because of hammers
        return;
    }
    Equip scrolled = (Equip) ii.scrollEquipWithId(toScroll, scroll.getItemId(), whiteScroll, 0, c.getPlayer().isGM());
    // fail
    ScrollResult scrollSuccess = Equip.ScrollResult.FAIL;
    if (scrolled == null) {
        scrollSuccess = Equip.ScrollResult.CURSE;
    } else if (scrolled.getLevel() > oldLevel || (ItemConstants.isCleanSlate(scroll.getItemId()) && scrolled.getUpgradeSlots() == oldSlots + 1) || ItemConstants.isFlagModifier(scroll.getItemId(), scrolled.getFlag())) {
        scrollSuccess = Equip.ScrollResult.SUCCESS;
    }
    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, scroll.getPosition(), (short) 1, false);
    if (whiteScroll && !ItemConstants.isCleanSlate(scroll.getItemId())) {
        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, wscroll.getPosition(), (short) 1, false, false);
    }
    final List<ModifyInventory> mods = new ArrayList<>();
    if (scrollSuccess == Equip.ScrollResult.CURSE) {
        mods.add(new ModifyInventory(3, toScroll));
        if (dst < 0) {
            c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).removeItem(toScroll.getPosition());
        } else {
            c.getPlayer().getInventory(MapleInventoryType.EQUIP).removeItem(toScroll.getPosition());
        }
    } else {
        mods.add(new ModifyInventory(3, scrolled));
        mods.add(new ModifyInventory(0, scrolled));
    }
    c.announce(MaplePacketCreator.modifyInventory(true, mods));
    c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.getScrollEffect(c.getPlayer().getId(), scrollSuccess, legendarySpirit));
    if (dst < 0 && (scrollSuccess == Equip.ScrollResult.SUCCESS || scrollSuccess == Equip.ScrollResult.CURSE)) {
        c.getPlayer().equipChanged();
    }
}
Also used : ArrayList(java.util.ArrayList) MapleInventory(client.inventory.MapleInventory) ModifyInventory(client.inventory.ModifyInventory) Equip(client.inventory.Equip) Item(client.inventory.Item) Skill(client.Skill) ScrollResult(client.inventory.Equip.ScrollResult) MapleItemInformationProvider(server.MapleItemInformationProvider)

Example 22 with MapleItemInformationProvider

use of server.MapleItemInformationProvider in project HeavenMS by ronancpl.

the class MapleMap method killMonster.

public void killMonster(final MapleMonster monster, final MapleCharacter chr, final boolean withDrops, int animation) {
    if (monster == null)
        return;
    if (chr == null) {
        spawnedMonstersOnMap.decrementAndGet();
        monster.setHpZero();
        removeMapObject(monster);
        monster.dispatchMonsterKilled(false);
        broadcastMessage(MaplePacketCreator.killMonster(monster.getObjectId(), animation), monster.getPosition());
        return;
    }
    if (monster.getStats().getLevel() >= chr.getLevel() + 30 && !chr.isGM()) {
        AutobanFactory.GENERAL.alert(chr, " for killing a " + monster.getName() + " which is over 30 levels higher.");
    }
    /*if (chr.getQuest(MapleQuest.getInstance(29400)).getStatus().equals(MapleQuestStatus.Status.STARTED)) {
         if (chr.getLevel() >= 120 && monster.getStats().getLevel() >= 120) {
         //FIX MEDAL SHET
         } else if (monster.getStats().getLevel() >= chr.getLevel()) {
         }
         }*/
    int buff = monster.getBuffToGive();
    if (buff > -1) {
        MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
        for (MapleMapObject mmo : this.getPlayers()) {
            MapleCharacter character = (MapleCharacter) mmo;
            if (character.isAlive()) {
                MapleStatEffect statEffect = mii.getItemEffect(buff);
                character.getClient().announce(MaplePacketCreator.showOwnBuffEffect(buff, 1));
                broadcastMessage(character, MaplePacketCreator.showBuffeffect(character.getId(), buff, 1), false);
                statEffect.applyTo(character);
            }
        }
    }
    spawnedMonstersOnMap.decrementAndGet();
    monster.setHpZero();
    removeMapObject(monster);
    if (monster.getCP() > 0 && chr.getCarnival() != null) {
        chr.getCarnivalParty().addCP(chr, monster.getCP());
        chr.announce(MaplePacketCreator.updateCP(chr.getCP(), chr.getObtainedCP()));
        broadcastMessage(MaplePacketCreator.updatePartyCP(chr.getCarnivalParty()));
    // they drop items too ):
    }
    if (monster.getId() >= 8800003 && monster.getId() <= 8800010) {
        boolean makeZakReal = true;
        Collection<MapleMapObject> objects = getMapObjects();
        for (MapleMapObject object : objects) {
            MapleMonster mons = getMonsterByOid(object.getObjectId());
            if (mons != null) {
                if (mons.getId() >= 8800003 && mons.getId() <= 8800010) {
                    makeZakReal = false;
                    break;
                }
            }
        }
        if (makeZakReal) {
            MapleMap map = chr.getMap();
            for (MapleMapObject object : objects) {
                MapleMonster mons = map.getMonsterByOid(object.getObjectId());
                if (mons != null) {
                    if (mons.getId() == 8800000) {
                        makeMonsterReal(mons);
                        updateMonsterController(mons);
                        break;
                    }
                }
            }
        }
    }
    MapleCharacter dropOwner = monster.killBy(chr);
    if (withDrops && !monster.dropsDisabled()) {
        if (dropOwner == null) {
            dropOwner = chr;
        }
        dropFromMonster(dropOwner, monster, false);
    }
    if (monster.hasBossHPBar()) {
        for (MapleCharacter mc : this.getAllPlayers()) {
            if (mc.getTargetHpBarHash() == monster.hashCode()) {
                mc.resetPlayerAggro();
            }
        }
    }
    monster.dispatchMonsterKilled(true);
    broadcastMessage(MaplePacketCreator.killMonster(monster.getObjectId(), animation), monster.getPosition());
}
Also used : MapleCharacter(client.MapleCharacter) MapleStatEffect(server.MapleStatEffect) MapleItemInformationProvider(server.MapleItemInformationProvider) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) MapleMonster(server.life.MapleMonster)

Example 23 with MapleItemInformationProvider

use of server.MapleItemInformationProvider in project HeavenMS by ronancpl.

the class MapleMap method dropGlobalItemsFromMonsterOnMap.

private byte dropGlobalItemsFromMonsterOnMap(List<MonsterGlobalDropEntry> globalEntry, Point pos, byte d, byte droptype, int mobpos, MapleCharacter chr, MapleMonster mob) {
    Collections.shuffle(globalEntry);
    Item idrop;
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    for (final MonsterGlobalDropEntry de : globalEntry) {
        if (Randomizer.nextInt(999999) < de.chance) {
            if (droptype == 3) {
                pos.x = (int) (mobpos + (d % 2 == 0 ? (40 * (d + 1) / 2) : -(40 * (d / 2))));
            } else {
                pos.x = (int) (mobpos + ((d % 2 == 0) ? (25 * (d + 1) / 2) : -(25 * (d / 2))));
            }
            if (de.itemId != 0) {
                if (ItemConstants.getInventoryType(de.itemId) == MapleInventoryType.EQUIP) {
                    idrop = ii.randomizeStats((Equip) ii.getEquipById(de.itemId));
                } else {
                    idrop = new Item(de.itemId, (short) 0, (short) (de.Maximum != 1 ? Randomizer.nextInt(de.Maximum - de.Minimum) + de.Minimum : 1));
                }
                spawnDrop(idrop, calcDropPos(pos, mob.getPosition()), mob, chr, droptype, de.questid);
                d++;
            }
        }
    }
    return d;
}
Also used : Item(client.inventory.Item) Equip(client.inventory.Equip) MapleItemInformationProvider(server.MapleItemInformationProvider) MonsterGlobalDropEntry(server.life.MonsterGlobalDropEntry)

Example 24 with MapleItemInformationProvider

use of server.MapleItemInformationProvider in project HeavenMS by ronancpl.

the class MapleMap method dropItemsFromMonsterOnMap.

private byte dropItemsFromMonsterOnMap(List<MonsterDropEntry> dropEntry, Point pos, byte d, int chRate, byte droptype, int mobpos, MapleCharacter chr, MapleMonster mob) {
    if (dropEntry.isEmpty()) {
        return d;
    }
    Collections.shuffle(dropEntry);
    Item idrop;
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    for (final MonsterDropEntry de : dropEntry) {
        if (Randomizer.nextInt(999999) < (long) de.chance * chRate) {
            if (droptype == 3) {
                pos.x = (int) (mobpos + ((d % 2 == 0) ? (40 * ((d + 1) / 2)) : -(40 * (d / 2))));
            } else {
                pos.x = (int) (mobpos + ((d % 2 == 0) ? (25 * ((d + 1) / 2)) : -(25 * (d / 2))));
            }
            if (de.itemId == 0) {
                // meso
                int mesos = Randomizer.nextInt(de.Maximum - de.Minimum) + de.Minimum;
                if (mesos > 0) {
                    if (chr.getBuffedValue(MapleBuffStat.MESOUP) != null) {
                        mesos = (int) (mesos * chr.getBuffedValue(MapleBuffStat.MESOUP).doubleValue() / 100.0);
                    }
                    mesos = mesos * chr.getMesoRate();
                    if (mesos <= 0)
                        mesos = Integer.MAX_VALUE;
                    spawnMesoDrop(mesos, calcDropPos(pos, mob.getPosition()), mob, chr, false, droptype);
                }
            } else {
                if (ItemConstants.getInventoryType(de.itemId) == MapleInventoryType.EQUIP) {
                    idrop = ii.randomizeStats((Equip) ii.getEquipById(de.itemId));
                } else {
                    idrop = new Item(de.itemId, (short) 0, (short) (de.Maximum != 1 ? Randomizer.nextInt(de.Maximum - de.Minimum) + de.Minimum : 1));
                }
                spawnDrop(idrop, calcDropPos(pos, mob.getPosition()), mob, chr, droptype, de.questid);
            }
            d++;
        }
    }
    return d;
}
Also used : Item(client.inventory.Item) Equip(client.inventory.Equip) MonsterDropEntry(server.life.MonsterDropEntry) MapleItemInformationProvider(server.MapleItemInformationProvider) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint)

Example 25 with MapleItemInformationProvider

use of server.MapleItemInformationProvider in project HeavenMS by ronancpl.

the class Pyramid method checkBuffs.

public void checkBuffs() {
    int total = (kill + cool);
    if (buffcount == 0 && total >= 250) {
        buffcount++;
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        for (MapleCharacter chr : getParticipants()) ii.getItemEffect(2022585).applyTo(chr);
    } else if (buffcount == 1 && total >= 500) {
        buffcount++;
        skill++;
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        for (MapleCharacter chr : getParticipants()) {
            chr.announce(MaplePacketCreator.getEnergy("massacre_skill", skill));
            ii.getItemEffect(2022586).applyTo(chr);
        }
    } else if (buffcount == 2 && total >= 1000) {
        buffcount++;
        skill++;
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        for (MapleCharacter chr : getParticipants()) {
            chr.announce(MaplePacketCreator.getEnergy("massacre_skill", skill));
            ii.getItemEffect(2022587).applyTo(chr);
        }
    } else if (buffcount == 3 && total >= 1500) {
        skill++;
        broadcastInfo("skill", skill);
    } else if (buffcount == 4 && total >= 2000) {
        buffcount++;
        skill++;
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        for (MapleCharacter chr : getParticipants()) {
            chr.announce(MaplePacketCreator.getEnergy("massacre_skill", skill));
            ii.getItemEffect(2022588).applyTo(chr);
        }
    } else if (buffcount == 5 && total >= 2500) {
        skill++;
        broadcastInfo("skill", skill);
    } else if (buffcount == 6 && total >= 3000) {
        skill++;
        broadcastInfo("skill", skill);
    }
}
Also used : MapleCharacter(client.MapleCharacter) MapleItemInformationProvider(server.MapleItemInformationProvider)

Aggregations

MapleItemInformationProvider (server.MapleItemInformationProvider)26 Item (client.inventory.Item)18 Equip (client.inventory.Equip)10 MapleCharacter (client.MapleCharacter)9 Point (java.awt.Point)9 MapleInventoryType (client.inventory.MapleInventoryType)5 ArrayList (java.util.ArrayList)5 SpawnPoint (server.life.SpawnPoint)5 SQLException (java.sql.SQLException)4 MapleMap (server.maps.MapleMap)4 Skill (client.Skill)3 MapleInventory (client.inventory.MapleInventory)3 MaplePet (client.inventory.MaplePet)3 MapleMonster (server.life.MapleMonster)3 MapleMapItem (server.maps.MapleMapItem)3 MapleMapObject (server.maps.MapleMapObject)3 ScrollResult (client.inventory.Equip.ScrollResult)2 ModifyInventory (client.inventory.ModifyInventory)2 IOException (java.io.IOException)2 UnknownHostException (java.net.UnknownHostException)2