Search in sources :

Example 6 with MapleItemInformationProvider

use of server.MapleItemInformationProvider in project HeavenMS by ronancpl.

the class MapleMap method spawnItemDropList.

// spawns item instances of all defined item ids on a list
public final void spawnItemDropList(List<Integer> list, int minCopies, int maxCopies, final MapleMapObject dropper, final MapleCharacter owner, Point pos, final boolean ffaDrop, final boolean playerDrop) {
    int copies = (maxCopies - minCopies) + 1;
    if (copies < 1)
        return;
    Collections.shuffle(list);
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    Random rnd = new Random();
    final Point dropPos = new Point(pos);
    dropPos.x -= (12 * list.size());
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i) == 0) {
            spawnMesoDrop(owner != null ? 10 * owner.getMesoRate() : 10, calcDropPos(dropPos, pos), dropper, owner, playerDrop, (byte) (ffaDrop ? 2 : 0));
        } else {
            final Item drop;
            int randomedId = list.get(i);
            if (ItemConstants.getInventoryType(randomedId) != MapleInventoryType.EQUIP) {
                drop = new Item(randomedId, (short) 0, (short) (rnd.nextInt(copies) + minCopies));
            } else {
                drop = ii.randomizeStats((Equip) ii.getEquipById(randomedId));
            }
            spawnItemDrop(dropper, owner, drop, calcDropPos(dropPos, pos), ffaDrop, playerDrop);
        }
        dropPos.x += 25;
    }
}
Also used : Item(client.inventory.Item) Equip(client.inventory.Equip) Random(java.util.Random) MapleItemInformationProvider(server.MapleItemInformationProvider) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint)

Example 7 with MapleItemInformationProvider

use of server.MapleItemInformationProvider in project HeavenMS by ronancpl.

the class MapleMonsterInformationProvider method retrieveDropPool.

public final List<Integer> retrieveDropPool(final int monsterId) {
    // ignores Quest and Party Quest items
    if (dropsChancePool.containsKey(monsterId)) {
        return dropsChancePool.get(monsterId);
    }
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    List<MonsterDropEntry> dropList = retrieveDrop(monsterId);
    List<Integer> ret = new ArrayList<>();
    int accProp = 0;
    for (MonsterDropEntry mde : dropList) {
        if (!ii.isQuestItem(mde.itemId) && !ii.isPartyQuestItem(mde.itemId)) {
            accProp += mde.chance;
        }
        ret.add(accProp);
    }
    // don't accept mobs dropping no relevant items
    if (accProp == 0)
        ret.clear();
    dropsChancePool.put(monsterId, ret);
    return ret;
}
Also used : MapleItemInformationProvider(server.MapleItemInformationProvider) ArrayList(java.util.ArrayList)

Example 8 with MapleItemInformationProvider

use of server.MapleItemInformationProvider in project HeavenMS by ronancpl.

the class Commands method executeHeavenMsCommandLv1.

