Search in sources :

Example 96 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class SoliniaLivingEntity method getMaxHP.

@Override
public double getMaxHP() {
    if (getNpcid() < 1 && !isPlayer())
        return 1;
    double statHp = Utils.getStatMaxHP(getClassObj(), getLevel(), getStamina());
    double itemHp = getItemHp();
    double totalHp = statHp + itemHp;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc == null)
                return totalHp;
            totalHp += Utils.getTotalEffectTotalHP(this.getBukkitLivingEntity());
            if (npc.isBoss()) {
                totalHp += (Utils.getBossHPMultiplier() * npc.getLevel());
            }
            if (npc.isHeroic()) {
                totalHp += (Utils.getHeroicHPMultiplier() * npc.getLevel());
            }
            if (npc.isRaidboss()) {
                totalHp += (Utils.getRaidBossHPMultiplier() * npc.getLevel());
            }
            if (npc.isRaidheroic()) {
                totalHp += (Utils.getRaidHeroicHPMultiplier() * npc.getLevel());
            }
            return totalHp;
        }
        if (isPlayer()) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
            if (solplayer == null)
                return totalHp;
            totalHp += Utils.getTotalEffectTotalHP(this.getBukkitLivingEntity());
            // get AA hp bonus
            totalHp += Utils.getTotalAAEffectMaxHp(this.getBukkitLivingEntity());
            return totalHp;
        }
    } catch (CoreStateInitException e) {
        return totalHp;
    }
    return totalHp;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 97 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class SoliniaActiveSpell method applyBackstab.

private void applyBackstab(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    if (getLivingEntity().isDead())
        return;
    if (Bukkit.getEntity(getSourceUuid()) == null)
        return;
    Entity sourceEntity = Bukkit.getEntity(getSourceUuid());
    if (sourceEntity == null)
        return;
    if (!(sourceEntity instanceof LivingEntity))
        return;
    LivingEntity sourceLivingEntity = (LivingEntity) sourceEntity;
    try {
        ISoliniaLivingEntity solSourceEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
        if (solSourceEntity == null)
            return;
        int backstabSkill = solSourceEntity.getSkill("BACKSTAB");
        if (backstabSkill < 1)
            backstabSkill = 1;
        EntityDamageSource source = new EntityDamageSource("thorns", ((CraftEntity) Bukkit.getEntity(getSourceUuid())).getHandle());
        source.setMagic();
        source.ignoresArmor();
        int weaponDamage = 0;
        // Offhand item only
        ItemStack mainitem = sourceLivingEntity.getEquipment().getItemInOffHand();
        if (mainitem != null) {
            try {
                ISoliniaItem item = SoliniaItemAdapter.Adapt(mainitem);
                if (item != null)
                    if (item.getDamage() > 0) {
                        weaponDamage = item.getDamage();
                    }
            } catch (SoliniaItemException e) {
            }
        }
        if (weaponDamage < 1)
            weaponDamage = 1;
        int hpToRemove = weaponDamage;
        // back stab formula
        if (solSourceEntity.isBehindEntity(this.getLivingEntity()))
            hpToRemove = (int) Math.floor((2 + backstabSkill / 50) * weaponDamage);
        ((CraftEntity) getLivingEntity()).getHandle().damageEntity(source, hpToRemove);
        solSourceEntity.tryIncreaseSkill("BACKSTAB", 1);
    } catch (CoreStateInitException e) {
    }
}
Also used : CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) LivingEntity(org.bukkit.entity.LivingEntity) PathEntity(net.minecraft.server.v1_12_R1.PathEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ItemStack(org.bukkit.inventory.ItemStack) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException) EntityDamageSource(net.minecraft.server.v1_12_R1.EntityDamageSource)

Example 98 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class SoliniaLivingEntity method getWisdom.

@Override
public int getWisdom() {
    if (getNpcid() < 1 && !isPlayer())
        return 1;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc == null)
                return 1;
            int stat = npc.getLevel() * 5;
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "WISDOM");
            if (stat > getMaxStat("WISDOM"))
                stat = getMaxStat("WISDOM");
            return stat;
        }
        if (isPlayer()) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
            if (solplayer == null)
                return 1;
            int stat = 1;
            if (solplayer.getRace() != null)
                stat += solplayer.getRace().getWisdom();
            stat += solplayer.getTotalItemStat("WISDOM");
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "WISDOM");
            stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "WISDOM");
            if (stat > getMaxStat("WISDOM"))
                stat = getMaxStat("WISDOM");
            return stat;
        }
    } catch (CoreStateInitException e) {
        return 1;
    }
    return 1;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 99 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class SoliniaLivingEntity method processInteractionEvent.

@Override
public void processInteractionEvent(LivingEntity triggerentity, InteractionType type, String data) {
    if (this.getNpcid() > 0) {
        ISoliniaNPC npc;
        try {
            npc = StateManager.getInstance().getConfigurationManager().getNPC(this.getNpcid());
            npc.processInteractionEvent(this, triggerentity, type, data);
        } catch (CoreStateInitException e) {
            e.printStackTrace();
        }
    }
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC)

Example 100 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class SoliniaLivingEntity method getStamina.

@Override
public int getStamina() {
    if (getNpcid() < 1 && !isPlayer())
        return 1;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc == null)
                return 1;
            int stat = npc.getLevel() * 5;
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STAMINA");
            if (stat > getMaxStat("STAMINA"))
                stat = getMaxStat("STAMINA");
            return stat;
        }
        if (isPlayer()) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
            if (solplayer == null)
                return 1;
            int stat = 1;
            if (solplayer.getRace() != null)
                stat += solplayer.getRace().getStamina();
            stat += solplayer.getTotalItemStat("STAMINA");
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STAMINA");
            stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "STAMINA");
            if (stat > getMaxStat("STAMINA"))
                stat = getMaxStat("STAMINA");
            return stat;
        }
    } catch (CoreStateInitException e) {
        return 1;
    }
    return 1;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Aggregations

CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)216 Player (org.bukkit.entity.Player)114 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)99 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)43 CommandSender (org.bukkit.command.CommandSender)42 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)41 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)36 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)36 LivingEntity (org.bukkit.entity.LivingEntity)32 ArrayList (java.util.ArrayList)31 Entity (org.bukkit.entity.Entity)21 ItemStack (org.bukkit.inventory.ItemStack)20 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)17 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)16 EventHandler (org.bukkit.event.EventHandler)16 Timestamp (java.sql.Timestamp)13 TextComponent (net.md_5.bungee.api.chat.TextComponent)12 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)11 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)11 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)10