Beispiel #1
0
 /**
  * Sets default attributes for the skill
  *
  * @param skill skill to apply to
  * @param prefix prefix to add to the name
  */
 @Override
 public void applyDefaults(DynamicSkill skill, String prefix) {
   skill.checkDefault(prefix + LENGTH, 3, 1);
   if (!skill.isSet(TYPE) || !STATUSES.containsKey(skill.getValue(TYPE))) {
     skill.setValue(TYPE, 0);
   }
 }
Beispiel #2
0
  /**
   * Applies a status to all targets
   *
   * @param player player using the skill
   * @param data data of the player using the skill
   * @param skill skill being used
   * @param target target type of the skill
   * @param targets targets for the effects
   * @return true if there were targets, false otherwise
   */
  @Override
  public boolean resolve(
      Player player,
      PlayerSkills data,
      DynamicSkill skill,
      Target target,
      List<LivingEntity> targets) {

    // Get attributes
    int level = data.getSkillLevel(skill.getName());
    int statusValue = skill.getValue(TYPE) + 1;
    double duration = skill.getAttribute(LENGTH, target, level);

    // Apply  potion effect to all
    boolean worked = false;
    while (statusValue > 0) {
      Status status = STATUSES.get((statusValue - 1) % 32);
      statusValue /= 32;
      for (LivingEntity t : targets) {
        if (t instanceof Player) {
          data.getAPI().getPlayer((Player) t).applyStatus(status, duration);
          worked = true;
        } else if (status == Status.ROOT || status == Status.STUN) {
          t.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, (int) (duration * 20)));
          worked = true;
        }
      }
    }
    return worked;
  }
  /**
   * Damages targets based on missing mana
   *
   * @param player player using the skill
   * @param data data of the player using the skill
   * @param skill skill being used
   * @param target target type of the skill
   * @param targets targets for the effects
   * @return true if there were targets, false otherwise
   */
  @Override
  public boolean resolve(
      Player player,
      PlayerSkills data,
      DynamicSkill skill,
      Target target,
      List<LivingEntity> targets) {

    // Change mana of all player targets
    boolean worked = false;
    int level = data.getSkillLevel(skill.getName());
    double amount = skill.getAttribute(HEALTH, target, level);
    int damageType = skill.getValue(TYPE);
    for (LivingEntity t : targets) {
      double damage;

      // Missing health
      if (damageType == 1) damage = amount * (t.getMaxHealth() - t.getHealth()) / 100.0;

      // Current health
      else if (damageType == 0) damage = amount * t.getHealth() / 100.0;

      // Max health
      else damage = amount * t.getMaxHealth() / 100;

      double prevHealth = t.getHealth();
      BukkitHelper.damage(t, player, damage);
      worked = worked || prevHealth != t.getHealth();
    }

    return worked;
  }
 /**
  * Sets default attributes for the skill
  *
  * @param skill skill to apply to
  * @param prefix prefix to add to the name
  */
 @Override
 public void applyDefaults(DynamicSkill skill, String prefix) {
   skill.checkDefault(prefix + SPEED, 3, 1);
   skill.checkDefault(prefix + QUANTITY, 1, 0);
   skill.checkDefault(prefix + ANGLE, 30, 0);
   if (!skill.isSet(SPREAD)) skill.setValue(SPREAD, 0);
   if (!skill.isSet(PROJECTILE)) skill.setValue(PROJECTILE, 0);
   if (!skill.isSet(USE_PROJECTILE)) skill.setValue(USE_PROJECTILE, 0);
 }
Beispiel #5
0
  /**
   * Gives mana to all targets
   *
   * @param player player using the skill
   * @param data data of the player using the skill
   * @param skill skill being used
   * @param target target type of the skill
   * @param targets targets for the effects
   * @return true if there were targets, false otherwise
   */
  @Override
  public boolean resolve(
      Player player,
      PlayerSkills data,
      DynamicSkill skill,
      Target target,
      List<LivingEntity> targets) {

    // Change mana of all player targets
    boolean worked = false;
    int level = data.getSkillLevel(skill.getName());
    int amount = (int) skill.getAttribute(MANA, target, level);
    for (LivingEntity t : targets) {
      if (t instanceof Player) {
        PlayerSkills p = skill.getAPI().getPlayer(((Player) t).getName());
        int prevMana = p.getMana();
        p.gainMana(amount);
        worked = worked || (p.getMana() != prevMana);
      }
    }

    return worked;
  }
  /**
   * Launches projectiles from a source
   *
   * @param player player using the skill
   * @param data data of the player using the skill
   * @param skill skill being used
   * @param target target type of the skill
   * @param targets targets for the effects
   * @return true if there were targets, false otherwise
   */
  @Override
  public boolean resolve(
      Player player,
      PlayerSkills data,
      DynamicSkill skill,
      Target target,
      List<LivingEntity> targets) {

    // Change mana of all player targets
    int level = data.getSkillLevel(skill.getName());
    double speed = skill.getAttribute(SPEED, target, level);
    int amount = (int) skill.getAttribute(QUANTITY, target, level);
    int angle = (int) skill.getAttribute(ANGLE, target, level);
    int spread = skill.getValue(SPREAD);
    int projectileId = skill.getValue(PROJECTILE);
    Class<? extends Projectile> projectile;
    if (PROJECTILES.containsKey(projectileId)) projectile = PROJECTILES.get(projectileId);
    else projectile = Arrow.class;

    // Using projectiles
    int removed = skill.getValue(USE_PROJECTILE);
    if (removed > 0) {
      Material mat;
      if (!MATERIALS.containsKey(projectileId)) mat = MATERIALS.get(0);
      else mat = MATERIALS.get(projectileId);
      if (player.getInventory().contains(mat, removed)) {
        player.getInventory().removeItem(new ItemStack(mat, removed));
      } else return false;
    }

    // Firing the projectiles
    List<Integer> list;
    if (spread == 0)
      list = ProjectileHelper.launchHorizontalCircle(player, projectile, amount, angle, speed);
    else list = ProjectileHelper.launchCircle(player, projectile, amount, angle, speed);

    // Applying embed data
    if (skill.hasEmbedEffects()) {
      for (int id : list) {
        projectiles.put(id, new EmbedData(player, data, skill));
      }
    }

    return true;
  }
 /**
  * Sets default attributes for the skill
  *
  * @param skill skill to apply to
  * @param prefix prefix to add to the name
  */
 @Override
 public void applyDefaults(DynamicSkill skill, String prefix) {
   skill.checkDefault(prefix + HEALTH, 10, 5);
   if (!skill.isSet(TYPE)) skill.setValue(TYPE, 0);
 }
Beispiel #8
0
 /**
  * Sets default attributes for the skill
  *
  * @param skill skill to apply to
  * @param prefix prefix to add to the name
  */
 @Override
 public void applyDefaults(DynamicSkill skill, String prefix) {
   skill.checkDefault(prefix + MANA, 4, 2);
 }