Beispiel #1
0
 private int getStat(MapleCharacter player) {
   switch (stat) {
     case STR:
       return player.getStat().getStr();
     case DEX:
       return player.getStat().getDex();
     case INT:
       return player.getStat().getInt();
     case LUK:
       return player.getStat().getLuk();
     case MAXHP:
       return player.getStat().getMaxHp();
     case MAXMP:
       return player.getStat().getMaxMp();
     default:
       throw new RuntimeException(); // Will never happen.
   }
 }
  /**
   * 角色快照数据
   *
   * @param chr
   */
  public CharacterTransfer(MapleCharacter chr) {
    this.characterid = chr.getId();
    this.accountid = chr.getAccountID();
    this.accountname = chr.getClient().getAccountName();
    this.channel = (byte) chr.getClient().getChannel();
    this.ACash = chr.getCSPoints(1);
    this.MaplePoints = chr.getCSPoints(2);
    this.vpoints = chr.getVPoints();
    this.name = chr.getName();
    this.fame = chr.getFame();
    this.love = chr.getLove();
    this.gender = chr.getClient().getGender();
    this.level = chr.getLevel();
    this.str = chr.getStat().getStr();
    this.dex = chr.getStat().getDex();
    this.int_ = chr.getStat().getInt();
    this.luk = chr.getStat().getLuk();
    this.hp = chr.getStat().getHp();
    this.mp = chr.getStat().getMp();
    this.maxhp = chr.getStat().getMaxHp();
    this.maxmp = chr.getStat().getMaxMp();
    this.exp = chr.getExp();
    this.hpApUsed = chr.getHpApUsed();
    this.remainingAp = chr.getRemainingAp();
    this.remainingSp = chr.getRemainingSp();
    this.meso = chr.getMeso();
    this.pvpExp = chr.getTotalBattleExp();
    this.pvpPoints = chr.getBattlePoints();
    this.skinColor = chr.getSkinColor();
    this.job = chr.getJob();
    this.hair = chr.getHair();
    this.face = chr.getFace();
    this.mapid = chr.getMapId();
    this.initialSpawnPoint = chr.getInitialSpawnpoint();
    this.marriageId = chr.getMarriageId();
    this.world = chr.getWorld();
    this.guildid = chr.getGuildId();
    this.guildrank = chr.getGuildRank();
    this.guildContribution = chr.getGuildContribution();
    this.alliancerank = chr.getAllianceRank();
    this.gmLevel = (byte) chr.getGMLevel();
    this.points = chr.getPoints();
    this.fairyExp = chr.getFairyExp();
    this.petStore = chr.getPetStores();
    this.subcategory = chr.getSubcategory();
    this.imps = chr.getImps();
    this.fatigue = chr.getFatigue();
    this.currentrep = chr.getCurrentRep();
    this.totalrep = chr.getTotalRep();
    this.totalWins = chr.getTotalWins();
    this.totalLosses = chr.getTotalLosses();
    this.gachexp = chr.getGachExp();
    this.boxed = chr.getBoxed();
    this.familiars = chr.getFamiliars();
    this.tempIP = chr.getClient().getTempIP();
    this.decorate = chr.getDecorate();
    this.dollars = chr.getDollars();
    this.shareLots = chr.getShareLots();
    this.apstorage = chr.getAPS();
    this.cardStack = chr.getCardStack();
    this.morphCount = chr.getMorphCount();
    this.powerCount = chr.getPowerCount();
    this.playerPoints = chr.getPlayerPoints();
    this.playerEnergy = chr.getPlayerEnergy();
    this.runningDark = chr.getDarkType();
    this.runningDarkSlot = chr.getDarkTotal();
    this.runningLight = chr.getLightType();
    this.runningLightSlot = chr.getLightTotal();

    boolean uneq = false;
    MaplePet pet = chr.getSpawnPet();
    if (this.petStore == 0) {
      this.petStore = -1;
    }
    if (pet != null) {
      uneq = true;
      this.petStore = (byte) Math.max(this.petStore, pet.getInventoryPosition());
    }
    if (uneq) {
      chr.unequipAllSpawnPets();
    }
    if (chr.getSidekick() != null) {
      this.sidekick = chr.getSidekick().getId();
    } else {
      this.sidekick = 0;
    }
    for (BuddylistEntry qs : chr.getBuddylist().getBuddies()) {
      this.buddies.put(
          new CharacterNameAndId(qs.getCharacterId(), qs.getName(), qs.getGroup()), qs.isVisible());
    }
    this.buddysize = chr.getBuddyCapacity();

    this.partyid = (chr.getParty() == null ? -1 : chr.getParty().getId());

    if (chr.getMessenger() != null) {
      this.messengerid = chr.getMessenger().getId();
    } else {
      this.messengerid = 0;
    }
    this.finishedAchievements = chr.getFinishedAchievements();
    this.KeyValue = chr.getKeyValue_Map();
    this.InfoQuest = chr.getInfoQuest_Map();
    for (Map.Entry qs : chr.getQuest_Map().entrySet()) {
      this.Quest.put(((MapleQuest) qs.getKey()).getId(), qs.getValue());
    }
    this.inventorys = chr.getInventorys();
    for (Entry<Skill, SkillEntry> qs : chr.getSkills().entrySet()) {
      this.Skills.put(((Skill) qs.getKey()).getId(), qs.getValue());
    }
    this.BlessOfFairy = chr.getBlessOfFairyOrigin();
    this.BlessOfEmpress = chr.getBlessOfEmpressOrigin();
    this.chalkboard = chr.getChalkboard();
    this.keymap = chr.getKeyLayout().Layout();
    this.quickslot = chr.getQuickSlot().Layout();
    this.savedlocation = chr.getSavedLocations();
    this.wishlist = chr.getWishlist();
    this.regrocks = chr.getRegRocks();
    this.famedcharacters = chr.getFamedCharacters();
    this.lastfametime = chr.getLastFameTime();
    this.storage = chr.getStorage();
    this.cs = chr.getCashInventory();
    MapleMount mount = chr.getMount();
    this.mount_itemid = mount.getItemId();
    this.mount_Fatigue = mount.getFatigue();
    this.mount_level = mount.getLevel();
    this.mount_exp = mount.getExp();
    this.battlers = chr.getBattlers();
    this.lastLoveTime = chr.getLastLoveTime();
    this.loveCharacters = chr.getLoveCharacters();
    this.TranferTime = System.currentTimeMillis();
  }
  /**
   * 可以创建定时技能
   *
   * @param chr
   * @param numTimes
   * @param hurt
   * @param now
   */
  public static void handleCooldowns(MapleCharacter chr, int numTimes, boolean hurt, long now) {
    if (chr == null) {
      return;
    }
    if (chr.getCooldownSize() > 0) {
      for (MapleCoolDownValueHolder m : chr.getCooldowns()) {
        if (m.startTime + m.length < now) {
          int skillId = m.skillId;
          chr.removeCooldown(skillId);
          chr.getClient().getSession().write(MaplePacketCreator.skillCooldown(skillId, 0));
        }
      }
    }

    if (chr.isAlive()) {
      if (((chr.getJob() == 131) || (chr.getJob() == 132)) && (chr.canBlood(now))) {
        chr.doDragonBlood();
      }

      if (chr.canRecover(now)) {
        chr.doRecovery();
      }
      if (chr.canHPRecover(now)) {
        chr.addHP((int) chr.getStat().getHealHP());
      }
      if (chr.canMPRecover(now)) {
        chr.addMP((int) chr.getStat().getHealMP());
        if ((chr.getJob() == 3111) || (chr.getJob() == 3112)) {
          chr.addDemonMp((int) chr.getStat().getHealMP());
        }
      }

      if (chr.canFairy(now)) {
        chr.doFairy();
      }
      if (chr.canFish(now)) {
        chr.doFish(now);
      }
      if (chr.canDOT(now)) {
        chr.doDOT();
      }
      if (chr.canExpiration(now)) {
        chr.expirationTask();
      }
    }

    if (chr.getDiseaseSize() > 0) {
      for (MapleDiseaseValueHolder m : chr.getAllDiseases()) {
        if ((m != null) && (m.startTime + m.length < now)) {
          chr.dispelDebuff(m.disease);
        }
      }
    }

    if ((numTimes % 7 == 0) && (chr.getMount() != null) && (chr.getMount().canTire(now))) {
      chr.getMount().increaseFatigue();
    }
    if (numTimes % 13 == 0) {
      chr.doFamiliarSchedule(now);
      for (MaplePet pet : chr.getSummonedPets()) {
        if ((pet.getPetItemId() == 5000054) && (pet.getSecondsLeft() > 0)) {
          pet.setSecondsLeft(pet.getSecondsLeft() - 1);
          if (pet.getSecondsLeft() <= 0) {
            chr.unequipSpawnPet(pet, true, true);
            return;
          }
        }
        int newFullness = pet.getFullness() - PetDataFactory.getHunger(pet.getPetItemId());
        if (newFullness <= 5) {
          pet.setFullness(15);
          chr.unequipSpawnPet(pet, true, true);
        } else {
          pet.setFullness(newFullness);
          chr.getClient()
              .getSession()
              .write(
                  PetPacket.updatePet(
                      pet,
                      chr.getInventory(MapleInventoryType.CASH).getItem(pet.getInventoryPosition()),
                      false));
        }
      }
    }
    if ((hurt) && (chr.isAlive())) {
      if (chr.getInventory(MapleInventoryType.EQUIPPED).findById(chr.getMap().getHPDecProtect())
          == null) {
        if ((chr.getMapId() == 749040100)
            && (chr.getInventory(MapleInventoryType.CASH).findById(5451000) == null)) {
          chr.addHP(-chr.getMap().getHPDec());
        } else if (chr.getMapId() != 749040100) {
          chr.addHP(-(chr.getMap().getHPDec()));
        }
      }
    }
  }
