Search in sources :

Example 1 with MonsterCarnival

use of server.partyquest.MonsterCarnival in project HeavenMS by ronancpl.

the class MonsterCarnivalHandler method handlePacket.

public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter chr = c.getPlayer();
    MonsterCarnival carnival = chr.getCarnival();
    int tab = slea.readByte();
    int number = slea.readShort();
    if (carnival != null) {
        if (chr.getCarnivalParty() != carnival.getPartyRed() || chr.getCarnivalParty() != carnival.getPartyBlue()) {
            chr.getMap().broadcastMessage(MaplePacketCreator.leaveCPQ(chr));
            chr.changeMap(980000010);
        }
        if (chr.getCP() > getPrice(tab, number)) {
            if (tab == 0) {
                // SPAWNING
                if (chr.getCarnivalParty().canSummon()) {
                    chr.getMap().spawnCPQMonster(MapleLifeFactory.getMonster(getMonster(number)), new Point(1, 1), carnival.oppositeTeam(chr.getCarnivalParty()).getTeam());
                    chr.getCarnivalParty().summon();
                } else
                    chr.announce(MaplePacketCreator.CPQMessage((byte) 2));
            } else if (tab == 1) {
            } else if (tab == 2) {
                int rid = 9980000 + chr.getTeam();
                MapleReactor reactor = new MapleReactor(MapleReactorFactory.getReactor(rid), rid);
                /*switch (number) {
                            case 0:
                                reactor.setMonsterStatus(tab, MonsterStatus.WEAPON_ATTACK_UP, MobSkillFactory.getMobSkill(150, 1));
                                break;
                            case 1:
                                reactor.setMonsterStatus(tab, MonsterStatus.WEAPON_DEFENSE_UP, MobSkillFactory.getMobSkill(151, 1));
                                break;
                            case 2:
                                reactor.setMonsterStatus(tab, MonsterStatus.MAGIC_ATTACK_UP, MobSkillFactory.getMobSkill(152, 1));
                                break;
                            case 3:
                                reactor.setMonsterStatus(tab, MonsterStatus.MAGIC_DEFENSE_UP, MobSkillFactory.getMobSkill(153, 1));
                                break;
                            case 4:
                                reactor.setMonsterStatus(tab, MonsterStatus.ACC, MobSkillFactory.getMobSkill(154, 1));
                                break;
                            case 5:
                                reactor.setMonsterStatus(tab, MonsterStatus.AVOID, MobSkillFactory.getMobSkill(155, 1));
                                break;
                            case 6:
                                reactor.setMonsterStatus(tab, MonsterStatus.SPEED, MobSkillFactory.getMobSkill(156, 1));
                                break;
                            case 7:
                                reactor.setMonsterStatus(tab, MonsterStatus.WEAPON_IMMUNITY, MobSkillFactory.getMobSkill(140, 1));
                                break;
                            case 8:
                                reactor.setMonsterStatus(tab, MonsterStatus.MAGIC_IMMUNITY, MobSkillFactory.getMobSkill(141, 1));
                                break;
                        } */
                chr.getMap().spawnReactor(reactor);
            }
        } else {
            chr.getMap().broadcastMessage(MaplePacketCreator.CPQMessage((byte) 1));
        }
    } else {
        chr.announce(MaplePacketCreator.CPQMessage((byte) 5));
    }
    chr.announce(MaplePacketCreator.enableActions());
}
Also used : MapleCharacter(client.MapleCharacter) MonsterCarnival(server.partyquest.MonsterCarnival) MapleReactor(server.maps.MapleReactor) Point(java.awt.Point) Point(java.awt.Point)

Example 2 with MonsterCarnival

use of server.partyquest.MonsterCarnival in project HeavenMS by ronancpl.

the class MapleMap method addPlayer.

