Beispiel #1
0
 private boolean isCorrectAnswer(MapleCharacter chr, int answer) {
   double x = chr.getTruePosition().getX();
   double y = chr.getTruePosition().getY();
   if ((x > -234 && y > -26 && answer == 0) || (x < -234 && y > -26 && answer == 1)) {
     chr.dropMessage(6, "[Ox Quiz] Correct!"); // I think this is its own packet
     return true;
   }
   chr.dropMessage(6, "[Ox Quiz] Incorrect!");
   return false;
 }
Beispiel #2
0
  public static void doFishing(client.MapleCharacter chr) {
    int mesoMultiplier = 1;
    int expMultiplier = 1;
    switch (chr.getWorld()) {
      case 0:
        mesoMultiplier = 40000;
        expMultiplier = 20000;
        break;
    }
    int mesoAward =
        (int) (1400.0 * Math.random() + 1201) * mesoMultiplier + (6 * chr.getLevel() / 5);
    int expAward =
        (int) ((645.0 * Math.random()) * expMultiplier + (15 * chr.getLevel() / 2) / 6)
            * chr.getFishingLevel();
    if (chr.getReborns() >= 5
        && chr.getMapId() == 970020001
        && chr.haveItem(3011000)
        && chr.getChair() == 3011000) {
      int rand = (int) (3.0 * Math.random());
      int fishingexp = (int) (7.0 * Math.random()) + 1;
      switch (rand) {
        case 0:
          chr.gainMeso(mesoAward, true, true, true);
          chr.gainFishingEXP(fishingexp);
          chr.getClient()
              .getSession()
              .write(MaplePacketCreator.catchMonster(9500336, 2000017, (byte) 1));
          chr.getMap()
              .broadcastMessage(
                  chr, MaplePacketCreator.catchMonster(9500336, 2000017, (byte) 1), false);
          break;
        case 1:
          chr.gainExp(expAward, true, true);
          chr.gainFishingEXP(fishingexp);
          chr.getClient()
              .getSession()
              .write(MaplePacketCreator.catchMonster(9500336, 2000017, (byte) 1));
          chr.getMap()
              .broadcastMessage(
                  chr, MaplePacketCreator.catchMonster(9500336, 2000017, (byte) 1), false);
          break;
        case 2:
          chr.gainFishingEXP(fishingexp * 2);
          chr.getClient()
              .getSession()
              .write(MaplePacketCreator.catchMonster(9500336, 2000017, (byte) 1));
          chr.getMap()
              .broadcastMessage(
                  chr, MaplePacketCreator.catchMonster(9500336, 2000017, (byte) 1), false);
          break;
      }

    } else {
      chr.dropMessage("Please sit on your fishing chair at the fishing lagoon to fish.");
    }
  }
