Exemple #1
0
 /**
  * Refreshes the action bar.
  *
  * @param slot The slots to refresh.
  */
 public void refresh(int... slot) {
   int maskData = (barIndex + 1) << 5;
   if (locked) {
     maskData |= 0x10; // 35651680 //35651696 // bar 3
   }
   player.getVars().setVarValueInt(682, maskData);
   if (slot.length < 1) {
     slot = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
   }
   for (int s : slot) {
     Keybind k = getActiveBar().getSlots()[s];
     if (s == 12 || s == 13) {
       player.getVars().setVarValueInt(s == 12 ? 4413 : 4414, k != null ? k.getClientId() : 0);
       player.getVars().setVarValueInt(s == 12 ? 4427 : 4428, k != null ? k.getItemId() : -1);
     } else {
       player.getVars().setVarValueInt(727 + s, k != null ? k.getClientId() : 0);
       player.getVars().setVarValueInt(751 + s, 0);
       player.getVars().setVarValueInt(811 + s, k != null ? k.getItemId() : -1);
       player.getVars().setVarValueInt(835 + s, -1);
     } // 2097152			   2195454   11108350
     player
         .getDispatcher()
         .sendWidgetEvents(
             1430, SLOT_CHILD_IDS[s], -1, -1, k == null ? 2098176 : (locked ? 2195454 : 11108350));
   }
   player.getVars().setVarValueInt(679, player.getCombatSchedule().getAdrenaline() * 10);
 }
Exemple #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;
 }
Exemple #3
0
 /**
  * Performs an keybind action.
  *
  * @param slot The keybind slot.
  */
 public void perform(int slot) {
   Keybind bind = getActiveBar().getSlots()[slot];
   if (bind != null) {
     if (bind.getItemId() > 0) {
       // TODO: Item bound action.
     } else {
       Ability ability = ABILITIES.get(bind.getAbilityId());
       if (ability == null) {
         player
             .getDispatcher()
             .sendGameMessage(
                 "Unhandled ability [slot=" + slot + ", id=" + bind.getAbilityId() + "]!");
         return;
       }
       player.getCombatSchedule().run(ability);
     }
   }
 }