/** Slayer monster picking which is gonna be slayed by the player. */
 public void appendTargetPicking() {
   if (p == null) {
     return;
   }
   if (!p.slayerTask) {
     for (int i = 0; i < p.slayerArray.length; i++) {
       p.slayerAmount = getRandom(p.slayerArray[i]);
     }
     setSlayerAmount(p.slayerAmount);
     setSlayerTask(true);
     p.getActionSender().sendMessage(p, "Your current slayer task has been updated.");
     p.getActionSender()
         .sendMessage(
             p,
             "Your task is to kill "
                 + p.slayerAmount
                 + " "
                 + Server.engine.getNPCName(getRandomSlayer())
                 + ".");
     // setSlayerType(p.slayerType);
   } else {
     p.getActionSender().sendMessage(p, "You currently already have a slayer task.");
     p.getActionSender().sendMessage(p, "Please finish your slayer task.");
   }
 }
예제 #2
0
 public void refresh() {
   player.getActionSender().sendConfig(300, amount);
   if (active) {
     player.getActionSender().sendConfig(301, 1);
   } else {
     player.getActionSender().sendConfig(301, 0);
   }
 }
예제 #3
0
  public void updatePosition() {
    long now = GameEngine.getAccurateTimestamp();
    Player victim = findVictim();

    if (!isBusy() && def.isAggressive() && now - getCombatTimer() > 3000 && victim != null) {
      resetPath();

      victim.resetPath();
      victim.resetAll();
      victim.setStatus(Action.FIGHTING_MOB);
      victim.getActionSender().sendSound("underattack");
      victim.getActionSender().sendMessage("You are under attack!");

      if (victim.isSleeping()) {
        victim.getActionSender().sendWakeUp(false, false);
        victim.getActionSender().sendFatigue(victim.getFatigue());
      }

      this.setLocation(victim.getLocation(), true);

      for (Player p : getViewArea().getPlayersInView()) {
        p.removeWatchedNpc(this);
      }

      victim.setBusy(true);
      victim.setSprite(9);
      victim.setOpponent(this);
      victim.setCombatTimer();

      setBusy(true);
      setSprite(8);
      setOpponent(victim);
      setCombatTimer();
      FightEvent fighting = new FightEvent(victim, this, true);
      fighting.setLastRun(0);
      World.getWorld().getDelayedEventHandler().add(fighting);
    }

    if (now - lastMovement > 2200) {
      lastMovement = now;
      int rand = DataConversions.random(0, 1);
      if (!isBusy() && finishedPath() && rand == 1 && !isRemoved()) {
        int newX = DataConversions.random(loc.minX(), loc.maxX());
        int newY = DataConversions.random(loc.minY(), loc.maxY());
        setPath(new Path(getX(), getY(), newX, newY));
      }
    }

    super.updatePosition();
  }
예제 #4
0
 private void useStatRestorePotion(
     Player player, final InvItem item, final int newItem, final int left) {
   player.setBusy(true);
   player.getActionSender().sendMessage("You drink some of your " + item.getDef().getName() + ".");
   world
       .getDelayedEventHandler()
       .add(
           new MiniEvent(player) {
             public void action() {
               owner.getActionSender().sendMessage("You have " + left + " doses left.");
               for (int i = 0; i < 18; i++) {
                 if (i == 3 || i == 5) {
                   continue;
                 }
                 int max = owner.getMaxStat(i);
                 if (owner.getCurStat(i) < max) {
                   owner.setCurStat(i, max);
                   owner.getActionSender().sendStat(i);
                 }
               }
               owner.getInventory().remove(item);
               owner.getInventory().add(new InvItem(newItem));
               owner.getActionSender().sendInventory();
               owner.setBusy(false);
             }
           });
 }
예제 #5
0
 public void cleanUp() {
   for (FloorItem floors : items) {
     for (Player p : World.getInstance().getPlayerList()) {
       p.getActionSender().sendDestroyGroundItem(floors);
     }
   }
   items.clear();
 }
예제 #6
0
 public void refresh(Player p) {
   for (FloorItem f : items) {
     if (p.getLocation().withinDistance(f.getLocation())
         && !f.isDestroyed()
         && (p == f.getPlayer() || f.getPlayer() == null)) {
       p.getActionSender().sendCreateGroundItem(f);
     }
   }
 }
예제 #7
0
 public void appendAffect(int spellbook, int spell) {
   try {
     if (!p.successfulCast) {
       return;
     }
     Player opp = Server.engine.players[p.magicOppIndex];
     if ((!opp.wildernessZone(opp.absX, opp.absY)) || (!p.wildernessZone(p.absX, p.absY))) {
       p.getActionSender().sendMessage(p, "You cannot attack players outside of the wilderness.");
       return;
     }
     if (p.InBounty == 0) {
       if (!p.properWildernessLevel(p.combatLevel, opp.combatLevel)
           || !opp.properWildernessLevel(opp.combatLevel, p.combatLevel)) {
         p.getActionSender().sendMessage(p, "Your combat difference is too great!");
         return;
       }
     }
     if (p.InBounty == 1) {
       if (opp.playerId != p.bhTarget && (p.playerId != opp.bhTarget)) {
         if (!opp.multiwayCombatZone(opp.absX, opp.absY)) {
           if (opp.attackedBy != null && (opp.attacking != null) && opp.attackedBy != p.username) {
             p.getActionSender().sendMessage(p, "This player is already in combat.");
             Engine.playerMovement.resetWalkingQueue(p);
             p.resetAttack();
             return;
           }
           if (opp.username != p.attackedBy && p.attackedBy != null) {
             p.getActionSender().sendMessage(p, "You are already in combat.");
             Engine.playerMovement.resetWalkingQueue(p);
             p.resetAttack();
             return;
           }
         }
       }
     }
     if (p.InBounty == 0) {
       if (!opp.multiwayCombatZone(opp.absX, opp.absY)) {
         if (opp.attackedBy != null
             && (opp.attacking != null || opp.attackedByCount >= 1)
             && opp.attackedBy != p.username) {
           p.getActionSender().sendMessage(p, "This player is already in combat.");
           Engine.playerMovement.resetWalkingQueue(p);
           p.resetAttack();
           return;
         }
         if (opp.username != p.attackedBy && p.attackedBy != null) {
           p.getActionSender().sendMessage(p, "You are already in combat.");
           Engine.playerMovement.resetWalkingQueue(p);
           p.resetAttack();
           return;
         }
       }
     }
     // }t
     opp.hitIndex = p.playerId;
     normalSpellAffect(opp);
   } catch (Exception e) {
     return;
   }
 }
예제 #8
0
 /**
  * Refreshes a floor item.
  *
  * @param floor
  */
 private void refresh(FloorItem floor) {
   if (floor.getDroppedAt() >= 60000 * 2) {
     for (Player p : World.getInstance().getPlayerList()) {
       p.getActionSender().sendDestroyGroundItem(floor);
     }
   }
   if (floor.isDestroyed()) {
     if (floor.getPlayer() == null) {
       for (Player p : World.getInstance().getPlayerList()) {
         if (p.getLocation().withinDistance(floor.getLocation())) {
           p.getActionSender().sendDestroyGroundItem(floor);
         }
       }
     } else {
       if (floor.getPlayer().isDisconnected()) {
         floor.setPlayer(null);
       } else {
         if (floor.getPlayer().getLocation().withinDistance(floor.getLocation())) {
           floor.getPlayer().getActionSender().sendDestroyGroundItem(floor);
         }
       }
     }
     return;
   }
   if (floor.getPlayer() == null) {
     for (Player p : World.getInstance().getPlayerList()) {
       if (p.getLocation().withinDistance(floor.getLocation())) {
         p.getActionSender().sendCreateGroundItem(floor);
       }
     }
   } else {
     if (floor.getPlayer().isDisconnected()) {
       floor.setPlayer(null);
     } else {
       if (floor.getPlayer().getLocation().withinDistance(floor.getLocation())) {
         floor.getPlayer().getActionSender().sendCreateGroundItem(floor);
       }
     }
   }
 }
예제 #9
0
  public void projectile(Player opp, int projectile) {
    if (graphic == 0) {
      return;
    }

    int casterX = p.absX;
    int casterY = p.absY;
    int offsetX = (p.absX - opp.absX) * -1;
    int offsetY = (p.absY - opp.absY) * -1;
    p.getActionSender()
        .timedSlopedProjectile(
            p, casterY, casterX, offsetY, offsetX, 50, 90, projectile, 46, 31, opp.playerId, 8, 70);
  }
예제 #10
0
 public void normalSpellAffect(Player opp) {
   if (!p.successfulCast) {
     return;
   }
   switch (p.spell) {
     case 56:
       if (!(opp.freezeDelay > 0)) {
         opp.freezeDelay = 15;
         Engine.playerMovement.resetWalkingQueue(opp);
       }
       break;
     case 63:
       opp.teleblocked = true;
       p.getActionSender().sendMessage(p, "You have teleport blocked your opponent.");
       break;
   }
 }
예제 #11
0
 private void useFishingPotion(
     Player player, final InvItem item, final int newItem, final int left) {
   player.setBusy(true);
   player.getActionSender().sendMessage("You drink some of your " + item.getDef().getName() + ".");
   world
       .getDelayedEventHandler()
       .add(
           new MiniEvent(player) {
             public void action() {
               owner.getActionSender().sendMessage("You have " + left + " doses left.");
               owner.setCurStat(10, owner.getMaxStat(10) + 3);
               owner.getInventory().remove(item);
               owner.getInventory().add(new InvItem(newItem));
               owner.getActionSender().sendStat(10);
               owner.getActionSender().sendInventory();
               owner.setBusy(false);
             }
           });
 }
예제 #12
0
 private void useNormalPotion(
     Player player,
     final InvItem item,
     final int affectedStat,
     final int percentageIncrease,
     final int modifier,
     final int newItem,
     final int left) {
   player.setBusy(true);
   player.getActionSender().sendMessage("You drink some of your " + item.getDef().getName() + ".");
   world
       .getDelayedEventHandler()
       .add(
           new MiniEvent(player) {
             public void action() {
               owner.getActionSender().sendMessage("You have " + left + " doses left.");
               int baseStat =
                   owner.getCurStat(affectedStat) > owner.getMaxStat(affectedStat)
                       ? owner.getMaxStat(affectedStat)
                       : owner.getCurStat(affectedStat);
               int newStat =
                   baseStat
                       + DataConversions.roundUp(
                           (owner.getMaxStat(affectedStat) / 100D) * percentageIncrease)
                       + modifier;
               if (newStat > owner.getCurStat(affectedStat)) {
                 owner.setCurStat(affectedStat, newStat);
                 owner.getActionSender().sendStat(affectedStat);
               }
               owner.getInventory().remove(item);
               owner.getInventory().add(new InvItem(newItem));
               owner.getActionSender().sendInventory();
               owner.setBusy(false);
             }
           });
 }
