Exemplo n.º 1
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   for (final ChannelServer cserv : ChannelServer.getAllInstances()) {
     cserv.broadcastGMMessage(
         tools.packet.CField.multiChat(
             "[GM Help] " + c.getPlayer().getName(), StringUtil.joinStringFrom(splitted, 1), 6));
   }
   c.getPlayer().dropMessage(5, "Your message had been sent successfully.");
   return 1;
 }
Exemplo n.º 2
0
 public void clear() {
   if (removal != null) {
     getBeginMap().broadcastMessage(CField.stopClock());
     removal.cancel(false);
     removal = null;
   }
   members.clear();
   bannedMembers.clear();
   leader = null;
   ChannelServer.getInstance(ch).removeMapleSquad(type);
   this.status = 0;
 }
Exemplo n.º 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"));
     }
   }
 }
Exemplo n.º 4
0
  public static final void Character_WithoutSecondPassword(
      final LittleEndianAccessor slea,
      final MapleClient c,
      final boolean haspic,
      final boolean view) {
    slea.readByte(); // 1?
    slea.readByte(); // 1?
    final int charId = slea.readInt();
    if (view) {
      c.setChannel(1);
      c.setWorld(slea.readInt());
    }
    final String currentpw = c.getSecondPassword();
    if (!c.isLoggedIn()
        || loginFailCount(c)
        || (currentpw != null && (!currentpw.equals("") || haspic))
        || !c.login_Auth(charId)
        || ChannelServer.getInstance(c.getChannel()) == null
        || c.getWorld() != 0) { // TODOO: MULTI WORLDS
      c.getSession().close();
      return;
    }
    c.updateMacs(slea.readMapleAsciiString());
    slea.readMapleAsciiString();
    if (slea.available() != 0) {
      final String setpassword = slea.readMapleAsciiString();

      if (setpassword.length() >= 6 && setpassword.length() <= 16) {
        c.setSecondPassword(setpassword);
        c.updateSecondPassword();
      } else {
        c.getSession().write(LoginPacket.secondPwError((byte) 0x14));
        return;
      }
    } else if (GameConstants.GMS && haspic) {
      return;
    }
    if (c.getIdleTask() != null) {
      c.getIdleTask().cancel(true);
    }
    final String s = c.getSessionIPAddress();
    LoginServer.putLoginAuth(
        charId, s.substring(s.indexOf('/') + 1, s.length()), c.getTempIP(), c.getChannel());
    c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION, s);
    c.getSession()
        .write(
            CField.getServerIP(
                c,
                Integer.parseInt(ChannelServer.getInstance(c.getChannel()).getIP().split(":")[1]),
                charId));
  }
Exemplo n.º 5
0
  public static final void MoveDragon(final LittleEndianAccessor slea, final MapleCharacter chr) {
    slea.skip(8); // POS
    final List<LifeMovementFragment> res = MovementParse.parseMovement(slea, 5);
    if (chr != null && chr.getDragon() != null && res.size() > 0) {
      final Point pos = chr.getDragon().getPosition();
      MovementParse.updatePosition(res, chr.getDragon(), 0);
      if (!chr.isHidden()) {
        chr.getMap()
            .broadcastMessage(
                chr, CField.moveDragon(chr.getDragon(), pos, res), chr.getTruePosition());
      }

      WeakReference<MapleCharacter>[] clones = chr.getClones();
      for (int i = 0; i < clones.length; i++) {
        if (clones[i].get() != null) {
          final MapleMap map = chr.getMap();
          final MapleCharacter clone = clones[i].get();
          CloneTimer.getInstance()
              .schedule(
                  new Runnable() {

                    public void run() {
                      try {
                        if (clone.getMap() == map && clone.getDragon() != null) {
                          final Point startPos = clone.getDragon().getPosition();
                          MovementParse.updatePosition(res, clone.getDragon(), 0);
                          if (!clone.isHidden()) {
                            map.broadcastMessage(
                                clone,
                                CField.moveDragon(clone.getDragon(), startPos, res),
                                clone.getTruePosition());
                          }
                        }
                      } catch (Exception e) {
                        // very rarely swallowed
                      }
                    }
                  },
                  500 * i + 500);
        }
      }
    }
  }