Beispiel #3
0
 public void copy() {
   while (type.queue.get(ch).size() > 0
       && ChannelServer.getInstance(ch).getMapleSquad(type) == null) {
     int index = 0;
     long lowest = 0;
     for (int i = 0; i < type.queue.get(ch).size(); i++) {
       if (lowest == 0 || type.queue.get(ch).get(i).right < lowest) {
         index = i;
         lowest = type.queue.get(ch).get(i).right;
       }
     }
     final String nextPlayerId = type.queue.get(ch).remove(index).left;
     final int theirCh = World.Find.findChannel(nextPlayerId);
     if (theirCh > 0) {
       final MapleCharacter lead =
           ChannelServer.getInstance(theirCh).getPlayerStorage().getCharacterByName(nextPlayerId);
       if (lead != null && lead.getMapId() == beginMapId && lead.getClient().getChannel() == ch) {
         final MapleSquad squad = new MapleSquad(ch, type.name(), lead, expiration, toSay);
         if (ChannelServer.getInstance(ch).addMapleSquad(squad, type.name())) {
           getBeginMap().broadcastMessage(CField.getClock(expiration / 1000));
           getBeginMap().broadcastMessage(CWvsContext.serverNotice(6, nextPlayerId + toSay));
           type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Success"));
         } else {
           squad.clear();
           type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Skipped"));
         }
         break;
       } else {
         if (lead != null) {
           lead.dropMessage(
               6,
               "Your squad has been skipped due to you not being in the right channel and map.");
         }
         getBeginMap()
             .broadcastMessage(
                 CWvsContext.serverNotice(
                     6,
                     nextPlayerId
                         + "'s squad has been skipped due to the player not being in the right channel and map."));
         type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Not in map"));
       }
     } else {
       getBeginMap()
           .broadcastMessage(
               CWvsContext.serverNotice(
                   6,
                   nextPlayerId
                       + "'s squad has been skipped due to the player not being online."));
       type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Not online"));
     }
   }
 }
 public static boolean handlePortal(String name, MapleCharacter c) {
   if (name.equals(FourthJobQuests.RUSH.getValue())) {
     if (!(c.getParty().getLeader().getId() == c.getId()) && !checkRush(c)) {
       c.dropMessage("You step into the portal, but it swiftly kicks you out.");
       c.getClient().announce(MaplePacketCreator.enableActions());
     }
     if (!(c.getParty().getLeader().getId() == c.getId()) && checkRush(c)) {
       c.dropMessage("You're not the party leader.");
       c.getClient().announce(MaplePacketCreator.enableActions());
       return true;
     }
     if (!checkRush(c)) {
       c.dropMessage("Someone in your party is not a 4th Job warrior.");
       c.getClient().announce(MaplePacketCreator.enableActions());
       return true;
     }
     c.getClient()
         .getChannelServer()
         .getEventSM()
         .getEventManager("4jrush")
         .startInstance(c.getParty(), c.getMap());
     return true;
   } else if (name.equals(FourthJobQuests.BERSERK.getValue())) {
     if (!c.haveItem(4031475)) {
       c.dropMessage("The portal to the Forgotten Shrine is locked");
       c.getClient().announce(MaplePacketCreator.enableActions());
       return true;
     }
     c.getClient()
         .getChannelServer()
         .getEventSM()
         .getEventManager("4jberserk")
         .startInstance(c.getParty(), c.getMap());
     return true;
   }
   return false;
 }
 public static final void DenyInvite(
     MapleClient c,
     final MapleGuild
         gs) { // playername that invited -> guildname that was invited but we also don't care
   final int inviteid = World.Guild.getInvitedId(c.getPlayer().getGuildId());
   if (inviteid > 0) {
     final int newAlliance = World.Alliance.getAllianceLeader(inviteid);
     if (newAlliance > 0) {
       final MapleCharacter chr =
           c.getChannelServer().getPlayerStorage().getCharacterById(newAlliance);
       if (chr != null) {
         chr.dropMessage(5, gs.getName() + " Guild has rejected the Guild Union invitation.");
       }
       World.Guild.setInvitedId(c.getPlayer().getGuildId(), 0);
     }
   }
   // c.getSession().write(CWvsContext.enableActions());
 }
  public static final void SummonPVP(final LittleEndianAccessor slea, final MapleClient c) {
    final MapleCharacter chr = c.getPlayer();
    if (chr == null
        || chr.isHidden()
        || !chr.isAlive()
        || chr.hasBlockedInventory()
        || chr.getMap() == null
        || !chr.inPVP()
        || !chr.getEventInstance().getProperty("started").equals("1")) {
      return;
    }
    final MapleMap map = chr.getMap();
    final MapleMapObject obj = map.getMapObject(slea.readInt(), MapleMapObjectType.SUMMON);
    if (obj == null || !(obj instanceof MapleSummon)) {
      chr.dropMessage(5, "The summon has disappeared.");
      return;
    }
    int tick = -1;
    if (slea.available() == 27) {
      slea.skip(23);
      tick = slea.readInt();
    }
    final MapleSummon summon = (MapleSummon) obj;
    if (summon.getOwnerId() != chr.getId() || summon.getSkillLevel() <= 0) {
      chr.dropMessage(5, "Error.");
      return;
    }
    final Skill skil = SkillFactory.getSkill(summon.getSkill());
    final MapleStatEffect effect = skil.getEffect(summon.getSkillLevel());
    final int lvl = Integer.parseInt(chr.getEventInstance().getProperty("lvl"));
    final int type = Integer.parseInt(chr.getEventInstance().getProperty("type"));
    final int ourScore =
        Integer.parseInt(chr.getEventInstance().getProperty(String.valueOf(chr.getId())));
    int addedScore = 0;
    final boolean magic = skil.isMagic();
    boolean killed = false, didAttack = false;
    double maxdamage =
        lvl == 3
            ? chr.getStat().getCurrentMaxBasePVPDamageL()
            : chr.getStat().getCurrentMaxBasePVPDamage();
    maxdamage *= (effect.getDamage() + chr.getStat().getDamageIncrease(summon.getSkill())) / 100.0;
    int mobCount = 1, attackCount = 1, ignoreDEF = chr.getStat().ignoreTargetDEF;

    final SummonSkillEntry sse = SkillFactory.getSummonData(summon.getSkill());
    if (summon.getSkill() / 1000000 != 35 && summon.getSkill() != 33101008 && sse == null) {
      chr.dropMessage(5, "Error in processing attack.");
      return;
    }
    Point lt, rb;
    if (sse != null) {
      if (sse.delay > 0) {
        if (tick != -1) {
          summon.CheckSummonAttackFrequency(chr, tick);
          chr.updateTick(tick);
        } else {
          summon.CheckPVPSummonAttackFrequency(chr);
        }
        chr.getCheatTracker().checkSummonAttack();
      }
      mobCount = sse.mobCount;
      attackCount = sse.attackCount;
      lt = sse.lt;
      rb = sse.rb;
    } else {
      lt = new Point(-100, -100);
      rb = new Point(100, 100);
    }
    final Rectangle box =
        MapleStatEffect.calculateBoundingBox(chr.getTruePosition(), chr.isFacingLeft(), lt, rb, 0);
    List<AttackPair> ourAttacks = new ArrayList<AttackPair>();
    List<Pair<Integer, Boolean>> attacks;
    maxdamage *= chr.getStat().dam_r / 100.0;
    for (MapleMapObject mo : chr.getMap().getCharactersIntersect(box)) {
      final MapleCharacter attacked = (MapleCharacter) mo;
      if (attacked.getId() != chr.getId()
          && attacked.isAlive()
          && !attacked.isHidden()
          && (type == 0 || attacked.getTeam() != chr.getTeam())) {
        double rawDamage =
            maxdamage
                / Math.max(
                    0,
                    ((magic ? attacked.getStat().mdef : attacked.getStat().wdef)
                            * Math.max(1.0, 100.0 - ignoreDEF)
                            / 100.0)
                        * (type == 3 ? 0.1 : 0.25));
        if (attacked.getBuffedValue(MapleBuffStat.INVINCIBILITY) != null
            || PlayersHandler.inArea(attacked)) {
          rawDamage = 0;
        }
        rawDamage += (rawDamage * chr.getDamageIncrease(attacked.getId()) / 100.0);
        rawDamage *= attacked.getStat().mesoGuard / 100.0;
        rawDamage = attacked.modifyDamageTaken(rawDamage, attacked).left;
        final double min = (rawDamage * chr.getStat().trueMastery / 100);
        attacks = new ArrayList<Pair<Integer, Boolean>>(attackCount);
        int totalMPLoss = 0, totalHPLoss = 0;
        for (int i = 0; i < attackCount; i++) {
          int mploss = 0;
          double ourDamage =
              Randomizer.nextInt((int) Math.abs(Math.round(rawDamage - min)) + 1) + min;
          if (attacked.getStat().dodgeChance > 0
              && Randomizer.nextInt(100) < attacked.getStat().dodgeChance) {
            ourDamage = 0;
            // i dont think level actually matters or it'd be too op
            // } else if (attacked.getLevel() > chr.getLevel() && Randomizer.nextInt(100) <
            // (attacked.getLevel() - chr.getLevel())) {
            //	ourDamage = 0;
          }
          if (attacked.getBuffedValue(MapleBuffStat.MAGIC_GUARD) != null) {
            mploss =
                (int)
                    Math.min(
                        attacked.getStat().getMp(),
                        (ourDamage
                            * attacked.getBuffedValue(MapleBuffStat.MAGIC_GUARD).doubleValue()
                            / 100.0));
          }
          ourDamage -= mploss;
          if (attacked.getBuffedValue(MapleBuffStat.INFINITY) != null) {
            mploss = 0;
          }
          attacks.add(new Pair<Integer, Boolean>((int) Math.floor(ourDamage), false));

          totalHPLoss += Math.floor(ourDamage);
          totalMPLoss += mploss;
        }
        attacked.addMPHP(-totalHPLoss, -totalMPLoss);
        ourAttacks.add(new AttackPair(attacked.getId(), attacked.getPosition(), attacks));
        attacked.getCheatTracker().setAttacksWithoutHit(false);
        if (totalHPLoss > 0) {
          didAttack = true;
        }
        if (attacked.getStat().getHPPercent() <= 20) {
          SkillFactory.getSkill(attacked.getStat().getSkillByJob(93, attacked.getJob()))
              .getEffect(1)
              .applyTo(attacked);
        }
        if (effect != null) {
          if (effect.getMonsterStati().size() > 0 && effect.makeChanceResult()) {
            for (Map.Entry<MonsterStatus, Integer> z : effect.getMonsterStati().entrySet()) {
              MapleDisease d = MonsterStatus.getLinkedDisease(z.getKey());
              if (d != null) {
                attacked.giveDebuff(d, z.getValue(), effect.getDuration(), d.getDisease(), 1);
              }
            }
          }
          effect.handleExtraPVP(chr, attacked);
        }
        chr.getClient()
            .getSession()
            .write(
                CField.getPVPHPBar(
                    attacked.getId(),
                    attacked.getStat().getHp(),
                    attacked.getStat().getCurrentMaxHp()));
        addedScore += (totalHPLoss / 100) + (totalMPLoss / 100); // ive NO idea
        if (!attacked.isAlive()) {
          killed = true;
        }

        if (ourAttacks.size() >= mobCount) {
          break;
        }
      }
    }
    if (killed || addedScore > 0) {
      chr.getEventInstance().addPVPScore(chr, addedScore);
      chr.getClient().getSession().write(CField.getPVPScore(ourScore + addedScore, killed));
    }
    if (didAttack) {
      chr.getMap()
          .broadcastMessage(
              SummonPacket.pvpSummonAttack(
                  chr.getId(),
                  chr.getLevel(),
                  summon.getObjectId(),
                  summon.isFacingLeft() ? 4 : 0x84,
                  summon.getTruePosition(),
                  ourAttacks));
      if (!summon.isMultiAttack()) {
        chr.getMap().broadcastMessage(SummonPacket.removeSummon(summon, true));
        chr.getMap().removeMapObject(summon);
        chr.removeVisibleMapObject(summon);
        chr.removeSummon(summon);
        if (summon.getSkill() != 35121011) {
          chr.cancelEffectFromBuffStat(MapleBuffStat.SUMMON);
        }
      }
    }
  }
  public static void SummonAttack(
      final LittleEndianAccessor slea, final MapleClient c, final MapleCharacter chr) {
    if (chr == null || !chr.isAlive() || chr.getMap() == null) {
      return;
    }
    final MapleMap map = chr.getMap();
    final MapleMapObject obj = map.getMapObject(slea.readInt(), MapleMapObjectType.SUMMON);
    if (obj == null || !(obj instanceof MapleSummon)) {
      chr.dropMessage(5, "The summon has disappeared.");
      return;
    }
    final MapleSummon summon = (MapleSummon) obj;
    if (summon.getOwnerId() != chr.getId() || summon.getSkillLevel() <= 0) {
      chr.dropMessage(5, "Error.");
      return;
    }
    final SummonSkillEntry sse = SkillFactory.getSummonData(summon.getSkill());
    if (summon.getSkill() / 1000000 != 35 && summon.getSkill() != 33101008 && sse == null) {
      chr.dropMessage(5, "Error in processing attack.");
      return;
    }
    if (!GameConstants.GMS) {
      slea.skip(8);
    }
    int tick = slea.readInt();
    if (sse != null && sse.delay > 0) {
      chr.updateTick(tick);
      // summon.CheckSummonAttackFrequency(chr, tick);
      // chr.getCheatTracker().checkSummonAttack();
    }
    if (!GameConstants.GMS) {
      slea.skip(8);
    }
    final byte animation = slea.readByte();
    if (!GameConstants.GMS) {
      slea.skip(8);
    }
    final byte numAttacked = slea.readByte();
    if (sse != null && numAttacked > sse.mobCount) {
      chr.dropMessage(5, "Warning: Attacking more monster than summon can do");
      chr.getCheatTracker().registerOffense(CheatingOffense.SUMMON_HACK_MOBS);
      // AutobanManager.getInstance().autoban(c, "Attacking more monster that summon can do (Skillid
      // : "+summon.getSkill()+" Count : " + numAttacked + ", allowed : " + sse.mobCount + ")");
      return;
    }
    slea.skip(summon.getSkill() == 35111002 ? 24 : 12); // some pos stuff
    final List<Pair<Integer, Integer>> allDamage = new ArrayList<Pair<Integer, Integer>>();
    for (int i = 0; i < numAttacked; i++) {
      final MapleMonster mob = map.getMonsterByOid(slea.readInt());

      if (mob == null) {
        continue;
      }
      slea.skip(22); // who knows
      final int damge = slea.readInt();
      allDamage.add(new Pair<Integer, Integer>(mob.getObjectId(), damge));
    }
    // if (!summon.isChangedMap()) {
    map.broadcastMessage(
        chr,
        SummonPacket.summonAttack(
            summon.getOwnerId(), summon.getObjectId(), animation, allDamage, chr.getLevel(), false),
        summon.getTruePosition());
    // }
    final Skill summonSkill = SkillFactory.getSkill(summon.getSkill());
    final MapleStatEffect summonEffect = summonSkill.getEffect(summon.getSkillLevel());
    if (summonEffect == null) {
      chr.dropMessage(5, "Error in attack.");
      return;
    }
    for (Pair<Integer, Integer> attackEntry : allDamage) {
      final int toDamage = attackEntry.right;
      final MapleMonster mob = map.getMonsterByOid(attackEntry.left);
      if (mob == null) {
        continue;
      }
      if (sse != null
          && sse.delay > 0
          && summon.getMovementType() != SummonMovementType.STATIONARY
          && summon.getMovementType() != SummonMovementType.CIRCLE_STATIONARY
          && summon.getMovementType() != SummonMovementType.WALK_STATIONARY
          && chr.getTruePosition().distanceSq(mob.getTruePosition()) > 400000.0) {
        // chr.getCheatTracker().registerOffense(CheatingOffense.ATTACK_FARAWAY_MONSTER_SUMMON);
      }
      if (toDamage > 0 && summonEffect.getMonsterStati().size() > 0) {
        if (summonEffect.makeChanceResult()) {
          for (Map.Entry<MonsterStatus, Integer> z : summonEffect.getMonsterStati().entrySet()) {
            mob.applyStatus(
                chr,
                new MonsterStatusEffect(z.getKey(), z.getValue(), summonSkill.getId(), null, false),
                summonEffect.isPoison(),
                4000,
                true,
                summonEffect);
          }
        }
      }
      if (chr.isGM()
          || toDamage
              < (chr.getStat().getCurrentMaxBaseDamage()
                  * 5.0
                  * (summonEffect.getSelfDestruction()
                      + summonEffect.getDamage()
                      + chr.getStat().getDamageIncrease(summonEffect.getSourceId()))
                  / 100.0)) { // 10 x dmg.. eh
        mob.damage(chr, toDamage, true);
        chr.checkMonsterAggro(mob);
        if (!mob.isAlive()) {
          chr.getClient().getSession().write(MobPacket.killMonster(mob.getObjectId(), 1));
        }
      } else {
        chr.dropMessage(5, "Warning - high damage.");
        // AutobanManager.getInstance().autoban(c, "High Summon Damage (" + toDamage + " to " +
        // attackEntry.right + ")");
        // TODO : Check player's stat for damage checking.
        break;
      }
    }
    if (!summon.isMultiAttack()) {
      chr.getMap().broadcastMessage(SummonPacket.removeSummon(summon, true));
      chr.getMap().removeMapObject(summon);
      chr.removeVisibleMapObject(summon);
      chr.removeSummon(summon);
      if (summon.getSkill() != 35121011) {
        chr.cancelEffectFromBuffStat(MapleBuffStat.SUMMON);
      }
    }
  }