예제 #1
0
 public int addMember(MapleCharacter member, boolean join) {
   if (getLeader() == null) {
     return -1;
   }
   final String job = MapleCarnivalChallenge.getJobBasicNameById(member.getJob());
   if (join) {
     if (!containsMember(member) && !getAllNextPlayer().contains(member.getName())) {
       if (members.size() <= 30) {
         members.put(member.getName(), job);
         getLeader().dropMessage(5, member.getName() + " (" + job + ") has joined the fight!");
         return 1;
       }
       return 2;
     }
     return -1;
   } else {
     if (containsMember(member)) {
       members.remove(member.getName());
       getLeader()
           .dropMessage(5, member.getName() + " (" + job + ") have withdrawed from the fight.");
       return 1;
     }
     return -1;
   }
 }
예제 #2
0
 @Override
 public void execute(MapleClient c, MessageCallback mc, String[] splitted)
     throws Exception, IllegalCommandSyntaxException {
   if (splitted[0].equals("!whosthere")) {
     MessageCallback callback = new ServernoticeMapleClientMessageCallback(c);
     StringBuilder builder = new StringBuilder("Players on Map: ");
     for (MapleCharacter chr : c.getPlayer().getMap().getCharacters()) {
       if (builder.length() > 150) { // wild guess :o
         builder.setLength(builder.length() - 2);
         callback.dropMessage(builder.toString());
         builder = new StringBuilder();
       }
       builder.append(MapleCharacter.makeMapleReadable(chr.getName()));
       builder.append(", ");
     }
     builder.setLength(builder.length() - 2);
     c.getSession().write(MaplePacketCreator.serverNotice(6, builder.toString()));
   } else if (splitted[0].equals("!cheaters")) {
     try {
       List<CheaterData> cheaters =
           c.getChannelServer().getWorldInterface().getCheaters(c.getWorld());
       for (int x = cheaters.size() - 1; x >= 0; x--) {
         CheaterData cheater = cheaters.get(x);
         mc.dropMessage(cheater.getInfo());
       }
     } catch (RemoteException e) {
       c.getChannelServer().reconnectWorld();
     }
   }
 }
예제 #3
0
 public boolean containsMember(MapleCharacter member) {
   for (String mmbr : members.keySet()) {
     if (mmbr.equalsIgnoreCase(member.getName())) {
       return true;
     }
   }
   return false;
 }
예제 #4
0
 public MapleSquad(
     final int ch,
     final String type,
     final MapleCharacter leader,
     final int expiration,
     final String toSay) {
   this.leader = new WeakReference<MapleCharacter>(leader);
   this.members.put(leader.getName(), MapleCarnivalChallenge.getJobBasicNameById(leader.getJob()));
   this.leaderName = leader.getName();
   this.ch = ch;
   this.toSay = toSay;
   this.type = MapleSquadType.valueOf(type.toLowerCase());
   this.status = 1;
   this.beginMapId = leader.getMapId();
   leader.getMap().setSquad(this.type);
   if (this.type.queue.get(ch) == null) {
     this.type.queue.put(ch, new ArrayList<Pair<String, Long>>());
     this.type.queuedPlayers.put(ch, new ArrayList<Pair<String, String>>());
   }
   this.startTime = System.currentTimeMillis();
   this.expiration = expiration;
 }
예제 #5
0
 public static void declineTrade(MapleCharacter c) {
   MapleTrade trade = c.getTrade();
   if (trade != null) {
     if (trade.getPartner() != null) {
       MapleCharacter other = trade.getPartner().getChr();
       other.getTrade().cancel();
       other.setTrade(null);
       other.message(c.getName() + " has declined your trade request.");
     }
     trade.cancel();
     c.setTrade(null);
   }
 }
예제 #6
0
 public void setMeso(int meso) {
   if (locked) {
     throw new RuntimeException("Trade is locked.");
   }
   if (meso < 0) {
     System.out.println("[h4x] " + chr.getName() + " Trying to trade < 0 mesos");
     return;
   }
   if (chr.getMeso() >= meso) {
     chr.gainMeso(-meso, false, true, false);
     this.meso += meso;
     chr.getClient().getSession().write(MaplePacketCreator.getTradeMesoSet((byte) 0, this.meso));
     if (partner != null) {
       partner
           .getChr()
           .getClient()
           .getSession()
           .write(MaplePacketCreator.getTradeMesoSet((byte) 1, this.meso));
     }
   } else {
   }
 }