예제 #13
0
  public void handlePacket(Packet p, IoSession session) throws Exception {
    Player player = (Player) session.getAttachment();
    if (player.isBusy()) {
      if (player.inCombat()) {
        player.getActionSender().sendMessage("You cannot do that whilst fighting!");
      }
      return;
    }
    player.resetAll();
    int idx = (int) p.readShort();
    if (idx < 0 || idx >= player.getInventory().size()) {
      player.setSuspiciousPlayer(true);
      return;
    }
    final InvItem item = player.getInventory().get(idx);
    if (item == null || item.getDef().getCommand().equals("")) {
      player.setSuspiciousPlayer(true);
      return;
    }
    if (item.isEdible()) {
      player.setBusy(true);
      player.getActionSender().sendSound("eat");
      player.getActionSender().sendMessage("You eat the " + item.getDef().getName() + ".");
      final boolean heals = player.getCurStat(3) < player.getMaxStat(3);
      if (heals) {
        int newHp = player.getCurStat(3) + item.eatingHeals();
        if (newHp > player.getMaxStat(3)) {
          newHp = player.getMaxStat(3);
        }
        player.setCurStat(3, newHp);
        player.getActionSender().sendStat(3);
      }
      world
          .getDelayedEventHandler()
          .add(
              new SingleEvent(player, 200) {
                public void action() {
                  if (heals) {
                    owner.getActionSender().sendMessage("It heals some health.");
                  }
                  owner.getInventory().remove(item);
                  switch (item.getID()) {
                    case 326: // Meat pizza
                      owner.getInventory().add(new InvItem(328));
                      break;
                    case 327: // Anchovie pizza
                      owner.getInventory().add(new InvItem(329));
                      break;
                    case 330: // Cake
                      owner.getInventory().add(new InvItem(333));
                      break;
                    case 333: // Partical cake
                      owner.getInventory().add(new InvItem(335));
                      break;
                    case 332: // Choc cake
                      owner.getInventory().add(new InvItem(334));
                      break;
                    case 334: // Partical choc cake
                      owner.getInventory().add(new InvItem(336));
                      break;
                    case 257: // Apple pie
                      owner.getInventory().add(new InvItem(263));
                      break;
                    case 261: // Half apple pie
                      owner.getInventory().add(new InvItem(251));
                      break;
                    case 258: // Redberry pie
                      owner.getInventory().add(new InvItem(262));
                      break;
                    case 262: // Half redberry pie
                      owner.getInventory().add(new InvItem(251));
                      break;
                    case 259: // Meat pie
                      owner.getInventory().add(new InvItem(261));
                      break;
                    case 263: // Half meat pie
                      owner.getInventory().add(new InvItem(251));
                      break;
                  }
                  owner.getActionSender().sendInventory();
                  owner.setBusy(false);
                }
              });
    } else if (item.getDef().getCommand().equalsIgnoreCase("bury")) {
      player.setBusy(true);
      player.getActionSender().sendMessage("You dig a hole in the ground.");
      world
          .getDelayedEventHandler()
          .add(
              new MiniEvent(player) {
                public void action() {
                  owner
                      .getActionSender()
                      .sendMessage("You bury the " + item.getDef().getName() + ".");
                  owner.getInventory().remove(item);
                  switch (item.getID()) {
                    case 20: // Bones
                    case 604: // Bat bones
                      owner.incExp(5, 8 * 10, true);
                      break;
                    case 413: // Big bones
                      owner.incExp(5, 24 * 10, true);
                      break;
                    case 814: // Dragon bones
                      owner.incExp(5, 90 * 10, true);
                      break;
                  }
                  owner.getActionSender().sendStat(5);
                  owner.getActionSender().sendInventory();
                  owner.setBusy(false);
                }
              });
    } else if (item.getDef().getCommand().equalsIgnoreCase("clean")) {
      if (!player.getQuestManager().completed("Druidic Ritual")) {
        player
            .getActionSender()
            .sendMessage(
                "You can not use Herblaw until you have completed the Druidic Ritual quest.");
        return;
      }
      ItemUnIdentHerbDef herb = item.getUnIdentHerbDef();
      if (herb == null) {
        return;
      }
      if (player.getMaxStat(15) < herb.getLevelRequired()) {
        player
            .getActionSender()
            .sendMessage("Your herblaw ability is not high enough to clean this herb.");
        return;
      }
      player.setBusy(true);
      world
          .getDelayedEventHandler()
          .add(
              new MiniEvent(player) {
                public void action() {
                  ItemUnIdentHerbDef herb = item.getUnIdentHerbDef();
                  InvItem newItem = new InvItem(herb.getNewId());
                  owner.getInventory().remove(item);
                  owner.getInventory().add(newItem);
                  owner
                      .getActionSender()
                      .sendMessage("You clean the mud off the " + newItem.getDef().getName() + ".");
                  owner.incExp(15, herb.getExp() * 10, true);
                  owner.getActionSender().sendStat(15);
                  owner.getActionSender().sendInventory();
                  owner.setBusy(false);
                }
              });
    } else if (item.getDef().getCommand().equalsIgnoreCase("drink")) {
      switch (item.getID()) {
        case 739: // Tea
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("It's nice and refreshing.");
                      owner.getInventory().remove(item);
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 193: // Beer
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 142: // Wine
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 8);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(140));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 246: // Half Jug of Wine
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 1);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(140));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 180: // Bad Wine
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("Yuck! Your head starts to hurt.");
                      owner.setCurStat(0, owner.getCurStat(0) - 8);
                      owner.getActionSender().sendStat(0);
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(140));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 830: // Greenmans Ale
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("It has a strange taste.");
                      for (int stat = 0; stat < 3; stat++) {
                        owner.setCurStat(stat, owner.getCurStat(stat) - 4);
                        owner.getActionSender().sendStat(stat);
                      }
                      if (owner.getCurStat(15) <= owner.getMaxStat(15)) {
                        owner.setCurStat(15, owner.getCurStat(15) + 1);
                        owner.getActionSender().sendStat(15);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 268: // Mind Bomb
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel very strange.");
                      for (int stat = 0; stat < 3; stat++) {
                        owner.setCurStat(stat, owner.getCurStat(stat) - 4);
                        owner.getActionSender().sendStat(stat);
                      }
                      if (owner.getCurStat(6) <= owner.getMaxStat(6)) {
                        owner.setCurStat(6, owner.getCurStat(6) + 2);
                        owner.getActionSender().sendStat(6);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 269: // Dwarven Stout
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("It tastes foul.");
                      for (int stat = 0; stat < 3; stat++) {
                        owner.setCurStat(stat, owner.getCurStat(stat) - 4);
                        owner.getActionSender().sendStat(stat);
                      }
                      if (owner.getCurStat(13) <= owner.getMaxStat(13)) {
                        owner.setCurStat(13, owner.getCurStat(13) + 1);
                        owner.getActionSender().sendStat(13);
                      }
                      if (owner.getCurStat(14) <= owner.getMaxStat(14)) {
                        owner.setCurStat(14, owner.getCurStat(14) + 1);
                        owner.getActionSender().sendStat(14);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 267: // Asgarnian Ale
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly reinvigorated");
                      owner.getActionSender().sendMessage("And slightly dizzy too.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
        case 829: // Dragon Bitter
          player.setBusy(true);
          player.getActionSender().sendMessage("You drink the " + item.getDef().getName() + ".");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.getActionSender().sendMessage("You feel slightly dizzy.");
                      owner.setCurStat(0, owner.getCurStat(0) - 4);
                      owner.getActionSender().sendStat(0);
                      if (owner.getCurStat(2) <= owner.getMaxStat(2)) {
                        owner.setCurStat(2, owner.getCurStat(2) + 2);
                        owner.getActionSender().sendStat(2);
                      }
                      owner.getInventory().remove(item);
                      owner.getInventory().add(new InvItem(620));
                      owner.getActionSender().sendInventory();
                      owner.setBusy(false);
                    }
                  });
          showBubble(player, item);
          break;
          /** HANDLE WINE+ CURE POISON AND ANTIDOTE AND ZAMAROCK POTIONS * */
        case 221: // Strength Potion - 4 dose
          useNormalPotion(player, item, 2, 10, 2, 222, 3);
          break;
        case 222: // Strength Potion - 3 dose
          useNormalPotion(player, item, 2, 10, 2, 223, 2);
          break;
        case 223: // Strength Potion - 2 dose
          useNormalPotion(player, item, 2, 10, 2, 224, 1);
          break;
        case 224: // Strength Potion - 1 dose
          useNormalPotion(player, item, 2, 10, 2, 465, 0);
          break;
        case 474: // attack Potion - 3 dose
          useNormalPotion(player, item, 0, 10, 2, 475, 2);
          break;
        case 475: // attack Potion - 2 dose
          useNormalPotion(player, item, 0, 10, 2, 476, 1);
          break;
        case 476: // attack Potion - 1 dose
          useNormalPotion(player, item, 0, 10, 2, 465, 0);
          break;
        case 477: // stat restoration Potion - 3 dose
          useStatRestorePotion(player, item, 478, 2);
          break;
        case 478: // stat restoration Potion - 2 dose
          useStatRestorePotion(player, item, 479, 1);
          break;
        case 479: // stat restoration Potion - 1 dose
          useStatRestorePotion(player, item, 465, 0);
          break;
        case 480: // defense Potion - 3 dose
          useNormalPotion(player, item, 1, 10, 2, 481, 2);
          break;
        case 481: // defense Potion - 2 dose
          useNormalPotion(player, item, 1, 10, 2, 482, 1);
          break;
        case 482: // defense Potion - 1 dose
          useNormalPotion(player, item, 1, 10, 2, 465, 0);
          break;
        case 483: // restore prayer Potion - 3 dose
          usePrayerPotion(player, item, 484, 2);
          break;
        case 484: // restore prayer Potion - 2 dose
          usePrayerPotion(player, item, 485, 1);
          break;
        case 485: // restore prayer Potion - 1 dose
          usePrayerPotion(player, item, 465, 0);
          break;
        case 486: // Super attack Potion - 3 dose
          useNormalPotion(player, item, 0, 15, 4, 487, 2);
          break;
        case 487: // Super attack Potion - 2 dose
          useNormalPotion(player, item, 0, 15, 4, 488, 1);
          break;
        case 488: // Super attack Potion - 1 dose
          useNormalPotion(player, item, 0, 15, 4, 465, 0);
          break;
        case 489: // fishing Potion - 3 dose
          useFishingPotion(player, item, 490, 2);
          break;
        case 490: // fishing Potion - 2 dose
          useFishingPotion(player, item, 491, 1);
          break;
        case 491: // fishing Potion - 1 dose
          useFishingPotion(player, item, 465, 0);
          break;
        case 492: // Super strength Potion - 3 dose
          useNormalPotion(player, item, 2, 15, 4, 493, 2);
          break;
        case 493: // Super strength Potion - 2 dose
          useNormalPotion(player, item, 2, 15, 4, 494, 1);
          break;
        case 494: // Super strength Potion - 1 dose
          useNormalPotion(player, item, 2, 15, 4, 465, 0);
          break;
        case 495: // Super defense Potion - 3 dose
          useNormalPotion(player, item, 1, 15, 4, 496, 2);
          break;
        case 496: // Super defense Potion - 2 dose
          useNormalPotion(player, item, 1, 15, 4, 497, 1);
          break;
        case 497: // Super defense Potion - 1 dose
          useNormalPotion(player, item, 1, 15, 4, 465, 0);
          break;
        case 498: // ranging Potion - 3 dose
          useNormalPotion(player, item, 4, 10, 2, 499, 2);
          break;
        case 499: // ranging Potion - 2 dose
          useNormalPotion(player, item, 4, 10, 2, 500, 1);
          break;
        case 500: // ranging Potion - 1 dose
          useNormalPotion(player, item, 4, 10, 2, 465, 0);
          break;
        default:
          player.getActionSender().sendMessage("Nothing interesting happens.");
          return;
      }
    } else {
      switch (item.getID()) {
        case 597: // Charged Dragonstone amulet
          player.getActionSender().sendMessage("You rub the amulet...");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      String[] options =
                          new String[] {
                            "Edgeville",
                            "Karamja",
                            "Draynor Village",
                            "Al Kharid",
                            "Mage Arena",
                            "Seers",
                            "Yanille"
                          };
                      owner.setMenuHandler(
                          new MenuHandler(options) {
                            public void handleReply(final int option, final String reply) {
                              if (owner.isBusy() || owner.getInventory().get(item) == null) {
                                return;
                              }
                              if (owner.getLocation().wildernessLevel() >= 30
                                  || (owner.getLocation().inModRoom() && !owner.isMod())
                                  || (owner.getLocation().inJail() && !owner.isMod())) {
                                owner
                                    .getActionSender()
                                    .sendMessage("A magical force stops you from teleporting.");
                                return;
                              }
                              owner.getActionSender().sendSound("spellok");
                              switch (option) {
                                case 0: // Edgeville
                                  owner.teleport(193, 435, true);
                                  break;
                                case 1: // Karamja
                                  owner.teleport(360, 696, true);
                                  break;
                                case 2: // Draynor Village
                                  owner.teleport(214, 632, true);
                                  break;
                                case 3: // Al Kharid
                                  owner.teleport(72, 696, true);
                                  break;
                                case 4: // Mage Arena
                                  owner.teleport(447, 3371, true);
                                  break;
                                case 5: // Seers
                                  owner.teleport(516, 460, true);
                                  break;
                                case 6: // Yanille
                                  owner.teleport(587, 761, true);
                                  break;
                                default:
                                  return;
                              }
                              if (DataConversions.random(0, 5) == 1
                                  && owner.getInventory().remove(item) > -1) {
                                owner.getInventory().add(new InvItem(522, 1));
                                owner.getActionSender().sendInventory();
                              }
                            }
                          });
                      owner.getActionSender().sendMenu(options);
                    }
                  });
          break;
        case 387: // Disk of Returning
          if (player.getLocation().wildernessLevel() >= 30
              || (player.getLocation().inModRoom() && !player.isMod())) {
            player.getActionSender().sendMessage("The disk doesn't seem to work here.");
            return;
          }
          player.getActionSender().sendMessage("The disk starts to spin...");
          world
              .getDelayedEventHandler()
              .add(
                  new MiniEvent(player) {
                    public void action() {
                      owner.resetPath();
                      owner.teleport(219, 455, true);
                      owner.getInventory().remove(item);
                      owner
                          .getActionSender()
                          .sendMessage("You find yourself back in Varrock with a sore bottom.");
                      owner.getActionSender().sendMessage("The disk has now gone");
                      owner.getActionSender().sendInventory();
                    }
                  });
          break;
        case 1263: // Sleeping Bag
          player.resetPath();
          player.getActionSender().sendMessage("You rest in the Sleeping Bag.");
          switch (rand(0, 10)) {
            case 0:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Quarter", "Quadah", "Korter", "Twenyfavcent", "Nubface"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 0) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;

            case 1:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"N00b", "Newbie", "Noobletz", "Noobz", "Noobcakez"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 1) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 2:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Jaquet", "Jaket", "Jackit", "Brangelina", "Jacket"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 4) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 3:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Marwolf", "Mar", "Wolf", "Mar!11", "Halp"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 2) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 4:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Dawg", "Dawggie", "Homeslice", "Dog", "Snoop"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 3) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 5:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Gangstar", "Gangsta", "Gangster", "Sean Brooks", "Thug lyfe yo"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 2) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 6:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Like", "Lyk", "Liek", "I suck at this", "I give up"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 0) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 7:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Wrong Answer",
                                "Right Answer",
                                "Wrong Answer",
                                "Wrong Answer",
                                "Wrong Answer"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 1) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 8:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Charictor", "Charactor", "Charector", "Carhuh?", "Character"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 4) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;
            case 9:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {
                                "Hatianz", "Zombies", "Botnetz", "Tom Cruise!1", "Elephantz"
                              };
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 1) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();

                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });
              break;

            case 10:
              world
                  .getDelayedEventHandler()
                  .add(
                      new ShortEvent(player) {
                        public void action() {
                          String[] options =
                              new String[] {"Deposet", "Deposat", "Despot", "Rapidshit", "Deposit"};
                          owner.setMenuHandler(
                              new MenuHandler(options) {
                                public void handleReply(final int option, final String reply) {
                                  if (option == 4) {
                                    owner.setFatigue(0);
                                    owner.getActionSender().sendFatigue();
                                    owner
                                        .getActionSender()
                                        .sendMessage("You wake up - feeling refreshed");
                                  } else
                                    owner
                                        .getActionSender()
                                        .sendMessage("Wrong answer, please try again!");
                                }
                              });
                          owner.getActionSender().sendMenu(options);
                        }
                      });

              break;
          }
        default:
          player.getActionSender().sendMessage("Match the word with the correct spelling.");
          return;
      }
    }
  }
