public void onTransferOnlyRemoveSkills(Player player, int toFinalClass, int baseKeepSkills) {
    boolean delete = false;

    if (Config.ALT_DELETE_AWAKEN_SKILL_FROM_DB) {
      delete = true;
    }

    List<Integer> allSkillsId = SkillAcquireHolder.getInstance().getAllClassSkillId();
    List<Integer> skillsToMantain =
        SkillAcquireHolder.getInstance().getMaintainSkillOnAwake(baseKeepSkills, toFinalClass);

    for (Skill skl : player.getAllSkills()) {
      if (allSkillsId.contains(skl.getId())) {
        player.removeSkill(skl, delete);
      }
    }

    for (int skillId : skillsToMantain) {
      int skillLv = SkillTable.getInstance().getBaseLevel(skillId);
      Skill newSkill = SkillTable.getInstance().getInfo(skillId, skillLv);
      player.addSkill(newSkill, true);
    }

    for (int alterSkill : ALTER_SKILLS.get(toFinalClass)) {
      int skillLv = SkillTable.getInstance().getBaseLevel(alterSkill);
      Skill newSkillAlter = SkillTable.getInstance().getInfo(alterSkill, skillLv);
      player.addSkill(newSkillAlter, true);
    }

    player.sendSkillList();
  }
Beispiel #2
0
  /**
   * Method restore.
   *
   * @param player Player
   */
  void restore(Player player) {
    if (player.getEffectList().getEffectsBySkillId(_skillId) != null) {
      for (Effect e : player.getEffectList().getAllEffects()) {
        if (e.getSkill().getId() == _skillId) {
          _level = e.getSkill().getLevel();
          e.exit();
        }
      }
    }

    if (!Config.ALLOW_DEATH_PENALTY_C5) {
      return;
    }

    if (getLevel(player) > 0) {
      Skill skill = SkillTable.getInstance().getInfo(_skillId, _level);

      if (skill == null) {
        return;
      }

      skill.getEffects(player, player, false, false);
      player.sendPacket(
          new SystemMessage(SystemMessage.THE_LEVEL_S1_SHILENS_BREATH_WILL_BE_ASSESSED)
              .addNumber(getLevel(player)));
    }

    player.updateStats();
  }
/**
 * @author Mobius
 * @version $Revision: 1.0 $
 */
public final class MatchBerserker extends MatchFighter {
  public static final Skill ATTACK_SKILL = SkillTable.getInstance().getInfo(4032, 6);

  /**
   * Constructor for MatchBerserker.
   *
   * @param actor NpcInstance
   */
  public MatchBerserker(NpcInstance actor) {
    super(actor);
  }

  /**
   * Method onEvtAttacked.
   *
   * @param attacker Creature
   * @param dam int
   */
  @Override
  public void onEvtAttacked(Creature attacker, int dam) {
    super.onEvtAttacked(attacker, dam);

    if (Rnd.chance(10)) {
      addTaskCast(attacker, ATTACK_SKILL);
    }
  }
}
Beispiel #4
0
 /**
  * Method doSupportMagic.
  *
  * @param npc NpcInstance
  * @param player Player
  * @param servitor boolean
  */
 public static void doSupportMagic(NpcInstance npc, Player player, boolean servitor) {
   if (player.isCursedWeaponEquipped()) {
     return;
   }
   int lvl = player.getLevel();
   if (servitor && (player.getSummonList().getFirstServitor() == null)) {
     show("default/newbie_nosupport_servitor.htm", player, npc);
     return;
   }
   if (lvl < minSupLvl) {
     show("default/newbie_nosupport_min.htm", player, npc);
     return;
   }
   if (lvl > maxSupLvl) {
     show("default/newbie_nosupport_max.htm", player, npc);
     return;
   }
   List<Creature> target = new ArrayList<>();
   if (servitor) {
     for (Summon summon : player.getSummonList()) {
       target.add(summon);
       for (int[] buff : _summonBuff) {
         if ((lvl >= buff[0]) && (lvl <= buff[1])) {
           npc.broadcastPacket(new MagicSkillUse(npc, summon, buff[2], buff[3], 0, 0));
           npc.callSkill(SkillTable.getInstance().getInfo(buff[2], buff[3]), target, true);
         }
       }
     }
   } else {
     target.add(player);
     if (!player.isMageClass() || (player.getTemplate().getRace() == Race.orc)) {
       for (int[] buff : _warrBuff) {
         if ((lvl >= buff[0]) && (lvl <= buff[1])) {
           npc.broadcastPacket(new MagicSkillUse(npc, player, buff[2], buff[3], 0, 0));
           npc.callSkill(SkillTable.getInstance().getInfo(buff[2], buff[3]), target, true);
         }
       }
     } else {
       for (int[] buff : _mageBuff) {
         if ((lvl >= buff[0]) && (lvl <= buff[1])) {
           npc.broadcastPacket(new MagicSkillUse(npc, player, buff[2], buff[3], 0, 0));
           npc.callSkill(SkillTable.getInstance().getInfo(buff[2], buff[3]), target, true);
         }
       }
     }
   }
 }
  /**
   * Method giveGiantEssences.
   *
   * @param player Player
   * @param onlyCalculateCount boolean
   * @return int
   */
  public int giveGiantEssences(Player player, boolean onlyCalculateCount) {
    List<Integer> enchantedSkills = new FastList<>();
    int count = 0;

    for (Skill skill : player.getAllSkills()) {
      if ((SkillTreeTable.isEnchantable(skill) != 0)
          && (player.getSkillDisplayLevel(skill.getId()) > 99)) {
        int skillLvl = skill.getDisplayLevel();
        int elevel = skillLvl % 100;
        EnchantSkillLearn sl = SkillTreeTable.getSkillEnchant(skill.getId(), skillLvl);

        if (sl != null) {
          if (sl.getMaxLevel() == 15) {
            elevel = Math.min(count15T.length, elevel);
            count += count15T[elevel];
          } else {
            elevel = Math.min(count30T.length, elevel);
            count += count30T[elevel];
          }
        }
      }

      enchantedSkills.add(Integer.valueOf(skill.getId()));
    }

    if (!onlyCalculateCount) {
      if (count > 0) {
        for (int i = 0; i < enchantedSkills.size(); i++) {
          player.removeSkillById(enchantedSkills.get(i));
          player.addSkill(
              SkillTable.getInstance()
                  .getInfo(
                      enchantedSkills.get(i),
                      SkillTable.getInstance().getBaseLevel(enchantedSkills.get(i))),
              true);
        }

        ItemFunctions.addItem(player, ESSENCE_OF_THE_LESSER_GIANTS, count, true);
      }
    }

    return count;
  }
  public void checkAwakenPlayerSkills(Player player) // For check on subclass change and logon
      {
    int classId = player.getActiveClassId();
    boolean delete = false;

    if (Config.ALT_DELETE_AWAKEN_SKILL_FROM_DB) {
      delete = true;
    }

    List<Integer> SkillsCheck = new ArrayList<>();
    List<Integer> SkillsToRemove = new ArrayList<>();
    List<Integer> allSkillsId = SkillAcquireHolder.getInstance().getAllClassSkillId();
    SkillsCheck.addAll(SkillAcquireHolder.getInstance().getAwakenGeneralKeepSkillList());
    SkillsCheck.addAll(SkillAcquireHolder.getInstance().getAwakenClassSkillForCheck(classId));
    SkillsCheck.addAll(SkillAcquireHolder.getInstance().getAllAwakenSkillsByClass(classId));

    if (player.getTransformation()
        == 0) // if the character log on with a transformation, do not remove any skill
    {
      for (Skill skl : player.getAllSkills()) {
        if (!SkillsCheck.contains(skl.getId()) && allSkillsId.contains(skl.getId())) {
          SkillsToRemove.add(skl.getId());
        }
      }
    } else {
      for (Skill skl : player.getAllSkills()) {
        if (!SkillsCheck.contains(skl.getId()) && SkillsCheck.contains(skl.getId())) {
          SkillsToRemove.add(skl.getId());
        }
      }
    }

    player.removeSkills(SkillsToRemove, delete);

    for (int alterSkill : ALTER_SKILLS.get(classId)) {
      int skillLv = SkillTable.getInstance().getBaseLevel(alterSkill);
      Skill newSkillAlter = SkillTable.getInstance().getInfo(alterSkill, skillLv);
      player.addSkill(newSkillAlter, true);
    }

    player.sendSkillList();
  }