Exemplo n.º 6
0
 public static void LeaveFarm(
     final LittleEndianAccessor slea, final MapleClient c, final MapleCharacter chr) {
   FarmServer.getPlayerStorage().deregisterPlayer(chr);
   c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION, c.getSessionIPAddress());
   try {
     World.ChannelChange_Data(new CharacterTransfer(chr), chr.getId(), c.getChannel());
     c.getSession()
         .write(
             CField.getChannelChange(
                 c,
                 Integer.parseInt(
                     ChannelServer.getInstance(c.getChannel()).getIP().split(":")[1])));
   } finally {
     final String s = c.getSessionIPAddress();
     LoginServer.addIPAuth(s.substring(s.indexOf('/') + 1, s.length()));
     chr.saveToDB(false, true);
     c.setPlayer(null);
     c.setReceiving(false);
     c.getSession().close(true);
   }
 }
Exemplo n.º 7
0
 public static final void Character_WithSecondPassword(
     LittleEndianAccessor slea, MapleClient c, boolean view) {
   String password = slea.readMapleAsciiString();
   int charId = slea.readInt();
   if (view) {
     c.setChannel(1);
     c.setWorld(slea.readInt());
   }
   if ((!c.isLoggedIn())
       || (loginFailCount(c))
       || (c.getSecondPassword() == null)
       || (!c.login_Auth(charId))
       || (ChannelServer.getInstance(c.getChannel()) == null)
       || (c.getWorld() != 0)) {
     c.getSession().close(true);
     return;
   }
   if (GameConstants.GMS) {
     c.updateMacs(slea.readMapleAsciiString());
   }
   if ((c.CheckSecondPassword(password))
       && (password.length() >= 6)
       && (password.length() <= 16)) {
     if (c.getIdleTask() != null) {
       c.getIdleTask().cancel(true);
     }
     String s = c.getSessionIPAddress();
     LoginServer.putLoginAuth(charId, s.substring(s.indexOf('/') + 1, s.length()), c.getTempIP());
     c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION, s);
     c.getSession()
         .write(
             CField.getServerIP(
                 c,
                 Integer.parseInt(ChannelServer.getInstance(c.getChannel()).getIP().split(":")[1]),
                 charId));
     System.out.println("Sent serverIp");
   } else {
     c.getSession().write(LoginPacket.secondPwError((byte) 0x14));
   }
 }
