Search in sources :

Example 6 with MaplePartyCharacter

use of net.server.world.MaplePartyCharacter in project HeavenMS by ronancpl.

the class EventInstanceManager method registerParty.

public void registerParty(MapleParty party, MapleMap map) {
    for (MaplePartyCharacter pc : party.getEligibleMembers()) {
        MapleCharacter c = map.getCharacterById(pc.getId());
        registerPlayer(c);
    }
}
Also used : MapleCharacter(client.MapleCharacter) MaplePartyCharacter(net.server.world.MaplePartyCharacter)

Example 7 with MaplePartyCharacter

use of net.server.world.MaplePartyCharacter in project HeavenMS by ronancpl.

the class MapleAlliance method getPartyGuildMasters.

private static List<MapleCharacter> getPartyGuildMasters(MapleParty party) {
    List<MapleCharacter> mcl = new LinkedList<>();
    for (MaplePartyCharacter mpc : party.getMembers()) {
        if (mpc.getPlayer().getGuildRank() == 1 && mpc.getPlayer().getMapId() == party.getLeader().getPlayer().getMapId())
            mcl.add(mpc.getPlayer());
    }
    if (!mcl.isEmpty() && !mcl.get(0).isPartyLeader()) {
        for (int i = 1; i < mcl.size(); i++) {
            if (mcl.get(i).isPartyLeader()) {
                MapleCharacter temp = mcl.get(0);
                mcl.set(0, mcl.get(i));
                mcl.set(i, temp);
            }
        }
    }
    return mcl;
}
Also used : MapleCharacter(client.MapleCharacter) LinkedList(java.util.LinkedList) MaplePartyCharacter(net.server.world.MaplePartyCharacter)

Example 8 with MaplePartyCharacter

use of net.server.world.MaplePartyCharacter in project HeavenMS by ronancpl.

the class MapleStatEffect method applyTo.

