Advertisement
GOODPower

Untitled

Dec 1st, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.78 KB | None | 0 0
  1. package quests._604_DaimontheWhiteEyedPart2;
  2.  
  3. import l2n.extensions.scripts.Functions;
  4. import l2n.extensions.scripts.ScriptFile;
  5. import l2n.game.instancemanager.ServerVariables;
  6. import l2n.game.listeners.actor.OnDeathListener;
  7. import l2n.game.model.L2ObjectsStorage;
  8. import l2n.game.model.actor.L2Character;
  9. import l2n.game.model.instances.L2NpcInstance;
  10. import l2n.game.model.quest.Quest;
  11. import l2n.game.model.quest.QuestState;
  12.  
  13. public class _604_DaimontheWhiteEyedPart2 extends Quest implements ScriptFile
  14. {
  15.     private static final class DeathListener implements OnDeathListener
  16.     {
  17.         static final DeathListener STATIC_INSTANCE = new DeathListener();
  18.  
  19.         /*
  20.          * (non-Javadoc)
  21.          * @see l2n.game.listeners.actor.OnDeathListener#onDeath(l2n.game.model.actor.L2Character, l2n.game.model.actor.L2Character)
  22.          */
  23.         @Override
  24.         public void onDeath(L2Character actor, L2Character killer)
  25.         {
  26.             ServerVariables.set(_604_DaimontheWhiteEyedPart2.class.getSimpleName(), String.valueOf(System.currentTimeMillis()));
  27.         }
  28.     }
  29.  
  30.     // NPC
  31.     private static final int EYE = 31683;
  32.     private static final int ALTAR = 31541;
  33.     // MOBS
  34.     private static final int DAIMON = 25290;
  35.     // ITEMS
  36.     private static final int U_SUMMON = 7192;
  37.     private static final int S_SUMMON = 7193;
  38.     private static final int ESSENCE = 7194;
  39.  
  40.     // REWARDS dye +2int-2men/+2int-2wit/+2men-2int/+2men-2wit/+2wit-2int/+2wit-2men
  41.     private static final int INT_MEN = 4595;
  42.     private static final int INT_WIT = 4596;
  43.     private static final int MEN_INT = 4597;
  44.     private static final int MEN_WIT = 4598;
  45.     private static final int WIT_INT = 4599;
  46.     private static final int WIT_MEN = 4600;
  47.  
  48.     private final static long RAIDBOSS_RESPAWN = 3 * 60 * 60 * 1000;
  49.  
  50.     @Override
  51.     public void onReload()
  52.     {}
  53.  
  54.     @Override
  55.     public void onShutdown()
  56.     {}
  57.  
  58.     public _604_DaimontheWhiteEyedPart2()
  59.     {
  60.         super(604, 1);
  61.         addStartNpc(EYE);
  62.         addTalkId(EYE);
  63.         addTalkId(ALTAR);
  64.         addKillId(DAIMON);
  65.     }
  66.  
  67.     @Override
  68.     public String onEvent(final String event, final QuestState st, final L2NpcInstance npc)
  69.     {
  70.         L2NpcInstance isQuest = L2ObjectsStorage.getByNpcId(DAIMON);
  71.         String htmltext = event;
  72.         if(event.equalsIgnoreCase("31683-02.htm"))
  73.         {
  74.             if(st.getPlayer().getLevel() < 73)
  75.             {
  76.                 htmltext = "31683-00b.htm";
  77.                 st.exitCurrentQuest(true);
  78.             }
  79.             else
  80.             {
  81.                 st.set("cond", "1");
  82.                 st.setState(STARTED);
  83.                 st.takeItems(U_SUMMON, 1);
  84.                 st.giveItems(S_SUMMON, 1);
  85.                 st.playSound(SOUND_ACCEPT);
  86.             }
  87.         }
  88.         else if(event.equalsIgnoreCase("31541-02.htm"))
  89.         {
  90.             if(st.getQuestItemsCount(S_SUMMON) == 0)
  91.                 htmltext = "31541-04.htm";
  92.             if(isQuest != null)
  93.                 return "31541-03.htm";
  94.             if(ServerVariables.getLong(_604_DaimontheWhiteEyedPart2.class.getSimpleName(), 0) + RAIDBOSS_RESPAWN > System.currentTimeMillis())
  95.                 return "31541-05.htm";
  96.             else
  97.             {
  98.                 isQuest = st.addSpawn(DAIMON, 186320, -43904, -3175);
  99.                 Functions.npcShout(isQuest, "I will crush you!");
  100.                 isQuest.addListener(DeathListener.STATIC_INSTANCE);
  101.                 st.playSound(SOUND_MIDDLE);
  102.                 st.set("cond", "2");
  103.                 st.setState(STARTED);
  104.                 st.getPlayer().sendMessage("Daimon the White-Eyed has despawned in 186320, -43904, -3175");
  105.                 st.startQuestTimer("DAIMON_Fail", 12000000);
  106.             }
  107.         }
  108.         else if(event.equalsIgnoreCase("31683-04.htm"))
  109.         {
  110.             if(st.getQuestItemsCount(ESSENCE) >= 1)
  111.                 htmltext = "list.htm";
  112.             else
  113.             {
  114.                 htmltext = "31683-05.htm";
  115.                 st.exitCurrentQuest(true);
  116.             }
  117.         }
  118.         else if(event.equalsIgnoreCase("INT_MEN"))
  119.         {
  120.             st.giveItems(INT_MEN, 5);
  121.             st.takeItems(ESSENCE, 1);
  122.             st.playSound("ItemSound.quest_finish");
  123.             st.exitCurrentQuest(true);
  124.             htmltext = null;
  125.         }
  126.         else if(event.equalsIgnoreCase("INT_WIT"))
  127.         {
  128.             st.giveItems(INT_WIT, 5);
  129.             st.takeItems(ESSENCE, 1);
  130.             st.playSound("ItemSound.quest_finish");
  131.             st.exitCurrentQuest(true);
  132.             htmltext = null;
  133.         }
  134.         else if(event.equalsIgnoreCase("MEN_INT"))
  135.         {
  136.             st.giveItems(MEN_INT, 5);
  137.             st.takeItems(ESSENCE, 1);
  138.             st.playSound("ItemSound.quest_finish");
  139.             st.exitCurrentQuest(true);
  140.             htmltext = null;
  141.         }
  142.         else if(event.equalsIgnoreCase("MEN_WIT"))
  143.         {
  144.             st.giveItems(MEN_WIT, 5);
  145.             st.takeItems(ESSENCE, 1);
  146.             st.playSound("ItemSound.quest_finish");
  147.             st.exitCurrentQuest(true);
  148.             htmltext = null;
  149.         }
  150.         else if(event.equalsIgnoreCase("WIT_INT"))
  151.         {
  152.             st.giveItems(WIT_INT, 5);
  153.             st.takeItems(ESSENCE, 1);
  154.             st.playSound("ItemSound.quest_finish");
  155.             st.exitCurrentQuest(true);
  156.             htmltext = null;
  157.         }
  158.         else if(event.equalsIgnoreCase("WIT_MEN"))
  159.         {
  160.             st.giveItems(WIT_MEN, 5);
  161.             st.takeItems(ESSENCE, 1);
  162.             st.playSound("ItemSound.quest_finish");
  163.             st.exitCurrentQuest(true);
  164.             htmltext = null;
  165.         }
  166.         else if(event.equalsIgnoreCase("DAIMON_Fail"))
  167.             if(isQuest != null)
  168.                 isQuest.deleteMe();
  169.         return htmltext;
  170.     }
  171.  
  172.     @Override
  173.     public String onTalk(final L2NpcInstance npc, final QuestState st)
  174.     {
  175.         L2NpcInstance isQuest = L2ObjectsStorage.getByNpcId(DAIMON);
  176.         String htmltext = "noquest";
  177.         final int npcId = npc.getNpcId();
  178.         final int cond = st.getInt("cond");
  179.         if(cond == 0)
  180.         {
  181.             if(npcId == EYE)
  182.                 if(st.getQuestItemsCount(U_SUMMON) >= 1)
  183.                     htmltext = "31683-01.htm";
  184.                 else
  185.                     htmltext = "31683-00a.htm";
  186.         }
  187.         else if(cond == 1)
  188.         {
  189.             if(npcId == EYE)
  190.                 htmltext = "31683-02a.htm";
  191.             else if(npcId == ALTAR)
  192.                 if(ServerVariables.getLong(_604_DaimontheWhiteEyedPart2.class.getSimpleName(), 0) + RAIDBOSS_RESPAWN > System.currentTimeMillis())
  193.                     htmltext = "31541-05.htm";
  194.                 else
  195.                     htmltext = "31541-01.htm";
  196.         }
  197.         else if(cond == 2)
  198.         {
  199.             if(npcId == ALTAR)
  200.                 if(isQuest != null)
  201.                     htmltext = "31541-03.htm";
  202.                 else if(ServerVariables.getLong(_604_DaimontheWhiteEyedPart2.class.getSimpleName(), 0) + RAIDBOSS_RESPAWN > System.currentTimeMillis())
  203.                     htmltext = "31541-05.htm";
  204.                 else
  205.                 {
  206.                     isQuest = st.addSpawn(DAIMON, 186320, -43904, -3175);
  207.                     isQuest.addListener(DeathListener.STATIC_INSTANCE);
  208.                     Functions.npcShout(isQuest, "I will crush you!");
  209.                     st.playSound(SOUND_MIDDLE);
  210.                     st.setState(STARTED);
  211.                     st.getPlayer().sendMessage("Daimon the White-Eyed has despawned in 186320, -43904, -3175");
  212.                     st.startQuestTimer("DAIMON_Fail", 12000000);
  213.                 }
  214.         }
  215.         else if(cond == 3)
  216.         {
  217.             if(npcId == EYE)
  218.                 if(st.getQuestItemsCount(ESSENCE) >= 1)
  219.                     htmltext = "31683-03.htm";
  220.                 else
  221.                     htmltext = "31683-06.htm";
  222.             if(npcId == ALTAR)
  223.                 htmltext = "31541-05.htm";
  224.         }
  225.         return htmltext;
  226.     }
  227.  
  228.     @Override
  229.     public String onKill(final L2NpcInstance npc, final QuestState st)
  230.     {
  231.         if(st.getQuestItemsCount(S_SUMMON) > 0)
  232.         {
  233.             st.takeItems(S_SUMMON, 1);
  234.             st.giveItems(ESSENCE, 1);
  235.             st.set("cond", "3");
  236.             st.setState(STARTED);
  237.             st.playSound("ItemSound.quest_middle");
  238.         }
  239.         return null;
  240.     }
  241. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement