Search in sources :

Example 1 with RangedInfo

use of de.Keyle.MyPet.api.skill.skills.RangedInfo in project MyPet by xXKeyleXx.

the class Ranged method upgrade.

public void upgrade(SkillInfo upgrade, boolean quiet) {
    if (upgrade instanceof RangedInfo) {
        boolean isPassive = damage <= 0;
        if (upgrade.getProperties().getCompoundData().containsKey("damage")) {
            int damage = upgrade.getProperties().getAs("damage", TagInt.class).getIntData();
            upgrade.getProperties().getCompoundData().remove("damage");
            TagDouble TagDouble = new TagDouble(damage);
            upgrade.getProperties().getCompoundData().put("damage_double", TagDouble);
        }
        if (upgrade.getProperties().getCompoundData().containsKey("damage_double")) {
            if (!upgrade.getProperties().getCompoundData().containsKey("addset_damage") || upgrade.getProperties().getAs("addset_damage", TagString.class).getStringData().equals("add")) {
                damage += upgrade.getProperties().getAs("damage_double", TagDouble.class).getDoubleData();
            } else {
                damage = upgrade.getProperties().getAs("damage_double", TagDouble.class).getDoubleData();
            }
        }
        if (upgrade.getProperties().getCompoundData().containsKey("projectile")) {
            String projectileName = upgrade.getProperties().getAs("projectile", TagString.class).getStringData();
            for (Projectiles projectile : Projectiles.values()) {
                if (projectile.name().equalsIgnoreCase(projectileName)) {
                    selectedProjectile = projectile;
                }
            }
        }
        if (upgrade.getProperties().getCompoundData().containsKey("rateoffire")) {
            if (!upgrade.getProperties().getCompoundData().containsKey("addset_rateoffire") || upgrade.getProperties().getAs("addset_rateoffire", TagString.class).getStringData().equals("add")) {
                rateOfFire += upgrade.getProperties().getAs("rateoffire", TagInt.class).getIntData();
            } else {
                rateOfFire = upgrade.getProperties().getAs("rateoffire", TagInt.class).getIntData();
            }
        }
        if (!quiet) {
            myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Skill.Ranged.Upgrade", myPet.getOwner()), myPet.getPetName(), Translation.getString("Name." + getProjectile().name(), myPet.getOwner()), damage, String.format("%1.2f", (1. / ((getRateOfFire() * 50.) / 1000.)) * 60.)));
        }
        if (isPassive != (damage <= 0)) {
            if (myPet.getStatus() == PetState.Here) {
                getMyPet().getEntity().get().getHandle().getPathfinder().clearGoals();
                getMyPet().getEntity().get().getHandle().getTargetSelector().clearGoals();
                getMyPet().getEntity().get().getHandle().setPathfinder();
                if (damage == 0) {
                    getMyPet().getEntity().get().setTarget(null);
                }
            }
        }
    }
}
Also used : RangedInfo(de.Keyle.MyPet.api.skill.skills.RangedInfo) TagInt(de.keyle.knbt.TagInt) TagString(de.keyle.knbt.TagString) TagString(de.keyle.knbt.TagString) TagDouble(de.keyle.knbt.TagDouble)

Aggregations

RangedInfo (de.Keyle.MyPet.api.skill.skills.RangedInfo)1 TagDouble (de.keyle.knbt.TagDouble)1 TagInt (de.keyle.knbt.TagInt)1 TagString (de.keyle.knbt.TagString)1