예제 #14
0
  @Override
  public void execute(GameEngine context) {
    /*
     * If the map region changed send the new one. We do this immediately as
     * the client can begin loading it before the actual packet is received.
     */
    if (player.isMapRegionChanging()) {
      player.getActionSender().sendMapRegion();
    }

    /*
     * The update block packet holds update blocks and is send after the
     * main packet.
     */
    final PacketBuilder updateBlock = new PacketBuilder();

    /*
     * The main packet is written in bits instead of bytes and holds
     * information about the local list, players to add and remove, movement
     * and which updates are required.
     */
    final PacketBuilder updatePacket = new PacketBuilder(216, Packet.Type.VARIABLE_SHORT);
    updatePacket.startBitAccess();

    /*
     * Updates this player.
     */
    updateThisPlayerMovement(updatePacket);
    updatePlayer(updateBlock, player, false);

    /*
     * Write the current size of the player list.
     */
    updatePacket.putBits(8, player.getLocalPlayers().size());

    /*
     * Iterate through the local player list.
     */
    for (final Iterator<Player> it$ = player.getLocalPlayers().iterator(); it$.hasNext(); ) {
      /*
       * Get the next player.
       */
      final Player otherPlayer = it$.next();

      /*
       * If the player should still be in our list.
       */
      if (World.getWorld().getPlayers().contains(otherPlayer)
          && !otherPlayer.isTeleporting()
          && otherPlayer.getLocation().isWithinDistance(player.getLocation(), 16)) {

        /*
         * Update the movement.
         */
        updatePlayerMovement(updatePacket, otherPlayer);

        /*
         * Check if an update is required, and if so, send the update.
         */
        if (otherPlayer.getUpdateFlags().isUpdateRequired()) {
          updatePlayer(updateBlock, otherPlayer, false);
        }
      } else {
        /*
         * Otherwise, remove the player from the list.
         */
        it$.remove();

        /*
         * Tell the client to remove the player from the list.
         */
        updatePacket.putBits(1, 1);
        updatePacket.putBits(2, 3);
      }
    }
    /*
     * Loop through every player.
     */
    for (final Player otherPlayer : World.getWorld().getRegionManager().getLocalPlayers(player)) {
      /*
       * Check if there is room left in the local list.
       */
      if (player.getLocalPlayers().size() >= 255) {
        /*
         * There is no more room left in the local list. We cannot add
         * more players, so we just ignore the extra ones. They will be
         * added as other players get removed.
         */
        break;
      }

      /*
       * If they should not be added ignore them.
       */
      if (otherPlayer == player || player.getLocalPlayers().contains(otherPlayer)) {
        continue;
      }

      /*
       * Add the player to the local list if it is within distance.
       */
      player.getLocalPlayers().add(otherPlayer);

      /*
       * Add the player in the packet.
       */
      addNewPlayer(updatePacket, otherPlayer);
      /*
       * Update the player, forcing the appearance flag.
       */
      updatePlayer(updateBlock, otherPlayer, true);
    }

    /*
     * Check if the update block is not empty.
     */
    if (!updateBlock.isEmpty()) {
      /*
       * Write a magic id indicating an update block follows.
       */
      updatePacket.putBits(11, 2047);
      updatePacket.finishBitAccess();
      /*
       * Add the update block at the end of this packet.
       */
      updatePacket.put(updateBlock.toPacket().getPayload());
    } else {
      /*
       * Terminate the packet normally.
       */
      updatePacket.finishBitAccess();
    }
    /*
     * Write the packet.
     */
    player.write(updatePacket.toPacket());
  }