Beispiel #7
0
 /** Method getProtectionBlessing. */
 public void getProtectionBlessing() {
   Player player = getSelf();
   NpcInstance npc = getNpc();
   if (player.getKarma() > 0) {
     return;
   }
   if ((player.getLevel() > 39) || player.getClassId().isOfLevel(ClassLevel.Second)) {
     show("default/newbie_blessing_no.htm", player, npc);
     return;
   }
   npc.doCast(SkillTable.getInstance().getInfo(5182, 1), player, true);
 }
Beispiel #8
0
  /**
   * Method castEffect.
   *
   * @param player Player
   */
  void castEffect(Player player) {
    if (getLevel(player) > 0) {
      Skill skill = SkillTable.getInstance().getInfo(_skillId, getLevel(player));

      if (skill == null) {
        return;
      }

      skill.getEffects(player, player, false, false);
      player.sendPacket(
          new SystemMessage(SystemMessage.THE_LEVEL_S1_SHILENS_BREATH_WILL_BE_ASSESSED)
              .addNumber(getLevel(player)));
      player.updateStats();
    }
  }
Beispiel #9
0
  /** Method thinkAttack. */
  @Override
  protected void thinkAttack() {
    final NpcInstance actor = getActor();
    final NpcInstance brother = getBrother();

    if (!brother.isDead() && !actor.isInRange(brother, 300)) {
      actor.altOnMagicUseTimer(getActor(), SkillTable.getInstance().getInfo(6371, 1));
    } else {
      removeInvul(actor);
    }

    if ((_spawnTimer + 40000) < System.currentTimeMillis()) {
      _spawnTimer = System.currentTimeMillis();
      final NpcInstance mob =
          actor
              .getReflection()
              .addSpawnWithoutRespawn(
                  _minions[Rnd.get(_minions.length)], Location.findAroundPosition(actor, 300), 0);
      mob.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, actor.getAggressionTarget(), 1000);
    }

    super.thinkAttack();
  }
  /**
   * Method getRaceSkill.
   *
   * @param player Player
   * @return null
   */
  public Skill getRaceSkill(Player player) {
    int race = player.getRace().ordinal();
    Skill skill = null;

    if (player.getClassId().isOfLevel(ClassLevel.Fourth)) {
      switch (race) {
        case 0:
          skill = SkillTable.getInstance().getInfo(248, 6);
          player.addSkill(skill);
          break;

        case 1:
          skill = SkillTable.getInstance().getInfo(248, 6);
          player.addSkill(skill);
          break;

        case 2:
          skill = SkillTable.getInstance().getInfo(248, 6);
          player.addSkill(skill);
          break;

        case 3:
          skill = SkillTable.getInstance().getInfo(248, 6);
          player.addSkill(skill);
          break;

        case 4:
          skill = SkillTable.getInstance().getInfo(248, 6);
          player.addSkill(skill);
          break;

        case 5:
          skill = SkillTable.getInstance().getInfo(248, 6);
          player.addSkill(skill);
      }
    } else {
      player.sendActionFailed();
    }

    player.updateStats();
    return null;
  }