// primary: the player caster of the buff
private boolean applyTo(MapleCharacter applyfrom, MapleCharacter applyto, boolean primary, Point pos, boolean useMaxRange) {
    if (skill && (sourceid == GM.HIDE || sourceid == SuperGM.HIDE)) {
        applyto.toggleHide(false);
        return true;
    }
    int hpchange = calcHPChange(applyfrom, primary);
    int mpchange = calcMPChange(applyfrom, primary);
    if (primary) {
        if (itemConNo != 0) {
            if (!applyto.getClient().getAbstractPlayerInteraction().hasItem(itemCon, itemConNo)) {
                applyto.getClient().announce(MaplePacketCreator.enableActions());
                return false;
            }
            MapleInventoryManipulator.removeById(applyto.getClient(), ItemConstants.getInventoryType(itemCon), itemCon, itemConNo, false, true);
        }
    }
    List<Pair<MapleStat, Integer>> hpmpupdate = new ArrayList<>(2);
    if (!primary) {
        if (isResurrection()) {
            hpchange = applyto.getMaxHp();
            applyto.setStance(0);
            applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
            applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapObject(applyto), false);
        }
    }
    if (isDispel() && makeChanceResult()) {
        applyto.dispelDebuffs();
    } else if (isCureAllAbnormalStatus()) {
        applyto.dispelDebuff(MapleDisease.SEDUCE);
        applyto.dispelDebuff(MapleDisease.ZOMBIFY);
        applyto.dispelDebuffs();
    } else if (isComboReset()) {
        applyto.setCombo((short) 0);
    }
    /*if (applyfrom.getMp() < getMpCon()) {
         AutobanFactory.MPCON.addPoint(applyfrom.getAutobanManager(), "mpCon hack for skill:" + sourceid + "; Player MP: " + applyto.getMp() + " MP Needed: " + getMpCon());
         } */
    if (hpchange != 0) {
        if (hpchange < 0 && (-hpchange) >= applyto.getHp() && (!applyto.hasDisease(MapleDisease.ZOMBIFY) || hpCon > 0)) {
            if (!applyto.isGM()) {
                applyto.getClient().announce(MaplePacketCreator.enableActions());
                return false;
            }
        }
        int newHp = applyto.getHp() + hpchange;
        if (newHp < 1) {
            newHp = 1;
        }
        applyto.setHp(newHp);
        hpmpupdate.add(new Pair<>(MapleStat.HP, Integer.valueOf(applyto.getHp())));
    }
    int newMp = applyto.getMp() + mpchange;
    if (mpchange != 0) {
        if (mpchange < 0 && -mpchange > applyto.getMp()) {
            if (!applyto.isGM()) {
                applyto.getClient().announce(MaplePacketCreator.enableActions());
                return false;
            } else {
                newMp = 0;
            }
        }
        applyto.setMp(newMp);
        hpmpupdate.add(new Pair<>(MapleStat.MP, Integer.valueOf(applyto.getMp())));
    }
    applyto.getClient().announce(MaplePacketCreator.updatePlayerStats(hpmpupdate, true, applyto));
    if (moveTo != -1) {
        if (moveTo != applyto.getMapId()) {
            MapleMap target;
            MaplePortal pt;
            if (moveTo == 999999999) {
                if (sourceid != 2030100) {
                    target = applyto.getMap().getReturnMap();
                    pt = target.getRandomPlayerSpawnpoint();
                } else {
                    if (!applyto.canRecoverLastBanish())
                        return false;
                    Pair<Integer, Integer> lastBanishInfo = applyto.getLastBanishData();
                    target = applyto.getWarpMap(lastBanishInfo.getLeft());
                    pt = target.getPortal(lastBanishInfo.getRight());
                }
            } else {
                target = applyto.getClient().getWorldServer().getChannel(applyto.getClient().getChannel()).getMapFactory().getMap(moveTo);
                int targetid = target.getId() / 10000000;
                if (targetid != 60 && applyto.getMapId() / 10000000 != 61 && targetid != applyto.getMapId() / 10000000 && targetid != 21 && targetid != 20 && targetid != 12 && (applyto.getMapId() / 10000000 != 10 && applyto.getMapId() / 10000000 != 12)) {
                    return false;
                }
                pt = target.getRandomPlayerSpawnpoint();
            }
            applyto.changeMap(target, pt);
        } else {
            return false;
        }
    }
    if (isShadowClaw()) {
        int projectile = 0;
        MapleInventory use = applyto.getInventory(MapleInventoryType.USE);
        for (int i = 1; i <= use.getSlotLimit(); i++) {
            // impose order...
            Item item = use.getItem((short) i);
            if (item != null) {
                if (ItemConstants.isThrowingStar(item.getItemId()) && item.getQuantity() >= 200) {
                    projectile = item.getItemId();
                    break;
                }
            }
        }
        if (projectile == 0) {
            return false;
        } else {
            MapleInventoryManipulator.removeById(applyto.getClient(), MapleInventoryType.USE, projectile, 200, false, true);
        }
    }
    SummonMovementType summonMovementType = getSummonMovementType();
    if (overTime || isCygnusFA() || summonMovementType != null) {
        if (summonMovementType != null && pos != null) {
            if (summonMovementType.getValue() == summonMovementType.STATIONARY.getValue())
                applyto.cancelBuffStats(MapleBuffStat.PUPPET);
            else
                applyto.cancelBuffStats(MapleBuffStat.SUMMON);
        }
        applyBuffEffect(applyfrom, applyto, primary);
    }
    if (primary && (overTime || isHeal())) {
        applyBuff(applyfrom, useMaxRange);
    }
    if (primary && isMonsterBuff()) {
        applyMonsterBuff(applyfrom);
    }
    if (this.getFatigue() != 0) {
        applyto.getMount().setTiredness(applyto.getMount().getTiredness() + this.getFatigue());
    }
    if (summonMovementType != null && pos != null) {
        final MapleSummon tosummon = new MapleSummon(applyfrom, sourceid, pos, summonMovementType);
        applyfrom.getMap().spawnSummon(tosummon);
        applyfrom.addSummon(sourceid, tosummon);
        tosummon.addHP(x);
        if (isBeholder()) {
            tosummon.addHP(1);
        }
    }
    if (isMagicDoor() && !FieldLimit.DOOR.check(applyto.getMap().getFieldLimit())) {
        // Magic Door
        int y = applyto.getFh();
        if (y == 0) {
            y = applyto.getPosition().y;
        }
        Point doorPosition = new Point(applyto.getPosition().x, y);
        MapleDoor door = new MapleDoor(applyto, doorPosition);
        if (door.getOwnerId() >= 0) {
            if (applyto.getParty() != null) {
                for (MaplePartyCharacter partyMember : applyto.getParty().getMembers()) {
                    partyMember.getPlayer().addDoor(door.getOwnerId(), door);
                    partyMember.addDoor(door.getOwnerId(), door);
                }
                applyto.silentPartyUpdate();
            } else {
                applyto.addDoor(door.getOwnerId(), door);
            }
            door.getTarget().spawnDoor(door.getAreaDoor());
            door.getTown().spawnDoor(door.getTownDoor());
            applyto.disableDoorSpawn();
        } else {
            MapleInventoryManipulator.addFromDrop(applyto.getClient(), new Item(4006000, (short) 0, (short) 1), false);
            if (door.getOwnerId() == -3)
                applyto.dropMessage(5, "Mystic Door cannot be cast far from a spawn point. Nearest one is at " + door.getDoorStatus().getRight() + "pts " + door.getDoorStatus().getLeft());
            else if (door.getOwnerId() == -2)
                applyto.dropMessage(5, "Mystic Door cannot be cast on a slope, try elsewhere.");
            else
                applyto.dropMessage(5, "There are no door portals available for the town at this moment. Try again later.");
            // cancel door buff
            applyto.cancelBuffStats(MapleBuffStat.SOULARROW);
        }
    } else if (isMist()) {
        Rectangle bounds = calculateBoundingBox(sourceid == NightWalker.POISON_BOMB ? pos : applyfrom.getPosition(), applyfrom.isFacingLeft());
        MapleMist mist = new MapleMist(bounds, applyfrom, this);
        applyfrom.getMap().spawnMist(mist, getDuration(), mist.isPoisonMist(), false, mist.isRecoveryMist());
    } else if (isTimeLeap()) {
        applyto.removeAllCooldownsExcept(Buccaneer.TIME_LEAP, true);
    } else if (isHyperBody() && !primary) {
        applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
        applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapObject(applyto), false);
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) Rectangle(java.awt.Rectangle) Point(java.awt.Point) MapleInventory(client.inventory.MapleInventory) Point(java.awt.Point) MapleMap(server.maps.MapleMap) Item(client.inventory.Item) MapleMist(server.maps.MapleMist) MapleSummon(server.maps.MapleSummon) Pair(tools.Pair) SummonMovementType(server.maps.SummonMovementType) MapleDoor(server.maps.MapleDoor) MaplePartyCharacter(net.server.world.MaplePartyCharacter)

