Example #1
0
 @Override
 public String onAggroRangeEnter(L2NpcInstance npc, L2PcInstance player, boolean isPet) {
   int npcId = npc.getNpcId();
   if (npcId == ZAKEN) {
     if (_Zone.isInsideZone(npc)) {
       L2Character target = isPet ? player.getPet() : player;
       ((L2Attackable) npc).addDamageHate(target, 1, 200);
     }
     if (player.getZ() > (npc.getZ() - 100) && player.getZ() < (npc.getZ() + 100)) {
       if (_quest0 < 5 && Rnd.get(3) < 1) {
         if (_quest0 == 0) {
           c_quest0 = player;
         } else if (_quest0 == 1) {
           c_quest1 = player;
         } else if (_quest0 == 2) {
           c_quest2 = player;
         } else if (_quest0 == 3) {
           c_quest3 = player;
         } else if (_quest0 == 4) {
           c_quest4 = player;
         }
         _quest0++;
       }
       if (Rnd.get(15) < 1) {
         int i0 = Rnd.get((15 * 15));
         if (i0 < 1) {
           npc.setTarget(player);
           npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
         } else if (i0 < 2) {
           npc.setTarget(player);
           npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
         } else if (i0 < 4) {
           npc.setTarget(player);
           npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
         } else if (i0 < 8) {
           npc.setTarget(player);
           npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
         } else if (i0 < 15) {
           for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100)) {
             if (character != player) continue;
             if (player != ((L2Attackable) npc).getMostHated()) {
               npc.setTarget(player);
               npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
             }
           }
         }
         if (Rnd.get(2) < 1) {
           if (player == ((L2Attackable) npc).getMostHated()) {
             npc.setTarget(player);
             npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
           }
         }
       }
     }
   }
   return super.onAggroRangeEnter(npc, player, isPet);
 }
Example #2
0
 @Override
 public String onAttack(L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet) {
   int npcId = npc.getNpcId();
   if (npcId == ZAKEN) {
     if (attacker.getMountType() == 1) {
       int sk_4258 = 0;
       L2Effect[] effects = attacker.getAllEffects();
       if (effects != null && effects.length != 0) {
         for (L2Effect e : effects) {
           if (e.getSkill().getId() == 4258) {
             sk_4258 = 1;
           }
         }
       }
       if (sk_4258 == 0) {
         npc.setTarget(attacker);
         npc.doCast(SkillTable.getInstance().getInfo(4258, 1));
       }
     }
     L2Character originalAttacker = isPet ? attacker.getPet() : attacker;
     int hate = (int) (((damage / npc.getMaxHp()) / 0.05) * 20000);
     ((L2Attackable) npc).addDamageHate(originalAttacker, 0, hate);
     if (Rnd.get(10) < 1) {
       int i0 = Rnd.get((15 * 15));
       if (i0 < 1) {
         npc.setTarget(attacker);
         npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
       } else if (i0 < 2) {
         npc.setTarget(attacker);
         npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
       } else if (i0 < 4) {
         npc.setTarget(attacker);
         npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
       } else if (i0 < 8) {
         npc.setTarget(attacker);
         npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
       } else if (i0 < 15) {
         for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100)) {
           if (character != attacker) continue;
           if (attacker != ((L2Attackable) npc).getMostHated()) {
             npc.setTarget(attacker);
             npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
           }
         }
       }
       if (Rnd.get(2) < 1) {
         if (attacker == ((L2Attackable) npc).getMostHated()) {
           npc.setTarget(attacker);
           npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
         }
       }
     }
     if (getTimeHour() < 5) {
     } else if (npc.getCurrentHp() < ((npc.getMaxHp() * _quest2) / 4.0)) {
       _quest2 = (_quest2 - 1);
       int i2 = Rnd.get(15);
       _ai1 = Xcoords[i2] + Rnd.get(650);
       _ai2 = Ycoords[i2] + Rnd.get(650);
       _ai3 = Zcoords[i2];
       npc.setTarget(npc);
       npc.doCast(SkillTable.getInstance().getInfo(4222, 1));
     }
   }
   return super.onAttack(npc, attacker, damage, isPet);
 }