/**
 * @author Mobius
 * @version $Revision: 1.0 $
 */
public class ResidenceFunction {
  /** Field _log. */
  private static final Logger _log = LoggerFactory.getLogger(ResidenceFunction.class);
  /** Field TELEPORT. (value is 1) */
  public static final int TELEPORT = 1;
  /** Field ITEM_CREATE. (value is 2) */
  public static final int ITEM_CREATE = 2;
  /** Field RESTORE_HP. (value is 3) */
  public static final int RESTORE_HP = 3;
  /** Field RESTORE_MP. (value is 4) */
  public static final int RESTORE_MP = 4;
  /** Field RESTORE_EXP. (value is 5) */
  public static final int RESTORE_EXP = 5;
  /** Field SUPPORT. (value is 6) */
  public static final int SUPPORT = 6;
  /** Field CURTAIN. (value is 7) */
  public static final int CURTAIN = 7;
  /** Field PLATFORM. (value is 8) */
  public static final int PLATFORM = 8;
  /** Field _id. */
  private final int _id;
  /** Field _type. */
  private final int _type;
  /** Field _level. */
  private int _level;
  /** Field _endDate. */
  private final Calendar _endDate;
  /** Field _inDebt. */
  private boolean _inDebt;
  /** Field _active. */
  private boolean _active;
  /** Field _leases. */
  private final Map<Integer, Integer> _leases = new ConcurrentSkipListMap<>();
  /** Field _teleports. */
  private final Map<Integer, TeleportLocation[]> _teleports = new ConcurrentSkipListMap<>();
  /** Field _buylists. */
  private final Map<Integer, int[]> _buylists = new ConcurrentSkipListMap<>();
  /** Field _buffs. */
  private final Map<Integer, Object[][]> _buffs = new ConcurrentSkipListMap<>();

  /**
   * Constructor for ResidenceFunction.
   *
   * @param id int
   * @param type int
   */
  public ResidenceFunction(int id, int type) {
    _id = id;
    _type = type;
    _endDate = Calendar.getInstance();
  }

  /**
   * Method getResidenceId.
   *
   * @return int
   */
  public int getResidenceId() {
    return _id;
  }

  /**
   * Method getType.
   *
   * @return int
   */
  public int getType() {
    return _type;
  }

  /**
   * Method getLevel.
   *
   * @return int
   */
  public int getLevel() {
    return _level;
  }

  /**
   * Method setLvl.
   *
   * @param lvl int
   */
  public void setLvl(int lvl) {
    _level = lvl;
  }

  /**
   * Method getEndTimeInMillis.
   *
   * @return long
   */
  public long getEndTimeInMillis() {
    return _endDate.getTimeInMillis();
  }

  /**
   * Method setEndTimeInMillis.
   *
   * @param time long
   */
  public void setEndTimeInMillis(long time) {
    _endDate.setTimeInMillis(time);
  }

  /**
   * Method setInDebt.
   *
   * @param inDebt boolean
   */
  public void setInDebt(boolean inDebt) {
    _inDebt = inDebt;
  }

  /**
   * Method isInDebt.
   *
   * @return boolean
   */
  public boolean isInDebt() {
    return _inDebt;
  }

  /**
   * Method setActive.
   *
   * @param active boolean
   */
  public void setActive(boolean active) {
    _active = active;
  }

  /**
   * Method isActive.
   *
   * @return boolean
   */
  public boolean isActive() {
    return _active;
  }

  /**
   * Method updateRentTime.
   *
   * @param inDebt boolean
   */
  public void updateRentTime(boolean inDebt) {
    setEndTimeInMillis(System.currentTimeMillis() + 86400000);
    Connection con = null;
    PreparedStatement statement = null;
    try {
      con = DatabaseFactory.getInstance().getConnection();
      statement =
          con.prepareStatement(
              "UPDATE residence_functions SET endTime=?, inDebt=? WHERE type=? AND id=?");
      statement.setInt(1, (int) (getEndTimeInMillis() / 1000));
      statement.setInt(2, inDebt ? 1 : 0);
      statement.setInt(3, getType());
      statement.setInt(4, getResidenceId());
      statement.executeUpdate();
    } catch (Exception e) {
      _log.error("", e);
    } finally {
      DbUtils.closeQuietly(con, statement);
    }
  }

  /**
   * Method getTeleports.
   *
   * @return TeleportLocation[]
   */
  public TeleportLocation[] getTeleports() {
    return getTeleports(_level);
  }

  /**
   * Method getTeleports.
   *
   * @param level int
   * @return TeleportLocation[]
   */
  public TeleportLocation[] getTeleports(int level) {
    return _teleports.get(level);
  }

  /**
   * Method addTeleports.
   *
   * @param level int
   * @param teleports TeleportLocation[]
   */
  public void addTeleports(int level, TeleportLocation[] teleports) {
    _teleports.put(level, teleports);
  }

  /**
   * Method getLease.
   *
   * @return int
   */
  public int getLease() {
    if (_level == 0) {
      return 0;
    }
    return getLease(_level);
  }

  /**
   * Method getLease.
   *
   * @param level int
   * @return int
   */
  public int getLease(int level) {
    return _leases.get(level);
  }

  /**
   * Method addLease.
   *
   * @param level int
   * @param lease int
   */
  public void addLease(int level, int lease) {
    _leases.put(level, lease);
  }

  /**
   * Method getBuylist.
   *
   * @return int[]
   */
  public int[] getBuylist() {
    return getBuylist(_level);
  }

  /**
   * Method getBuylist.
   *
   * @param level int
   * @return int[]
   */
  public int[] getBuylist(int level) {
    return _buylists.get(level);
  }