Beispiel #4
0
 private void setStat(MapleCharacter player, int current, int amount) {
   switch (stat) {
     case STR:
       player.getStat().setStr((short) (current + amount), player);
       player.updateSingleStat(MapleStat.STR, player.getStat().getStr());
       break;
     case DEX:
       player.getStat().setDex((short) (current + amount), player);
       player.updateSingleStat(MapleStat.DEX, player.getStat().getDex());
       break;
     case INT:
       player.getStat().setInt((short) (current + amount), player);
       player.updateSingleStat(MapleStat.INT, player.getStat().getInt());
       break;
     case LUK:
       player.getStat().setLuk((short) (current + amount), player);
       player.updateSingleStat(MapleStat.LUK, player.getStat().getLuk());
       break;
     case MAXHP:
       long maxhp = Math.min(500000, Math.abs(current + amount * 30));
       //      player.getStat().setMaxHp((short) (current + amount * 30), player);
       player.getStat().setMaxHp((short) maxhp, player);
       player.updateSingleStat(MapleStat.HP, player.getStat().getHp());
       break;
     case MAXMP:
       long maxmp = Math.min(500000, Math.abs(current + amount));
       player.getStat().setMaxMp((short) maxmp, player);
       player.updateSingleStat(MapleStat.MP, player.getStat().getMp());
       break;
     case HAIR:
       int hair = amount;
       player.setSecondHair(hair);
       player.updateSingleStat(MapleStat.HAIR, player.getSecondHair());
       break;
   }
 }
