示例#1
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);
    }
  }
  /**
   * 可以创建定时技能
   *
   * @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()));
        }
      }
    }
  }
 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);
   }
 }