Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. 1   package npc.model.residences.fortress;
  2. 2  
  3. 3   import org.mmocore.commons.dao.JdbcEntityState;
  4. 4   import org.mmocore.gameserver.data.xml.holder.NpcHolder;
  5. 5   import org.mmocore.gameserver.model.Player;
  6. 6   import org.mmocore.gameserver.model.entity.residence.Fortress;
  7. 7   import org.mmocore.gameserver.model.instances.NpcInstance;
  8. 8   import org.mmocore.gameserver.scripts.Functions;
  9. 9   import org.mmocore.gameserver.serverpackets.NpcHtmlMessage;
  10. 10  import org.mmocore.gameserver.templates.npc.NpcTemplate;
  11. 11  import org.mmocore.gameserver.utils.Location;
  12. 12 
  13. 13  /**
  14. 14   * @author VISTALL
  15. 15   */
  16. 16  public class LogisticsOfficerInstance extends FacilityManagerInstance {
  17. 17      private static final int[] SUPPLY_NPC = new int[]
  18. 18              {
  19. 19                      35665,
  20. 20                      35697,
  21. 21                      35734,
  22. 22                      35766,
  23. 23                      35803,
  24. 24                      35834
  25. 25              };
  26. 26 
  27. 27      private static final int ITEM_ID = 9910; // Blood Oath
  28. 28 
  29. 29      public LogisticsOfficerInstance(int objectId, NpcTemplate template) {
  30. 30          super(objectId, template);
  31. 31      }
  32. 32 
  33. 33      @Override
  34. 34      public void onBypassFeedback(Player player, String command) {
  35. 35          if (!canBypassCheck(player, this))
  36. 36              return;
  37. 37 
  38. 38          Fortress fortress = getFortress();
  39. 39 
  40. 40          if (!player.isClanLeader() || fortress.getOwnerId() != player.getClanId()) {
  41. 41              showChatWindow(player, "residence2/fortress/fortress_not_authorized.htm");
  42. 42              return;
  43. 43          }
  44. 44 
  45. 45          if (command.equalsIgnoreCase("guardInfo")) {
  46. 46              if (fortress.getContractState() != Fortress.CONTRACT_WITH_CASTLE) {
  47. 47                  showChatWindow(player, "residence2/fortress/fortress_supply_officer005.htm");
  48. 48                  return;
  49. 49              }
  50. 50 
  51. 51              showChatWindow(player, "residence2/fortress/fortress_supply_officer002.htm", "%guard_buff_level%", fortress.getFacilityLevel(Fortress.GUARD_BUFF));
  52. 52          } else if (command.equalsIgnoreCase("supplyInfo")) {
  53. 53              if (fortress.getContractState() != Fortress.CONTRACT_WITH_CASTLE) {
  54. 54                  showChatWindow(player, "residence2/fortress/fortress_supply_officer005.htm");
  55. 55                  return;
  56. 56              }
  57. 57 
  58. 58              showChatWindow(player, "residence2/fortress/fortress_supply_officer009.htm", "%supply_count%", fortress.getSupplyCount());
  59. 59          } else if (command.equalsIgnoreCase("rewardInfo")) {
  60. 60              showChatWindow(player, "residence2/fortress/fortress_supply_officer010.htm", "%blood_oaths%", fortress.getRewardCount());
  61. 61          } else if (command.equalsIgnoreCase("receiveSupply")) {
  62. 62              String filename;
  63. 63              if (fortress.getSupplyCount() > 0 && player.getVar("supplyBox") == null) {
  64. 64                  filename = "residence2/fortress/fortress_supply_officer016.htm";
  65. 65 
  66. 66                  NpcInstance npc = NpcHolder.getInstance().getTemplate(SUPPLY_NPC[fortress.getSupplyCount() - 1]).getNewInstance();
  67. 67                  npc.setCurrentHpMp(npc.getMaxHp(), npc.getMaxMp());
  68. 68                  npc.spawnMe(new Location(getX() - 23, getY() + 41, getZ()));
  69. 69                  player.setVar("supplyBox", "LogisticsOfficerFort", 43200000);
  70. 70              } else
  71. 71                  filename = "residence2/fortress/fortress_supply_officer017.htm";
  72. 72 
  73. 73              NpcHtmlMessage html = new NpcHtmlMessage(player, this);
  74. 74              html.setFile(filename);
  75. 75              player.sendPacket(html);
  76. 76          } else if (command.equalsIgnoreCase("receiveRewards")) {
  77. 77              String filename;
  78. 78              int count = fortress.getRewardCount();
  79. 79              if (count > 0) {
  80. 80                  filename = "residence2/fortress/fortress_supply_officer013.htm";
  81. 81                  fortress.setRewardCount(0);
  82. 82                  fortress.setJdbcState(JdbcEntityState.UPDATED);
  83. 83                  fortress.update();
  84. 84 
  85. 85                  Functions.addItem(player, ITEM_ID, count);
  86. 86              } else
  87. 87                  filename = "residence2/fortress/fortress_supply_officer014.htm";
  88. 88 
  89. 89              NpcHtmlMessage html = new NpcHtmlMessage(player, this);
  90. 90              html.setFile(filename);
  91. 91              player.sendPacket(html);
  92. 92          } else if (command.equalsIgnoreCase("toLevel1"))
  93. 93              buyFacility(player, Fortress.GUARD_BUFF, 1, 100000);
  94. 94          else if (command.equalsIgnoreCase("toLevel2"))
  95. 95              buyFacility(player, Fortress.GUARD_BUFF, 2, 150000);
  96. 96          else
  97. 97              super.onBypassFeedback(player, command);
  98. 98      }
  99. 99 
  100. 100     @Override
  101. 101     public void showChatWindow(Player player, int val, Object... arg) {
  102. 102         showChatWindow(player, "residence2/fortress/fortress_supply_officer001.htm");
  103. 103     }
  104. 104 }