Tryskell

FrenzyOnAttack

Feb 6th, 2013
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.35 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 ai.group;
  16.  
  17. import ai.AbstractNpcAI;
  18.  
  19. import net.sf.l2j.gameserver.datatables.SkillTable;
  20. import net.sf.l2j.gameserver.model.L2Skill;
  21. import net.sf.l2j.gameserver.model.actor.L2Npc;
  22. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  23. import net.sf.l2j.util.Rnd;
  24.  
  25. /**
  26.  * Frenzy behavior, so far 5 types of orcs.<br>
  27.  * Few others monsters got that skillid, need to investigate later :
  28.  * <ul>
  29.  * <li>Halisha's Officer</li>
  30.  * <li>Executioner of Halisha</li>
  31.  * <li>Alpine Kookaburra</li>
  32.  * <li>Alpine Buffalo</li>
  33.  * <li>Alpine Cougar</li>
  34.  * </ul>
  35.  * @author Tryskell
  36.  */
  37. public class FrenzyOnAttack extends AbstractNpcAI
  38. {
  39.     private static final L2Skill ULTIMATE_BUFF = SkillTable.getInstance().getInfo(4318, 1);
  40.    
  41.     private static final String[] ORCS_WORDS =
  42.     {
  43.         "Dear ultimate power!!!",
  44.         "The battle has just begun!",
  45.         "I never thought I'd use this against a novice!",
  46.         "You won't take me down easily."
  47.     };
  48.    
  49.     public FrenzyOnAttack(String name, String descr)
  50.     {
  51.         super(name, descr);
  52.         addAttackId(20270, 20495, 20588, 20778, 21116);
  53.     }
  54.    
  55.     @Override
  56.     public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
  57.     {
  58.         // The only requirements are HPs < 25% and not already under the buff. It's not 100% aswell.
  59.         if (npc.getCurrentHp() / npc.getMaxHp() < 0.25 && npc.getFirstEffect(ULTIMATE_BUFF) == null && Rnd.get(10) == 0)
  60.         {
  61.             npc.broadcastNpcSay(ORCS_WORDS[Rnd.get(ORCS_WORDS.length)]);
  62.             npc.setTarget(npc);
  63.             npc.doCast(ULTIMATE_BUFF);
  64.         }
  65.         return super.onAttack(npc, attacker, damage, isPet);
  66.     }
  67.    
  68.     public static void main(String[] args)
  69.     {
  70.         new FrenzyOnAttack(FrenzyOnAttack.class.getSimpleName(), "ai/group");
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment