Example #1
0
 public MapleOxQuiz(MapleMap map) {
   this.map = map;
   this.round = Randomizer.getInstance().nextInt(9);
   this.question = 1;
 }
Example #2
0
 public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
   int objectid = slea.readInt();
   short moveid = slea.readShort();
   MapleMapObject mmo = c.getPlayer().getMap().getMapObject(objectid);
   if (mmo == null || mmo.getType() != MapleMapObjectType.MONSTER) {
     return;
   }
   MapleMonster monster = (MapleMonster) mmo;
   List<LifeMovementFragment> res = null;
   byte skillByte = slea.readByte();
   byte skill = slea.readByte();
   int skill_1 = slea.readByte() & 0xFF;
   byte skill_2 = slea.readByte();
   byte skill_3 = slea.readByte();
   slea.readByte();
   slea.readLong(); // v88 change
   MobSkill toUse = null;
   if (skillByte == 1 && monster.getNoSkills() > 0) {
     int random = Randomizer.getInstance().nextInt(monster.getNoSkills());
     Pair<Integer, Integer> skillToUse = monster.getSkills().get(random);
     toUse = MobSkillFactory.getMobSkill(skillToUse.getLeft(), skillToUse.getRight());
     int percHpLeft = (monster.getHp() / monster.getMaxHp()) * 100;
     if (toUse.getHP() < percHpLeft || !monster.canUseSkill(toUse)) {
       toUse = null;
     }
   }
   if ((skill_1 >= 100 && skill_1 <= 200) && monster.hasSkill(skill_1, skill_2)) {
     MobSkill skillData = MobSkillFactory.getMobSkill(skill_1, skill_2);
     if (skillData != null && monster.canUseSkill(skillData)) {
       skillData.applyEffect(c.getPlayer(), monster, true);
     }
   }
   slea.readByte();
   slea.readInt(); // whatever
   slea.skip(12); // v88 skip
   short start_x = slea.readShort(); // hmm.. startpos?
   short start_y = slea.readShort(); // hmm...
   slea.readInt(); // v88 skip
   Point startPos = new Point(start_x, start_y);
   res = parseMovement(slea);
   if (monster.getController() != c.getPlayer()) {
     if (monster.isAttackedBy(c.getPlayer())) { // aggro and controller change
       monster.switchController(c.getPlayer(), true);
     } else {
       return;
     }
   } else if (skill == -1
       && monster.isControllerKnowsAboutAggro()
       && !monster.isMobile()
       && !monster.isFirstAttack()) {
     monster.setControllerHasAggro(false);
     monster.setControllerKnowsAboutAggro(false);
   }
   boolean aggro = monster.isControllerHasAggro();
   if (toUse != null) {
     c.getSession()
         .write(
             MaplePacketCreator.moveMonsterResponse(
                 objectid,
                 moveid,
                 monster.getMp(),
                 aggro,
                 toUse.getSkillId(),
                 toUse.getSkillLevel()));
   } else {
     c.getSession()
         .write(MaplePacketCreator.moveMonsterResponse(objectid, moveid, monster.getMp(), aggro));
   }
   if (aggro) {
     monster.setControllerKnowsAboutAggro(true);
   }
   if (res != null && slea.available() == 17) {
     c.getPlayer()
         .getMap()
         .broadcastMessage(
             c.getPlayer(),
             MaplePacketCreator.moveMonster(
                 skillByte, skill, skill_1, skill_2, skill_3, objectid, startPos, res),
             monster.getPosition());
     updatePosition(res, monster, -1);
     c.getPlayer().getMap().moveMonster(monster, monster.getPosition());
   }
 }