Tryskell

return

Aug 30th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.52 KB | None | 0 0
  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 version.
  5.  *
  6.  * This program is distributed in the hope that it will be useful, but WITHOUT
  7.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8.  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9.  *
  10.  * You should have received a copy of the GNU General Public License along with
  11.  * this program. If not, see <http://www.gnu.org/licenses/>.
  12.  */
  13. package quests.Q001_LettersOfLove;
  14.  
  15. import net.sf.l2j.gameserver.model.actor.L2Npc;
  16. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  17. import net.sf.l2j.gameserver.model.quest.Quest;
  18. import net.sf.l2j.gameserver.model.quest.QuestState;
  19.  
  20. public class Q001_LettersOfLove extends Quest
  21. {
  22.     private static final String qn = "Q001_LettersOfLove";
  23.    
  24.     // Npcs
  25.     private final static int DARIN = 30048;
  26.     private final static int ROXXY = 30006;
  27.     private final static int BAULRO = 30033;
  28.    
  29.     // Items
  30.     private final static int DARINGS_LETTER = 687;
  31.     private final static int RAPUNZELS_KERCHIEF = 688;
  32.     private final static int DARINGS_RECEIPT = 1079;
  33.     private final static int BAULROS_POTION = 1080;
  34.    
  35.     // Reward
  36.     private final static int NECKLACE = 906;
  37.    
  38.     public Q001_LettersOfLove(int questId, String name, String descr)
  39.     {
  40.         super(questId, name, descr);
  41.        
  42.         questItemIds = new int[]
  43.         {
  44.             DARINGS_LETTER,
  45.             RAPUNZELS_KERCHIEF,
  46.             DARINGS_RECEIPT,
  47.             BAULROS_POTION
  48.         };
  49.        
  50.         addStartNpc(DARIN);
  51.         addTalkId(DARIN, ROXXY, BAULRO);
  52.     }
  53.    
  54.     @Override
  55.     public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  56.     {
  57.         QuestState st = player.getQuestState(qn);
  58.         if (st == null)
  59.             return event;
  60.        
  61.         if (event.equalsIgnoreCase("30048-06.htm"))
  62.         {
  63.             st.set("cond", "1");
  64.             st.setState(Quest.STATE_STARTED);
  65.             st.giveItems(DARINGS_LETTER, 1);
  66.             st.playSound(QuestState.SOUND_ACCEPT);
  67.         }
  68.        
  69.         return event;
  70.     }
  71.    
  72.     @Override
  73.     public String onTalk(L2Npc npc, L2PcInstance player)
  74.     {
  75.         QuestState st = player.getQuestState(qn);
  76.         if (st == null)
  77.             return getNoQuestMsg();
  78.        
  79.         switch (st.getState())
  80.         {
  81.             case Quest.STATE_CREATED:
  82.             {
  83.                 if (player.getLevel() >= 2)
  84.                     return "30048-02.htm";
  85.                
  86.                 st.exitQuest(true);
  87.                 return "30048-01.htm";
  88.             }
  89.            
  90.             case Quest.STATE_STARTED:
  91.             {
  92.                 int cond = st.getInt("cond");
  93.                 switch (npc.getNpcId())
  94.                 {
  95.                     case DARIN:
  96.                     {
  97.                         if (cond == 1)
  98.                             return "30048-07.htm";
  99.                        
  100.                         if (cond == 2 && st.getQuestItemsCount(RAPUNZELS_KERCHIEF) == 1)
  101.                         {
  102.                             st.takeItems(RAPUNZELS_KERCHIEF, 1);
  103.                             st.giveItems(DARINGS_RECEIPT, 1);
  104.                             st.set("cond", "3");
  105.                             st.playSound(QuestState.SOUND_MIDDLE);
  106.                             return "30048-08.htm";
  107.                         }
  108.                        
  109.                         if (cond == 3)
  110.                             return "30048-09.htm";
  111.                        
  112.                         if (cond == 4 && st.getQuestItemsCount(BAULROS_POTION) == 1)
  113.                         {
  114.                             st.takeItems(BAULROS_POTION, 1);
  115.                             st.giveItems(NECKLACE, 1);
  116.                             st.playSound(QuestState.SOUND_FINISH);
  117.                             st.exitQuest(false);
  118.                             return "30048-10.htm";
  119.                         }
  120.                     }
  121.                         break;
  122.                    
  123.                     case ROXXY:
  124.                     {
  125.                         if (cond == 1 && st.getQuestItemsCount(RAPUNZELS_KERCHIEF) == 0 && st.getQuestItemsCount(DARINGS_LETTER) > 0)
  126.                         {
  127.                             st.takeItems(DARINGS_LETTER, 1);
  128.                             st.giveItems(RAPUNZELS_KERCHIEF, 1);
  129.                             st.set("cond", "2");
  130.                             st.playSound(QuestState.SOUND_MIDDLE);
  131.                             return "30006-01.htm";
  132.                         }
  133.                        
  134.                         if (cond == 2 && st.getQuestItemsCount(RAPUNZELS_KERCHIEF) > 0)
  135.                             return "30006-02.htm";
  136.                        
  137.                         if (cond > 2 && (st.getQuestItemsCount(BAULROS_POTION) > 0 || st.getQuestItemsCount(DARINGS_RECEIPT) > 0))
  138.                             return "30006-03.htm";
  139.                     }
  140.                         break;
  141.                    
  142.                     case BAULRO:
  143.                     {
  144.                         if (cond == 3 && st.getQuestItemsCount(DARINGS_RECEIPT) == 1)
  145.                         {
  146.                             st.takeItems(DARINGS_RECEIPT, 1);
  147.                             st.giveItems(BAULROS_POTION, 1);
  148.                             st.set("cond", "4");
  149.                             st.playSound(QuestState.SOUND_MIDDLE);
  150.                             return "30033-01.htm";
  151.                         }
  152.                        
  153.                         if (cond == 4)
  154.                             return "30033-02.htm";
  155.                     }
  156.                         break;
  157.                 }
  158.             }
  159.                 break;
  160.            
  161.             case Quest.STATE_COMPLETED:
  162.                 return Quest.getAlreadyCompletedMsg();
  163.         }
  164.         return null;
  165.     }
  166.    
  167.     public static void main(String[] args)
  168.     {
  169.         new Q001_LettersOfLove(1, qn, "Letters of Love");
  170.     }
  171. }
Advertisement
Add Comment
Please, Sign In to add comment