Search in sources :

Example 1 with MapleReactor

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

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

the class ReactorHitHandler method handlePacket.

public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    // System.out.println(slea); //To see if there are any differences with packets
    // CD 00 6B 00 00 00 01 00 00 00 03 00 00 00 20 03 F7 03 00 00
    // [CD 00] [66 00 00 00] [00 00 00 00] [02 00] [00 00 19 01] [00 00 00 00]
    int oid = slea.readInt();
    int charPos = slea.readInt();
    short stance = slea.readShort();
    slea.skip(4);
    int skillid = slea.readInt();
    MapleReactor reactor = c.getPlayer().getMap().getReactorByOid(oid);
    if (reactor != null && reactor.isAlive()) {
        reactor.hitReactor(true, charPos, stance, skillid, c);
    }
}
Also used : MapleReactor(server.maps.MapleReactor)

Example 3 with MapleReactor

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

the class ReactorActionManager method dropItems.

public void dropItems(boolean delayed, int posX, int posY, boolean meso, int mesoChance, final int minMeso, final int maxMeso, int minItems) {
    if (c.getPlayer() == null)
        return;
    List<ReactorDropEntry> items = generateDropList(getDropChances(), c.getPlayer().getDropRate(), meso, mesoChance, minItems);
    if (items.size() % 2 == 0)
        posX -= 12;
    final Point dropPos = new Point(posX, posY);
    if (!delayed) {
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        byte p = 1;
        for (ReactorDropEntry d : items) {
            dropPos.x = (int) (posX + ((p % 2 == 0) ? (25 * ((p + 1) / 2)) : -(25 * (p / 2))));
            p++;
            if (d.itemId == 0) {
                int range = maxMeso - minMeso;
                int displayDrop = (int) (Math.random() * range) + minMeso;
                int mesoDrop = (displayDrop * client.getWorldServer().getMesoRate());
                reactor.getMap().spawnMesoDrop(mesoDrop, reactor.getMap().calcDropPos(dropPos, reactor.getPosition()), reactor, client.getPlayer(), false, (byte) 2);
            } else {
                Item drop;
                if (ItemConstants.getInventoryType(d.itemId) != MapleInventoryType.EQUIP) {
                    drop = new Item(d.itemId, (short) 0, (short) 1);
                } else {
                    drop = ii.randomizeStats((Equip) ii.getEquipById(d.itemId));
                }
                reactor.getMap().dropFromReactor(getPlayer(), reactor, drop, dropPos, (short) d.questid);
            }
        }
    } else {
        final MapleCharacter chr = client.getPlayer();
        final MapleReactor r = reactor;
        final List<ReactorDropEntry> dropItems = items;
        final int worldMesoRate = client.getWorldServer().getMesoRate();
        dropPos.x -= (12 * items.size());
        sprayTask = TimerManager.getInstance().register(new Runnable() {

            @Override
            public void run() {
                if (dropItems.isEmpty()) {
                    sprayTask.cancel(false);
                    return;
                }
                ReactorDropEntry d = dropItems.remove(0);
                if (d.itemId == 0) {
                    int range = maxMeso - minMeso;
                    int displayDrop = (int) (Math.random() * range) + minMeso;
                    int mesoDrop = (displayDrop * worldMesoRate);
                    r.getMap().spawnMesoDrop(mesoDrop, r.getMap().calcDropPos(dropPos, r.getPosition()), r, chr, false, (byte) 2);
                } else {
                    Item drop;
                    if (ItemConstants.getInventoryType(d.itemId) != MapleInventoryType.EQUIP) {
                        drop = new Item(d.itemId, (short) 0, (short) 1);
                    } else {
                        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
                        drop = ii.randomizeStats((Equip) ii.getEquipById(d.itemId));
                    }
                    r.getMap().dropFromReactor(getPlayer(), r, drop, dropPos, (short) d.questid);
                }
                dropPos.x += 25;
            }
        }, 100);
    }
}
Also used : ReactorDropEntry(server.maps.ReactorDropEntry) Item(client.inventory.Item) Equip(client.inventory.Equip) MapleCharacter(client.MapleCharacter) MapleReactor(server.maps.MapleReactor) MapleItemInformationProvider(server.MapleItemInformationProvider) Point(java.awt.Point) Point(java.awt.Point)

Example 4 with MapleReactor

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

the class Commands method executeHeavenMsCommandLv5.

