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);
}
}
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);
}
}
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);
}
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();
}
}
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;
}
Aggregations