Search in sources :

Example 1 with MapleCoconut

use of server.events.gm.MapleCoconut 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)

Example 2 with MapleCoconut

use of server.events.gm.MapleCoconut in project HeavenMS by ronancpl.

the class MapleMap method startEvent.

public void startEvent(final MapleCharacter chr) {
    if (this.mapid == 109080000 && getCoconut() == null) {
        setCoconut(new MapleCoconut(this));
        coconut.startEvent();
    } else if (this.mapid == 109040000) {
        chr.setFitness(new MapleFitness(chr));
        chr.getFitness().startFitness();
    } else if (this.mapid == 109030101 || this.mapid == 109030201 || this.mapid == 109030301 || this.mapid == 109030401) {
        chr.setOla(new MapleOla(chr));
        chr.getOla().startOla();
    } else if (this.mapid == 109020001 && getOx() == null) {
        setOx(new MapleOxQuiz(this));
        getOx().sendQuestion();
        setOxQuiz(true);
    } else if (this.mapid == 109060000 && getSnowball(chr.getTeam()) == null) {
        setSnowball(0, new MapleSnowball(0, this));
        setSnowball(1, new MapleSnowball(1, this));
        getSnowball(chr.getTeam()).startEvent();
    }
}
Also used : MapleCoconut(server.events.gm.MapleCoconut) MapleOxQuiz(server.events.gm.MapleOxQuiz) MapleSnowball(server.events.gm.MapleSnowball) MapleFitness(server.events.gm.MapleFitness) MapleOla(server.events.gm.MapleOla)

Aggregations

MapleCoconut (server.events.gm.MapleCoconut)2 MapleCoconuts (server.events.gm.MapleCoconuts)1 MapleFitness (server.events.gm.MapleFitness)1 MapleOla (server.events.gm.MapleOla)1 MapleOxQuiz (server.events.gm.MapleOxQuiz)1 MapleSnowball (server.events.gm.MapleSnowball)1 MapleMap (server.maps.MapleMap)1