Example #1
0
 public static final void processLunarSpell(Player player, int spellId, int packetId) {
   player.stopAll(false);
   switch (spellId) {
     case 37:
       if (player.getSkills().getLevel(Skills.MAGIC) < 94) {
         player
             .getPackets()
             .sendGameMessage("Your Magic level is not high enough for this spell.");
         return;
       } else if (player.getSkills().getLevel(Skills.DEFENCE) < 40) {
         player.getPackets().sendGameMessage("You need a Defence level of 40 for this spell");
         return;
       }
       Long lastVeng = (Long) player.getTemporaryAttributtes().get("LAST_VENG");
       if (lastVeng != null && lastVeng + 30000 > Utils.currentTimeMillis()) {
         player
             .getPackets()
             .sendGameMessage("Players may only cast vengeance once every 30 seconds.");
         return;
       }
       if (!checkRunes(player, true, ASTRAL_RUNE, 4, DEATH_RUNE, 2, EARTH_RUNE, 10)) return;
       player.setNextGraphics(new Graphics(726, 0, 100));
       player.setNextAnimation(new Animation(4410));
       player.setCastVeng(true);
       player.getTemporaryAttributtes().put("LAST_VENG", Utils.currentTimeMillis());
       player.getPackets().sendGameMessage("You cast a vengeance.");
       break;
     case 39:
       useHomeTele(player);
       break;
   }
 }
Example #2
0
 public void replayMusic() {
   if (playListOn && playList.size() > 0) {
     if (shuffleOn) playingMusic = playList.get(Utils.getRandom(playList.size() - 1));
     else {
       if (nextPlayListMusic >= playList.size()) nextPlayListMusic = 0;
       playingMusic = playList.get(nextPlayListMusic++);
     }
   } else if (unlockedMusics.size() > 0) // random music
   playingMusic = unlockedMusics.get(Utils.getRandom(unlockedMusics.size() - 1));
   playMusic(playingMusic);
 }
Example #3
0
 public static final boolean checkRunes(Player player, boolean delete, int... runes) {
   int weaponId = player.getEquipment().getWeaponId();
   int shieldId = player.getEquipment().getShieldId();
   int runesCount = 0;
   while (runesCount < runes.length) {
     int runeId = runes[runesCount++];
     int ammount = runes[runesCount++];
     if (hasInfiniteRunes(runeId, weaponId, shieldId)) continue;
     if (hasStaffOfLight(weaponId)
         && Utils.getRandom(8) == 0
         && runeId != 21773) // 1 in eight chance of keeping runes
     continue;
     if (!player.getInventory().containsItem(runeId, ammount)) {
       player
           .getPackets()
           .sendGameMessage(
               "You do not have enough "
                   + ItemDefinitions.getItemDefinitions(runeId).getName().replace("rune", "Rune")
                   + "s to cast this spell.");
       return false;
     }
   }
   if (delete) {
     runesCount = 0;
     while (runesCount < runes.length) {
       int runeId = runes[runesCount++];
       int ammount = runes[runesCount++];
       if (hasInfiniteRunes(runeId, weaponId, shieldId)) continue;
       player.getInventory().deleteItem(runeId, ammount);
     }
   }
   return true;
 }
Example #4
0
 public void playMusic(int musicId) {
   if (!player.hasStarted()) return;
   playingMusicDelay = Utils.currentTimeMillis();
   if (musicId == -2) {
     playingMusic = musicId;
     player.getPackets().sendMusic(-1);
     player.getPackets().sendIComponentText(187, 4, "");
     return;
   }
   player.getPackets().sendMusic(musicId, playingMusic == -1 ? 0 : 100, 255);
   playingMusic = musicId;
   int musicIndex = (int) ClientScriptMap.getMap(1351).getKeyForValue(musicId);
   if (musicIndex != -1) {
     String musicName = ClientScriptMap.getMap(1345).getStringValue(musicIndex);
     if (musicName.equals(" ")) musicName = Region.getMusicName1(player.getRegionId());
     player.getPackets().sendIComponentText(187, 4, musicName != null ? musicName : "");
     if (!unlockedMusics.contains(musicId)) {
       addMusic(musicId);
       if (musicName != null)
         player
             .getPackets()
             .sendGameMessage(
                 "<col=ff0000>You have unlocked a new music track: " + musicName + ".");
     }
   }
 }