예제 #7
0
  public HiredMerchant(final MapleCharacter owner, int itemId, String desc) {
    this.setPosition(owner.getPosition());
    this.start = System.currentTimeMillis();
    this.ownerId = owner.getId();
    this.channel = owner.getClient().getChannel();
    this.world = owner.getWorld();
    this.itemId = itemId;
    this.ownerName = owner.getName();
    this.description = desc;
    this.map = owner.getMap();
    this.schedule =
        TimerManager.getInstance()
            .schedule(
                new Runnable() {

                  @Override
                  public void run() {
                    HiredMerchant.this.closeShop(owner.getClient(), true);
                  }
                },
                1000 * 60 * 60 * 24);
  }
  @Override
  public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    int cid = slea.readInt();
    MapleCharacter player = null;
    try {
      player = MapleCharacter.loadCharFromDB(cid, c, true);
      c.setPlayer(player);
    } catch (SQLException e) {
    }
    c.setAccID(player.getAccountID());
    int state = c.getLoginState();
    boolean allowLogin = true;
    ChannelServer cserv = c.getChannelServer();
    synchronized (this) {
      try {
        WorldChannelInterface worldInterface = cserv.getWorldInterface();
        if (state == MapleClient.LOGIN_SERVER_TRANSITION) {
          for (String charName : c.loadCharacterNames(c.getWorld())) {
            if (worldInterface.isConnected(charName)) {
              int chanNum = c.getChannelServer().getWorldInterface().getLocation(charName).channel;
              System.err.print(
                  charName
                      + " on channel "
                      + chanNum
                      + " has been unstuck, for bug-testing purposes.");
              MapleCharacter player_to_dc =
                  ChannelServer.getInstance(chanNum)
                      .getPlayerStorage()
                      .getCharacterByName(charName);
              if (player_to_dc.getEventInstance() != null)
                player_to_dc.getEventInstance().removePlayer(player_to_dc);
              player_to_dc.getMap().removePlayer(player_to_dc);
              ChannelServer.getInstance(chanNum).removePlayer(player_to_dc);
              player_to_dc.getClient().disconnect();
              player_to_dc.getClient().getSession().close();
              c.disconnect();
              allowLogin = false;
              break;
            }
          }
        }
      } catch (RemoteException e) {
        cserv.reconnectWorld();
        allowLogin = false;
      } catch (Exception e) {
        System.out.println("Error unsticking char:");
        e.printStackTrace();
      }
      if (state != MapleClient.LOGIN_SERVER_TRANSITION || !allowLogin) {
        c.setPlayer(null);
        c.getSession().close(true);
        return;
      }
      c.updateLoginState(MapleClient.LOGIN_LOGGEDIN);
    }
    cserv.addPlayer(player);
    try {
      List<PlayerBuffValueHolder> buffs = cserv.getWorldInterface().getBuffsFromStorage(cid);
      if (buffs != null) {
        c.getPlayer().silentGiveBuffs(buffs);
      }
    } catch (RemoteException e) {
      cserv.reconnectWorld();
    }
    Connection con = DatabaseConnection.getConnection();
    try {
      PreparedStatement ps =
          con.prepareStatement("SELECT SkillID,StartTime,length FROM cooldowns WHERE charid = ?");
      ps.setInt(1, c.getPlayer().getId());
      ResultSet rs = ps.executeQuery();
      while (rs.next()) {
        final long length = rs.getLong("length"), startTime = rs.getLong("StartTime");
        if (length + startTime > System.currentTimeMillis()) {
          c.getPlayer().giveCoolDowns(rs.getInt("SkillID"), startTime, length);
        }
      }
      rs.close();
      ps.close();
      ps = con.prepareStatement("DELETE FROM cooldowns WHERE charid = ?");
      ps.setInt(1, c.getPlayer().getId());
      ps.executeUpdate();
      ps.close();
      ps =
          con.prepareStatement(
              "SELECT Mesos FROM dueypackages WHERE RecieverId = ? and Checked = 1");
      ps.setInt(1, c.getPlayer().getId());
      rs = ps.executeQuery();
      if (rs.next()) {
        try {
          PreparedStatement pss =
              DatabaseConnection.getConnection()
                  .prepareStatement("UPDATE dueypackages SET Checked = 0 where RecieverId = ?");
          pss.setInt(1, c.getPlayer().getId());
          pss.executeUpdate();
          pss.close();
        } catch (SQLException e) {
        }
        c.getSession().write(MaplePacketCreator.sendDueyMSG((byte) 0x1B));
      }
      rs.close();
      ps.close();
      rs = null;
      ps = null;
    } catch (SQLException e) {
      e.printStackTrace();
    }
    c.getSession().write(MaplePacketCreator.getCharInfo(player));
    c.getPlayer().InitiateSaveEvent();
    if (player.isGM()) {
      SkillFactory.getSkill(GM.HIDE).getEffect(1).applyTo(player);
    }
    player.sendKeymap();
    player.sendMacros();
    player.getMap().addPlayer(player);
    try {
      int buddyIds[] = player.getBuddylist().getBuddyIds();
      cserv
          .getWorldInterface()
          .loggedOn(player.getName(), player.getId(), c.getChannel(), buddyIds);
      for (CharacterIdChannelPair onlineBuddy :
          cserv.getWorldInterface().multiBuddyFind(player.getId(), buddyIds)) {
        BuddylistEntry ble = player.getBuddylist().get(onlineBuddy.getCharacterId());
        ble.setChannel(onlineBuddy.getChannel());
        player.getBuddylist().put(ble);
      }
      c.getSession().write(MaplePacketCreator.updateBuddylist(player.getBuddylist().getBuddies()));
    } catch (RemoteException e) {
      cserv.reconnectWorld();
    }
    /*  c.getSession().write(MaplePacketCreator.loadFamily(player));
    if (player.getFamilyId() > 0) {
        c.getSession().write(MaplePacketCreator.getFamilyInfo(player));
    }*/
    if (player.getGuildId() > 0) {
      try {
        MapleGuild playerGuild =
            cserv.getWorldInterface().getGuild(player.getGuildId(), player.getMGC());
        if (playerGuild == null) {
          player.deleteGuild(player.getGuildId());
          player.resetMGC();
          player.setGuildId(0);
        } else {
          cserv.getWorldInterface().setGuildMemberOnline(player.getMGC(), true, c.getChannel());
          c.getSession().write(MaplePacketCreator.showGuildInfo(player));
          int allianceId = player.getGuild().getAllianceId();
          if (allianceId > 0) {
            MapleAlliance newAlliance = cserv.getWorldInterface().getAlliance(allianceId);
            if (newAlliance == null) {
              newAlliance = MapleAlliance.loadAlliance(allianceId);
              if (newAlliance != null) {
                cserv.getWorldInterface().addAlliance(allianceId, newAlliance);
              } else {
                player.getGuild().setAllianceId(0);
              }
            }
            if (newAlliance != null) {
              c.getSession().write(MaplePacketCreator.getAllianceInfo(newAlliance));
              c.getSession().write(MaplePacketCreator.getGuildAlliances(newAlliance, c));
              cserv
                  .getWorldInterface()
                  .allianceMessage(
                      allianceId,
                      MaplePacketCreator.allianceMemberOnline(player, true),
                      player.getId(),
                      -1);
            }
          }
        }
      } catch (RemoteException e) {
        cserv.reconnectWorld();
      }
    }
    try {
      //  c.getPlayer().showNote();
      if (player.getParty() != null) {
        cserv
            .getWorldInterface()
            .updateParty(
                player.getParty().getId(),
                PartyOperation.LOG_ONOFF,
                new MaplePartyCharacter(player));
      }
      player.updatePartyMemberHP();
    } catch (RemoteException e) {
      cserv.reconnectWorld();
    }
    for (MapleQuestStatus status : player.getStartedQuests()) {
      if (status.hasMobKills()) {
        c.getSession().write(MaplePacketCreator.updateQuestMobKills(status));
      }
    }
    CharacterNameAndId pendingBuddyRequest = player.getBuddylist().pollPendingRequest();
    if (pendingBuddyRequest != null) {
      player
          .getBuddylist()
          .put(
              new BuddylistEntry(
                  pendingBuddyRequest.getName(), "그룹 미지정", pendingBuddyRequest.getId(), -1, false));
      c.getSession()
          .write(
              MaplePacketCreator.requestBuddylistAdd(
                  pendingBuddyRequest.getId(),
                  c.getPlayer().getId(),
                  pendingBuddyRequest.getName(),
                  0,
                  0)); // todo: make actual levels / jobids appear
    }
    c.getSession().write(MaplePacketCreator.updateBuddylist(player.getBuddylist().getBuddies()));
    //    c.getSession().write(MaplePacketCreator.updateGender(player));
    player.checkMessenger();
    //  c.getSession().write(MaplePacketCreator.enableReport());
    /*     if (!player.isGM() && !player.hasWatchedCygnusIntro() && player.getLevel() > 19 && !player.isCygnus() && player.getCygnusLinkId() == 0) {
        player.startCygnusIntro();
        player.setWatchedCygnusIntro(true);
    }*/
    // unneeded in 83+ as cygnus is created at char select

    ISkill bof =
        SkillFactory.getSkill(
            10000000 * player.getJobType() + 12); // todo: find opcode and re-enable
    player.changeSkillLevel(bof, player.getLinkedLevel() / 10, bof.getMaxLevel());
    player.checkBerserk();
    player.expirationTask();
    player.setRates(false);
  }
  /**
   * 角色快照数据
   *
   * @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();
  }
예제 #10
0
 public void removeMember(MapleCharacter chr) {
   if (members.containsKey(chr.getName())) {
     members.remove(chr.getName());
   }
 }
예제 #11
0
 public void reAddMember(MapleCharacter chr) {
   removeMember(chr);
   members.put(chr.getName(), MapleCarnivalChallenge.getJobBasicNameById(chr.getJob()));
 }
예제 #12
0
 public boolean isBanned(MapleCharacter member) {
   return bannedMembers.containsKey(member.getName());
 }
예제 #13
0
파일: MaplePvp.java 프로젝트: kuzzie/src
  private static void monsterBomb(
      MapleCharacter player,
      MapleCharacter attackedPlayers,
      MapleMap map,
      AbstractDealDamageHandler.AttackInfo attack) {
    // level balances
    if (attackedPlayers.getLevel() > player.getLevel() + 25) {
      pvpDamage *= 1.35;
    } else if (attackedPlayers.getLevel() < player.getLevel() - 25) {
      pvpDamage /= 1.35;
    } else if (attackedPlayers.getLevel() > player.getLevel() + 100) {
      pvpDamage *= 1.50;
    } else if (attackedPlayers.getLevel() < player.getLevel() - 100) {
      pvpDamage /= 1.50;
    }
    // class balances
    if (player.getJob().equals(MapleJob.MAGICIAN)) {
      pvpDamage *= 1.20;
    }

    // buff modifiers
    Integer mguard = attackedPlayers.getBuffedValue(MapleBuffStat.MAGIC_GUARD);
    Integer mesoguard = attackedPlayers.getBuffedValue(MapleBuffStat.MESOGUARD);
    if (mguard != null) {
      int mploss = (int) (pvpDamage / .5);
      pvpDamage *= .70;
      if (mploss > attackedPlayers.getMp()) {
        pvpDamage /= .70;
        attackedPlayers.cancelBuffStats(MapleBuffStat.MAGIC_GUARD);
      } else {
        attackedPlayers.setMp(attackedPlayers.getMp() - mploss);
        attackedPlayers.updateSingleStat(MapleStat.MP, attackedPlayers.getMp());
      }
    } else if (mesoguard != null) {
      int mesoloss = (int) (pvpDamage * .75);
      pvpDamage *= .75;
      if (mesoloss > attackedPlayers.getMeso()) {
        pvpDamage /= .75;
        attackedPlayers.cancelBuffStats(MapleBuffStat.MESOGUARD);
      } else {
        attackedPlayers.gainMeso(-mesoloss, false);
      }
    }

    // set up us teh bonmb
    // training thingy = 9409000
    MapleMonster pvpMob = MapleLifeFactory.getMonster(9400711);
    map.spawnMonsterOnGroundBelow(pvpMob, attackedPlayers.getPosition());
    for (int attacks = 0; attacks < attack.numDamage; attacks++) {
      map.broadcastMessage(
          MaplePacketCreator.damagePlayer(
              attack.numDamage, pvpMob.getId(), attackedPlayers.getId(), pvpDamage));
      attackedPlayers.addHP(-pvpDamage);
    }
    int attackedDamage = pvpDamage * attack.numDamage;
    attackedPlayers
        .getClient()
        .getSession()
        .write(
            MaplePacketCreator.serverNotice(
                5, player.getName() + " has hit you for " + attackedDamage + " damage!"));
    map.killMonster(pvpMob, player, false);

    // rewards
    if (attackedPlayers.getHp() <= 0 && !attackedPlayers.isAlive()) {
      int expReward = attackedPlayers.getLevel() * 100;
      if (player.getPvpKills() * .25 >= player.getPvpDeaths()) {
        expReward *= 20;
      }
      player.gainExp(expReward, true, false);
      player.gainPvpKill();
      player
          .getClient()
          .getSession()
          .write(
              MaplePacketCreator.serverNotice(
                  6,
                  "You've killed " + attackedPlayers.getName() + "!! You've gained a pvp kill!"));
      attackedPlayers.gainPvpDeath();
      attackedPlayers
          .getClient()
          .getSession()
          .write(MaplePacketCreator.serverNotice(6, player.getName() + " has killed you!"));
      attackedPlayers.setHp(0);
      attackedPlayers.updateSingleStat(MapleStat.HP, 0);
    }
  }