예제 #15
0
  /**
   * Distributes the XP from this monster and the loot
   *
   * @param attacker the person that "finished off" the npc
   * @return the player who did the most damage / should get the loot
   */
  public Player handleLootAndXpDistribution(Player attacker) {
    Player toLoot = attacker;
    int mostDamageDone = 0;
    int exp = DataConversions.roundUp(Formulae.combatExperience(this) / 4D);

    for (long playerHash : getCombatDamagers()) {
      int newXP = 0;
      Player p = World.getWorld().getPlayer(playerHash);
      if (p == null) continue;
      int dmgDoneByPlayer = getCombatDamageDoneBy(p);

      if (dmgDoneByPlayer > mostDamageDone) {
        toLoot = p;
        mostDamageDone = dmgDoneByPlayer;
      }

      newXP = (exp * dmgDoneByPlayer) / this.getDef().hits;
      switch (p.getCombatStyle()) {
        case 0:
          for (int x = 0; x < 3; x++) {
            p.incExp(x, newXP, true, true, true);
            p.getActionSender().sendStat(x);
          }
          break;
        case 1:
          p.incExp(2, newXP * 3, true, true, true);
          p.getActionSender().sendStat(2);
          break;
        case 2:
          p.incExp(0, newXP * 3, true, true, true);
          p.getActionSender().sendStat(0);
          break;
        case 3:
          p.incExp(1, newXP * 3, true, true, true);
          p.getActionSender().sendStat(1);
          break;
      }
      p.incExp(3, newXP, true, true, true);
      p.getActionSender().sendStat(3);
    }
    for (long playerHash : getRangeDamagers()) {

      int newXP = 0;
      Player p = World.getWorld().getPlayer(playerHash);
      int dmgDoneByPlayer = getRangeDamageDoneBy(p);
      if (p == null) continue;

      if (dmgDoneByPlayer > mostDamageDone) {
        toLoot = p;
        mostDamageDone = dmgDoneByPlayer;
      }
      newXP = (exp * dmgDoneByPlayer) / this.getDef().hits;
      p.incExp(4, newXP * 4, true, true, true);
      p.getActionSender().sendStat(4);
    }
    for (long playerHash : getMageDamagers()) {

      Player p = World.getWorld().getPlayer(playerHash);

      int dmgDoneByPlayer = getMageDamageDoneBy(p);
      if (p == null) continue;

      if (dmgDoneByPlayer > mostDamageDone) {
        toLoot = p;
        mostDamageDone = dmgDoneByPlayer;
      }
    }
    return toLoot;
  }
예제 #16
0
  public void handlePacket(Packet p, IoSession session) throws Exception {
    Player player = (Player) session.getAttachment();
    int pID = ((RSCPacket) p).getID();
    Player affectedPlayer;

    if (busy(player)) {
      affectedPlayer = player.getWishToTrade();
      unsetOptions(player);
      unsetOptions(affectedPlayer);
      return;
    }
    switch (pID) {
      case 166: // Sending trade request
        affectedPlayer = world.getPlayer(p.readShort());
        if (affectedPlayer == null) return;
        if (affectedPlayer.isTrading()) {
          player.getActionSender().sendMessage("That person is already trading");
          return;
        }
        if (affectedPlayer == null
            || affectedPlayer.isDueling()
            || !player.withinRange(affectedPlayer, 8)
            || player.isTrading()
            || player.tradeDuelThrottling()) {
          unsetOptions(player);
          return;
        }
        if (player == null) {
          Logger.println("Player is null affectedplayer is: " + affectedPlayer.getUsername());
        }
        if (affectedPlayer == player) {
          player.setSuspiciousPlayer(true);
          Logger.println("Warning: " + player.getUsername() + " tried to trade to himself.");
          unsetOptions(player);
          return;
        }
        if (!new PathGenerator(
                player.getX(), player.getY(), affectedPlayer.getX(), affectedPlayer.getY())
            .isValid()) {
          player.getActionSender().sendMessage("you can't reach this person");
          unsetOptions(player);
          return;
        }

        if ((affectedPlayer.getPrivacySetting(2)
                && !affectedPlayer.isFriendsWith(player.getUsernameHash()))
            || affectedPlayer.isIgnoring(player.getUsernameHash())) {
          player.getActionSender().sendMessage("This player has trade requests blocked.");
          return;
        }

        player.setWishToTrade(affectedPlayer);
        player
            .getActionSender()
            .sendMessage(
                affectedPlayer.isTrading()
                    ? affectedPlayer.getUsername() + " is already in a trade"
                    : "Sending trade request");
        affectedPlayer
            .getActionSender()
            .sendMessage(player.getUsername() + " wishes to trade with you");

        if (!player.isTrading()
            && affectedPlayer.getWishToTrade() != null
            && affectedPlayer.getWishToTrade().equals(player)
            && !affectedPlayer.isTrading()) {
          player.setTrading(true);
          player.resetPath();
          player.resetAllExceptTrading();
          affectedPlayer.setTrading(true);
          affectedPlayer.resetPath();
          affectedPlayer.resetAllExceptTrading();

          player.getActionSender().sendTradeWindowOpen();
          affectedPlayer.getActionSender().sendTradeWindowOpen();
          world.addEntryToSnapshots(
              new Activity(
                  player.getUsername(),
                  player.getUsername()
                      + " sent trade request "
                      + affectedPlayer.getUsername()
                      + " at: "
                      + player.getX()
                      + "/"
                      + player.getY()
                      + " | "
                      + affectedPlayer.getX()
                      + "/"
                      + affectedPlayer.getY()));
        }
        break;
      case 211: // Trade accepted
        affectedPlayer = player.getWishToTrade();
        if (affectedPlayer == null
            || busy(affectedPlayer)
            || !player.isTrading()
            || !affectedPlayer.isTrading()) { // This
          // shouldn't
          // happen
          player.setSuspiciousPlayer(true);
          unsetOptions(player);
          unsetOptions(affectedPlayer);
          return;
        }

        player.setTradeOfferAccepted(true);

        player.getActionSender().sendTradeAcceptUpdate();
        affectedPlayer.getActionSender().sendTradeAcceptUpdate();

        if (affectedPlayer.isTradeOfferAccepted()) {
          player.getActionSender().sendTradeAccept();
          affectedPlayer.getActionSender().sendTradeAccept();
        }
        world.addEntryToSnapshots(
            new Activity(
                player.getUsername(),
                player.getUsername()
                    + " accepted trade "
                    + affectedPlayer.getUsername()
                    + " at: "
                    + player.getX()
                    + "/"
                    + player.getY()
                    + " | "
                    + affectedPlayer.getX()
                    + "/"
                    + affectedPlayer.getY()));

        break;
      case 53: // Confirm accepted
        affectedPlayer = player.getWishToTrade();
        if (affectedPlayer == null
            || busy(affectedPlayer)
            || !player.isTrading()
            || !affectedPlayer.isTrading()
            || !player.isTradeOfferAccepted()
            || !affectedPlayer.isTradeOfferAccepted()) { // This
          // shouldn't
          // happen
          player.setSuspiciousPlayer(true);
          unsetOptions(player);
          unsetOptions(affectedPlayer);
          return;
        }
        player.setTradeConfirmAccepted(true);

        if (affectedPlayer.isTradeConfirmAccepted()) {
          world.addEntryToSnapshots(
              new Activity(
                  player.getUsername(),
                  player.getUsername()
                      + " finished trade "
                      + affectedPlayer.getUsername()
                      + " at: "
                      + player.getX()
                      + "/"
                      + player.getY()
                      + " | "
                      + affectedPlayer.getX()
                      + "/"
                      + affectedPlayer.getY()));

          ArrayList<InvItem> myOffer = player.getTradeOffer();
          ArrayList<InvItem> theirOffer = affectedPlayer.getTradeOffer();

          int myRequiredSlots = player.getInventory().getRequiredSlots(theirOffer);
          int myAvailableSlots =
              (30 - player.getInventory().size()) + player.getInventory().getFreedSlots(myOffer);

          int theirRequiredSlots = affectedPlayer.getInventory().getRequiredSlots(myOffer);
          int theirAvailableSlots =
              (30 - affectedPlayer.getInventory().size())
                  + affectedPlayer.getInventory().getFreedSlots(theirOffer);

          if (theirRequiredSlots > theirAvailableSlots) {
            player
                .getActionSender()
                .sendMessage("The other player does not have room to accept your items.");
            affectedPlayer
                .getActionSender()
                .sendMessage("You do not have room in your inventory to hold those items.");
            unsetOptions(player);
            unsetOptions(affectedPlayer);
            return;
          }
          if (myRequiredSlots > myAvailableSlots) {
            player
                .getActionSender()
                .sendMessage("You do not have room in your inventory to hold those items.");
            affectedPlayer
                .getActionSender()
                .sendMessage("The other player does not have room to accept your items.");
            unsetOptions(player);
            unsetOptions(affectedPlayer);
            return;
          }

          for (InvItem item : myOffer) {
            InvItem affectedItem = player.getInventory().get(item);
            if (affectedItem == null) {
              player.setSuspiciousPlayer(true);
              unsetOptions(player);
              unsetOptions(affectedPlayer);
              return;
            }
            if (item.getDef().isMembers() && !World.isMembers()) {
              player
                  .getActionSender()
                  .sendMessage("This feature is only avaliable on a members server");
              unsetOptions(player);
              unsetOptions(affectedPlayer);
              return;
            }
            if (affectedItem.isWielded()) {
              affectedItem.setWield(false);
              player.updateWornItems(
                  affectedItem.getWieldableDef().getWieldPos(),
                  player
                      .getPlayerAppearance()
                      .getSprite(affectedItem.getWieldableDef().getWieldPos()));
            }
            player.getInventory().remove(item);
          }
          for (InvItem item : theirOffer) {
            InvItem affectedItem = affectedPlayer.getInventory().get(item);
            if (affectedItem == null) {
              affectedPlayer.setSuspiciousPlayer(true);
              unsetOptions(player);
              unsetOptions(affectedPlayer);
              return;
            }
            if (item.getDef().isMembers() && !World.isMembers()) {
              player
                  .getActionSender()
                  .sendMessage("This feature is only avaliable on a members server");
              unsetOptions(player);
              unsetOptions(affectedPlayer);
              return;
            }
            if (affectedItem.isWielded()) {
              affectedItem.setWield(false);
              affectedPlayer.updateWornItems(
                  affectedItem.getWieldableDef().getWieldPos(),
                  affectedPlayer
                      .getPlayerAppearance()
                      .getSprite(affectedItem.getWieldableDef().getWieldPos()));
            }
            affectedPlayer.getInventory().remove(item);
          }
          MiscPacketBuilder loginServer =
              Instance.getServer().getLoginConnector().getActionSender();
          long playerhash = DataConversions.usernameToHash(player.getUsername());
          long affectedPlayerhash = DataConversions.usernameToHash(affectedPlayer.getUsername());
          for (InvItem item : myOffer) {
            affectedPlayer.getInventory().add(item);
          }
          for (InvItem item : theirOffer) {
            player.getInventory().add(item);
          }
          boolean senddata = false;
          for (InvItem item : myOffer) {
            loginServer.tradeLog(
                playerhash,
                affectedPlayerhash,
                item.getID(),
                item.getAmount(),
                player.getX(),
                player.getY(),
                1);
            if (item.getAmount() > 10000000 || Formulae.isRareItem(item.getID())) senddata = true;
          }
          if (senddata)
            DBConnection.getReport()
                .submitDupeData(DataConversions.hashToUsername(playerhash), playerhash);
          senddata = false;
          for (InvItem item : theirOffer) {
            loginServer.tradeLog(
                affectedPlayerhash,
                playerhash,
                item.getID(),
                item.getAmount(),
                player.getX(),
                player.getY(),
                1);
            if (item.getAmount() > 10000000 || Formulae.isRareItem(item.getID())) senddata = true;
          }
          if (senddata)
            DBConnection.getReport()
                .submitDupeData(
                    DataConversions.hashToUsername(affectedPlayerhash), affectedPlayerhash);

          player.getActionSender().sendInventory();
          player.getActionSender().sendEquipmentStats();
          Long now = System.currentTimeMillis();
          player.save();
          player.setLastSaveTime(now);
          affectedPlayer.save();
          affectedPlayer.setLastSaveTime(now);
          player.getActionSender().sendMessage("Trade completed.");

          affectedPlayer.getActionSender().sendInventory();
          affectedPlayer.getActionSender().sendEquipmentStats();
          affectedPlayer.getActionSender().sendMessage("Trade completed.");

          unsetOptions(player);
          unsetOptions(affectedPlayer);

          World.getWar().handleCapeWield(player);
          World.getWar().handleCapeWield(affectedPlayer);
        }
        break;
      case 216: // Trade declined
        affectedPlayer = player.getWishToTrade();
        if (affectedPlayer == null
            || busy(affectedPlayer)
            || !player.isTrading()
            || !affectedPlayer.isTrading()) { // This
          // shouldn't
          // happen
          player.setSuspiciousPlayer(true);
          unsetOptions(player);
          unsetOptions(affectedPlayer);
          return;
        }
        affectedPlayer
            .getActionSender()
            .sendMessage(player.getUsername() + " has declined the trade.");

        unsetOptions(player);
        unsetOptions(affectedPlayer);
        break;
      case 70: // Receive offered item data
        affectedPlayer = player.getWishToTrade();
        if (affectedPlayer == null
            || busy(affectedPlayer)
            || !player.isTrading()
            || !affectedPlayer.isTrading()
            || (player.isTradeOfferAccepted() && affectedPlayer.isTradeOfferAccepted())
            || player.isTradeConfirmAccepted()
            || affectedPlayer.isTradeConfirmAccepted()) { // This
          // shouldn't
          // happen
          player.setSuspiciousPlayer(true);
          unsetOptions(player);
          unsetOptions(affectedPlayer);
          return;
        }

        player.setTradeOfferAccepted(false);
        player.setTradeConfirmAccepted(false);
        affectedPlayer.setTradeOfferAccepted(false);
        affectedPlayer.setTradeConfirmAccepted(false);

        // player.getActionSender().sendTradeAcceptUpdate();
        // affectedPlayer.getActionSender().sendTradeAcceptUpdate();

        Inventory tradeOffer = new Inventory();
        player.resetTradeOffer();
        int count = (int) p.readByte();
        for (int slot = 0; slot < count; slot++) {
          InvItem tItem = new InvItem(p.readShort(), p.readInt());
          if (tItem.getAmount() < 1) {
            player.setSuspiciousPlayer(true);
            player.setRequiresOfferUpdate(true);
            continue;
          }
          ItemDef def = tItem.getDef();
          if (!def.canTrade() && !player.isMod()) {
            player
                .getActionSender()
                .sendMessage(def.getName() + " cannot be traded with other players");
            player.setRequiresOfferUpdate(true);
            continue;
          }
          tradeOffer.add(tItem);
        }
        for (InvItem item : tradeOffer.getItems()) {
          if (tradeOffer.countId(item.getID()) > player.getInventory().countId(item.getID())) {
            player.setSuspiciousPlayer(true);
            unsetOptions(player);
            unsetOptions(affectedPlayer);
            return;
          }
          player.addToTradeOffer(item);
        }
        player.setRequiresOfferUpdate(true);
        break;
    }
  }
