Don't like ads? PRO users don't see any ads ;-)

L2j Noblesse Manager

By: Gladicek on May 2nd, 2012  |  syntax: Java  |  size: 3.00 KB  |  hits: 139  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  * This program is free software: you can redistribute it and/or modify it under
  3.  * the terms of the GNU General Public License as published by the Free Software
  4.  * Foundation, either version 3 of the License, or (at your option) any later
  5.  * version.
  6.  *
  7.  * This program is distributed in the hope that it will be useful, but WITHOUT
  8.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9.  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10.  * details.
  11.  *
  12.  * You should have received a copy of the GNU General Public License along with
  13.  * this program. If not, see <http://www.gnu.org/licenses/>.
  14.  */
  15. package custom.NoblesseManager;
  16.  
  17. import com.l2jserver.gameserver.model.actor.L2Npc;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.model.quest.Quest;
  20. import com.l2jserver.gameserver.model.quest.QuestState;
  21. import com.l2jserver.gameserver.instancemanager.QuestManager;
  22. import com.l2jserver.gameserver.network.serverpackets.UserInfo;
  23.  
  24. /*********************************
  25.  * @author Gladicek              *
  26.  * Custom Npc 'Noblesse Manager' *
  27.  ********************************/
  28.  
  29.   public class NoblesseManager extends Quest
  30. {
  31.   // Npc
  32.         private static final int NpcId = 49296; // Custom Npc
  33.   // Item
  34.   private static final int ItemId = 6673; // Festival Adena
  35.   private static final int NOBLESS_TIARA = 7694;
  36.   // Level check
  37.   private static final int LEVEL = 75;
  38.  
  39.         public NoblesseManager(int questId, String name, String descr)
  40.         {
  41.                 super(questId, name, descr);
  42.                 addStartNpc(NpcId);
  43.     addFirstTalkId(NpcId);
  44.     addTalkId(NpcId);
  45.         }
  46.  
  47.         @Override
  48.         public String onFirstTalk(L2Npc npc, L2PcInstance player)
  49.         {
  50.                 QuestState st = player.getQuestState(getName());
  51.                 if (st == null)
  52.                 {
  53.                         Quest q = QuestManager.getInstance().getQuest(getName());
  54.                         st = q.newQuestState(player);
  55.     }  
  56.                 return "49296.htm";          
  57.         }
  58.  
  59.         @Override
  60.         public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  61.         {
  62.                 String htmltext = event;
  63.                 final QuestState st = player.getQuestState(getName());
  64.    
  65.                 if (event.equalsIgnoreCase("noblesse"))
  66.                 {    
  67.       if (st.getQuestItemsCount(ItemId) >= 10 && player.getLevel() >= LEVEL)  // 10x Festival Adena  and "LEVEL" check
  68.       {
  69.         st.takeItems(ItemId,10);
  70.         player.setNoble(!player.isNoble());
  71.         st.giveItems(NOBLESS_TIARA,1);      
  72.         player.sendPacket(new UserInfo(player));
  73.         player.sendMessage("Congratulations! You are now Noblesse!");
  74.         return null;            
  75.       }
  76.       else
  77.         return "49296-no.htm";      
  78.      }
  79.            else if (event.equalsIgnoreCase("49296-1.htm"))    
  80.      {
  81.        if (player.isNoble())
  82.        {
  83.          return "49296-already.htm";
  84.        }
  85.      }
  86.      return htmltext;
  87.    }
  88.    
  89.         public static void main(String[] args)
  90.         {
  91.                 new NoblesseManager(-1, "NoblesseManager", "custom");
  92.     _log.info("NoblesseManager: Loaded successfully.");    
  93.         }
  94. }