public void addPlayer(final MapleCharacter chr) {
    int chrSize;
    chrWLock.lock();
    try {
        characters.add(chr);
        chrSize = characters.size();
        addPartyMemberInternal(chr);
    } finally {
        chrWLock.unlock();
    }
    chr.setMapId(mapid);
    itemMonitorTimeout = 1;
    if (chrSize == 1) {
        if (!hasItemMonitor())
            startItemMonitor();
        if (onFirstUserEnter.length() != 0 && !chr.hasEntered(onFirstUserEnter, mapid) && MapScriptManager.getInstance().scriptExists(onFirstUserEnter, true)) {
            chr.enteredScript(onFirstUserEnter, mapid);
            MapScriptManager.getInstance().getMapScript(chr.getClient(), onFirstUserEnter, true);
        }
    }
    if (onUserEnter.length() != 0) {
        if (onUserEnter.equals("cygnusTest") && (mapid < 913040000 || mapid > 913040006)) {
            chr.saveLocation("INTRO");
        }
        MapScriptManager.getInstance().getMapScript(chr.getClient(), onUserEnter, false);
    }
    if (FieldLimit.CANNOTUSEMOUNTS.check(fieldLimit) && chr.getBuffedValue(MapleBuffStat.MONSTER_RIDING) != null) {
        chr.cancelEffectFromBuffStat(MapleBuffStat.MONSTER_RIDING);
        chr.cancelBuffStats(MapleBuffStat.MONSTER_RIDING);
    }
    if (mapid == 923010000 && getMonsterById(9300102) == null) {
        // Kenta's Mount Quest
        spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300102), new Point(77, 426));
    } else if (mapid == 200090060) {
        // To Rien
        chr.announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090060) {
                    chr.changeMap(140020300, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090070) {
        // To Lith Harbor
        chr.announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090070) {
                    chr.changeMap(104000000, 3);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090030) {
        // To Ereve (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090030) {
                    chr.changeMap(130000210, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090031) {
        // To Victoria Island (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090031) {
                    chr.changeMap(101000400, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090021) {
        // To Orbis (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090021) {
                    chr.changeMap(200000161, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090020) {
        // To Ereve From Orbis (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090020) {
                    chr.changeMap(130000210, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 103040400) {
        if (chr.getEventInstance() != null) {
            chr.getEventInstance().movePlayer(chr);
        }
    } else if (MapleMiniDungeonInfo.isDungeonMap(mapid)) {
        MapleMiniDungeon mmd = chr.getClient().getChannelServer().getMiniDungeon(mapid);
        if (mmd != null)
            mmd.registerPlayer(chr);
    }
    MaplePet[] pets = chr.getPets();
    for (int i = 0; i < pets.length; i++) {
        if (pets[i] != null) {
            pets[i].setPos(getGroundBelow(chr.getPosition()));
            chr.announce(MaplePacketCreator.showPet(chr, pets[i], false, false));
        } else {
            break;
        }
    }
    if (chr.isHidden()) {
        broadcastGMMessage(chr, MaplePacketCreator.spawnPlayerMapObject(chr), false);
        chr.announce(MaplePacketCreator.getGMEffect(0x10, (byte) 1));
        List<Pair<MapleBuffStat, Integer>> dsstat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DARKSIGHT, 0));
        broadcastGMMessage(chr, MaplePacketCreator.giveForeignBuff(chr.getId(), dsstat), false);
    } else {
        broadcastMessage(chr, MaplePacketCreator.spawnPlayerMapObject(chr), false);
    }
    sendObjectPlacement(chr.getClient());
    if (isStartingEventMap() && !eventStarted()) {
        chr.getMap().getPortal("join00").setPortalStatus(false);
    }
    if (hasForcedEquip()) {
        chr.getClient().announce(MaplePacketCreator.showForcedEquip(-1));
    }
    if (specialEquip()) {
        chr.getClient().announce(MaplePacketCreator.coconutScore(0, 0));
        chr.getClient().announce(MaplePacketCreator.showForcedEquip(chr.getTeam()));
    }
    objectWLock.lock();
    try {
        this.mapobjects.put(Integer.valueOf(chr.getObjectId()), chr);
    } finally {
        objectWLock.unlock();
    }
    if (chr.getPlayerShop() != null) {
        addMapObject(chr.getPlayerShop());
    }
    final MapleDragon dragon = chr.getDragon();
    if (dragon != null) {
        dragon.setPosition(chr.getPosition());
        this.addMapObject(dragon);
        if (chr.isHidden()) {
            this.broadcastGMMessage(chr, MaplePacketCreator.spawnDragon(dragon));
        } else {
            this.broadcastMessage(chr, MaplePacketCreator.spawnDragon(dragon));
        }
    }
    MapleStatEffect summonStat = chr.getStatForBuff(MapleBuffStat.SUMMON);
    if (summonStat != null) {
        MapleSummon summon = chr.getSummonByKey(summonStat.getSourceId());
        summon.setPosition(chr.getPosition());
        chr.getMap().spawnSummon(summon);
        updateMapObjectVisibility(chr, summon);
    }
    if (mapEffect != null) {
        mapEffect.sendStartData(chr.getClient());
    }
    chr.getClient().announce(MaplePacketCreator.resetForcedStats());
    if (mapid == 914000200 || mapid == 914000210 || mapid == 914000220) {
        chr.getClient().announce(MaplePacketCreator.aranGodlyStats());
    }
    if (chr.getEventInstance() != null && chr.getEventInstance().isTimerStarted()) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (chr.getEventInstance().getTimeLeft() / 1000)));
    }
    if (chr.getFitness() != null && chr.getFitness().isTimerStarted()) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (chr.getFitness().getTimeLeft() / 1000)));
    }
    if (chr.getOla() != null && chr.getOla().isTimerStarted()) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (chr.getOla().getTimeLeft() / 1000)));
    }
    if (mapid == 109060000) {
        chr.announce(MaplePacketCreator.rollSnowBall(true, 0, null, null));
    }
    MonsterCarnival carnival = chr.getCarnival();
    MonsterCarnivalParty cparty = chr.getCarnivalParty();
    if (carnival != null && cparty != null && (mapid == 980000101 || mapid == 980000201 || mapid == 980000301 || mapid == 980000401 || mapid == 980000501 || mapid == 980000601)) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (carnival.getTimeLeft() / 1000)));
        chr.getClient().announce(MaplePacketCreator.startCPQ(chr, carnival.oppositeTeam(cparty)));
    }
    if (hasClock()) {
        Calendar cal = Calendar.getInstance();
        chr.getClient().announce((MaplePacketCreator.getClockTime(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND))));
    }
    if (hasBoat() > 0) {
        if (hasBoat() == 1)
            chr.getClient().announce((MaplePacketCreator.boatPacket(true)));
        else
            chr.getClient().announce(MaplePacketCreator.boatPacket(false));
    }
    chr.receivePartyMemberHP();
}
Also used : MapleBuffStat(client.MapleBuffStat) MonsterCarnival(server.partyquest.MonsterCarnival) Calendar(java.util.Calendar) MonsterCarnivalParty(server.partyquest.MonsterCarnivalParty) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapleStatEffect(server.MapleStatEffect) MaplePet(client.inventory.MaplePet) Pair(tools.Pair)

Aggregations

Point (java.awt.Point)2 MonsterCarnival (server.partyquest.MonsterCarnival)2 MapleBuffStat (client.MapleBuffStat)1 MapleCharacter (client.MapleCharacter)1 MaplePet (client.inventory.MaplePet)1 Calendar (java.util.Calendar)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MapleStatEffect (server.MapleStatEffect)1 SpawnPoint (server.life.SpawnPoint)1 MapleReactor (server.maps.MapleReactor)1 MonsterCarnivalParty (server.partyquest.MonsterCarnivalParty)1 Pair (tools.Pair)1