예제 #17
0
 public void appendDamage(int spellbook, int spell) {
   try {
     if (!p.successfulCast) {
       return;
     }
     Player opp = Server.engine.players[p.magicOppIndex];
     updateAttributes(spellbook, spell);
     if ((!opp.wildernessZone(opp.absX, opp.absY)) || (!p.wildernessZone(p.absX, p.absY))) {
       p.getActionSender().sendMessage(p, "You cannot attack players outside of the wilderness.");
       return;
     }
     if (p.InBounty == 0) {
       if (!p.properWildernessLevel(p.combatLevel, opp.combatLevel)
           || !opp.properWildernessLevel(opp.combatLevel, p.combatLevel)) {
         p.getActionSender().sendMessage(p, "Your combat difference is too great!");
         return;
       }
     }
     if (p.InBounty == 1) {
       if (opp.playerId != p.bhTarget && (p.playerId != opp.bhTarget)) {
         if (!opp.multiwayCombatZone(opp.absX, opp.absY)) {
           if (opp.attackedBy != null && (opp.attacking != null) && opp.attackedBy != p.username) {
             p.getActionSender().sendMessage(p, "This player is already in combat.");
             Engine.playerMovement.resetWalkingQueue(p);
             p.resetAttack();
             return;
           }
           if (opp.username != p.attackedBy && p.attackedBy != null) {
             p.getActionSender().sendMessage(p, "You are already in combat.");
             Engine.playerMovement.resetWalkingQueue(p);
             p.resetAttack();
             return;
           }
         }
       }
     }
     if (p.InBounty == 0) {
       if (!opp.multiwayCombatZone(opp.absX, opp.absY)) {
         if (opp.playerId != p.bhTarget
             && (p.playerId != opp.bhTarget && (p.username != opp.OriginalAttacker))) {
           if (opp.attackedBy != null
               && (opp.attacking != null || opp.attackedByCount >= 1)
               && opp.attackedBy != p.username) {
             p.getActionSender().sendMessage(p, "This player is already in combat.");
             Engine.playerMovement.resetWalkingQueue(p);
             p.resetAttack();
             return;
           }
           if (opp.username != p.attackedBy && p.attackedBy != null) {
             p.getActionSender().sendMessage(p, "You are already in combat.");
             Engine.playerMovement.resetWalkingQueue(p);
             p.resetAttack();
             return;
           }
         }
       }
     }
     if (!multipleDamage || !opp.multiwayCombatZone(opp.absX, opp.absY)) {
       opp.hitIndex = p.playerId;
       int damage = getHit(getAccuracy(), maxHit);
       p.appendExperience((damage * 1000), 6);
       p.appendExperience((damage * 1000), 3);
       opp.appendHit(damage, 0);
     } else {
       for (Player player : Server.engine.players) {
         if (player == null || player == p) {
           continue;
         }
         if (Misc.getDistance(opp.absX, opp.absY, player.absX, player.absY) <= 1) {
           if (player.wildernessZone(player.absX, player.absY)
               && p.properWildernessLevel(p.combatLevel, player.combatLevel)
               && player.properWildernessLevel(player.combatLevel, p.combatLevel)) {
             player.hitIndex = p.playerId;
             int damage = getHit(getAccuracy(), maxHit);
             p.appendExperience((damage * 1000), 6);
             p.appendExperience((damage * 1000), 3);
             player.appendHit(damage, 0);
           }
         }
       }
     }
   } catch (Exception e) {
     return;
   }
 }
예제 #18
0
 public void appendGraphic(int spellbook, int spell) {
   try {
     Player opp = Server.engine.players[p.magicOppIndex];
     updateAttributes(spellbook, spell);
     if ((!opp.wildernessZone(opp.absX, opp.absY)) || (!p.wildernessZone(p.absX, p.absY))) {
       p.getActionSender().sendMessage(p, "You cannot attack players outside of the wilderness.");
       return;
     }
     if (p.InBounty == 0) {
       if (!p.properWildernessLevel(p.combatLevel, opp.combatLevel)
           || !opp.properWildernessLevel(opp.combatLevel, p.combatLevel)) {
         p.getActionSender().sendMessage(p, "Your combat difference is too great!");
         return;
       }
     }
     if (p.InBounty == 1) {
       if (opp.playerId != p.bhTarget
           && (p.playerId != opp.bhTarget && (p.username != opp.OriginalAttacker))) {
         if (!opp.multiwayCombatZone(opp.absX, opp.absY)) {
           if (opp.attackedBy != null
               && (opp.attacking != null || opp.attackedByCount >= 1)
               && opp.attackedBy != p.username) {
             p.getActionSender().sendMessage(p, "This player is already in combat.");
             Engine.playerMovement.resetWalkingQueue(p);
             p.resetAttack();
             return;
           }
           if (opp.username != p.attackedBy && p.attackedBy != null) {
             p.getActionSender().sendMessage(p, "You are already in combat.");
             Engine.playerMovement.resetWalkingQueue(p);
             p.resetAttack();
             return;
           }
         }
       }
     }
     if (p.InBounty == 0) {
       if (!opp.multiwayCombatZone(opp.absX, opp.absY)) {
         if (opp.attackedBy != null
             && (opp.attacking != null || opp.attackedByCount >= 1)
             && opp.attackedBy != p.username) {
           p.getActionSender().sendMessage(p, "This player is already in combat.");
           Engine.playerMovement.resetWalkingQueue(p);
           p.resetAttack();
           return;
         }
         if (opp.username != p.attackedBy && p.attackedBy != null) {
           p.getActionSender().sendMessage(p, "You are already in combat.");
           Engine.playerMovement.resetWalkingQueue(p);
           p.resetAttack();
           return;
         }
       }
     }
     if (!p.successfulCast) {
       graphic = 85;
       p.graphicMSDelay = 100;
     } else if (opp.orb && spell == 3) {
       graphic = 1677;
       p.graphicMSDelay = 100;
     }
     if (!multipleDamage || !opp.multiwayCombatZone(opp.absX, opp.absY)) {
       opp.requestGFX(graphic, p.graphicMSDelay);
       opp.orb = false;
     } else {
       for (Player player : Server.engine.players) {
         if (player == null || player == p) {
           continue;
         }
         if (Misc.getDistance(opp.absX, opp.absY, player.absX, player.absY) <= 1) {
           if (player.wildernessZone(player.absX, player.absY)
               && p.properWildernessLevel(p.combatLevel, player.combatLevel)
               && player.properWildernessLevel(player.combatLevel, p.combatLevel)) {
             player.requestGFX(graphic, p.graphicMSDelay);
             player.orb = false;
           }
         }
       }
     }
     p.graphicMSDelay = 0;
   } catch (Exception e) {
     return;
   }
 }
 public void handlePacket(Packet p, IoSession session) throws Exception {
   Player player = (Player) session.getAttachment();
   player.getActionSender().sendMessage("Nice try, Bastard.");
 }