public static boolean executeHeavenMsCommandLv1(Channel cserv, Server srv, MapleClient c, String[] sub) {
    // Donator
    MapleCharacter player = c.getPlayer();
    switch(sub[0]) {
        case "buffme":
            // GM Skills : Haste(Super) - Holy Symbol - Bless - Hyper Body - Echo of Hero
            SkillFactory.getSkill(4101004).getEffect(SkillFactory.getSkill(4101004).getMaxLevel()).applyTo(player);
            SkillFactory.getSkill(2311003).getEffect(SkillFactory.getSkill(2311003).getMaxLevel()).applyTo(player);
            SkillFactory.getSkill(1301007).getEffect(SkillFactory.getSkill(1301007).getMaxLevel()).applyTo(player);
            SkillFactory.getSkill(2301004).getEffect(SkillFactory.getSkill(2301004).getMaxLevel()).applyTo(player);
            SkillFactory.getSkill(1005).getEffect(SkillFactory.getSkill(1005).getMaxLevel()).applyTo(player);
            player.setHp(player.getMaxHp());
            player.updateSingleStat(MapleStat.HP, player.getMaxHp());
            player.setMp(player.getMaxMp());
            player.updateSingleStat(MapleStat.MP, player.getMaxMp());
            break;
        case "goto":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !goto <map name>");
                break;
            }
            if (gotomaps.containsKey(sub[1])) {
                MapleMap target = c.getChannelServer().getMapFactory().getMap(gotomaps.get(sub[1]));
                MaplePortal targetPortal = target.getPortal(0);
                if (player.getEventInstance() != null) {
                    player.getEventInstance().removePlayer(player);
                }
                player.changeMap(target, targetPortal);
            } else {
                player.dropMessage(5, "That map does not exist.");
            }
            break;
        case "recharge":
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            for (Item torecharge : c.getPlayer().getInventory(MapleInventoryType.USE).list()) {
                if (ItemConstants.isThrowingStar(torecharge.getItemId())) {
                    torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
                    c.getPlayer().forceUpdateItem(torecharge);
                } else if (ItemConstants.isArrow(torecharge.getItemId())) {
                    torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
                    c.getPlayer().forceUpdateItem(torecharge);
                } else if (ItemConstants.isBullet(torecharge.getItemId())) {
                    torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
                    c.getPlayer().forceUpdateItem(torecharge);
                } else if (ItemConstants.isConsumable(torecharge.getItemId())) {
                    torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
                    c.getPlayer().forceUpdateItem(torecharge);
                }
            }
            player.dropMessage(5, "USE Recharged.");
            break;
        case "whereami":
            player.yellowMessage("Map ID: " + player.getMap().getId());
            player.yellowMessage("Players on this map:");
            for (MapleMapObject mmo : player.getMap().getPlayers()) {
                MapleCharacter chr = (MapleCharacter) mmo;
                player.dropMessage(5, ">> " + chr.getName() + " - " + chr.getId() + " - Oid: " + chr.getObjectId());
            }
            player.yellowMessage("NPCs on this map:");
            for (MapleMapObject npcs : player.getMap().getMapObjects()) {
                if (npcs instanceof MapleNPC) {
                    MapleNPC npc = (MapleNPC) npcs;
                    player.dropMessage(5, ">> " + npc.getName() + " - " + npc.getId() + " - Oid: " + npc.getObjectId());
                }
            }
            player.yellowMessage("Monsters on this map:");
            for (MapleMapObject mobs : player.getMap().getMapObjects()) {
                if (mobs instanceof MapleMonster) {
                    MapleMonster mob = (MapleMonster) mobs;
                    if (mob.isAlive()) {
                        player.dropMessage(5, ">> " + mob.getName() + " - " + mob.getId() + " - Oid: " + mob.getObjectId());
                    }
                }
            }
            break;
        default:
            return false;
    }
    return true;
}
Also used : MapleMap(server.maps.MapleMap) MapleMapItem(server.maps.MapleMapItem) Item(client.inventory.Item) MapleCharacter(client.MapleCharacter) MaplePortal(server.MaplePortal) MapleItemInformationProvider(server.MapleItemInformationProvider) MapleMapObject(server.maps.MapleMapObject) MapleNPC(server.life.MapleNPC) MapleMonster(server.life.MapleMonster)

Example 9 with MapleItemInformationProvider

use of server.MapleItemInformationProvider in project HeavenMS by ronancpl.

the class Commands method executeHeavenMsCommandLv4.

