Ejemplo n.º 1
0
 public boolean isDistanceOption(OptionButton option) {
   if ("Attack".equalsIgnoreCase(getType().op[option.getId() - 1])) {
     return true; // Handle attack targeting using the combat system, rather than the general
                  // interaction
   }
   return OptionButton.SIX.equals(option);
 }
Ejemplo n.º 2
0
 /**
  * Handles an interaction with this npc
  *
  * @param player The player performing the interaction
  * @param option The option selected
  * @return True if the interaction was handled, false otherwise
  */
 public boolean interact(Player player, OptionButton option) {
   if (OptionButton.SIX.equals(option)) {
     NpcType npcType = getType(player);
     if (npcType != null) {
       player.getDispatcher().sendGameMessage(npcType.getDescription());
     } else {
       player.getDispatcher().sendGameMessage(getType().getDescription());
     }
     if (PrivilegeLevel.ADMINISTRATOR.equals(player.getPrivilegeLevel())) {
       player.getDispatcher().sendGameMessage(this.toString());
     }
     return true;
   }
   if ("Attack".equalsIgnoreCase(getType().op[option.getId() - 1])) {
     //			if (!player.getCombat().inCombat()) {
     //				player.getCombat().startCombat(this);
     //			}
     player.getCombatSchedule().lock(this);
     return true;
   }
   ScriptEventType eventType;
   switch (option) {
     case ONE:
       eventType = ScriptEventType.OPNPC1;
       break;
     case TWO:
       eventType = ScriptEventType.OPNPC2;
       break;
     case THREE:
       eventType = ScriptEventType.OPNPC3;
       break;
     case FOUR:
       eventType = ScriptEventType.OPNPC4;
       break;
     case FIVE:
       eventType = ScriptEventType.OPNPC5;
       break;
     default:
       eventType = null;
       break;
   }
   ScriptManager scripts = Virtue.getInstance().getScripts();
   if (eventType != null && scripts.hasBinding(eventType, this.getId())) {
     Map<String, Object> args = new HashMap<>();
     args.put("player", player);
     args.put("npc", this);
     scripts.invokeScriptChecked(eventType, this.getId(), args);
     return true;
   }
   return false;
 }