  /**
   * Method addBuylist.
   *
   * @param level int
   * @param buylist int[]
   */
  public void addBuylist(int level, int[] buylist) {
    _buylists.put(level, buylist);
  }

  /**
   * Method getBuffs.
   *
   * @return Object[][]
   */
  public Object[][] getBuffs() {
    return getBuffs(_level);
  }

  /**
   * Method getBuffs.
   *
   * @param level int
   * @return Object[][]
   */
  public Object[][] getBuffs(int level) {
    return _buffs.get(level);
  }

  /**
   * Method addBuffs.
   *
   * @param level int
   */
  public void addBuffs(int level) {
    _buffs.put(level, buffs_template[level]);
  }

  /**
   * Method getLevels.
   *
   * @return Set<Integer>
   */
  public Set<Integer> getLevels() {
    return _leases.keySet();
  }

  /** Field A. (value is """") */
  public static final String A = "";
  /** Field W. (value is ""W"") */
  public static final String W = "W";
  /** Field M. (value is ""M"") */
  public static final String M = "M";
  /** Field buffs_template. */
  /*
  15374	1	Clan Hall - Horn Melody	For 30 min., P. Atk. + 17%, P. Def. + 15%, M. Atk. + 79%, and M. Def. + 30%.	none	none\0
  15375	1	Clan Hall - Drum Melody	For 30 min., Max MP + 20%, HP Recovery Bonus + 20%, M. Critical Rate + 20, Critical Damage during a standard attack + 20%, P. Atk. + 10%, P. Def. + 20%, Atk. Spd. + 20%, M. Atk. + 20%, M. Def. + 20%, Casting Spd. + 20%, Debuff Resistance + 10%, and P. Def. when receiving a critical attack. Also, Spd. - 15%, and Critical Damage during a standard attack is increased after receiving a certain amount of damage.	none	none\0
  15376	1	Clan Hall - Pipe Organ Melody	For 30 min., Max HP/ MP/ CP + 37%, and HP Recovery Bonus + 20%.	none	none\0
  15377	1	Clan Hall - Guitar Melody	For 30 min., P. Critical Rate + 32%, P. Critical Damage + 35%, and M. Critical Rate + 20. Also, P. Skill MP Consumption - 20%, M. Skill MP Consumption -10%, and the Iss Enchanter's Enchant Skill MP Consumption - 20%.	none	none\0
  15378	1	Clan Hall - Harp Melody	For 30 min., P. Accuracy + 5, P. Evasion/ M. Evasion + 5, and Spd. + 34. Also, Received Critical Damage - 30%.	none	none\0
  15379	1	Clan Hall - Lute Melody	For 30 min., Atk. Spd. + 34%, Casting Spd. + 31%, and has a chance of applying 9% Vampiric Rage effect.	none	none\0

  15374	2	Clan Hall - Horn Melody	For 30 min., P. Atk. + 19%, P. Def. + 15%, M. Atk. + 83%, and M. Def. + 30%.	none	none\0
  15375	2	Clan Hall - Drum Melody	For 30 min., Max MP + 20%, HP Recovery Bonus + 20%, M. Critical Rate + 20, Critical Damage during a standard attack + 20%, P. Atk. + 10%, P. Def. + 20%, Atk. Spd. + 20%, M. Atk. + 20%, M. Def. + 20%, Casting Spd. + 20%, Debuff Resistance + 10%, and P. Def. when receiving a critical attack. Also, Spd. - 10%, and Critical Damage during a standard attack is increased after receiving a certain amount of damage.	none	none\0
  15376	2	Clan Hall - Pipe Organ Melody	For 30 min., Max HP/ MP/ CP + 39%, and HP Recovery Bonus + 20%.	none	none\0
  15377	2	Clan Hall - Guitar Melody	For 30 min., P. Critical Rate + 34%, P. Critical Damage + 35%, and M. Critical Rate + 20. Also, P. Skill MP Consumption - 20%, M. Skill MP Consumption - 10%, and the Iss Enchanter's Enchant Skill MP Consumption - 20%.	none	none\0
  15378	2	Clan Hall - Harp Melody	For 30 min., P. Accuracy + 6, P. Evasion/ M. Evasion + 6, and Spd. + 35. Also, Received Critical Damage - 30%.	none	none\0
  15379	2	Clan Hall - Lute Melody	For 30 min., Atk. Spd. + 35%, Casting Spd. + 32%, and has a chance of applying 9% Vampiric Rage effect.	none	none\0
  15380	1	Clan Hall - Knight's Harmony	For 30 min., P. Atk. + 12%, P. Critical Damage + 35%, P. Critical Rate + 100%, P. Def. + 45%, Shield Defense Rate + 30%, and Shield Defense + 50%.	none	none\0
  15381	1	Clan Hall - Warrior's Harmony	For 30 min., P. Atk. + 35%, P. Critical Damage + 35%, P. Critical Rate + 100%, Atk. Spd. + 8%, M. Atk. + 16%, Casting Spd. + 8%, and Spd. + 8.	none	none\0
  15382	1	Clan Hall - Wizard's Harmony	For 30 min., M. Atk. + 40%, M. Critical Rate + 100%, Casting Spd. + 8%, P. Atk. + 8%, Atk. Spd. + 8%, Spd. + 8, M. Def. + 14%, and MP Recovery Bonus + 20%. Also, M. Skill MP Consumption - 15%, P. Skill MP Consumption - 5%, Skill Cooldown - 20%.	none	none\0
  */
  private static final Object[][][] buffs_template = {
    {
      // level 0 - no buff
    },
    {
      // level 1
      {SkillTable.getInstance().getInfo(4342, 1), A},
      {SkillTable.getInstance().getInfo(4343, 1), A},
      {SkillTable.getInstance().getInfo(4344, 1), A},
      {SkillTable.getInstance().getInfo(4346, 1), A},
      {SkillTable.getInstance().getInfo(4345, 1), W},
    },
    {
      // level 2
      {SkillTable.getInstance().getInfo(4342, 2), A},
      {SkillTable.getInstance().getInfo(4343, 3), A},
      {SkillTable.getInstance().getInfo(4344, 3), A},
      {SkillTable.getInstance().getInfo(4346, 4), A},
      {SkillTable.getInstance().getInfo(4345, 3), W},
    },
    {
      // level 3
      {SkillTable.getInstance().getInfo(4342, 2), A},
      {SkillTable.getInstance().getInfo(4343, 3), A},
      {SkillTable.getInstance().getInfo(4344, 3), A},
      {SkillTable.getInstance().getInfo(4346, 4), A},
      {SkillTable.getInstance().getInfo(4345, 3), W},
    },
    {
      // level 4
      {SkillTable.getInstance().getInfo(4342, 2), A},
      {SkillTable.getInstance().getInfo(4343, 3), A},
      {SkillTable.getInstance().getInfo(4344, 3), A},
      {SkillTable.getInstance().getInfo(4346, 4), A},
      {SkillTable.getInstance().getInfo(4345, 3), W},
      {SkillTable.getInstance().getInfo(4347, 2), A},
      {SkillTable.getInstance().getInfo(4349, 1), A},
      {SkillTable.getInstance().getInfo(4350, 1), W},
      {SkillTable.getInstance().getInfo(4348, 2), A},
    },
    {
      // level 5
      {SkillTable.getInstance().getInfo(4342, 2), A},
      {SkillTable.getInstance().getInfo(4343, 3), A},
      {SkillTable.getInstance().getInfo(4344, 3), A},
      {SkillTable.getInstance().getInfo(4346, 4), A},
      {SkillTable.getInstance().getInfo(4345, 3), W},
      {SkillTable.getInstance().getInfo(4347, 2), A},
      {SkillTable.getInstance().getInfo(4349, 1), A},
      {SkillTable.getInstance().getInfo(4350, 1), W},
      {SkillTable.getInstance().getInfo(4348, 2), A},
      {SkillTable.getInstance().getInfo(4351, 2), M},
      {SkillTable.getInstance().getInfo(4352, 1), A},
      {SkillTable.getInstance().getInfo(4353, 2), W},
      {SkillTable.getInstance().getInfo(4358, 1), W},
      {SkillTable.getInstance().getInfo(4354, 1), W},
    },
    {
      // level 6 - unused
    },
    {
      // level 7
      {SkillTable.getInstance().getInfo(4342, 2), A},
      {SkillTable.getInstance().getInfo(4343, 3), A},
      {SkillTable.getInstance().getInfo(4344, 3), A},
      {SkillTable.getInstance().getInfo(4346, 4), A},
      {SkillTable.getInstance().getInfo(4345, 3), W},
      {SkillTable.getInstance().getInfo(4347, 6), A},
      {SkillTable.getInstance().getInfo(4349, 2), A},
      {SkillTable.getInstance().getInfo(4350, 4), W},
      {SkillTable.getInstance().getInfo(4348, 6), A},
      {SkillTable.getInstance().getInfo(4351, 6), M},
      {SkillTable.getInstance().getInfo(4352, 2), A},
      {SkillTable.getInstance().getInfo(4353, 6), W},
      {SkillTable.getInstance().getInfo(4358, 3), W},
      {SkillTable.getInstance().getInfo(4354, 4), W},
      // GOD
      {SkillTable.getInstance().getInfo(15374, 1), M},
      {SkillTable.getInstance().getInfo(15375, 1), M},
      {SkillTable.getInstance().getInfo(15376, 1), M},
      {SkillTable.getInstance().getInfo(15377, 1), M},
      {SkillTable.getInstance().getInfo(15378, 1), M},
      {SkillTable.getInstance().getInfo(15379, 1), M},
      {SkillTable.getInstance().getInfo(15380, 1), M},
      {SkillTable.getInstance().getInfo(15381, 1), M},
      {SkillTable.getInstance().getInfo(15382, 1), M}
    },
    {
      // level 8
      {SkillTable.getInstance().getInfo(4342, 2), A},
      {SkillTable.getInstance().getInfo(4343, 3), A},
      {SkillTable.getInstance().getInfo(4344, 3), A},
      {SkillTable.getInstance().getInfo(4346, 4), A},
      {SkillTable.getInstance().getInfo(4345, 3), W},
      {SkillTable.getInstance().getInfo(4347, 6), A},
      {SkillTable.getInstance().getInfo(4349, 2), A},
      {SkillTable.getInstance().getInfo(4350, 4), W},
      {SkillTable.getInstance().getInfo(4348, 6), A},
      {SkillTable.getInstance().getInfo(4351, 6), M},
      {SkillTable.getInstance().getInfo(4352, 2), A},
      {SkillTable.getInstance().getInfo(4353, 6), W},
      {SkillTable.getInstance().getInfo(4358, 3), W},
      {SkillTable.getInstance().getInfo(4354, 4), W},
      {SkillTable.getInstance().getInfo(4355, 1), M},
      {SkillTable.getInstance().getInfo(4356, 1), M},
      {SkillTable.getInstance().getInfo(4357, 1), W},
      {SkillTable.getInstance().getInfo(4359, 1), W},
      {SkillTable.getInstance().getInfo(4360, 1), W},
      // GOD
      {SkillTable.getInstance().getInfo(15374, 2), M},
      {SkillTable.getInstance().getInfo(15375, 2), M},
      {SkillTable.getInstance().getInfo(15376, 2), M},
      {SkillTable.getInstance().getInfo(15377, 2), M},
      {SkillTable.getInstance().getInfo(15378, 2), M},
      {SkillTable.getInstance().getInfo(15379, 2), M},
      {SkillTable.getInstance().getInfo(15380, 1), M},
      {SkillTable.getInstance().getInfo(15381, 1), M},
      {SkillTable.getInstance().getInfo(15382, 1), M}
    },
    {
      // Level 9 - unused
    },
    {
      // level 10 - unused
    },
    {
      // level 11
      {SkillTable.getInstance().getInfo(4342, 3), A},
      {SkillTable.getInstance().getInfo(4343, 4), A},
      {SkillTable.getInstance().getInfo(4344, 4), A},
      {SkillTable.getInstance().getInfo(4346, 5), A},
      {SkillTable.getInstance().getInfo(4345, 4), W},
    },
    {
      // level 12
      {SkillTable.getInstance().getInfo(4342, 4), A},
      {SkillTable.getInstance().getInfo(4343, 6), A},
      {SkillTable.getInstance().getInfo(4344, 6), A},
      {SkillTable.getInstance().getInfo(4346, 8), A},
      {SkillTable.getInstance().getInfo(4345, 6), W},
    },
    {
      // level 13
      {SkillTable.getInstance().getInfo(4342, 4), A},
      {SkillTable.getInstance().getInfo(4343, 6), A},
      {SkillTable.getInstance().getInfo(4344, 6), A},
      {SkillTable.getInstance().getInfo(4346, 8), A},
      {SkillTable.getInstance().getInfo(4345, 6), W},
    },
    {
      // level 14
      {SkillTable.getInstance().getInfo(4342, 4), A},
      {SkillTable.getInstance().getInfo(4343, 6), A},
      {SkillTable.getInstance().getInfo(4344, 6), A},
      {SkillTable.getInstance().getInfo(4346, 8), A},
      {SkillTable.getInstance().getInfo(4345, 6), W},
      {SkillTable.getInstance().getInfo(4347, 8), A},
      {SkillTable.getInstance().getInfo(4349, 3), A},
      {SkillTable.getInstance().getInfo(4350, 5), W},
      {SkillTable.getInstance().getInfo(4348, 8), A},
    },
    {
      // level 15
      {SkillTable.getInstance().getInfo(4342, 4), A},
      {SkillTable.getInstance().getInfo(4343, 6), A},
      {SkillTable.getInstance().getInfo(4344, 6), A},
      {SkillTable.getInstance().getInfo(4346, 8), A},
      {SkillTable.getInstance().getInfo(4345, 6), W},
      {SkillTable.getInstance().getInfo(4347, 8), A},
      {SkillTable.getInstance().getInfo(4349, 3), A},
      {SkillTable.getInstance().getInfo(4350, 5), W},
      {SkillTable.getInstance().getInfo(4348, 8), A},
      {SkillTable.getInstance().getInfo(4351, 8), M},
      {SkillTable.getInstance().getInfo(4352, 3), A},
      {SkillTable.getInstance().getInfo(4353, 8), W},
      {SkillTable.getInstance().getInfo(4358, 4), W},
      {SkillTable.getInstance().getInfo(4354, 5), W},
    },
    {
      // level 16 - unused
    },
    {
      // level 17
      {SkillTable.getInstance().getInfo(4342, 4), A},
      {SkillTable.getInstance().getInfo(4343, 6), A},
      {SkillTable.getInstance().getInfo(4344, 6), A},
      {SkillTable.getInstance().getInfo(4346, 8), A},
      {SkillTable.getInstance().getInfo(4345, 6), W},
      {SkillTable.getInstance().getInfo(4347, 12), A},
      {SkillTable.getInstance().getInfo(4349, 4), A},
      {SkillTable.getInstance().getInfo(4350, 8), W},
      {SkillTable.getInstance().getInfo(4348, 12), A},
      {SkillTable.getInstance().getInfo(4351, 12), M},
      {SkillTable.getInstance().getInfo(4352, 4), A},
      {SkillTable.getInstance().getInfo(4353, 12), W},
      {SkillTable.getInstance().getInfo(4358, 6), W},
      {SkillTable.getInstance().getInfo(4354, 8), W},
    },
    {
      // level 18
      {SkillTable.getInstance().getInfo(4342, 4), A},
      {SkillTable.getInstance().getInfo(4343, 6), A},
      {SkillTable.getInstance().getInfo(4344, 6), A},
      {SkillTable.getInstance().getInfo(4346, 8), A},
      {SkillTable.getInstance().getInfo(4345, 6), W},
      {SkillTable.getInstance().getInfo(4347, 12), A},
      {SkillTable.getInstance().getInfo(4349, 4), A},
      {SkillTable.getInstance().getInfo(4350, 8), W},
      {SkillTable.getInstance().getInfo(4348, 12), A},
      {SkillTable.getInstance().getInfo(4351, 12), M},
      {SkillTable.getInstance().getInfo(4352, 4), A},
      {SkillTable.getInstance().getInfo(4353, 12), W},
      {SkillTable.getInstance().getInfo(4358, 6), W},
      {SkillTable.getInstance().getInfo(4354, 8), W},
      {SkillTable.getInstance().getInfo(4355, 4), M},
      {SkillTable.getInstance().getInfo(4356, 4), M},
      {SkillTable.getInstance().getInfo(4357, 3), W},
      {SkillTable.getInstance().getInfo(4359, 4), W},
      {SkillTable.getInstance().getInfo(4360, 4), W},
    },
  };
}
 /** Constructor for StartEvent. */
 public StartEvent() {
   _freeze = SkillTable.getInstance().getInfo(6034, 1);
   _transformationRed = SkillTable.getInstance().getInfo(6035, 1);
   _transformationBlue = SkillTable.getInstance().getInfo(6036, 1);
 }
 /** Method runImpl. */
 @Override
 public void runImpl() {
   Skill fp = SkillTable.getInstance().getInfo(4616, 1);
   fp.getEffects(activeChar, activeChar, false, false);
 }