public static boolean executeHeavenMsCommandLv4(Channel cserv, Server srv, MapleClient c, String[] sub) {
    // SuperGM
    MapleCharacter player = c.getPlayer();
    switch(sub[0]) {
        case "servermessage":
            c.getWorldServer().setServerMessage(joinStringFrom(sub, 1));
            break;
        case "proitem":
            if (sub.length < 3) {
                player.yellowMessage("Syntax: !proitem <itemid> <statvalue>");
                break;
            }
            int itemid = Integer.parseInt(sub[1]);
            short multiply = Short.parseShort(sub[2]);
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            MapleInventoryType type = ItemConstants.getInventoryType(itemid);
            if (type.equals(MapleInventoryType.EQUIP)) {
                Item it = ii.getEquipById(itemid);
                it.setOwner(player.getName());
                hardsetItemStats((Equip) it, multiply);
                MapleInventoryManipulator.addFromDrop(c, it);
            } else {
                player.dropMessage(6, "Make sure it's an equippable item.");
            }
            break;
        case "seteqstat":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !seteqstat <statvalue>");
                break;
            }
            int newStat = Integer.parseInt(sub[1]);
            MapleInventory equip = player.getInventory(MapleInventoryType.EQUIP);
            for (byte i = 1; i <= equip.getSlotLimit(); i++) {
                try {
                    Equip eu = (Equip) equip.getItem(i);
                    if (eu == null)
                        continue;
                    short incval = (short) newStat;
                    eu.setWdef(incval);
                    eu.setAcc(incval);
                    eu.setAvoid(incval);
                    eu.setJump(incval);
                    eu.setMatk(incval);
                    eu.setMdef(incval);
                    eu.setHp(incval);
                    eu.setMp(incval);
                    eu.setSpeed(incval);
                    eu.setWatk(incval);
                    eu.setDex(incval);
                    eu.setInt(incval);
                    eu.setStr(incval);
                    eu.setLuk(incval);
                    byte flag = eu.getFlag();
                    flag |= ItemConstants.UNTRADEABLE;
                    eu.setFlag(flag);
                    player.forceUpdateItem(eu);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            break;
        case "exprate":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !exprate <newrate>");
                break;
            }
            int exprate = Math.max(Integer.parseInt(sub[1]), 1);
            c.getWorldServer().setExpRate(exprate);
            c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Exp Rate has been changed to " + exprate + "x."));
            break;
        case "mesorate":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !mesorate <newrate>");
                break;
            }
            int mesorate = Math.max(Integer.parseInt(sub[1]), 1);
            c.getWorldServer().setMesoRate(mesorate);
            c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Meso Rate has been changed to " + mesorate + "x."));
            break;
        case "droprate":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !droprate <newrate>");
                break;
            }
            int droprate = Math.max(Integer.parseInt(sub[1]), 1);
            c.getWorldServer().setDropRate(droprate);
            c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Drop Rate has been changed to " + droprate + "x."));
            break;
        case "questrate":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !questrate <newrate>");
                break;
            }
            int questrate = Math.max(Integer.parseInt(sub[1]), 1);
            c.getWorldServer().setQuestRate(questrate);
            c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Quest Rate has been changed to " + questrate + "x."));
            break;
        case "itemvac":
            List<MapleMapObject> list = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
            for (MapleMapObject item : list) {
                player.pickupItem(item);
            }
            break;
        case "forcevac":
            List<MapleMapObject> items = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
            for (MapleMapObject item : items) {
                MapleMapItem mapItem = (MapleMapItem) item;
                if (mapItem.getMeso() > 0) {
                    player.gainMeso(mapItem.getMeso(), true);
                } else if (mapItem.getItemId() == 4031865 || mapItem.getItemId() == 4031866) {
                    // Add NX to account, show effect and make item disappear
                    player.getCashShop().gainCash(1, mapItem.getItemId() == 4031865 ? 100 : 250);
                } else if (mapItem.getItem().getItemId() >= 5000000 && mapItem.getItem().getItemId() <= 5000100) {
                    int petId = MaplePet.createPet(mapItem.getItem().getItemId());
                    if (petId == -1) {
                        continue;
                    }
                    MapleInventoryManipulator.addById(c, mapItem.getItem().getItemId(), mapItem.getItem().getQuantity(), null, petId);
                } else {
                    MapleInventoryManipulator.addFromDrop(c, mapItem.getItem(), true);
                }
                player.getMap().pickItemDrop(MaplePacketCreator.removeItemFromMap(mapItem.getObjectId(), 2, player.getId()), mapItem);
            }
            break;
        case "zakum":
            player.getMap().spawnFakeMonsterOnGroundBelow(MapleLifeFactory.getMonster(8800000), player.getPosition());
            for (int x = 8800003; x < 8800011; x++) {
                player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(x), player.getPosition());
            }
            break;
        case "horntail":
            final Point targetPoint = player.getPosition();
            final MapleMap targetMap = player.getMap();
            targetMap.spawnHorntailOnGroundBelow(targetPoint);
            break;
        case "pinkbean":
            player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8820001), player.getPosition());
            break;
        case "pap":
            player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8500001), player.getPosition());
            break;
        case "pianus":
            player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8510000), player.getPosition());
            break;
        case "cake":
            MapleMonster monster = MapleLifeFactory.getMonster(9400606);
            if (sub.length > 1) {
                int newHp = Integer.parseInt(sub[1]);
                if (newHp < 0)
                    newHp = Integer.MAX_VALUE;
                monster.getStats().setHp(newHp);
                monster.setStartingHp(newHp);
            }
            player.getMap().spawnMonsterOnGroundBelow(monster, player.getPosition());
            break;
        default:
            return false;
    }
    return true;
}
Also used : MapleCharacter(client.MapleCharacter) MapleMapObject(server.maps.MapleMapObject) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) MapleInventory(client.inventory.MapleInventory) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) SQLException(java.sql.SQLException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) MapleMapItem(server.maps.MapleMapItem) Item(client.inventory.Item) Equip(client.inventory.Equip) MapleMap(server.maps.MapleMap) MapleInventoryType(client.inventory.MapleInventoryType) MapleItemInformationProvider(server.MapleItemInformationProvider) MapleMapItem(server.maps.MapleMapItem) MapleMonster(server.life.MapleMonster)

Example 10 with MapleItemInformationProvider

use of server.MapleItemInformationProvider in project HeavenMS by ronancpl.

the class UseSolomonHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    slea.readInt();
    short slot = slea.readShort();
    int itemId = slea.readInt();
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    Item slotItem = c.getPlayer().getInventory(MapleInventoryType.USE).getItem(slot);
    int gachaexp = ii.getExpById(itemId);
    if (c.getPlayer().getInventory(MapleInventoryType.USE).countById(itemId) <= 0 || slotItem.getItemId() != itemId || c.getPlayer().getLevel() > ii.getMaxLevelById(itemId)) {
        return;
    }
    if ((c.getPlayer().getGachaExp() + gachaexp) > Integer.MAX_VALUE) {
        return;
    }
    c.getPlayer().gainGachaExp(gachaexp);
    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, (short) 1, false);
    c.announce(MaplePacketCreator.enableActions());
}
Also used : Item(client.inventory.Item) 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