Example 9 with MaplePartyCharacter

use of net.server.world.MaplePartyCharacter in project HeavenMS by ronancpl.

the class NPCConversationManager method createPyramid.

public boolean createPyramid(String mode, boolean party) {
    // lol
    PyramidMode mod = PyramidMode.valueOf(mode);
    MapleParty partyz = getPlayer().getParty();
    MapleMapFactory mf = c.getChannelServer().getMapFactory();
    MapleMap map = null;
    int mapid = 926010100;
    if (party) {
        mapid += 10000;
    }
    mapid += (mod.getMode() * 1000);
    for (byte b = 0; b < 5; b++) {
        // They cannot warp to the next map before the timer ends (:
        map = mf.getMap(mapid + b);
        if (map.getCharacters().size() > 0) {
            continue;
        } else {
            break;
        }
    }
    if (map == null) {
        return false;
    }
    if (!party) {
        partyz = new MapleParty(-1, new MaplePartyCharacter(getPlayer()));
    }
    Pyramid py = new Pyramid(partyz, mod, map.getId());
    getPlayer().setPartyQuest(py);
    py.warp(mapid);
    dispose();
    return true;
}
Also used : PyramidMode(server.partyquest.Pyramid.PyramidMode) MapleMapFactory(server.maps.MapleMapFactory) MapleMap(server.maps.MapleMap) Pyramid(server.partyquest.Pyramid) MapleParty(net.server.world.MapleParty) MaplePartyCharacter(net.server.world.MaplePartyCharacter)

Example 10 with MaplePartyCharacter

use of net.server.world.MaplePartyCharacter in project HeavenMS by ronancpl.

the class MapleCharacter method getPartyMembers.

public List<MapleCharacter> getPartyMembers() {
    List<MapleCharacter> list = new LinkedList<>();
    prtLock.lock();
    try {
        if (party != null) {
            for (MaplePartyCharacter partyMembers : party.getMembers()) {
                list.add(partyMembers.getPlayer());
            }
        }
    } finally {
        prtLock.unlock();
    }
    return list;
}
Also used : LinkedList(java.util.LinkedList) MaplePartyCharacter(net.server.world.MaplePartyCharacter)

Aggregations

MaplePartyCharacter (net.server.world.MaplePartyCharacter)16 MapleCharacter (client.MapleCharacter)6 Point (java.awt.Point)6 MapleParty (net.server.world.MapleParty)6 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 World (net.server.world.World)4 MapleMap (server.maps.MapleMap)4 Pair (tools.Pair)4 SQLException (java.sql.SQLException)3 MapleDoor (server.maps.MapleDoor)3 Item (client.inventory.Item)2 MaplePet (client.inventory.MaplePet)2 Server (net.server.Server)2 MapleGuild (net.server.guild.MapleGuild)2 MapleGuildCharacter (net.server.guild.MapleGuildCharacter)2 MapleMapFactory (server.maps.MapleMapFactory)2 MapleMapItem (server.maps.MapleMapItem)2 BuddylistEntry (client.BuddylistEntry)1 CharacterNameAndId (client.CharacterNameAndId)1