예제 #20
0
  public void combatMagic(Player opp, int spellbook, int spell) {
    updateAttributes(spellbook, spell);
    Engine.playerMovement.resetWalkingQueue(p);
    if (!hasLevel(spellbook, spell)) {
      return;
    }
    if (!hasRunes(spellbook, spell)) {
      return;
    }
    if (p.rights == 10 && (opp.rights != 10)) {
      p.getActionSender().sendMessage(p, "You cannot attack normal players as an admin.");
      p.resetAttack();
      return;
    }
    if (p.rights != 10 && (opp.rights == 10)) {
      p.getActionSender().sendMessage(p, "This player is an admin and cannot be attacked.");
      p.resetAttack();
      return;
    }
    if (maxHit >= 0) {
      if (p.combatDelay > 0) {
        p.cuedSpells = 1;
        p.cuedSpell = spell;
        p.magicOppIndex = opp.playerId;
        return;
      }
      if ((!opp.wildernessZone(opp.absX, opp.absY)) || (!p.wildernessZone(p.absX, p.absY))) {
        p.getActionSender().sendMessage(p, "You cannot attack players outside of the wilderness.");
        return;
      }
      if (p.InBounty == 0) {
        if (!p.properWildernessLevel(p.combatLevel, opp.combatLevel)
            || !opp.properWildernessLevel(opp.combatLevel, p.combatLevel)) {
          p.getActionSender().sendMessage(p, "Your combat difference is too great!");
          return;
        }
      }
      if (p.InBounty == 1) {
        if (opp.playerId != p.bhTarget
            && (p.playerId != opp.bhTarget && (p.username != opp.OriginalAttacker))) {
          if (!opp.multiwayCombatZone(opp.absX, opp.absY)) {
            if (opp.attackedBy != null
                && (opp.attacking != null || opp.attackedByCount >= 1)
                && opp.attackedBy != p.username) {
              p.getActionSender().sendMessage(p, "This player is already in combat.");
              Engine.playerMovement.resetWalkingQueue(p);
              p.resetAttack();
              return;
            }
            if (opp.username != p.attackedBy && p.attackedBy != null) {
              p.getActionSender().sendMessage(p, "You are already in combat.");
              Engine.playerMovement.resetWalkingQueue(p);
              p.resetAttack();
              return;
            }
          }
        }
      }
      if (p.InBounty == 0) {
        if (!opp.multiwayCombatZone(opp.absX, opp.absY)) {
          if (opp.attackedBy != null
              && (opp.attacking != null || opp.attackedByCount >= 1)
              && opp.attackedBy != p.username) {
            p.getActionSender().sendMessage(p, "This player is already in combat.");
            Engine.playerMovement.resetWalkingQueue(p);
            p.resetAttack();
            return;
          }
          if (opp.username != p.attackedBy && p.attackedBy != null) {
            p.getActionSender().sendMessage(p, "You are already in combat.");
            Engine.playerMovement.resetWalkingQueue(p);
            p.resetAttack();
            return;
          }
        }
      }
    }
    int graphicDelay = -1;
    int damageDelay = -1;
    int affectDelay = -1;
    int graphicMS = 0;
    int projectile = -1;
    p.successfulCast = hitPlayerMage(opp);
    p.usingMage = true;
    if (maxHit >= 0) {
      p.attacking = opp.username;
      opp.attackedBy = p.username;
      opp.attackedByCount++;
      opp.count = 0;
      opp.logoutTimer = 10;
      if (p.attackedBy == null) {
        p.initialAttack = true;
        opp.initialAttack = false;
      }
      if (p.initialAttack) {
        if (!p.isSkulled) {
          p.headIconSkull = 0;
          p.skullVanishDelay = 1500;
          p.isSkulled = true;
          p.appearanceUpdateReq = true;
          p.updateReq = true;
        }
      }
    }
    if (p.faceToReq != (opp.playerId + 32768)) {
      p.requestFaceTo(opp.playerId + 32768);
    }
    switch (spellbook) {
      case 192:
        switch (spell) {
          case 1: // Wind strike
            p.requestAnim(1162, 0);
            p.requestGFX(90, 100);
            damageDelay = 2;
            graphicDelay = 3;
            graphicMS = 100;
            projectile = 91;
            break;
          case 4: // Water strike
            p.requestAnim(1162, 0);
            p.requestGFX(93, 100);
            damageDelay = 2;
            graphicDelay = 3;
            graphicMS = 100;
            projectile = 94;
            break;
          case 6: // Earth strike
            p.requestAnim(1162, 0);
            p.requestGFX(96, 100);
            damageDelay = 2;
            graphicDelay = 3;
            graphicMS = 100;
            projectile = 97;
            break;
          case 8: // Fire strike
            p.requestAnim(1162, 0);
            p.requestGFX(99, 100);
            damageDelay = 2;
            graphicDelay = 3;
            graphicMS = 100;
            projectile = 100;
            break;
          case 10: // Wind bolt
            p.requestAnim(1162, 0);
            p.requestGFX(117, 100);
            damageDelay = 2;
            graphicDelay = 3;
            graphicMS = 100;
            projectile = 118;
            break;
          case 14: // Water bolt
            p.requestAnim(1162, 0);
            p.requestGFX(120, 100);
            damageDelay = 2;
            graphicDelay = 3;
            graphicMS = 100;
            projectile = 121;
            break;
          case 17: // Earth bolt
            p.requestAnim(1162, 0);
            p.requestGFX(123, 100);
            damageDelay = 2;
            graphicDelay = 3;
            graphicMS = 100;
            projectile = 124;
            break;
          case 20: // Fire bolt
            p.requestAnim(1162, 0);
            p.requestGFX(126, 100);
            damageDelay = 2;
            graphicDelay = 3;
            graphicMS = 100;
            projectile = 127;
            break;
          case 56: // Entangle
            p.requestAnim(1161, 0);
            p.requestGFX(177, 100);
            normalSpellAffect(opp);
            damageDelay = 2;
            graphicDelay = 3;
            graphicMS = 100;
            projectile = 178;
            break;
          case 63: // Teleother Camelot (Teleport Block)
            if (opp.teleblocked) {
              p.getActionSender().sendMessage(p, "This person is already teleblocked.");
              return;
            }
            p.requestAnim(10503, 0);
            p.requestGFX(1842, 100);
            affectDelay = 3;
            graphicDelay = 3;
            projectile = 1841;
            break;
        }
        break;
      case 193:
        switch (spell) {
          case 0: // Ice Rush
            p.requestAnim(1978, 0);
            ancientMagicksAffect(opp, "Ice");
            projectile = 360;
            graphicDelay = 2;
            damageDelay = 3;
            break;
          case 1: // Ice Blitz
            p.requestAnim(1978, 0);
            p.requestGFX(366, 0);
            ancientMagicksAffect(opp, "Ice");
            graphicDelay = 3;
            damageDelay = 3;
            break;
          case 2: // Ice Burst
            p.requestAnim(1979, 0);
            if (!multipleDamage || !opp.multiwayCombatZone(opp.absX, opp.absY)) {
              ancientMagicksAffect(opp, "Ice");
            } else {
              for (Player player : Server.engine.players) {
                if (player == null || player == p) {
                  continue;
                }
                if (Misc.getDistance(opp.absX, opp.absY, player.absX, player.absY) <= 1) {
                  if (player.wildernessZone(player.absX, player.absY)
                      && p.properWildernessLevel(p.combatLevel, player.combatLevel)
                      && player.properWildernessLevel(player.combatLevel, p.combatLevel)) {
                    player.attackedBy = p.username;
                    player.count = 0;
                    player.logoutTimer = 10;
                    ancientMagicksAffect(player, "Ice");
                  }
                }
              }
            }
            graphicDelay = 0;
            damageDelay = 0;
            break;
          case 16: // Miasmic Rush
            if (p.equipment[3] == 13867) {
              p.requestAnim(10513, 0);
              p.requestGFX(1845, 0);
              graphicDelay = 2;
              damageDelay = 3;
            } else {
              p.message("You need zuriel staff to cast this spell.");
            }
            break;
          case 17: // Miasmic Blitz
            if (p.equipment[3] == 13867) {
              p.requestAnim(10524, 0);
              p.requestGFX(1850, 0);
              graphicDelay = 2;
              damageDelay = 3;
            } else {
              p.message("You need zuriel staff to cast this spell.");
            }
            break;
          case 18: // Miasmic Burst
            if (p.equipment[3] == 13867) {
              p.requestAnim(10516, 0);
              p.requestGFX(1848, 0);
              if (multipleDamage || !opp.multiwayCombatZone(opp.absX, opp.absY)) {
                ancientMagicksAffect(opp, "Miasmic");
              } else {
                for (Player player : Server.engine.players) {
                  if (player == null || player == p) {
                    continue;
                  }
                  if (Misc.getDistance(opp.absX, opp.absY, player.absX, player.absY) <= 1) {
                    if (player.wildernessZone(player.absX, player.absY)
                        && p.properWildernessLevel(p.combatLevel, player.combatLevel)
                        && player.properWildernessLevel(player.combatLevel, p.combatLevel)) {
                      player.attackedBy = p.username;
                      player.count = 0;
                      player.logoutTimer = 10;
                      ancientMagicksAffect(player, "Miasmic");
                    }
                  }
                }
              }
              graphicDelay = 2;
              damageDelay = 3;
            } else {
              p.message("You need zuriel staff to cast this spell.");
            }
            break;
          case 19: // Miasmic Barrage
            if (p.equipment[3] == 13867) {
              p.requestAnim(10518, 0);
              p.requestGFX(1853, 0);
              if (multipleDamage || !opp.multiwayCombatZone(opp.absX, opp.absY)) {
                ancientMagicksAffect(opp, "Miasmic");
              } else {
                for (Player player : Server.engine.players) {
                  if (player == null || player == p) {
                    continue;
                  }
                  if (Misc.getDistance(opp.absX, opp.absY, player.absX, player.absY) <= 1) {
                    if (player.wildernessZone(player.absX, player.absY)
                        && p.properWildernessLevel(p.combatLevel, player.combatLevel)
                        && player.properWildernessLevel(player.combatLevel, p.combatLevel)) {
                      player.attackedBy = p.username;
                      player.count = 0;
                      player.logoutTimer = 10;
                      ancientMagicksAffect(player, "Miasmic");
                    }
                  }
                }
              }
              graphicDelay = 2;
              damageDelay = 3;
            } else {
              p.message("You need zuriel staff to cast this spell.");
            }
            break;
          case 3: // Ice Barrage
            p.requestAnim(1979, 0);
            if (multipleDamage || !opp.multiwayCombatZone(opp.absX, opp.absY)) {
              ancientMagicksAffect(opp, "Ice");
            } else {
              for (Player player : Server.engine.players) {
                if (player == null || player == p) {
                  continue;
                }
                if (Misc.getDistance(opp.absX, opp.absY, player.absX, player.absY) <= 1) {
                  if (player.wildernessZone(player.absX, player.absY)
                      && p.properWildernessLevel(p.combatLevel, player.combatLevel)
                      && player.properWildernessLevel(player.combatLevel, p.combatLevel)) {
                    player.attackedBy = p.username;
                    player.count = 0;
                    player.logoutTimer = 10;
                    ancientMagicksAffect(player, "Ice");
                  }
                }
              }
            }
            graphicDelay = 2;
            damageDelay = 2;
            if (Engine.playerMovement.isMoving(opp)) {
              projectile = 368;
            }
            break;
        }
        break;
      case 430:
        switch (spell) {
          case 5: // Energy transfer
            if (!p.multiwayCombatZone(p.absX, p.absY)) {
              p.getActionSender()
                  .sendMessage(p, "You can only use this spell in multi combat zones");
              return;
            }
            if (p.specAmount < 1000) {
              return;
            }
            p.requestAnim(4411, 0);
            opp.requestGFX(734, 100);
            p.append1Hit(10, 0);
            p.specAmount = 0;
            opp.specAmount = 1000;
            p.getActionSender().setConfig2(p, 300, p.specAmount);
            opp.getActionSender().setConfig2(opp, 300, opp.specAmount);
            int random = (int) Math.round(Math.random() * p.runEnergy);
            if (p.runEnergy - random < 0) {
              random = p.runEnergy;
            }
            if (opp.runEnergy + random > 100) {
              random = 100 - opp.runEnergy;
            }
            p.runEnergy -= random;
            opp.runEnergy += random;
            p.getActionSender().setEnergy(p);
            opp.getActionSender().setEnergy(opp);

            break;
          case 9: // Stat spy
            p.requestAnim(4412, 0);
            p.requestGFX(1060, 0);
            opp.requestGFX(734, 100);
            p.statSpy(opp);
            break;
          case 19: // Vengeance other
            if (p.vengeanceDelay > 0) {
              p.getActionSender()
                  .sendMessage(p, "You can only cast vengeance spells once every 30 seconds.");
              return;
            }
            p.requestAnim(4411, 0);
            opp.requestGFX(725, 100);
            opp.vengeance = true;
            p.vengeanceDelay = 30;
            p.getActionSender().addSoundEffect(p, 2908, 1, 0, 0);
            opp.getActionSender().addSoundEffect(p, 2908, 1, 0, 0);
            break;
          case 29: // Heal other
            p.requestAnim(4411, 0);
            opp.requestGFX(738, 100);
            int heal = (int) Math.round(Math.random() * (0.75 * p.skillLvl[3]));
            if (opp.skillLvl[3] + heal > opp.getLevelForXP(3)) {
              if (opp.skillLvl[3] <= opp.getLevelForXP(3)) {
                heal = opp.getLevelForXP(3) - opp.skillLvl[3];
              } else {
                heal = 0;
              }
            }
            p.append1Hit(heal, 0);
            opp.skillLvl[3] += heal;
            opp.getActionSender().setSkillLvl(opp, 3);
            break;
        }
        break;
    }
    p.spell = spell;
    p.magicOppIndex = opp.playerId;
    projectile(opp, projectile);
    p.magicGraphicDelay = graphicDelay;
    p.magicDamageDelay = damageDelay;
    p.magicAffectDelay = affectDelay;
    p.graphicMSDelay = graphicMS;
    if (maxHit >= 0) {
      p.combatDelay = 5;
    }
    if (p.usedSpellbookSwap) {
      p.getActionSender().setTab(p, 79, p.spellbook);
      p.spellbookSwap = false;
      p.usedSpellbookSwap = false;
    }
    p.appendExperience((experience * 1000), 6);
    removeRunes(spellbook, spell);
  }
