コード例 #1
0
  public static final void ItemMaker(final LittleEndianAccessor slea, final MapleClient c) {
    // System.out.println(slea.toString()); //change?
    final int makerType = slea.readInt();

    switch (makerType) {
      case 1:
        { // Gem
          final int toCreate = slea.readInt();

          if (GameConstants.isGem(toCreate)) {
            final GemCreateEntry gem = ItemMakerFactory.getInstance().getGemInfo(toCreate);
            if (gem == null) {
              return;
            }
            if (!hasSkill(c, gem.getReqSkillLevel())) {
              return; // H4x
            }
            if (c.getPlayer().getMeso() < gem.getCost()) {
              return; // H4x
            }
            final int randGemGiven = getRandomGem(gem.getRandomReward());

            if (c.getPlayer().getInventory(GameConstants.getInventoryType(randGemGiven)).isFull()) {
              return; // We'll do handling for this later
            }
            final int taken = checkRequiredNRemove(c, gem.getReqRecipes());
            if (taken == 0) {
              return; // We'll do handling for this later
            }
            c.getPlayer().gainMeso(-gem.getCost(), false);
            MapleInventoryManipulator.addById(
                c,
                randGemGiven,
                (byte) (taken == randGemGiven ? 9 : 1),
                "Made by Gem "
                    + toCreate
                    + " on "
                    + FileoutputUtil.CurrentReadable_Date()); // Gem is always 1

            c.getSession().write(EffectPacket.ItemMaker_Success());
            c.getPlayer()
                .getMap()
                .broadcastMessage(
                    c.getPlayer(),
                    EffectPacket.ItemMaker_Success_3rdParty(c.getPlayer().getId()),
                    false);
          } else if (GameConstants.isOtherGem(toCreate)) {
            // non-gems that are gems
            // stim and numEnchanter always 0
            final GemCreateEntry gem = ItemMakerFactory.getInstance().getGemInfo(toCreate);
            if (gem == null) {
              return;
            }
            if (!hasSkill(c, gem.getReqSkillLevel())) {
              return; // H4x
            }
            if (c.getPlayer().getMeso() < gem.getCost()) {
              return; // H4x
            }

            if (c.getPlayer().getInventory(GameConstants.getInventoryType(toCreate)).isFull()) {
              return; // We'll do handling for this later
            }
            if (checkRequiredNRemove(c, gem.getReqRecipes()) == 0) {
              return; // We'll do handling for this later
            }
            c.getPlayer().gainMeso(-gem.getCost(), false);
            if (GameConstants.getInventoryType(toCreate) == MapleInventoryType.EQUIP) {
              MapleInventoryManipulator.addbyItem(
                  c, MapleItemInformationProvider.getInstance().getEquipById(toCreate));
            } else {
              MapleInventoryManipulator.addById(
                  c,
                  toCreate,
                  (byte) 1,
                  "Made by Gem "
                      + toCreate
                      + " on "
                      + FileoutputUtil.CurrentReadable_Date()); // Gem is always 1
            }

            c.getSession().write(EffectPacket.ItemMaker_Success());
            c.getPlayer()
                .getMap()
                .broadcastMessage(
                    c.getPlayer(),
                    EffectPacket.ItemMaker_Success_3rdParty(c.getPlayer().getId()),
                    false);
          } else {
            final boolean stimulator = slea.readByte() > 0;
            final int numEnchanter = slea.readInt();

            final ItemMakerCreateEntry create =
                ItemMakerFactory.getInstance().getCreateInfo(toCreate);
            if (create == null) {
              return;
            }
            if (numEnchanter > create.getTUC()) {
              return; // h4x
            }
            if (!hasSkill(c, create.getReqSkillLevel())) {
              return; // H4x
            }
            if (c.getPlayer().getMeso() < create.getCost()) {
              return; // H4x
            }
            if (c.getPlayer().getInventory(GameConstants.getInventoryType(toCreate)).isFull()) {
              return; // We'll do handling for this later
            }
            if (checkRequiredNRemove(c, create.getReqItems()) == 0) {
              return; // We'll do handling for this later
            }
            c.getPlayer().gainMeso(-create.getCost(), false);

            final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            final Equip toGive = (Equip) ii.getEquipById(toCreate);

            if (stimulator || numEnchanter > 0) {
              if (c.getPlayer().haveItem(create.getStimulator(), 1, false, true)) {
                ii.randomizeStats_Above(toGive);
                MapleInventoryManipulator.removeById(
                    c, MapleInventoryType.ETC, create.getStimulator(), 1, false, false);
              }
              for (int i = 0; i < numEnchanter; i++) {
                final int enchant = slea.readInt();
                if (c.getPlayer().haveItem(enchant, 1, false, true)) {
                  final Map<String, Integer> stats = ii.getEquipStats(enchant);
                  if (stats != null) {
                    addEnchantStats(stats, toGive);
                    MapleInventoryManipulator.removeById(
                        c, MapleInventoryType.ETC, enchant, 1, false, false);
                  }
                }
              }
            }
            if (!stimulator || Randomizer.nextInt(10) != 0) {
              MapleInventoryManipulator.addbyItem(c, toGive);
              c.getPlayer()
                  .getMap()
                  .broadcastMessage(
                      c.getPlayer(),
                      EffectPacket.ItemMaker_Success_3rdParty(c.getPlayer().getId()),
                      false);
            } else {
              c.getPlayer().dropMessage(5, "The item was overwhelmed by the stimulator.");
            }
            c.getSession().write(EffectPacket.ItemMaker_Success());
          }
          break;
        }
      case 3:
        { // Making Crystals
          final int etc = slea.readInt();
          if (c.getPlayer().haveItem(etc, 100, false, true)) {
            MapleInventoryManipulator.addById(
                c,
                getCreateCrystal(etc),
                (short) 1,
                "Made by Maker " + etc + " on " + FileoutputUtil.CurrentReadable_Date());
            MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, etc, 100, false, false);

            c.getSession().write(EffectPacket.ItemMaker_Success());
            c.getPlayer()
                .getMap()
                .broadcastMessage(
                    c.getPlayer(),
                    EffectPacket.ItemMaker_Success_3rdParty(c.getPlayer().getId()),
                    false);
          }
          break;
        }
      case 4:
        { // Disassembling EQ.
          final int itemId = slea.readInt();
          c.getPlayer().updateTick(slea.readInt());
          final byte slot = (byte) slea.readInt();

          final Item toUse = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(slot);
          if (toUse == null || toUse.getItemId() != itemId || toUse.getQuantity() < 1) {
            return;
          }
          final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();

          if (!ii.isDropRestricted(itemId) && !ii.isAccountShared(itemId)) {
            final int[] toGive = getCrystal(itemId, ii.getReqLevel(itemId));
            MapleInventoryManipulator.addById(
                c,
                toGive[0],
                (byte) toGive[1],
                "Made by disassemble " + itemId + " on " + FileoutputUtil.CurrentReadable_Date());
            MapleInventoryManipulator.removeFromSlot(
                c, MapleInventoryType.EQUIP, slot, (byte) 1, false);
          }
          c.getSession().write(EffectPacket.ItemMaker_Success());
          c.getPlayer()
              .getMap()
              .broadcastMessage(
                  c.getPlayer(),
                  EffectPacket.ItemMaker_Success_3rdParty(c.getPlayer().getId()),
                  false);
          break;
        }
    }
  }
