Search in sources :

Example 81 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class MapleTrade method declineTrade.

public static void declineTrade(MapleCharacter c) {
    MapleTrade trade = c.getTrade();
    if (trade != null) {
        if (trade.getPartner() != null) {
            MapleCharacter other = trade.getPartner().getChr();
            other.getTrade().cancel();
            other.setTrade(null);
            other.message(c.getName() + " has declined your trade request.");
        }
        trade.cancel();
        c.setTrade(null);
    }
}
Also used : MapleCharacter(client.MapleCharacter)

Example 82 with MapleCharacter

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

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class EventInstanceManager method startEventTimer.

public void startEventTimer(long time) {
    timeStarted = System.currentTimeMillis();
    eventTime = time;
    for (MapleCharacter chr : getPlayers()) {
        chr.announce(MaplePacketCreator.getClock((int) (time / 1000)));
    }
    event_schedule = TimerManager.getInstance().schedule(new Runnable() {

        @Override
        public void run() {
            try {
                dismissEventTimer();
                sL.lock();
                try {
                    em.getIv().invokeFunction("scheduledTimeout", EventInstanceManager.this);
                } finally {
                    sL.unlock();
                }
            } catch (ScriptException | NoSuchMethodException ex) {
                Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }, time);
}
Also used : ScriptException(javax.script.ScriptException) MapleCharacter(client.MapleCharacter)

Example 84 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class EventInstanceManager method dispose.

public synchronized void dispose() {
    if (disposed)
        return;
    disposed = true;
    try {
        sL.lock();
        try {
            em.getIv().invokeFunction("dispose", this);
        } finally {
            sL.unlock();
        }
    } catch (ScriptException | NoSuchMethodException ex) {
        ex.printStackTrace();
    }
    wL.lock();
    try {
        for (MapleCharacter chr : chars.values()) chr.setEventInstance(null);
        chars.clear();
        mobs.clear();
        mapFactory.dispose();
        mapFactory = null;
    } finally {
        wL.unlock();
    }
    cancelSchedule();
    killCount.clear();
    mapIds.clear();
    disposeExpedition();
    sL.lock();
    try {
        if (!eventCleared)
            em.disposeInstance(name);
        em = null;
    } finally {
        sL.unlock();
    }
}
Also used : ScriptException(javax.script.ScriptException) MapleCharacter(client.MapleCharacter)

Example 85 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class EventInstanceManager method dismissEventTimer.

private void dismissEventTimer() {
    for (MapleCharacter chr : getPlayers()) {
        chr.getClient().getSession().write(MaplePacketCreator.removeClock());
    }
    event_schedule = null;
    eventTime = 0;
    timeStarted = 0;
}
Also used : MapleCharacter(client.MapleCharacter)

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