Search in sources :

Example 46 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class AllianceOperationHandler method changeLeaderAllianceRank.

private void changeLeaderAllianceRank(MapleAlliance alliance, MapleCharacter newLeader) {
    MapleGuildCharacter lmgc = alliance.getLeader();
    MapleCharacter leader = Server.getInstance().getWorld(newLeader.getWorld()).getPlayerStorage().getCharacterById(lmgc.getId());
    leader.getMGC().setAllianceRank(2);
    leader.saveGuildStatus();
    newLeader.getMGC().setAllianceRank(1);
    newLeader.saveGuildStatus();
    Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, newLeader.getWorld()), -1, -1);
    alliance.dropMessage("'" + newLeader.getName() + "' has been appointed as the new head of this Alliance.");
}
Also used : MapleCharacter(client.MapleCharacter) MapleGuildCharacter(net.server.guild.MapleGuildCharacter)

Example 47 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class AranComboHandler method handlePacket.

@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    final MapleCharacter player = c.getPlayer();
    int skillLevel = player.getSkillLevel(SkillFactory.getSkill(Aran.COMBO_ABILITY));
    if (GameConstants.isAran(player.getJob().getId()) && (skillLevel > 0 || player.getJob().getId() == 2000)) {
        final long currentTime = System.currentTimeMillis();
        short combo = player.getCombo();
        if ((currentTime - player.getLastCombo()) > 3000 && combo > 0) {
            combo = 0;
        }
        combo++;
        switch(combo) {
            case 10:
            case 20:
            case 30:
            case 40:
            case 50:
            case 60:
            case 70:
            case 80:
            case 90:
            case 100:
                if (player.getJob().getId() != 2000 && (combo / 10) > skillLevel)
                    break;
                SkillFactory.getSkill(Aran.COMBO_ABILITY).getEffect(combo / 10).applyComboBuff(player, combo);
                break;
        }
        player.setCombo(combo);
        player.setLastCombo(currentTime);
    }
}
Also used : MapleCharacter(client.MapleCharacter)

Example 48 with MapleCharacter

use of client.MapleCharacter 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 49 with MapleCharacter

use of client.MapleCharacter 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 50 with MapleCharacter

use of client.MapleCharacter 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)

Aggregations

MapleCharacter (client.MapleCharacter)163 Point (java.awt.Point)32 SQLException (java.sql.SQLException)22 Item (client.inventory.Item)21 Connection (java.sql.Connection)15 PreparedStatement (java.sql.PreparedStatement)15 MapleMonster (server.life.MapleMonster)15 MapleMapObject (server.maps.MapleMapObject)15 DatabaseConnection (tools.DatabaseConnection)15 MapleMap (server.maps.MapleMap)14 ArrayList (java.util.ArrayList)13 Skill (client.Skill)12 SpawnPoint (server.life.SpawnPoint)12 LinkedList (java.util.LinkedList)11 MapleInventory (client.inventory.MapleInventory)10 World (net.server.world.World)10 MapleStatEffect (server.MapleStatEffect)10 MapleInventoryType (client.inventory.MapleInventoryType)9 ResultSet (java.sql.ResultSet)9 MapleItemInformationProvider (server.MapleItemInformationProvider)9