Search in sources :

Example 6 with MapleMapObject

use of server.maps.MapleMapObject 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 7 with MapleMapObject

use of server.maps.MapleMapObject 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 8 with MapleMapObject

use of server.maps.MapleMapObject in project HeavenMS by ronancpl.

the class CharInfoRequestHandler method handlePacket.

public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    slea.skip(4);
    int cid = slea.readInt();
    MapleMapObject target = c.getPlayer().getMap().getMapObject(cid);
    if (target != null) {
        if (target instanceof MapleCharacter) {
            MapleCharacter player = (MapleCharacter) target;
            if (c.getPlayer().getId() != player.getId()) {
                player.exportExcludedItems(c);
            }
            c.announce(MaplePacketCreator.charInfo(player));
        }
    }
}
Also used : MapleCharacter(client.MapleCharacter) MapleMapObject(server.maps.MapleMapObject)

Example 9 with MapleMapObject

use of server.maps.MapleMapObject in project HeavenMS by ronancpl.

the class AbstractPlayerInteraction method resetMap.

public void resetMap(int mapid) {
    getMap(mapid).resetReactors();
    getMap(mapid).killAllMonsters();
    for (MapleMapObject i : getMap(mapid).getMapObjectsInRange(c.getPlayer().getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM))) {
        getMap(mapid).removeMapObject(i);
        getMap(mapid).broadcastMessage(MaplePacketCreator.removeItemFromMap(i.getObjectId(), 0, c.getPlayer().getId()));
    }
}
Also used : MapleMapObject(server.maps.MapleMapObject)

Example 10 with MapleMapObject

use of server.maps.MapleMapObject in project HeavenMS by ronancpl.

the class MapleStatEffect method applyMonsterBuff.

private void applyMonsterBuff(MapleCharacter applyfrom) {
    Rectangle bounds = calculateBoundingBox(applyfrom.getPosition(), applyfrom.isFacingLeft());
    List<MapleMapObject> affected = applyfrom.getMap().getMapObjectsInRect(bounds, Arrays.asList(MapleMapObjectType.MONSTER));
    Skill skill_ = SkillFactory.getSkill(sourceid);
    int i = 0;
    for (MapleMapObject mo : affected) {
        MapleMonster monster = (MapleMonster) mo;
        if (isDispel()) {
            monster.debuffMob(skill_.getId());
        } else {
            if (makeChanceResult()) {
                monster.applyStatus(applyfrom, new MonsterStatusEffect(getMonsterStati(), skill_, null, false), isPoison(), getDuration());
                if (isCrash()) {
                    monster.debuffMob(skill_.getId());
                }
            }
        }
        i++;
        if (i >= mobCount) {
            break;
        }
    }
}
Also used : Skill(client.Skill) MonsterStatusEffect(client.status.MonsterStatusEffect) Rectangle(java.awt.Rectangle) MapleMapObject(server.maps.MapleMapObject) Point(java.awt.Point) MapleMonster(server.life.MapleMonster)

Aggregations

MapleMapObject (server.maps.MapleMapObject)21 MapleCharacter (client.MapleCharacter)15 MapleMonster (server.life.MapleMonster)9 Point (java.awt.Point)8 MapleMap (server.maps.MapleMap)6 Item (client.inventory.Item)5 ArrayList (java.util.ArrayList)5 MapleMapItem (server.maps.MapleMapItem)5 Skill (client.Skill)3 MapleInventoryType (client.inventory.MapleInventoryType)3 MonsterStatusEffect (client.status.MonsterStatusEffect)3 Rectangle (java.awt.Rectangle)3 MapleItemInformationProvider (server.MapleItemInformationProvider)3 MapleNPC (server.life.MapleNPC)3 SpawnPoint (server.life.SpawnPoint)3 MapleInventory (client.inventory.MapleInventory)2 IOException (java.io.IOException)2 UnknownHostException (java.net.UnknownHostException)2 SQLException (java.sql.SQLException)2 MaplePortal (server.MaplePortal)2