Beispiel #5
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));
    }
  }
Beispiel #6
0
  public static void CreateChar(final LittleEndianAccessor slea, final MapleClient c) {
    if (!c.isLoggedIn()) {
      c.getSession().close();
      return;
    }
    final String name = slea.readMapleAsciiString();
    final JobType jobType =
        JobType.getByType(
            slea.readInt()); // BIGBANG: 0 = Resistance, 1 = Adventurer, 2 = Cygnus, 3 = Aran, 4 =
    // Evan, 5 = mercedes
    final short db = slea.readShort(); // whether dual blade = 1 or adventurer = 0
    final byte gender = slea.readByte(); // ??idk corresponds with the thing in addCharStats
    byte skinColor = slea.readByte(); // 01
    int hairColor = 0;
    final byte unk2 = slea.readByte(); // 08
    final boolean mercedes = (jobType == JobType.Mercedes);
    final boolean demon = (jobType == JobType.Demon);
    final boolean mihile = (jobType == JobType.Mihile);
    boolean jettPhantom =
        (jobType == LoginInformationProvider.JobType.Jett)
            || (jobType == LoginInformationProvider.JobType.Phantom)
            || (jobType == LoginInformationProvider.JobType.DualBlade);
    final int face = slea.readInt();
    final int hair = slea.readInt();
    if (!mercedes
        && !mihile
        && !demon
        && !jettPhantom) { // mercedes/demon dont need hair color since its already in the hair
      hairColor = slea.readInt();
      skinColor = (byte) slea.readInt();
    }
    final int demonMark = demon ? slea.readInt() : 0;
    final int top = (mihile) ? 0 : slea.readInt();
    final int bottom = (mihile) ? 0 : slea.readInt();
    final int shoes = (mihile) ? 0 : slea.readInt();
    final int weapon =
        jobType == LoginInformationProvider.JobType.Phantom
            ? 1362046
            : mercedes ? 1522038 : (mihile || demon) ? 0 : slea.readInt();
    int shield =
        jobType == LoginInformationProvider.JobType.Phantom
            ? 1352100
            : jobType == LoginInformationProvider.JobType.Mihile
                ? 1098000
                : mercedes ? 1352000 : demon ? slea.readInt() : 0;
    MapleCharacter newchar = MapleCharacter.getDefault(c, jobType);
    newchar.setWorld((byte) c.getWorld());
    newchar.setFace(face);
    newchar.setHair(hair + hairColor);
    newchar.setGender(gender);
    newchar.setName(name);
    newchar.setSkinColor(skinColor);
    newchar.setDemonMarking(demonMark);

    final MapleItemInformationProvider li = MapleItemInformationProvider.getInstance();
    final MapleInventory equip = newchar.getInventory(MapleInventoryType.EQUIPPED);

    Item item = li.getEquipById(top);
    item.setPosition((byte) -5);
    equip.addFromDB(item);

    if (bottom > 0) { // resistance have overall
      item = li.getEquipById(bottom);
      item.setPosition((short) (byte) (jettPhantom ? -9 : -6));
      equip.addFromDB(item);
    }

    item = li.getEquipById(shoes);
    item.setPosition((byte) -7);
    equip.addFromDB(item);

    item = li.getEquipById(weapon);
    item.setPosition((byte) -11);
    equip.addFromDB(item);

    if (shield > 0) {
      item = li.getEquipById(shield);
      item.setPosition((byte) -10);
      equip.addFromDB(item);
    }

    newchar
        .getInventory(MapleInventoryType.USE)
        .addItem(new Item(2000013, (byte) 0, (short) 100, (byte) 0));
    newchar
        .getInventory(MapleInventoryType.USE)
        .addItem(new Item(2000014, (byte) 0, (short) 100, (byte) 0));
    // blue/red pots
    switch (jobType) {
      case Resistance: // Resistance
        newchar
            .getInventory(MapleInventoryType.ETC)
            .addItem(new Item(4161001, (byte) 0, (short) 1, (byte) 0));
        final Map<Skill, SkillEntry> ss = new HashMap<>();
        ss.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1));
        newchar.changeSkillLevel_Skip(ss, false);
        break;
      case Adventurer: // Adventurer
        newchar
            .getInventory(MapleInventoryType.ETC)
            .addItem(new Item(4161001, (byte) 0, (short) 1, (byte) 0));
        final Map<Skill, SkillEntry> ss1 = new HashMap<>();
        ss1.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1));
        newchar.changeSkillLevel_Skip(ss1, false);
        break;
      case Cygnus: // Cygnus
        newchar
            .getInventory(MapleInventoryType.ETC)
            .addItem(new Item(4161047, (byte) 0, (short) 1, (byte) 0));
        newchar.setQuestAdd(MapleQuest.getInstance(20022), (byte) 1, "1");
        newchar.setQuestAdd(MapleQuest.getInstance(20010), (byte) 1, null); // >_>_>_> ugh
        final Map<Skill, SkillEntry> ss2 = new HashMap<>();
        ss2.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1));
        newchar.changeSkillLevel_Skip(ss2, false);
        break;
      case Aran: // Aran
        newchar
            .getInventory(MapleInventoryType.ETC)
            .addItem(new Item(4161048, (byte) 0, (short) 1, (byte) 0));
        final Map<Skill, SkillEntry> ss3 = new HashMap<>();
        ss3.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1));
        newchar.changeSkillLevel_Skip(ss3, false);
        break;
      case Evan: // Evan
        newchar
            .getInventory(MapleInventoryType.ETC)
            .addItem(new Item(4161052, (byte) 0, (short) 1, (byte) 0));
        final Map<Skill, SkillEntry> ss4 = new HashMap<>();
        ss4.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1));
        newchar.changeSkillLevel_Skip(ss4, false);
        break;
      case Mercedes: // Mercedes
        newchar
            .getInventory(MapleInventoryType.ETC)
            .addItem(new Item(4161079, (byte) 0, (short) 1, (byte) 0));
        final Map<Skill, SkillEntry> ss5 = new HashMap<>();
        ss5.put(SkillFactory.getSkill(20021000), new SkillEntry((byte) 0, (byte) 0, -1));
        ss5.put(SkillFactory.getSkill(20021001), new SkillEntry((byte) 0, (byte) 0, -1));
        ss5.put(SkillFactory.getSkill(20020002), new SkillEntry((byte) 0, (byte) 0, -1));
        ss5.put(SkillFactory.getSkill(20020022), new SkillEntry((byte) 1, (byte) 1, -1));
        ss5.put(SkillFactory.getSkill(20020109), new SkillEntry((byte) 1, (byte) 1, -1));
        ss5.put(SkillFactory.getSkill(20021110), new SkillEntry((byte) 1, (byte) 1, -1));
        ss5.put(SkillFactory.getSkill(20020111), new SkillEntry((byte) 1, (byte) 1, -1));
        ss5.put(SkillFactory.getSkill(20020112), new SkillEntry((byte) 1, (byte) 1, -1));
        ss5.put(SkillFactory.getSkill(20021181), new SkillEntry((byte) -1, (byte) 0, -1));
        ss5.put(SkillFactory.getSkill(20021166), new SkillEntry((byte) -1, (byte) 0, -1));
        ss5.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1));
        newchar.changeSkillLevel_Skip(ss5, false);
        break;
      case Demon: // Demon
        newchar
            .getInventory(MapleInventoryType.ETC)
            .addItem(new Item(4161054, (byte) 0, (short) 1, (byte) 0));
        final Map<Skill, SkillEntry> ss6 = new HashMap<>();
        ss6.put(SkillFactory.getSkill(30011000), new SkillEntry((byte) 0, (byte) 0, -1));
        ss6.put(SkillFactory.getSkill(30011001), new SkillEntry((byte) 0, (byte) 0, -1));
        ss6.put(SkillFactory.getSkill(30010002), new SkillEntry((byte) 0, (byte) 0, -1));
        ss6.put(SkillFactory.getSkill(30010185), new SkillEntry((byte) 1, (byte) 1, -1));
        ss6.put(SkillFactory.getSkill(30010112), new SkillEntry((byte) 1, (byte) 1, -1));
        ss6.put(SkillFactory.getSkill(30010111), new SkillEntry((byte) 1, (byte) 1, -1));
        ss6.put(SkillFactory.getSkill(30010110), new SkillEntry((byte) 1, (byte) 1, -1));
        ss6.put(SkillFactory.getSkill(30010022), new SkillEntry((byte) 1, (byte) 1, -1));
        ss6.put(SkillFactory.getSkill(30011109), new SkillEntry((byte) 1, (byte) 1, -1));
        ss6.put(SkillFactory.getSkill(30011170), new SkillEntry((byte) 1, (byte) 1, -1));
        ss6.put(SkillFactory.getSkill(30011169), new SkillEntry((byte) 1, (byte) 1, -1));
        ss6.put(SkillFactory.getSkill(30011168), new SkillEntry((byte) 1, (byte) 1, -1));
        ss6.put(SkillFactory.getSkill(30011167), new SkillEntry((byte) 1, (byte) 1, -1));
        ss6.put(SkillFactory.getSkill(30010166), new SkillEntry((byte) 1, (byte) 1, -1));
        ss6.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1));
        newchar.changeSkillLevel_Skip(ss6, false);
        break;

      case Phantom:
        newchar.setLevel((short) 10);
        newchar.setJob(2400);
        newchar.getStat().maxhp += 294; // Beginner 10 levels
        newchar.getStat().maxmp += 113;
        newchar.getStat().hp += 294; // Beginner 10 levels
        newchar.getStat().mp += 113;
        newchar.getStat().str -= 8;
        newchar.getStat().dex -= 1;
        newchar.getStat().luk += 31;
        newchar.setRemainingAp((short) 23);
        newchar.setRemainingSp(5);
        final Map<Skill, SkillEntry> ss7 = new HashMap<>();
        ss7.put(SkillFactory.getSkill(20031203), new SkillEntry((byte) 1, (byte) 1, -1));
        ss7.put(SkillFactory.getSkill(20030204), new SkillEntry((byte) 1, (byte) 1, -1));
        ss7.put(SkillFactory.getSkill(20031205), new SkillEntry((byte) 1, (byte) 1, -1));
        ss7.put(SkillFactory.getSkill(20030206), new SkillEntry((byte) 1, (byte) 1, -1));
        ss7.put(SkillFactory.getSkill(20031207), new SkillEntry((byte) 1, (byte) 1, -1));
        ss7.put(SkillFactory.getSkill(20031208), new SkillEntry((byte) 1, (byte) 1, -1));
        ss7.put(SkillFactory.getSkill(20031209), new SkillEntry((byte) 1, (byte) 1, -1));
        ss7.put(SkillFactory.getSkill(20031210), new SkillEntry((byte) 1, (byte) 1, -1));
        ss7.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1));
        newchar.changeSkillLevel_Skip(ss7, false);
        break;

      case Jett:
        newchar.setLevel((short) 10);
        newchar.setJob(508);
        newchar.getStat().maxhp += 294; // Beginner 10
        newchar.getStat().maxmp += 113;
        newchar.getStat().hp += 294; // Beginner 10
        newchar.getStat().mp += 113;
        newchar.getStat().str -= 8;
        newchar.getStat().dex += 15;
        newchar.setRemainingAp((short) 38);
        newchar.setRemainingSp(1);
        final Map<Skill, SkillEntry> ss8 = new HashMap<>();
        ss8.put(SkillFactory.getSkill(228), new SkillEntry((byte) 1, (byte) 1, -1));
        ss8.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1));
        // ss8.put(SkillFactory.getSkill(80001151), new SkillEntry((byte) 1, (byte) 1, -1));
        newchar.changeSkillLevel_Skip(ss8, false);
        break;

      case Mihile:
        final Map<Skill, SkillEntry> ss9 = new HashMap<>();
        ss9.put(SkillFactory.getSkill(80001152), new SkillEntry((byte) 1, (byte) 1, -1));
        newchar.changeSkillLevel_Skip(ss9, false);
        break;
    }

    if (MapleCharacterUtil.canCreateChar(name, c.isGm())
        && (!LoginInformationProvider.getInstance().isForbiddenName(name) || c.isGm())
        && (c.isGm() || c.canMakeCharacter(c.getWorld()))) {
      MapleCharacter.saveNewCharToDB(newchar, jobType, db);
      c.getSession().write(LoginPacket.addNewCharEntry(newchar, true));
      c.createdChar(newchar.getId());
    } else {
      c.getSession().write(LoginPacket.addNewCharEntry(newchar, false));
    }
  }
  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 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);
   }
 }
  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);
      }
    }
  }