Search in sources :

Example 1 with MonsterGlobalDropEntry

use of server.life.MonsterGlobalDropEntry in project HeavenMS by ronancpl.

the class MapleMap method dropFromMonster.

private void dropFromMonster(final MapleCharacter chr, final MapleMonster mob, final boolean useBaseRate) {
    if (mob.dropsDisabled() || !dropsOn) {
        return;
    }
    final byte droptype = (byte) (mob.getStats().isExplosiveReward() ? 3 : mob.getStats().isFfaLoot() ? 2 : chr.getParty() != null ? 1 : 0);
    final int mobpos = mob.getPosition().x;
    int chRate = chr.getDropRate();
    byte d = 1;
    Point pos = new Point(0, mob.getPosition().y);
    MonsterStatusEffect stati = mob.getStati(MonsterStatus.SHOWDOWN);
    if (stati != null) {
        chRate *= (stati.getStati().get(MonsterStatus.SHOWDOWN).doubleValue() / 100.0 + 1.0);
    }
    if (useBaseRate)
        chRate = 1;
    final MapleMonsterInformationProvider mi = MapleMonsterInformationProvider.getInstance();
    final List<MonsterDropEntry> dropEntry = new ArrayList<>();
    final List<MonsterDropEntry> questEntry = new ArrayList<>();
    sortDropEntries(mi.retrieveEffectiveDrop(mob.getId()), dropEntry, questEntry);
    // Normal Drops
    d = dropItemsFromMonsterOnMap(dropEntry, pos, d, chRate, droptype, mobpos, chr, mob);
    // Global Drops
    final List<MonsterGlobalDropEntry> globalEntry = mi.getGlobalDrop();
    d = dropGlobalItemsFromMonsterOnMap(globalEntry, pos, d, droptype, mobpos, chr, mob);
    // Quest Drops
    dropItemsFromMonsterOnMap(questEntry, pos, d, chRate, droptype, mobpos, chr, mob);
}
Also used : MapleMonsterInformationProvider(server.life.MapleMonsterInformationProvider) MonsterStatusEffect(client.status.MonsterStatusEffect) MonsterDropEntry(server.life.MonsterDropEntry) ArrayList(java.util.ArrayList) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) MonsterGlobalDropEntry(server.life.MonsterGlobalDropEntry)

Example 2 with MonsterGlobalDropEntry

use of server.life.MonsterGlobalDropEntry 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)

Aggregations

MonsterGlobalDropEntry (server.life.MonsterGlobalDropEntry)2 Equip (client.inventory.Equip)1 Item (client.inventory.Item)1 MonsterStatusEffect (client.status.MonsterStatusEffect)1 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 MapleItemInformationProvider (server.MapleItemInformationProvider)1 MapleMonsterInformationProvider (server.life.MapleMonsterInformationProvider)1 MonsterDropEntry (server.life.MonsterDropEntry)1 SpawnPoint (server.life.SpawnPoint)1