Example #5
0
 public static void main(String[] args) throws IOException {
   Cache.init();
   for (int id = 0; id < Utils.getNPCDefinitionsSize(); id++) {
     NPCDefinitions def = NPCDefinitions.getNPCDefinitions(id);
     if (def.name.contains("Elemental")) {
       System.out.println(id + " - " + def.name);
     }
   }
 }
 @Override
 public int attack(QueenBlackDragon npc, Player victim) {
   for (Iterator<TorturedSoul> it = npc.getSouls().iterator(); it.hasNext(); ) {
     if (it.next().isDead()) {
       it.remove();
     }
   }
   npc.getTemporaryAttributtes().put("_last_soul_summon", npc.getTicks() + Utils.random(41, 100));
   int count = npc.getPhase() - 1;
   if (count == 3) {
     count = 4;
   }
   if (npc.getSouls().size() < count) {
     victim
         .getPackets()
         .sendGameMessage(
             (count - npc.getSouls().size()) < 2
                 ? "<col=9900CC>The Queen Black Dragon summons one of her captive, tortured souls.</col>"
                 : "<col=9900CC>The Queen Black Dragon summons several of her captive, tortured souls.</col>");
     for (int i = npc.getSouls().size(); i < count; i++) {
       npc.getSouls()
           .add(
               new TorturedSoul(
                   npc,
                   victim,
                   npc.getBase().transform(SPAWN_LOCATIONS[i][0], SPAWN_LOCATIONS[i][1], 0)));
     }
   }
   for (int i = 0; i < count; i++) {
     if (i >= npc.getSouls().size()) {
       break;
     }
     TorturedSoul s = npc.getSouls().get(i);
     if (s == null || s.isDead()) {
       continue;
     }
     s.specialAttack(npc.getBase().transform(SPAWN_LOCATIONS[i][0], SPAWN_LOCATIONS[i][1], 0));
   }
   return Utils.random(4, 15);
 }
 public static final void main(String[] args) throws IOException {
   System.out.println("Starting..");
   Cache.init();
   for (int itemId = 113; itemId < Utils.getItemDefinitionsSize(); itemId++) {
     if (!ItemDefinitions.getItemDefinitions(itemId).isNoted())
       if (dumpItem(itemId)) System.out.println("DUMPED ITEM : " + itemId);
       else
         System.out.println(
             "FAILED ITEM: "
                 + itemId
                 + ", "
                 + ItemDefinitions.getItemDefinitions(itemId).getName());
   }
 }
Example #8
0
  public static final boolean sendTeleportSpell(
      final Player player,
      int upEmoteId,
      final int downEmoteId,
      int upGraphicId,
      final int downGraphicId,
      int level,
      final double xp,
      final WorldTile tile,
      int delay,
      final boolean randomize,
      final int teleType,
      int... runes) {
    long currentTime = Utils.currentTimeMillis();
    if (player.getLockDelay() > currentTime) return false;
    if (player.getSkills().getLevel(Skills.MAGIC) < level) {
      player.getPackets().sendGameMessage("Your Magic level is not high enough for this spell.");
      return false;
    }
    if (!checkRunes(player, false, runes)) return false;
    if (teleType == MAGIC_TELEPORT) {
      if (!player.getControlerManager().processMagicTeleport(tile)) return false;
    } else if (teleType == ITEM_TELEPORT) {
      if (!player.getControlerManager().processItemTeleport(tile)) return false;
    } else if (teleType == OBJECT_TELEPORT) {
      if (!player.getControlerManager().processObjectTeleport(tile)) return false;
    }
    checkRunes(player, true, runes);
    player.stopAll();
    if (upEmoteId != -1) player.setNextAnimation(new Animation(upEmoteId));
    if (upGraphicId != -1) player.setNextGraphics(new Graphics(upGraphicId));
    if (teleType == MAGIC_TELEPORT) player.getPackets().sendSound(5527, 0, 2);
    player.lock(3 + delay);
    WorldTasksManager.schedule(
        new WorldTask() {

          boolean removeDamage;

          @Override
          public void run() {
            if (!removeDamage) {
              WorldTile teleTile = tile;
              if (randomize) {
                // attemps to randomize tile by 4x4 area
                for (int trycount = 0; trycount < 10; trycount++) {
                  teleTile = new WorldTile(tile, 2);
                  if (World.canMoveNPC(
                      tile.getPlane(), teleTile.getX(), teleTile.getY(), player.getSize())) break;
                  teleTile = tile;
                }
              }
              player.setNextWorldTile(teleTile);
              player.getControlerManager().magicTeleported(teleType);
              if (player.getControlerManager().getControler() == null)
                teleControlersCheck(player, teleTile);
              if (xp != 0) player.getSkills().addXp(Skills.MAGIC, xp);
              if (downEmoteId != -1)
                player.setNextAnimation(new Animation(downEmoteId == -2 ? -1 : downEmoteId));
              if (downGraphicId != -1) player.setNextGraphics(new Graphics(downGraphicId));
              if (teleType == MAGIC_TELEPORT) {
                player.getPackets().sendSound(5524, 0, 2);
                player.setNextFaceWorldTile(
                    new WorldTile(teleTile.getX(), teleTile.getY() - 1, teleTile.getPlane()));
                player.setDirection(6);
              }
              removeDamage = true;
            } else {
              player.resetReceivedDamage();
              stop();
            }
          }
        },
        delay,
        0);
    return true;
  }
Example #9
0
 public void checkMusic(int requestMusicId) {
   if (playListOn || settedMusic && playingMusicDelay + (180000) >= Utils.currentTimeMillis())
     return;
   settedMusic = false;
   if (playingMusic != requestMusicId) playMusic(requestMusicId);
 }
Example #10
0
 public boolean musicEnded() {
   return playingMusic != -2 && playingMusicDelay + (180000) < Utils.currentTimeMillis();
 }