/**
 * @author Mobius
 * @version $Revision: 1.0 $
 */
public final class AlfredVonHellmann extends SiegeGuardFighter {
  public static final Skill DAMAGE_SKILL = SkillTable.getInstance().getInfo(5000, 1);
  public static final Skill DRAIN_SKILL = SkillTable.getInstance().getInfo(5001, 1);
  private static final Zone ZONE_3 = ReflectionUtils.getZone("lidia_zone3");

  /**
   * Constructor for AlfredVonHellmann.
   *
   * @param actor NpcInstance
   */
  public AlfredVonHellmann(NpcInstance actor) {
    super(actor);
  }

  /** Method onEvtSpawn. */
  @Override
  public void onEvtSpawn() {
    super.onEvtSpawn();
    ZONE_3.setActive(true);
    Functions.npcShout(
        getActor(),
        NpcString
            .HEH_HEH_I_SEE_THAT_THE_FEAST_HAS_BEGAN_BE_WARY_THE_CURSE_OF_THE_HELLMANN_FAMILY_HAS_POISONED_THIS_LAND);
  }

  /**
   * Method onEvtDead.
   *
   * @param killer Creature
   */
  @Override
  public void onEvtDead(Creature killer) {
    final NpcInstance actor = getActor();
    super.onEvtDead(killer);
    ZONE_3.setActive(false);
    Functions.npcShout(actor, NpcString.AARGH_IF_I_DIE_THEN_THE_MAGIC_FORCE_FIELD_OF_BLOOD_WILL);
    final ClanHallSiegeEvent siegeEvent = actor.getEvent(ClanHallSiegeEvent.class);

    if (siegeEvent == null) {
      return;
    }

    final SpawnExObject spawnExObject = siegeEvent.getFirstObject(ClanHallSiegeEvent.BOSS);
    final NpcInstance lidiaNpc = spawnExObject.getFirstSpawned();

    if (lidiaNpc.getCurrentHpRatio() == 1.) {
      lidiaNpc.setCurrentHp(lidiaNpc.getMaxHp() >> 1, true);
    }
  }