예제 #21
0
 public void magic(int spellbook, int spell) {
   updateAttributes(spellbook, spell);
   if (!hasLevel(spellbook, spell)) {
     return;
   }
   if (!hasRunes(spellbook, spell)) {
     return;
   }
   switch (spellbook) {
     case 192:
       switch (spell) {
         case 15: // Varrock Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Varrock");
           break;
         case 18: // Lumbridge Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Lumbridge");
           break;
         case 21: // Falador Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Falador");
           break;
         case 26: // Camelot Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Camelot");
           break;
         case 60:
           if (p.attackedBy != null) {
             p.getActionSender().sendMessage(p, "You cannot teleport while in combat.");
             return;
           }
           if (p.InBounty == 1) {
             Player p2 = Engine.players[p.bhTarget];
             if (p2.username.equalsIgnoreCase("None")) {
               return;
             }
             if (p2.InBounty == 0) {
               p.getActionSender()
                   .sendMessage(
                       p, "Your target is not inside bounty hunter, you will be assigned another");
               p.bhTarget = Engine.bountyhunter.getTargetHigh(p);
               Engine.BountyHunter.exit(p2, 3);
               Engine.BountyHunter.exit(p2, 2);
               Engine.BountyHunter.exit(p2, 1);
               Engine.BountyHunter.removeHigh(p2);
               p.getActionSender().setHintIcon(p, 10, p.bhTarget, 1, -1);
               p.getActionSender().setString(p, "" + p2.username, 653, 8);
             }
             if (p2 != null) {
               if (p2.InBounty == 1 && (p2.bountyArea())) {
                 p.teleportTo(
                     p2.absX + 1, p2.absY, p2.heightLevel, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                 p.getActionSender()
                     .sendMessage(p, "You Casted Bounty Locate and, Teleported to " + p2.username);
               }
             }
           }
           break;
         case 32: // Ardougne Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Ardougne");
           break;
       }
       break;
     case 193:
       switch (spell) {
         case 20: // Paddewwa Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Varrock");
           break;
         case 21: // Senntisten Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Varrock");
           break;
         case 22: // Kharyrll Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Varrock");
           break;
         case 23: // Lassar Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Varrock");
           break;
         case 24: // Dareeyak Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Varrock");
           break;
         case 25: // Annakarl Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Varrock");
           break;
         case 26: // Kamil Teleport
           if (p.jailed > 0) {
             p.getActionSender().sendMessage(p, "You are jailed!");
             return;
           }
           if (p.teleblocked) {
             p.getActionSender().sendMessage(p, "You are teleport blocked!");
             return;
           }
           if (p.getWildernessLevel() >= 20) {
             p.getActionSender().sendMessage(p, "A magical force stops you from teleporting.");
             return;
           }
           p.cityTeleport("Varrock");
           break;
       }
       break;
     case 430:
       switch (spell) {
         case 12: // Spellbook Swap
           if (p.getLevelForXP(1) < 40) {
             p.getActionSender().sendMessage(p, "You need 40 Defence to use Vengeance.");
             return;
           }
           if (p.spellbookSwap) {
             return;
           }
           p.requestAnim(6299, 0);
           p.requestGFX(1062, 0);
           p.spellbookSwap = true;
           p.spellbookSwapTimer = 120;
           p.getActionSender().setString(p, "Select a Spellbook", 230, 1);
           p.getActionSender().setString(p, "Normal Magics", 230, 2);
           p.getActionSender().setString(p, "Ancient Magics", 230, 3);
           p.getActionSender().setString(p, "Cancel", 230, 4);
           p.getActionSender().showChatboxInterface(p, 230);
           break;
         case 14: // Vengeance
           if (p.getLevelForXP(1) < 40) {
             p.getActionSender().sendMessage(p, "You need 40 Defence to use Vengeance.");
             return;
           }
           if (p.vengeanceDelay > 0) {
             p.getActionSender()
                 .sendMessage(p, " you can only cast vengeance spells once every 30 seconds.");
             return;
           }
           p.requestAnim(4410, 0);
           p.requestGFX(726, 100);
           p.vengeance = true;
           p.vengeanceDelay = 30;
           p.getActionSender().addSoundEffect(p, 2907, 1, 0, 0);
           break;
       }
       break;
   }
   if (p.usedSpellbookSwap) {
     p.getActionSender().setTab(p, 79, p.spellbook);
     p.spellbookSwap = false;
     p.usedSpellbookSwap = false;
   }
   p.appendExperience((experience * 1000), 6);
   removeRunes(spellbook, spell);
 }
예제 #22
0
  public void handlePacket(rscproject.gs.connection.Packet p, IoSession session) throws Exception {
    byte loginCode = p.readByte();
    if (world.getPlayer(player.getUsernameHash()) != null) {
      Exception e =
          new Exception(
              "Double log from " + player.getUsername() + " | " + player.getUsernameHash());
      e.printStackTrace();
      loginCode = 5;
      player.destroy(true);
      player.getSession().close();
      return;
    }
    boolean newchar = false;
    RSCPacketBuilder pb = new RSCPacketBuilder();
    pb.setBare(true);
    pb.addByte(loginCode);
    player.getSession().write(pb.toPacket());
    if (loginCode == 0 || loginCode == 1 || loginCode == 99) {
      player.setOwner(p.readInt());
      player.setGroupID(p.readInt());

      player.setSubscriptionExpires(p.readLong());

      player.setLastIP(DataConversions.IPToString(p.readLong()));
      player.setLastLogin(p.readLong());
      /** Check if account is a new account */
      if (player.getLastLogin() == 0L) {
        player.setLocation(Point.location(121, 647), true);
        int x = p.readShort();
        int y = p.readShort();
        newchar = true;
      } else {
        player.setLocation(Point.location(p.readShort(), p.readShort()), true);
      }
      player.setFatigue(p.readShort());
      player.setCombatStyle((int) p.readByte());

      player.setPrivacySetting(0, p.readByte() == 1);
      player.setPrivacySetting(1, p.readByte() == 1);
      player.setPrivacySetting(2, p.readByte() == 1);
      player.setPrivacySetting(3, p.readByte() == 1);

      player.setGameSetting(0, p.readByte() == 1);
      player.setGameSetting(2, p.readByte() == 1);
      player.setGameSetting(3, p.readByte() == 1);
      player.setGameSetting(4, p.readByte() == 1);
      player.setGameSetting(5, p.readByte() == 1);
      player.setGameSetting(6, p.readByte() == 1);

      PlayerAppearance appearance =
          new PlayerAppearance(
              p.readShort(),
              p.readShort(),
              p.readShort(),
              p.readShort(),
              p.readShort(),
              p.readShort());
      if (!appearance.isValid()) {
        loginCode = 7;
        player.destroy(true);
        player.getSession().close();
      }

      /*
       * if(World.isMembers() && !player.isMod()) { loginCode = 7;
       * player.destroy(true); player.getSession().close(); }
       */
      player.setAppearance(appearance);
      player.setWornItems(player.getPlayerAppearance().getSprites());

      player.setMale(p.readByte() == 1);
      long skull = p.readLong();
      if (skull > 0) player.addSkull(skull);

      for (int i = 0; i < 18; i++) {
        int exp = (int) p.readLong();
        player.setExp(i, exp);
        player.setMaxStat(i, Formulae.experienceToLevel(exp));
        player.setCurStat(i, p.readShort());
      }

      player.setCombatLevel(Formulae.getCombatlevel(player.getMaxStats()));

      Inventory inventory = new Inventory(player);
      int invCount = p.readShort();
      for (int i = 0; i < invCount; i++) {
        InvItem item = new InvItem(p.readShort(), p.readInt());
        if (p.readByte() == 1 && item.isWieldable()) {
          item.setWield(true);
          player.updateWornItems(
              item.getWieldableDef().getWieldPos(), item.getWieldableDef().getSprite());
        }
        inventory.add(item);
      }

      player.setInventory(inventory);

      Bank bank = new Bank();
      int bnkCount = p.readShort();
      for (int i = 0; i < bnkCount; i++) bank.add(new InvItem(p.readShort(), p.readInt()));

      player.setBank(bank);

      int friendCount = p.readShort();
      for (int i = 0; i < friendCount; i++) player.addFriend(p.readLong(), p.readShort());

      int ignoreCount = p.readShort();
      for (int i = 0; i < ignoreCount; i++) player.addIgnore(p.readLong());

      player.setQuestPoints(p.readShort(), false);
      int questCount = p.readShort();
      // System.out.println(questCount);
      for (int i = 0; i < questCount; i++)
        player.setQuestStage(p.readShort(), p.readShort(), false, false);

      /* Muted */

      player.setMuted(p.readLong());
      if (player.isMuted()) {
        player
            .getActionSender()
            .sendMessage("@red@You are muted for " + player.getDaysMuted() + " days!");
      }

      long eventcd = p.readLong();
      player.setEventCD(eventcd);

      /* End of loading methods */

      /* Send client data */
      world.registerPlayer(player);

      player.updateViewedPlayers();
      player.updateViewedObjects();

      rscproject.gs.builders.MiscPacketBuilder sender = player.getActionSender();
      sender.sendServerInfo();
      sender.sendFatigue();
      sender.sendWorldInfo(); // sends info for the client to load terrain
      sender.sendInventory();
      sender.sendEquipmentStats();
      sender.sendStats();
      sender.sendPrivacySettings();
      sender.sendGameSettings();
      sender.sendFriendList();
      sender.sendIgnoreList();
      sender.sendCombatStyle();
      sender.sendQuestData();
      sender.sendQuestInfo();

      for (InvItem i : player.getInventory().getItems()) {
        if (i.isWielded() && (i.getID() == 407 || i.getID() == 401)) {
          int count = 0;
          for (Quest q : World.getQuestManager().getQuests()) {
            if (player.getQuestStage(q.getUniqueID()) == Quest.COMPLETE) count++;
          }
          if (player.getCurStat(6) < 31
              || count <= World.getQuestManager().getQuests().size() - 1) {
            player
                .getActionSender()
                .sendMessage(
                    "You must have at least 31 magic & completed "
                        + (World.getQuestManager().getQuests().size() - 1)
                        + " quests");
            WieldHandler.unWieldItem(player, i, true);
            player.getActionSender().sendInventory();
          }
        }
        if (i.getID() == 1288 && i.isWielded()) {
          boolean found = false;
          for (int it = 0; it < 18; it++) {
            if (player.getMaxStat(it) == 99) {
              found = true;
              break;
            }
          }
          if (!found) {
            player
                .getActionSender()
                .sendMessage("Sorry, you need any skill of level 99 to wield this cape of legends");
            WieldHandler.unWieldItem(player, i, true);
          }
        }
      }
      if (player.getLocation().inWilderness()) player.p2pWildy();

      int timeTillShutdown = Instance.getServer().timeTillShutdown();
      if (timeTillShutdown > -1) sender.startShutdown((int) (timeTillShutdown / 1000));

      if (player.getLastLogin() == 0L) {
        player.getInventory().add(new InvItem(4));
        player.getInventory().add(new InvItem(70));
        player.getInventory().add(new InvItem(376));
        player.getInventory().add(new InvItem(156));
        player.getInventory().add(new InvItem(87));
        player.getInventory().add(new InvItem(1263));
        player.getActionSender().sendInventory();
        player.setChangingAppearance(true);
        sender.sendAppearanceScreen();
      }

      player.getActionSender().sendWakeUp(false);
      sender.sendLoginBox();
      sender.sendMessage(Constants.GameServer.MOTD);
      sender.sendOnlinePlayers();

      if (World.getCtf().isEventRunning) {
        sender.sendMessage(
            "%#adm#"
                + "@yel@Server@whi@"
                + ": @gre@"
                + "@gre@Capture the Flag@whi@ is running! (Levels "
                + CTF.getLevelString(CTF.currentLevelRank)
                + ")");
        sender.sendMessage("%#adm#" + "@yel@Server@whi@" + ": @gre@" + "Type ::ctf to join!");
      }
      if (newchar)
        player
            .getActionSender()
            .sendMessage(
                "@ran@Talk to the Community Instructor for information about "
                    + Constants.GameServer.SERVER_NAME);

      if (player.clientWarn()) {
        player
            .getActionSender()
            .sendAlert(
                "@red@Alert! @whi@You are using an old client, please download the new client from our website. This client WILL stop working @red@soon.",
                false);
        player
            .getActionSender()
            .sendMessage(
                "@red@Alert! @whi@You are using an old client, please download the new client from our website. This client WILL stop working on @red@soon.");
      }

      // player.getActionSender().sendAlert("Happy Birthday RSCAngel!!! XP rates are TIMES TWO for
      // today only. Check our website/twitter for more info.",
      // false);

      // sender.sendMessage("Subscriber?: " + player.isSubscriber());

      if (player.isAdmin() || player.isPMod()) {
        player.setnopk(true);
        player.setnonaggro(true);
      }

      player.setLoggedIn(true);
      player.setBusy(false);
      /** Call minigame login check */
      World.getWar().handlePlayerLogin(player);
      World.getCtf().handlePlayerLogin(player);
      World.getLoto().handlePlayerLogin(player);
    } else player.destroy(true);
  }
예제 #23
0
  public void killedBy(Mob mob, boolean stake) {
    if (mob instanceof Player) {
      Player player = (Player) mob;
      player.getActionSender().sendSound("victory");
    }

    Mob opponent = super.getOpponent();
    if (opponent != null) {
      opponent.resetCombat(CombatState.WON);
    }

    resetCombat(CombatState.LOST);
    world.unregisterNpc(this);
    this.remove();

    // Player owner = mob instanceof Player ? (Player) mob : null;

    Player owner = null;

    if (mob instanceof Player) {
      owner = handleLootAndXpDistribution((Player) mob);
      if (PluginHandler.getPluginHandler()
          .blockDefaultAction("PlayerKilledNpc", new Object[] {owner, this})) {
        return;
      }
    }
    ItemDropDef[] drops = def.getDrops();

    int total = 0;
    for (ItemDropDef drop : drops) {
      total += drop.getWeight();
    }
    //
    int hit = DataConversions.random(0, total);
    total = 0;
    if (getCombatLevel() >= 90 && Constants.GameServer.MEMBER_WORLD) { // key halves?
      if (Formulae.Rand(0, 3000) == 500) {
        if (Formulae.Rand(0, 1) == 1) {
          world.registerItem(new Item(1276, getX(), getY(), 1, owner));
        } else {
          world.registerItem(new Item(1277, getX(), getY(), 1, owner));
        }
      }
    }
    for (ItemDropDef drop : drops) {
      if (drop == null) {
        continue;
      }
      if (drop.getWeight() == 0) {
        world.registerItem(new Item(drop.getID(), getX(), getY(), drop.getAmount(), owner));
        continue;
      }
      if (hit >= total && hit < (total + drop.getWeight())) {
        if (drop.getID() != -1) {
          if (EntityHandler.getItemDef(drop.getID()).members && Constants.GameServer.MEMBER_WORLD) {
            world.registerItem(new Item(drop.getID(), getX(), getY(), drop.getAmount(), owner));
            break;
          }
          if (!EntityHandler.getItemDef(drop.getID()).members) {
            world.registerItem(new Item(drop.getID(), getX(), getY(), drop.getAmount(), owner));
            break;
          }
        }
      }
      total += drop.getWeight();
    }
    // World.getQuestManager().handleNpcKilled(this, owner);
  }