public static boolean executeHeavenMsCommandLv5(Channel cserv, Server srv, MapleClient c, String[] sub) {
    // Developer
    MapleCharacter player = c.getPlayer();
    MapleMonster monster;
    switch(sub[0]) {
        case "debugmonster":
            List<MapleMapObject> monsters = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.MONSTER));
            for (MapleMapObject monstermo : monsters) {
                monster = (MapleMonster) monstermo;
                player.message("Monster ID: " + monster.getId() + " Aggro target: " + ((monster.getController() != null) ? monster.getController().getName() : "<none>"));
            }
            break;
        case "debugpacket":
            player.getMap().broadcastMessage(MaplePacketCreator.customPacket(joinStringFrom(sub, 1)));
            break;
        case "debugportal":
            MaplePortal portal = player.getMap().findClosestPortal(player.getPosition());
            if (portal != null)
                player.dropMessage(6, "Closest portal: " + portal.getId() + " '" + portal.getName() + "' Type: " + portal.getType() + " --> toMap: " + portal.getTargetMapId() + " scriptname: '" + portal.getScriptName() + "' state: " + portal.getPortalState() + ".");
            else
                player.dropMessage(6, "There is no portal on this map.");
            break;
        case "debugspawnpoint":
            SpawnPoint sp = player.getMap().findClosestSpawnpoint(player.getPosition());
            if (sp != null)
                player.dropMessage(6, "Closest mob spawn point: " + " Position: x " + sp.getPosition().getX() + " y " + sp.getPosition().getY() + " Spawns mobid: '" + sp.getMonsterId() + "' --> canSpawn: " + !sp.getDenySpawn() + " canSpawnRightNow: " + sp.shouldSpawn() + ".");
            else
                player.dropMessage(6, "There is no mob spawn point on this map.");
            break;
        case "debugpos":
            player.dropMessage(6, "Current map position: (" + player.getPosition().getX() + ", " + player.getPosition().getY() + ").");
            break;
        case "debugmap":
            player.dropMessage(6, "Current map id " + player.getMap().getId() + ", event: '" + ((player.getMap().getEventInstance() != null) ? player.getMap().getEventInstance().getName() : "null") + "'; Players: " + player.getMap().getAllPlayers().size() + ", Mobs: " + player.getMap().countMonsters() + ", Reactors: " + player.getMap().countReactors() + ", Items: " + player.getMap().countItems() + ", Objects: " + player.getMap().getMapObjects().size() + ".");
            break;
        case "debugmobsp":
            player.getMap().reportMonsterSpawnPoints(player);
            break;
        case "debugevent":
            if (player.getEventInstance() == null)
                player.dropMessage(6, "Player currently not in an event.");
            else
                player.dropMessage(6, "Current event name: " + player.getEventInstance().getName() + ".");
            break;
        case "debugareas":
            player.dropMessage(6, "Configured areas on map " + player.getMapId() + ":");
            byte index = 0;
            for (Rectangle rect : player.getMap().getAreas()) {
                player.dropMessage(6, "Id: " + index + " -> posX: " + rect.getX() + " posY: '" + rect.getY() + "' dX: " + rect.getWidth() + " dY: " + rect.getHeight() + ".");
                index++;
            }
            break;
        case "debugreactors":
            player.dropMessage(6, "Current reactor states on map " + player.getMapId() + ":");
            for (MapleMapObject mmo : player.getMap().getReactors()) {
                MapleReactor mr = (MapleReactor) mmo;
                player.dropMessage(6, "Id: " + mr.getId() + " Oid: " + mr.getObjectId() + " name: '" + mr.getName() + "' -> Type: " + mr.getReactorType() + " State: " + mr.getState() + " Event State: " + mr.getEventState() + " Position: x " + mr.getPosition().getX() + " y " + mr.getPosition().getY() + ".");
            }
            break;
        case "debugservercoupons":
        case "debugcoupons":
            String s = "Currently active SERVER coupons: ";
            for (Integer i : Server.getInstance().getActiveCoupons()) {
                s += (i + " ");
            }
            player.dropMessage(6, s);
            break;
        case "debugplayercoupons":
            String st = "Currently active PLAYER coupons: ";
            for (Integer i : player.getActiveCoupons()) {
                st += (i + " ");
            }
            player.dropMessage(6, st);
            break;
        case "debugtimer":
            TimerManager tMan = TimerManager.getInstance();
            player.dropMessage(6, "Total Task: " + tMan.getTaskCount() + " Current Task: " + tMan.getQueuedTasks() + " Active Task: " + tMan.getActiveCount() + " Completed Task: " + tMan.getCompletedTaskCount());
            break;
        default:
            return false;
    }
    return true;
}
Also used : MapleCharacter(client.MapleCharacter) MaplePortal(server.MaplePortal) MapleReactor(server.maps.MapleReactor) Rectangle(java.awt.Rectangle) MapleMapObject(server.maps.MapleMapObject) TimerManager(server.TimerManager) SpawnPoint(server.life.SpawnPoint) MapleMonster(server.life.MapleMonster)

Example 5 with MapleReactor

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

the class TouchReactorHandler method handlePacket.

public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    int oid = slea.readInt();
    MapleReactor reactor = c.getPlayer().getMap().getReactorByOid(oid);
    if (reactor != null) {
        if (slea.readByte() != 0) {
            ReactorScriptManager.getInstance().touch(c, reactor);
        } else {
            ReactorScriptManager.getInstance().untouch(c, reactor);
        }
    }
}
Also used : MapleReactor(server.maps.MapleReactor)

Aggregations

MapleReactor (server.maps.MapleReactor)5 MapleCharacter (client.MapleCharacter)3 Point (java.awt.Point)2 Equip (client.inventory.Equip)1 Item (client.inventory.Item)1 Rectangle (java.awt.Rectangle)1 MapleItemInformationProvider (server.MapleItemInformationProvider)1 MaplePortal (server.MaplePortal)1 TimerManager (server.TimerManager)1 MapleMonster (server.life.MapleMonster)1 SpawnPoint (server.life.SpawnPoint)1 MapleMapObject (server.maps.MapleMapObject)1 ReactorDropEntry (server.maps.ReactorDropEntry)1 MonsterCarnival (server.partyquest.MonsterCarnival)1