Exemplo n.º 8
0
  public static final void CreateUltimate(final LittleEndianAccessor slea, final MapleClient c) {
    if (!c.isLoggedIn()
        || c.getPlayer() == null
        || c.getPlayer().getLevel() < 120
        || c.getPlayer().getMapId() != 130000000
        || c.getPlayer().getQuestStatus(20734) != 0
        || c.getPlayer().getQuestStatus(20616) != 2
        || !GameConstants.isKOC(c.getPlayer().getJob())
        || !c.canMakeCharacter(c.getPlayer().getWorld())) {
      c.getPlayer().dropMessage(1, "You have no character slots.");
      c.getSession().write(CField.createUltimate(0));
      return;
    }
    System.out.println(slea.toString());
    final String name = slea.readMapleAsciiString();
    final int job = slea.readInt(); // job ID

    final int face = slea.readInt();
    final int hair = slea.readInt();

    final int hat = slea.readInt();
    final int top = slea.readInt();
    final int glove = slea.readInt();
    final int shoes = slea.readInt();
    final int weapon = slea.readInt();

    final byte gender = c.getPlayer().getGender();
    JobType jobType = JobType.Adventurer;
    // if (!LoginInformationProvider.getInstance().isEligibleItem(gender, 0, jobType.type, face) ||
    // !LoginInformationProvider.getInstance().isEligibleItem(gender, 1, jobType.type, hair)) {
    //    c.getPlayer().dropMessage(1, "An error occurred.");
    //    c.getSession().write(CField.createUltimate(0));
    //    return;
    // }

    jobType = JobType.UltimateAdventurer;

    MapleCharacter newchar = MapleCharacter.getDefault(c, jobType);
    newchar.setJob(job);
    newchar.setWorld((byte) c.getPlayer().getWorld());
    newchar.setFace(face);
    newchar.setHair(hair);
    newchar.setGender(gender);
    newchar.setName(name);
    newchar.setSkinColor((byte) 3); // troll
    newchar.setLevel((short) 50);
    newchar.getStat().str = (short) 4;
    newchar.getStat().dex = (short) 4;
    newchar.getStat().int_ = (short) 4;
    newchar.getStat().luk = (short) 4;
    newchar.setRemainingAp((short) 254); // 49*5 + 25 - 16
    newchar.setRemainingSp(
        job / 100 == 2 ? 128 : 122); // 2 from job advancements. 120 from leveling. (mages get +6)
    newchar.getStat().maxhp += 150; // Beginner 10 levels
    newchar.getStat().maxmp += 125;
    newchar.getStat().hp += 150; // Beginner 10 levels
    newchar.getStat().mp += 125;
    switch (job) {
      case 110:
      case 120:
      case 130:
        newchar.getStat().maxhp += 600; // Job Advancement
        newchar.getStat().maxhp += 2000; // Levelup 40 times
        newchar.getStat().maxmp += 200;
        newchar.getStat().hp += 600; // Job Advancement
        newchar.getStat().hp += 2000; // Levelup 40 times
        newchar.getStat().mp += 200;
        break;
      case 210:
      case 220:
      case 230:
        newchar.getStat().maxmp += 600;
        newchar.getStat().maxhp += 500; // Levelup 40 times
        newchar.getStat().maxmp += 2000;
        newchar.getStat().mp += 600;
        newchar.getStat().hp += 500; // Levelup 40 times
        newchar.getStat().mp += 2000;
        break;
      case 310:
      case 320:
      case 410:
      case 420:
      case 520:
        newchar.getStat().maxhp += 500;
        newchar.getStat().maxmp += 250;
        newchar.getStat().maxhp += 900; // Levelup 40 times
        newchar.getStat().maxmp += 600;
        newchar.getStat().maxhp += 500;
        newchar.getStat().mp += 250;
        newchar.getStat().hp += 900; // Levelup 40 times
        newchar.getStat().mp += 600;
        break;
      case 510:
        newchar.getStat().maxhp += 500;
        newchar.getStat().maxmp += 250;
        newchar.getStat().maxhp += 450; // Levelup 20 times
        newchar.getStat().maxmp += 300;
        newchar.getStat().maxhp += 800; // Levelup 20 times
        newchar.getStat().maxmp += 400;
        newchar.getStat().hp += 500;
        newchar.getStat().mp += 250;
        newchar.getStat().hp += 450; // Levelup 20 times
        newchar.getStat().mp += 300;
        newchar.getStat().hp += 800; // Levelup 20 times
        newchar.getStat().mp += 400;
        break;
      default:
        return;
    }
    for (int i = 2490; i < 2507; i++) {
      newchar.setQuestAdd(MapleQuest.getInstance(i), (byte) 2, null);
    }
    newchar.setQuestAdd(MapleQuest.getInstance(29947), (byte) 2, null);
    newchar.setQuestAdd(
        MapleQuest.getInstance(GameConstants.ULT_EXPLORER), (byte) 0, c.getPlayer().getName());

    final Map<Skill, SkillEntry> ss = new HashMap<>();
    ss.put(SkillFactory.getSkill(1074 + (job / 100)), new SkillEntry((byte) 5, (byte) 5, -1));
    ss.put(SkillFactory.getSkill(1195 + (job / 100)), new SkillEntry((byte) 5, (byte) 5, -1));
    ss.put(SkillFactory.getSkill(80), new SkillEntry((byte) 1, (byte) 1, -1));
    newchar.changeSkillLevel_Skip(ss, false);
    final MapleItemInformationProvider li = MapleItemInformationProvider.getInstance();

    int[] items =
        new int[] {
          1142257,
          hat,
          top,
          shoes,
          glove,
          weapon,
          hat + 1,
          top + 1,
          shoes + 1,
          glove + 1,
          weapon + 1
        }; // brilliant = fine+1
    for (byte i = 0; i < items.length; i++) {
      Item item = li.getEquipById(items[i]);
      item.setPosition((byte) (i + 1));
      newchar.getInventory(MapleInventoryType.EQUIP).addFromDB(item);
    }
    newchar
        .getInventory(MapleInventoryType.USE)
        .addItem(new Item(2000004, (byte) 0, (short) 100, (byte) 0));
    newchar
        .getInventory(MapleInventoryType.USE)
        .addItem(new Item(2000004, (byte) 0, (short) 100, (byte) 0));
    c.getPlayer().fakeRelog();
    if (MapleCharacterUtil.canCreateChar(name, c.isGm())
        && (!LoginInformationProvider.getInstance().isForbiddenName(name) || c.isGm())) {
      MapleCharacter.saveNewCharToDB(newchar, jobType, (short) 0);
      MapleQuest.getInstance(20734).forceComplete(c.getPlayer(), 1101000);
      c.getSession().write(CField.createUltimate(1));
    } else {
      c.getSession().write(CField.createUltimate(0));
    }
  }
Exemplo n.º 9
0
  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);
        }
      }
    }
  }