Package org.moparscape.msc.gs.event

Examples of org.moparscape.msc.gs.event.WalkToMobEvent


    player.setFollowing(affectedMob);
    player.setStatus(Action.ATTACKING_MOB);

    if (player.getRangeEquip() < 0) {
      Instance.getDelayedEventHandler().add(
          new WalkToMobEvent(player, affectedMob,
              affectedMob instanceof Npc ? 1 : 2) {
            public void arrived() {
              owner.resetPath();
              owner.resetFollowing();
              boolean cont = false;
              if (affectedMob instanceof Player) {
                Player opp = (Player) affectedMob;

                if (GameEngine.getTime()
                    - opp.getLastMineTimer() < 2000
                    && opp.isBusy())
                  cont = true;
              }
              if (affectedMob instanceof Player) {
                world.addEntryToSnapshots(new Activity(owner
                    .getUsername(), owner.getUsername()
                    + " attacked a Player ("
                    + ((Player) affectedMob).getUsername()
                    + ")"));
              } else {
                world.addEntryToSnapshots(new Activity(owner
                    .getUsername(), owner.getUsername()
                    + " attacked a NPC ("
                    + ((Npc) affectedMob).getDef().name
                    + ")"));
              }
              if (cont) {
                if (owner.isBusy()
                    || !owner.nextTo(affectedMob)
                    || !owner.checkAttack(affectedMob,
                        false)
                    || owner.getStatus() != Action.ATTACKING_MOB) {
                  return;
                }
              } else {
                if (owner.isBusy()
                    || affectedMob.isBusy()
                    || !owner.nextTo(affectedMob)
                    || !owner.checkAttack(affectedMob,
                        false)
                    || owner.getStatus() != Action.ATTACKING_MOB) {
                  return;
                }
              }
              if (affectedMob.getID() == 35) {
                owner.getActionSender()
                    .sendMessage(
                        "Delrith can not be attacked without the Silverlight sword");
                return;
              }
              if (affectedMob.getID() == 140
                  && affectedMob.getX() > 327
                  && affectedMob.getX() < 335
                  && affectedMob.getY() > 433
                  && affectedMob.getY() < 439) {
                owner.informOfNpcMessage(new ChatMessage(
                    affectedMob, "a curse be upon you",
                    owner));
                for (int i = 0; i < 3; i++) {
                  int stat = owner.getCurStat(i);
                  if (stat < 3)
                    owner.setCurStat(i, 0);
                  else
                    owner.setCurStat(i, stat - 3);
                }
                owner.getActionSender().sendStats();

              }

              owner.resetAll();
              owner.setStatus(Action.FIGHTING_MOB);
              if (affectedMob instanceof Player) {
                Player affectedPlayer = (Player) affectedMob;
                affectedPlayer.resetAll();
                affectedPlayer.setStatus(Action.FIGHTING_MOB);
                affectedPlayer.getActionSender().sendSound(
                    "underattack");
                affectedPlayer.getActionSender().sendMessage(
                    "You are under attack!");
                owner.setSkulledOn(affectedPlayer);
              }
              affectedMob.resetPath();

              owner.setLocation(affectedMob.getLocation(), true);
              for (Player p : owner.getViewArea()
                  .getPlayersInView()) {
                p.removeWatchedPlayer(owner);
              }

              owner.setBusy(true);
              owner.setSprite(9);
              /*
               * if(affectedMob instanceof Npc) { Npc n =
               * (Npc)affectedMob; for(Fighter p : n.fighters) {
               * p.useCombat = true; if(p.player == owner)
               * if(p.useMagic) { p.useMagic = false; break; } } }
               */
              owner.setOpponent(affectedMob);
              owner.setCombatTimer();
              affectedMob.setBusy(true);
              affectedMob.setSprite(8);
              affectedMob.setOpponent(owner);
              affectedMob.setCombatTimer();
              FightEvent fighting = new FightEvent(owner,
                  affectedMob);
              fighting.setLastRun(0);
              Instance.getDelayedEventHandler().add(fighting);
            }
          });
    } else {
      if (!new ProjectilePath(player.getX(), player.getY(),
          affectedMob.getX(), affectedMob.getY()).isValid()) {
        player.getActionSender().sendMessage(
            "I can't get a clear shot from here");
        player.resetPath();
        return;
      }
      if (Config.f2pWildy && player.getLocation().inWilderness()) {

        for (InvItem i : player.getInventory().getItems()) {
          if (i.id == 638 || i.id == 640 || i.id == 642
              || i.id == 644 || i.id == 646) {
            player.getActionSender()
                .sendMessage(
                    "You can not have any P2P arrows in your inventory in a F2P wilderness");
            return;
          }
        }

      }
      int radius = 7;
      if (player.getRangeEquip() == 59 || player.getRangeEquip() == 60)
        radius = 5;
      if (player.getRangeEquip() == 189)
        radius = 4;
      Instance.getDelayedEventHandler().add(
          new WalkToMobEvent(player, affectedMob, radius) {
            public void arrived() {
              owner.resetPath();
              if (owner.isBusy()
                  || !owner.checkAttack(affectedMob, true)
                  || owner.getStatus() != Action.ATTACKING_MOB) {
View Full Code Here


          player.getActionSender().sendPrayers();
          affectedPlayer.getActionSender().sendPrayers();
        }

        player.setFollowing(affectedPlayer);
        WalkToMobEvent walking = new WalkToMobEvent(player,
            affectedPlayer, 1) {
          public void arrived() {
            Instance.getDelayedEventHandler().add(
                new SingleEvent(owner, 300) {
                  public void action() {
                    Player affectedPlayer = (Player) affectedMob;
                    owner.resetPath();
                    if (!owner.nextTo(affectedPlayer)) {
                      unsetOptions(owner);
                      unsetOptions(affectedPlayer);
                      return;
                    }
                    affectedPlayer.resetPath();

                    owner.resetAllExceptDueling();
                    affectedPlayer.resetAllExceptDueling();

                    owner.setLocation(
                        affectedPlayer.getLocation(),
                        true);
                    for (Player p : owner.getViewArea()
                        .getPlayersInView()) {
                      p.removeWatchedPlayer(owner);
                    }

                    owner.setSprite(9);
                    owner.setOpponent(affectedMob);
                    owner.setCombatTimer();

                    affectedPlayer.setSprite(8);
                    affectedPlayer.setOpponent(owner);
                    affectedPlayer.setCombatTimer();

                    Player attacker, opponent;
                    if (owner.getCombatLevel() > affectedPlayer
                        .getCombatLevel()) {
                      attacker = affectedPlayer;
                      opponent = owner;
                    } else if (affectedPlayer
                        .getCombatLevel() > owner
                        .getCombatLevel()) {
                      attacker = owner;
                      opponent = affectedPlayer;
                    } else if (DataConversions.random(0, 1) == 1) {
                      attacker = owner;
                      opponent = affectedPlayer;
                    } else {
                      attacker = affectedPlayer;
                      opponent = owner;
                    }
                    DuelEvent dueling = new DuelEvent(
                        attacker, opponent);
                    dueling.setLastRun(0);
                    Instance.getDelayedEventHandler().add(
                        dueling);
                  }
                });
          }

          public void failed() {
            Player affectedPlayer = (Player) affectedMob;
            owner.getActionSender().sendMessage(
                "Error walking to "
                    + affectedPlayer.getUsername()
                    + " (known bug)");
            affectedPlayer.getActionSender().sendMessage(
                "Error walking to " + owner.getUsername()
                    + " (known bug)");
            unsetOptions(owner);
            unsetOptions(affectedPlayer);
            owner.setBusy(false);
            affectedPlayer.setBusy(false);
          }
        };
        walking.setLastRun(GameEngine.getTime() + 500);
        Instance.getDelayedEventHandler().add(walking);
      }
      break;
    case 35: // Decline duel
      affectedPlayer = player.getWishToDuel();
View Full Code Here

        + affectedNpc.getX() + "/" + affectedNpc.getY()));

    player.setFollowing(affectedNpc);
    player.setStatus(Action.TALKING_MOB);
    Instance.getDelayedEventHandler().add(
        new WalkToMobEvent(player, affectedNpc, 1) {
          public void arrived() {
            owner.resetFollowing();
            owner.resetPath();
            if (owner.isBusy() || owner.isRanging()
                || !owner.nextTo(affectedNpc)
View Full Code Here

      return;
    }
    player.setFollowing(affectedMob);
    player.setStatus(Action.CASTING_MOB);
    Instance.getDelayedEventHandler().add(
        new WalkToMobEvent(player, affectedMob, 5) {
          public void arrived() {
            if (!new ProjectilePath(owner.getX(), owner.getY(),
                affectedMob.getX(), affectedMob.getY())
                .isValid()) {
              owner.getActionSender().sendMessage(
View Full Code Here

        + affectedPlayer.getY()));

    player.setFollowing(affectedPlayer);
    player.setStatus(Action.USING_INVITEM_ON_PLAYER);
    Instance.getDelayedEventHandler().add(
        new WalkToMobEvent(player, affectedPlayer, 1) {
          public void arrived() {
            owner.resetPath();
            owner.resetFollowing();
            if (!owner.getInventory().contains(item.id)
                || !owner.nextTo(affectedPlayer)
View Full Code Here

        + player.getY()));

    player.setFollowing(affectedNpc);
    player.setStatus(Action.USING_INVITEM_ON_NPC);
    Instance.getDelayedEventHandler().add(
        new WalkToMobEvent(player, affectedNpc, 1) {
          public void arrived() {
            owner.resetPath();
            owner.resetFollowing();
            if (!owner.getInventory().contains(item.id)
                || owner.isBusy()
View Full Code Here

TOP

Related Classes of org.moparscape.msc.gs.event.WalkToMobEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.