  /**
   * Method onEvtAttacked.
   *
   * @param attacker Creature
   * @param damage int
   */
  @Override
  public void onEvtAttacked(Creature attacker, int damage) {
    final NpcInstance actor = getActor();
    super.onEvtAttacked(attacker, damage);

    if ((PositionUtils.calculateDistance(attacker, actor, false) > 300.) && Rnd.chance(0.13)) {
      addTaskCast(attacker, DRAIN_SKILL);
    }

    final Creature target = actor.getAggroList().getMostHated();

    if ((target.equals(attacker)) && Rnd.chance(0.3)) {
      addTaskCast(attacker, DAMAGE_SKILL);
    }
  }
}
  /**
   * Method endOfLife.
   *
   * @param cw CursedWeapon
   */
  public void endOfLife(CursedWeapon cw) {
    if (cw.isActivated()) {
      Player player = cw.getOnlineOwner();

      if (player != null) {
        _log.info(
            "CursedWeaponsManager: " + cw.getName() + " being removed online from " + player + ".");
        player.abortAttack(true, true);
        player.setKarma(cw.getPlayerKarma());
        player.setPkKills(cw.getPlayerPkKills());
        player.setCursedWeaponEquippedId(0);
        player.setTransformation(0);
        player.setTransformationName(null);
        player.removeSkill(
            SkillTable.getInstance()
                .getInfo(cw.getSkillId(), player.getSkillLevel(cw.getSkillId())),
            false);
        player.getInventory().destroyItemByItemId(cw.getItemId(), 1L);
        player.broadcastCharInfo();
      } else {
        _log.info("CursedWeaponsManager: " + cw.getName() + " being removed offline.");
        Connection con = null;
        PreparedStatement statement = null;

        try {
          con = DatabaseFactory.getInstance().getConnection();
          statement = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
          statement.setInt(1, cw.getPlayerId());
          statement.setInt(2, cw.getItemId());
          statement.executeUpdate();
          DbUtils.close(statement);
          statement =
              con.prepareStatement(
                  "DELETE FROM character_skills WHERE char_obj_id=? AND skill_id=?");
          statement.setInt(1, cw.getPlayerId());
          statement.setInt(2, cw.getSkillId());
          statement.executeUpdate();
          DbUtils.close(statement);
          statement =
              con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE obj_Id=?");
          statement.setInt(1, cw.getPlayerKarma());
          statement.setInt(2, cw.getPlayerPkKills());
          statement.setInt(3, cw.getPlayerId());
          statement.executeUpdate();
        } catch (SQLException e) {
          _log.warn("CursedWeaponsManager: Could not delete : " + e);
        } finally {
          DbUtils.closeQuietly(con, statement);
        }
      }
    } else if ((cw.getPlayer() != null)
        && (cw.getPlayer().getInventory().getItemByItemId(cw.getItemId()) != null)) {
      Player player = cw.getPlayer();

      if (!cw.getPlayer().getInventory().destroyItemByItemId(cw.getItemId(), 1)) {
        _log.info("CursedWeaponsManager[453]: Error! Cursed weapon not found!!!");
      }

      player.sendChanges();
      player.broadcastUserInfo();
    } else if (cw.getItem() != null) {
      cw.getItem().deleteMe();
      cw.getItem().delete();
      _log.info("CursedWeaponsManager: " + cw.getName() + " item has been removed from World.");
    }

    cw.initWeapon();
    removeFromDb(cw.getItemId());
    announce(new SystemMessage(SystemMessage.S1_HAS_DISAPPEARED_CW).addString(cw.getName()));
  }
