Gladicek

L2j Event Rabbit Ramapger (Nedokončený)

May 2nd, 2012
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.49 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
  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 events.RabbitRampage;
  16.  
  17. import com.l2jserver.gameserver.instancemanager.QuestManager;
  18. import com.l2jserver.gameserver.model.actor.L2Npc;
  19. import com.l2jserver.gameserver.model.L2Object;
  20. import com.l2jserver.gameserver.model.L2Skill;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  23. import com.l2jserver.gameserver.model.quest.Quest;
  24. import com.l2jserver.gameserver.model.quest.QuestState;
  25. import com.l2jserver.gameserver.model.quest.State;
  26. import com.l2jserver.gameserver.network.SystemMessageId;
  27. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  28. import com.l2jserver.gameserver.network.clientpackets.Say2;
  29. import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  30. import com.l2jserver.gameserver.skills.SkillHolder;
  31. import com.l2jserver.util.Rnd;
  32.  
  33. /**
  34.  ** @author Gladicek
  35.  **
  36.  ** Retail Event : 'Rabbit Rampage'
  37.  *
  38.  * TODO:
  39.  *  2) Retail values for exchange items
  40.  *  4) Rabbits should cast skill which make your head big (like from herb)
  41.  *  5) Need to add all bunnies to script/sql + Huge Pig
  42.  *  8) All monsters should have chance to drop items for event (scrolls/juice)  
  43.  *        
  44.  */
  45.  public class RabbitRampage extends Quest
  46. {
  47.  // Npc (Magic Research Institute Employee
  48.  private static final int MRIE = 153;
  49.  // Skills
  50.  private static final int BUNNY_ANGER_JUICE_SKILL = ; // Skill is not done yet
  51.  private static final int IMPROVED_BUNNY_ANGER_JUICE_SKILL = ; // Skill is not done yet
  52.  // Rabbit skills
  53. // private static final SkillHolder[] SKILLS_DMG_BY_ME = { new SkillHolder(, 1) }; // Skill is not done yet
  54.  // Monsters
  55.  private static final int[] BUNNIES = { 36600 };
  56.  private static final int HUGE_PIG = 13196;
  57.  // Items
  58.  private static final int BUNNY_ANGER_MANAGEMENT_KIT = 22180;
  59.  private static final int BUNNY_PACIFIER_JUICE  = 22181;
  60.  
  61.  private static final int EVENT_APIGA  = 14720;
  62.  private static final int EVENT_GOLDEN_APIGA  = 14721;
  63.  
  64.  // Time
  65.  private static final int _hours = 24;
  66.  
  67.  // Spawns for Npc
  68.    private static final int[][] _spawns =
  69.     {
  70.         {  82766,  149438, -3464, 33865 },
  71.         {  82286,   53291, -1488, 15250 },
  72.         { 147060,   25943, -2008, 18774 },
  73.         { 148096,  -55466, -2728, 40541 },
  74.         {  87116, -141332, -1336, 52193 },
  75.         {  43521,  -47542,  -792, 31655 },
  76.         {  17203,  144949, -3024, 18166 },
  77.         { 111164,  221062, -3544,  2714 },
  78.         { -13869,  122063, -2984, 18270 },
  79.         { -83161,  150915, -3120, 17311 },
  80.         {  45402,   48355, -3056, 49153 },
  81.         { 115616, -177941,  -896, 30708 },
  82.         { -44928, -113608,  -192, 30212 },
  83.         { -84037,  243194, -3728,  8992 },
  84.         {-119690,   44583,   360, 29289 },
  85.         {  12084,   16576, -4584, 57345 }
  86.     };
  87.  
  88.  
  89.     private static final String[] _NOSKILL_TEXT = {
  90.         "Rage level is rising...FEEL MY RAGE!",
  91.     "Wiw! I feel so warm and fuzzy now!",
  92.     "Boy, the next time I feel like going on a rampage I hope you are there",
  93.     "Here comes the furry flurry of fury! *Quick, use the Bunny Pacifier Juice*"
  94.     };
  95.    
  96.     private static final String[] _SKILL_TEXT = {
  97.         "I'm feeling, less angry...what is this witchcraft?",
  98.         "That tickless..I still want you dead.",
  99.         "Feel kind of funny... but also so joyful.",
  100.         "World cannot express my happiness!",
  101.         "I'm on cloud nine!",
  102.     "Squee! Are you a rabbit whisperer %nick%, cause I feel great.",
  103.     "I hope your happy because I'm not. Next time try bringing some friends."
  104.     };
  105.  
  106.   private static final String[] _DEAD_TEXT = {
  107.     "I feel so happy now.",
  108.     "Thanks for taking care of my rage %nick%!",
  109.     "Whew...I need a nap now."
  110.   };
  111.  
  112.   private static final String[] _PIG_TEXT = {
  113.     "Where am I? This doesn't look night at all..Oink oink!",
  114.     "What's going on...How did I get here... Oink oink!"
  115.   };
  116.  
  117.    
  118.   public RabbitRampage(int questId, String name, String descr)
  119.     {
  120.         super(questId, name, descr);
  121.    
  122.         addStartNpc(MRIE);
  123.     addFirstTalkId(MRIE);
  124.         addTalkId(MRIE);
  125.    
  126.         for(int[] _spawn : _spawns)
  127.             addSpawn(MRIE, _spawn[0], _spawn[1], _spawn[2], _spawn[3], false, 0);
  128.      
  129.     for (int i : BUNNIES)
  130.     {
  131.             addKillId(i);
  132.       addAttackId(i);
  133.             addSpawnId(i);
  134.             addSkillSeeId(i);
  135.     }    
  136.     }
  137.  
  138.   @Override
  139.     public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  140.     {
  141.         String htmltext = "";
  142.     Quest q = QuestManager.getInstance().getQuest(getName());
  143.         QuestState st = player.getQuestState(getName());
  144.     htmltext = event;
  145.     int prize;
  146.        
  147.         if (event.equalsIgnoreCase("kit"))
  148.         {
  149.      // Check if player have 2011 Adena = if yes give him bunny anger management kit
  150.             if (st.getQuestItemsCount(57) > 2011)
  151.             {
  152.                 long _curr_time = System.currentTimeMillis();
  153.                 String value = q.loadGlobalQuestVar(player.getAccountName());
  154.                 long _reuse_time = value == "" ? 0 : Long.parseLong(value);
  155.        
  156.                 if (_curr_time > _reuse_time)
  157.                 {
  158.                     st.setState(State.STARTED);
  159.                     st.takeItems(57, 2011);
  160.                     st.giveItems(BUNNY_ANGER_MANAGEMENT_KIT, 1);
  161.                     q.saveGlobalQuestVar(player.getAccountName(), Long.toString(System.currentTimeMillis() + (_hours * 3600000)));
  162.           return null;
  163.                 }
  164.                 else
  165.                 {
  166.                     long remainingTime = (_reuse_time - System.currentTimeMillis()) / 1000;
  167.                     int hours = (int) (remainingTime / 3600);
  168.                     int minutes = (int) ((remainingTime % 3600) / 60);
  169.                     SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.AVAILABLE_AFTER_S1_S2_HOURS_S3_MINUTES);
  170.                     sm.addItemName(BUNNY_ANGER_MANAGEMENT_KIT);
  171.                     sm.addNumber(hours);
  172.                     sm.addNumber(minutes);
  173.                     player.sendPacket(sm);
  174.           return null;
  175.                 }
  176.        }
  177.       else
  178.             {
  179.       // if no = show html 13292-4.htm
  180.        htmltext = "13292-4.htm";
  181.             }
  182.       }
  183.  
  184.     // Check if player have 2011 Adena = if yes give him bunny anger juice  
  185.     else if (event.equalsIgnoreCase("juice"))
  186.     {
  187.      if (st.getQuestItemsCount(57) > 2011)
  188.       {
  189.         st.takeItems(57, 2011);
  190.         st.giveItems(BUNNY_PACIFIER_JUICE, 200);
  191.         return null;
  192.       }
  193.       else
  194.       {
  195.       // if no = show html 13292-4a.htm
  196.         htmltext = "13292-4a.htm";
  197.       }
  198.     }
  199.    
  200.     else if (event.equalsIgnoreCase("goldenapiga"))
  201.     {
  202.     // Check if player have 20 Event Apiga = if yes give him reward
  203.      if (st.getQuestItemsCount(EVENT_GOLDEN_APIGA) > 20)
  204.      {
  205.          st.takeItems(EVENT_GOLDEN_APIGA,20);
  206.                
  207.               prize = Rnd.get(1000);
  208.                 // Need to get retail values and list of all items
  209.                 if (prize <= 100)
  210.                     st.giveItems(22208,1); // 1 - Angry Bunny Necklace Box
  211.                 else if (prize <= 100)
  212.                     st.giveItems(22209,1); // 1 - Angry Bunny Earring Box
  213.                 else if (prize <= 100)
  214.                     st.giveItems(22210,1); // 1 - Angry Bunny Ring Box
  215.                 else if (prize <= 50)
  216.                     st.giveItems(22206,1); // 1 - Soul Crystal - Stage 17 Box
  217.               else if (prize <= 50)
  218.                     st.giveItems(22207,1); // 1 - Soul Crystal - Stage 18 Box
  219.                 else if (prize <= 100)
  220.                     st.giveItems(22205,1); // 1 - Attribute Crystal Box
  221.                 else if (prize <= 350)
  222.                     st.giveItems(8752,1); // 1 - High-Grade 76 Life Stone
  223.               else if (prize <= 300)
  224.                     st.giveItems(9575,1); // 1 - High-Grade 80 Life Stone
  225.               else if (prize <= 250)
  226.                     st.giveItems(10485,1); // 1 - High-Grade 82 Life Stone
  227.               else if (prize <= 200)
  228.                     st.giveItems(8762,1); // 1 - Top-Grade 76 Life Stone
  229.               else if (prize <= 150)
  230.                     st.giveItems(9576,1); // 1 - Top-Grade 80 Life Stone  
  231.               else if (prize <= 100)
  232.                     st.giveItems(10486,1); // 1 - Top-Grade 82 Life Stone                                                                                                                                                                        
  233.                 else if (prize <= 100)
  234.                     st.giveItems(2134,2); // 2 - Gemstone S
  235.             return null;      
  236.             }
  237.             else
  238.       // if no = show html 13292-6.htm
  239.                 htmltext = "13292-6.htm";      
  240.       }
  241.     else if (event.equalsIgnoreCase("apiga"))
  242.     {
  243.      if (st.getQuestItemsCount(EVENT_APIGA) > 10)
  244.      {
  245.        st.takeItems(EVENT_APIGA,10);
  246.  
  247.               prize = Rnd.get(1000);
  248.                 // Need to get retail values and list of all items
  249.                 if (prize <= 100)
  250.                     st.giveItems(22208,1); // 1 - Angry Bunny Necklace Box
  251.                 else if (prize <= 100)
  252.                     st.giveItems(22209,1); // 1 - Angry Bunny Earring Box
  253.             return null;      
  254.      }
  255.       else
  256.       // if no = show html 13292-7.htm
  257.                 htmltext = "13292-7.htm";      
  258.     }                          
  259.      return htmltext;
  260.     }
  261.    
  262.    @Override
  263.    public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
  264.   {  
  265.             L2Object trg = caster.getTarget();
  266.             if (trg != null && trg.getObjectId() == npc.getObjectId())
  267.             {
  268.                 if (skill.getId() == BUNNY_ANGER_JUICE_SKILL)
  269.                 {
  270.                  if(Rnd.get(100) < 10)
  271.                   {
  272.                         npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.ALL, npc.getName(), _SKILL_TEXT[Rnd.get(_SKILL_TEXT.length)].replaceAll("%nick%", caster.getName())));
  273.                               npc.setIsInvul(false);
  274.                               npc.getStatus().reduceHp(1000, caster);
  275.                       return null;
  276.                   }    
  277.                 }
  278.                 else if (skill.getId() == IMPROVED_BUNNY_ANGER_JUICE_SKILL)
  279.                 {
  280.                  if(Rnd.get(100) < 10)
  281.                   {                
  282.                         npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.ALL, npc.getName(), _SKILL_TEXT[Rnd.get(_SKILL_TEXT.length)].replaceAll("%nick%", caster.getName())));
  283.                               npc.setIsInvul(false);
  284.                       npc.setTarget(attacker);
  285.                               npc.getStatus().reduceHp(5000, caster);
  286.                               return null;
  287.                      
  288.                      
  289.                   }                      
  290.                 }
  291.                 else
  292.                 {
  293.                  if(Rnd.get(100) < 20)
  294.                   {                
  295.                             npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.ALL, npc.getName(), _NOSKILL_TEXT[Rnd.get(_NOSKILL_TEXT.length)]));
  296.                               npc.setIsInvul(true);
  297.                               return null;
  298.                   }    
  299.                 }
  300.              }
  301.         return super.onSkillSee(npc, caster, skill, targets, isPet);
  302.     }
  303.  
  304.  
  305.   @Override
  306.   public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
  307.     {      
  308.         for(int npcId : BUNNIES)
  309.         {
  310.      // if player is trying to attack rabbit without skill -> set rabbit invulnerable
  311.      if (npc.getNpcId() == npcId)
  312.       {
  313.        // if dd is pet set npc invul.
  314.              if(isPet)
  315.               {
  316.           if(Rnd.get(100) < 20)
  317.           {        
  318.             npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.ALL, npc.getName(), _NOSKILL_TEXT[Rnd.get(_NOSKILL_TEXT.length)]));
  319.                     npc.setIsInvul(true);              
  320.                     return null;
  321.                 }            
  322.               }
  323.             npc.setTarget(attacker);
  324.           npc.setIsInvul(true);      
  325.        if(Rnd.get(100) < 20)
  326.        {        
  327.          npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.ALL, npc.getName(), _NOSKILL_TEXT[Rnd.get(_NOSKILL_TEXT.length)]));
  328.                return null;
  329.        }
  330.       }
  331.     }
  332.         return super.onAttack(npc, attacker, damage, isPet);
  333.     }
  334.    
  335.    @Override
  336.    public String onKill (L2Npc npc, L2PcInstance killer, boolean isPet)
  337.    {      
  338.       dropItem(npc, killer);
  339.       npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.ALL, npc.getName(), _DEAD_TEXT[Rnd.get(_DEAD_TEXT.length)].replaceAll("%nick%", killer.getName())));
  340.         // 10% chance to get spawn for Huge Pig
  341.       if(Rnd.get(100) < 90)
  342.       {
  343.         L2MonsterInstance monster = (L2MonsterInstance) addSpawn(HUGE_PIG, npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 60000);
  344.         monster.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.ALL, npc.getName(), _PIG_TEXT[Rnd.get(_PIG_TEXT.length)]));      
  345.         return null;
  346.       }
  347.       return super.onKill(npc, killer, isPet);
  348.    }
  349.            
  350.        
  351.     @Override
  352.     public String onFirstTalk(L2Npc npc, L2PcInstance player)
  353.     {
  354.         QuestState st = player.getQuestState(getName());
  355.         if (st == null)
  356.         {
  357.             Quest q = QuestManager.getInstance().getQuest(getName());
  358.             st = q.newQuestState(player);
  359.         }
  360.         return "153.htm";
  361.     }
  362.  
  363.   public static void main(String[] args)
  364.     {
  365.         new RabbitRampage(-1, "RabbitRampage", "events");
  366.     _log.info("Event - Rabbit Rampage is now active! *Created by Gladicek*");
  367.     }
  368. }
Advertisement
Add Comment
Please, Sign In to add comment