Search in sources :

Example 26 with MapleMap

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

the class MapleCharacter method changeMap.

public void changeMap(int map, String portal) {
    MapleMap warpMap;
    EventInstanceManager eim = getEventInstance();
    if (eim != null) {
        warpMap = eim.getMapInstance(map);
    } else {
        warpMap = client.getChannelServer().getMapFactory().getMap(map);
    }
    changeMap(warpMap, warpMap.getPortal(portal));
}
Also used : MapleMap(server.maps.MapleMap) EventInstanceManager(scripting.event.EventInstanceManager)

Example 27 with MapleMap

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

the class MobDamageMobHandler method handlePacket.

public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    int from = slea.readInt();
    slea.readInt();
    int to = slea.readInt();
    slea.readByte();
    int dmg = slea.readInt();
    MapleMap map = c.getPlayer().getMap();
    if (map.getMonsterByOid(from) != null && map.getMonsterByOid(to) != null) {
        map.damageMonster(c.getPlayer(), map.getMonsterByOid(to), dmg);
    }
}
Also used : MapleMap(server.maps.MapleMap)

Example 28 with MapleMap

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

the class AutoAggroHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    if (c.getPlayer().isHidden())
        // Don't auto aggro GM's in hide...
        return;
    MapleMap map = c.getPlayer().getMap();
    int oid = slea.readInt();
    MapleMonster monster = map.getMonsterByOid(oid);
    if (monster != null && monster.getController() != null) {
        if (!monster.isControllerHasAggro()) {
            if (map.getCharacterById(monster.getController().getId()) == null) {
                monster.switchController(c.getPlayer(), true);
            } else {
                monster.switchController(monster.getController(), true);
            }
        } else if (map.getCharacterById(monster.getController().getId()) == null) {
            monster.switchController(c.getPlayer(), true);
        }
    } else if (monster != null && monster.getController() == null) {
        monster.switchController(c.getPlayer(), true);
    }
}
Also used : MapleMap(server.maps.MapleMap) MapleMonster(server.life.MapleMonster)

Example 29 with MapleMap

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

the class ChangeMapHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter chr = c.getPlayer();
    if (chr.isChangingMaps() || chr.isBanned()) {
        c.announce(MaplePacketCreator.enableActions());
        return;
    }
    if (chr.getTrade() != null) {
        MapleTrade.cancelTrade(chr);
    }
    if (slea.available() == 0) {
        // Cash Shop :)
        if (!chr.getCashShop().isOpened()) {
            c.disconnect(false, false);
            return;
        }
        String[] socket = c.getChannelServer().getIP().split(":");
        chr.getCashShop().open(false);
        c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION);
        try {
            c.announce(MaplePacketCreator.getChannelChange(InetAddress.getByName(socket[0]), Integer.parseInt(socket[1])));
        } catch (UnknownHostException ex) {
            ex.printStackTrace();
        }
    } else {
        if (chr.getCashShop().isOpened()) {
            c.disconnect(false, false);
            return;
        }
        try {
            // 1 = from dying 0 = regular portals
            slea.readByte();
            int targetid = slea.readInt();
            String startwp = slea.readMapleAsciiString();
            MaplePortal portal = chr.getMap().getPortal(startwp);
            slea.readByte();
            boolean wheel = slea.readShort() > 0;
            if (targetid != -1 && !chr.isAlive()) {
                boolean executeStandardPath = true;
                if (chr.getEventInstance() != null) {
                    executeStandardPath = chr.getEventInstance().revivePlayer(chr);
                }
                if (executeStandardPath) {
                    MapleMap to = chr.getMap();
                    if (wheel && chr.haveItemWithId(5510000, false)) {
                        MapleInventoryManipulator.removeById(c, MapleInventoryType.CASH, 5510000, 1, true, false);
                        chr.announce(MaplePacketCreator.showWheelsLeft(chr.getItemQuantity(5510000, false)));
                    } else {
                        chr.cancelAllBuffs(false);
                        to = chr.getWarpMap(chr.getMap().getReturnMapId());
                        chr.setStance(0);
                    }
                    chr.setHp(50);
                    chr.updatePartyMemberHP();
                    chr.changeMap(to, to.getRandomPlayerSpawnpoint());
                }
            } else if (targetid != -1) {
                if (chr.isGM()) {
                    MapleMap to = chr.getWarpMap(targetid);
                    chr.changeMap(to, to.getPortal(0));
                } else {
                    final int divi = chr.getMapId() / 100;
                    boolean warp = false;
                    if (divi == 0) {
                        if (targetid == 10000) {
                            warp = true;
                        }
                    } else if (divi == 20100) {
                        if (targetid == 104000000) {
                            c.announce(MaplePacketCreator.lockUI(false));
                            c.announce(MaplePacketCreator.disableUI(false));
                            warp = true;
                        }
                    } else if (divi == 9130401) {
                        // Only allow warp if player is already in Intro map, or else = hack
                        if (targetid == 130000000 || targetid / 100 == 9130401) {
                            // Cygnus introduction
                            warp = true;
                        }
                    } else if (divi == 9140900) {
                        // Aran Introduction
                        if (targetid == 914090011 || targetid == 914090012 || targetid == 914090013 || targetid == 140090000) {
                            warp = true;
                        }
                    } else if (divi / 10 == 1020) {
                        // Adventurer movie clip Intro
                        if (targetid == 1020000) {
                            warp = true;
                        }
                    } else if (divi / 10 >= 980040 && divi / 10 <= 980045) {
                        if (targetid == 980040000) {
                            warp = true;
                        }
                    }
                    if (warp) {
                        final MapleMap to = chr.getWarpMap(targetid);
                        chr.changeMap(to, to.getPortal(0));
                    }
                }
            }
            if (portal != null && !portal.getPortalStatus()) {
                c.announce(MaplePacketCreator.blockedMessage(1));
                c.announce(MaplePacketCreator.enableActions());
                return;
            }
            if (chr.getMapId() == 109040004) {
                chr.getFitness().resetTimes();
            }
            if (chr.getMapId() == 109030003 || chr.getMapId() == 109030103) {
                chr.getOla().resetTimes();
            }
            if (portal != null) {
                if (portal.getPosition().distanceSq(chr.getPosition()) > 400000) {
                    c.announce(MaplePacketCreator.enableActions());
                    return;
                }
                portal.enterPortal(c);
            } else {
                c.announce(MaplePacketCreator.enableActions());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : MapleMap(server.maps.MapleMap) MapleCharacter(client.MapleCharacter) UnknownHostException(java.net.UnknownHostException) MaplePortal(server.MaplePortal) UnknownHostException(java.net.UnknownHostException)

Example 30 with MapleMap

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

the class CoconutHandler method handlePacket.

public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    /*CB 00 A6 00 06 01
		 * A6 00 = coconut id
		 * 06 01 = ?
		 */
    int id = slea.readShort();
    MapleMap map = c.getPlayer().getMap();
    MapleCoconut event = map.getCoconut();
    MapleCoconuts nut = event.getCoconut(id);
    if (!nut.isHittable()) {
        return;
    }
    if (event == null) {
        return;
    }
    if (System.currentTimeMillis() < nut.getHitTime()) {
        return;
    }
    if (nut.getHits() > 2 && Math.random() < 0.4) {
        if (Math.random() < 0.01 && event.getStopped() > 0) {
            nut.setHittable(false);
            event.stopCoconut();
            map.broadcastMessage(MaplePacketCreator.hitCoconut(false, id, 1));
            return;
        }
        // for sure :)
        nut.setHittable(false);
        // For next event (without restarts)
        nut.resetHits();
        if (Math.random() < 0.05 && event.getBombings() > 0) {
            map.broadcastMessage(MaplePacketCreator.hitCoconut(false, id, 2));
            event.bombCoconut();
        } else if (event.getFalling() > 0) {
            map.broadcastMessage(MaplePacketCreator.hitCoconut(false, id, 3));
            event.fallCoconut();
            if (c.getPlayer().getTeam() == 0) {
                event.addMapleScore();
                map.broadcastMessage(MaplePacketCreator.serverNotice(5, c.getPlayer().getName() + " of Team Maple knocks down a coconut."));
            } else {
                event.addStoryScore();
                map.broadcastMessage(MaplePacketCreator.serverNotice(5, c.getPlayer().getName() + " of Team Story knocks down a coconut."));
            }
            map.broadcastMessage(MaplePacketCreator.coconutScore(event.getMapleScore(), event.getStoryScore()));
        }
    } else {
        nut.hit();
        map.broadcastMessage(MaplePacketCreator.hitCoconut(false, id, 1));
    }
}
Also used : MapleCoconut(server.events.gm.MapleCoconut) MapleMap(server.maps.MapleMap) MapleCoconuts(server.events.gm.MapleCoconuts)

Aggregations

MapleMap (server.maps.MapleMap)33 MapleCharacter (client.MapleCharacter)12 Item (client.inventory.Item)9 Point (java.awt.Point)9 MapleMonster (server.life.MapleMonster)7 MapleMapItem (server.maps.MapleMapItem)7 SQLException (java.sql.SQLException)6 MapleMapObject (server.maps.MapleMapObject)6 ArrayList (java.util.ArrayList)5 EventInstanceManager (scripting.event.EventInstanceManager)5 MaplePortal (server.MaplePortal)5 Skill (client.Skill)4 UnknownHostException (java.net.UnknownHostException)4 MaplePartyCharacter (net.server.world.MaplePartyCharacter)4 MapleItemInformationProvider (server.MapleItemInformationProvider)4 MapleInventoryType (client.inventory.MapleInventoryType)3 IOException (java.io.IOException)3 Channel (net.server.channel.Channel)3 MapleParty (net.server.world.MapleParty)3 SpawnPoint (server.life.SpawnPoint)3