Beispiel #16
0
 /**
  * Method readData.
  *
  * @param rootElement org.dom4j.Element
  * @throws Exception
  */
 @Override
 protected void readData(org.dom4j.Element rootElement) throws Exception {
   for (Iterator<org.dom4j.Element> itemIterator = rootElement.elementIterator();
       itemIterator.hasNext(); ) {
     org.dom4j.Element itemElement = itemIterator.next();
     StatsSet set = new StatsSet();
     set.set("item_id", itemElement.attributeValue("id"));
     set.set("name", itemElement.attributeValue("name"));
     set.set("add_name", itemElement.attributeValue("add_name", StringUtils.EMPTY));
     int slot = 0;
     for (Iterator<org.dom4j.Element> subIterator = itemElement.elementIterator();
         subIterator.hasNext(); ) {
       org.dom4j.Element subElement = subIterator.next();
       String subName = subElement.getName();
       if (subName.equalsIgnoreCase("set")) {
         set.set(subElement.attributeValue("name"), subElement.attributeValue("value"));
       } else if (subName.equalsIgnoreCase("equip")) {
         for (Iterator<org.dom4j.Element> slotIterator = subElement.elementIterator();
             slotIterator.hasNext(); ) {
           org.dom4j.Element slotElement = slotIterator.next();
           Bodypart bodypart = Bodypart.valueOf(slotElement.attributeValue("id"));
           if (bodypart.getReal() != null) {
             slot = bodypart.mask();
           } else {
             slot |= bodypart.mask();
           }
         }
       }
     }
     set.set("bodypart", slot);
     ItemTemplate template = null;
     try {
       if (itemElement.getName().equalsIgnoreCase("weapon")) {
         if (!set.containsKey("class")) {
           if ((slot & ItemTemplate.SLOT_L_HAND) > 0) {
             set.set("class", ItemTemplate.ItemClass.ARMOR);
           } else {
             set.set("class", ItemTemplate.ItemClass.WEAPON);
           }
         }
         template = new WeaponTemplate(set);
       }
     } catch (Exception e) {
       warn("Fail create item: " + set.get("item_id"), e);
       continue;
     }
     for (Iterator<org.dom4j.Element> subIterator = itemElement.elementIterator();
         subIterator.hasNext(); ) {
       org.dom4j.Element subElement = subIterator.next();
       String subName = subElement.getName();
       if (subName.equalsIgnoreCase("for")) {
         parseFor(subElement, template);
       } else if (subName.equalsIgnoreCase("triggers")) {
         parseTriggers(subElement, template);
       } else if (subName.equalsIgnoreCase("skills")) {
         for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator();
             nextIterator.hasNext(); ) {
           org.dom4j.Element nextElement = nextIterator.next();
           int id = Integer.parseInt(nextElement.attributeValue("id"));
           int level = Integer.parseInt(nextElement.attributeValue("level"));
           Skill skill = SkillTable.getInstance().getInfo(id, level);
           if (skill != null) {
             template.attachSkill(skill);
           } else {
             info(
                 "Skill not found("
                     + id
                     + ","
                     + level
                     + ") for item:"
                     + set.getObject("item_id")
                     + "; file:"
                     + getCurrentFileName());
           }
         }
       } else if (subName.equalsIgnoreCase("enchant4_skill")) {
         int id = Integer.parseInt(subElement.attributeValue("id"));
         int level = Integer.parseInt(subElement.attributeValue("level"));
         Skill skill = SkillTable.getInstance().getInfo(id, level);
         if (skill != null) {
           template.setEnchant4Skill(skill);
         }
       } else if (subName.equalsIgnoreCase("unequip_skill")) {
         int id = Integer.parseInt(subElement.attributeValue("id"));
         int level = Integer.parseInt(subElement.attributeValue("level"));
         Skill skill = SkillTable.getInstance().getInfo(id, level);
         if (skill != null) {
           template.setUnequipeSkill(skill);
         }
       } else if (subName.equalsIgnoreCase("cond")) {
         Condition condition = parseFirstCond(subElement);
         if (condition != null) {
           int msgId = parseNumber(subElement.attributeValue("msgId")).intValue();
           condition.setSystemMsg(msgId);
           template.setCondition(condition);
         }
       } else if (subName.equalsIgnoreCase("attributes")) {
         int[] attributes = new int[6];
         for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator();
             nextIterator.hasNext(); ) {
           org.dom4j.Element nextElement = nextIterator.next();
           Element element;
           if (nextElement.getName().equalsIgnoreCase("attribute")) {
             element = Element.getElementByName(nextElement.attributeValue("element"));
             attributes[element.getId()] = Integer.parseInt(nextElement.attributeValue("value"));
           }
         }
         template.setBaseAtributeElements(attributes);
       } else if (subName.equalsIgnoreCase("enchant_options")) {
         for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator();
             nextIterator.hasNext(); ) {
           org.dom4j.Element nextElement = nextIterator.next();
           if (nextElement.getName().equalsIgnoreCase("level")) {
             int val = Integer.parseInt(nextElement.attributeValue("val"));
             int i = 0;
             int[] options = new int[3];
             for (org.dom4j.Element optionElement : nextElement.elements()) {
               OptionDataTemplate optionData =
                   OptionDataHolder.getInstance()
                       .getTemplate(Integer.parseInt(optionElement.attributeValue("id")));
               if (optionData == null) {
                 error(
                     "Not found option_data for id: "
                         + optionElement.attributeValue("id")
                         + "; item_id: "
                         + set.get("item_id"));
                 continue;
               }
               options[i++] = optionData.getId();
             }
             template.addEnchantOptions(val, options);
           }
         }
       }
     }
     getHolder().addItem(template);
   }
 }