use of server.events.gm.MapleCoconuts 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));
}
}
Aggregations