コード例 #2
0
 public static final void SubSummon(final LittleEndianAccessor slea, final MapleCharacter chr) {
   final MapleMapObject obj = chr.getMap().getMapObject(slea.readInt(), MapleMapObjectType.SUMMON);
   if (obj == null || !(obj instanceof MapleSummon)) {
     return;
   }
   final MapleSummon sum = (MapleSummon) obj;
   if (sum == null
       || sum.getOwnerId() != chr.getId()
       || sum.getSkillLevel() <= 0
       || !chr.isAlive()) {
     return;
   }
   switch (sum.getSkill()) {
     case 35121009:
       if (!chr.canSummon(2000)) {
         return;
       }
       final int skillId = slea.readInt(); // 35121009?
       if (sum.getSkill() != skillId) {
         return;
       }
       slea.skip(1); // 0E?
       chr.updateTick(slea.readInt());
       for (int i = 0; i < 3; i++) {
         final MapleSummon tosummon =
             new MapleSummon(
                 chr,
                 SkillFactory.getSkill(35121011).getEffect(sum.getSkillLevel()),
                 new Point(sum.getTruePosition().x, sum.getTruePosition().y - 5),
                 SummonMovementType.WALK_STATIONARY);
         chr.getMap().spawnSummon(tosummon);
         chr.addSummon(tosummon);
       }
       break;
     case 35111011: // healing
       if (!chr.canSummon(1000)) {
         return;
       }
       chr.addHP(
           (int)
               (chr.getStat().getCurrentMaxHp()
                   * SkillFactory.getSkill(sum.getSkill()).getEffect(sum.getSkillLevel()).getHp()
                   / 100.0));
       chr.getClient()
           .getSession()
           .write(
               EffectPacket.showOwnBuffEffect(
                   sum.getSkill(), 2, chr.getLevel(), sum.getSkillLevel()));
       chr.getMap()
           .broadcastMessage(
               chr,
               EffectPacket.showBuffeffect(
                   chr.getId(), sum.getSkill(), 2, chr.getLevel(), sum.getSkillLevel()),
               false);
       break;
     case 1321007: // beholder
       Skill bHealing = SkillFactory.getSkill(slea.readInt());
       final int bHealingLvl = chr.getTotalSkillLevel(bHealing);
       if (bHealingLvl <= 0 || bHealing == null) {
         return;
       }
       final MapleStatEffect healEffect = bHealing.getEffect(bHealingLvl);
       if (bHealing.getId() == 1320009) {
         healEffect.applyTo(chr);
       } else if (bHealing.getId() == 1320008) {
         if (!chr.canSummon(healEffect.getX() * 1000)) {
           return;
         }
         chr.addHP(healEffect.getHp());
       }
       chr.getClient()
           .getSession()
           .write(EffectPacket.showOwnBuffEffect(sum.getSkill(), 2, chr.getLevel(), bHealingLvl));
       chr.getMap()
           .broadcastMessage(
               SummonPacket.summonSkill(
                   chr.getId(),
                   sum.getSkill(),
                   bHealing.getId() == 1320008 ? 5 : (Randomizer.nextInt(3) + 6)));
       chr.getMap()
           .broadcastMessage(
               chr,
               EffectPacket.showBuffeffect(
                   chr.getId(), sum.getSkill(), 2, chr.getLevel(), bHealingLvl),
               false);
       break;
   }
   if (GameConstants.isAngel(sum.getSkill())) {
     if (sum.getSkill() % 10000 == 1087) {
       MapleItemInformationProvider.getInstance().getItemEffect(2022747).applyTo(chr);
     } else if (sum.getSkill() % 10000 == 1179) {
       MapleItemInformationProvider.getInstance().getItemEffect(2022823).applyTo(chr);
     } else if (sum.getSkill() % 10000 == 1085) {
       MapleItemInformationProvider.getInstance().getItemEffect(2022746).applyTo(chr);
     }
     chr.getClient().getSession().write(EffectPacket.showOwnBuffEffect(sum.getSkill(), 2, 2, 1));
     chr.getMap()
         .broadcastMessage(
             chr, EffectPacket.showBuffeffect(chr.getId(), sum.getSkill(), 2, 2, 1), false);
   }
 }