Search in sources :

Example 16 with ISoliniaLivingEntity

use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.

the class SoliniaActiveSpell method applySenseDead.

private void applySenseDead(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    try {
        for (Entity e : this.getLivingEntity().getNearbyEntities(100, 100, 100)) {
            if (!(e instanceof LivingEntity))
                continue;
            ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) e);
            if (!solEntity.isUndead())
                continue;
            Vector dir = ((LivingEntity) e).getLocation().clone().subtract(getLivingEntity().getEyeLocation()).toVector();
            Location loc = getLivingEntity().getLocation().setDirection(dir);
            getLivingEntity().teleport(loc);
            return;
        }
    } 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) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 17 with ISoliniaLivingEntity

use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity 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 18 with ISoliniaLivingEntity

use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.

the class CommandStats method onCommand.

public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        try {
            Player player = (Player) sender;
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
            ISoliniaLivingEntity solentity = SoliniaLivingEntityAdapter.Adapt(player);
            player.sendMessage("Your Level: " + solplayer.getLevel());
            player.sendMessage("STR: " + solentity.getStrength() + " STA: " + solentity.getStamina() + " AGI: " + solentity.getAgility() + " DEX: " + solentity.getDexterity() + " INT: " + solentity.getIntelligence() + " WIS: " + solentity.getWisdom() + " CHA: " + solentity.getCharisma());
            player.sendMessage("You have a maximum HP of: " + player.getHealth() + "/" + player.getMaxHealth());
            player.sendMessage("You have a maximum MP of: " + solplayer.getMana() + "/" + solentity.getMaxMP());
            player.sendMessage("You currently have a Armour Class Mitigation of: " + solentity.getMitigationAC());
            player.sendMessage("You currently have a Attack Value of: " + solentity.getAttk());
            player.sendMessage("You currently have a Total Rune of: " + solentity.getRune());
            player.sendMessage("FR: " + solplayer.getResist(SpellResistType.RESIST_FIRE) + " CR: " + solplayer.getResist(SpellResistType.RESIST_COLD) + " MR: " + solplayer.getResist(SpellResistType.RESIST_MAGIC) + " PR: " + solplayer.getResist(SpellResistType.RESIST_POISON) + " DR: " + solplayer.getResist(SpellResistType.RESIST_DISEASE));
            Double newlevel = (double) solplayer.getLevel();
            Double xpneededforcurrentlevel = Utils.getExperienceRequirementForLevel((int) (newlevel + 0));
            Double xpneededfornextlevel = Utils.getExperienceRequirementForLevel((int) (newlevel + 1));
            Double totalxpneeded = xpneededfornextlevel - xpneededforcurrentlevel;
            Double currentxpprogress = solplayer.getExperience() - xpneededforcurrentlevel;
            Double percenttolevel = Math.floor((currentxpprogress / totalxpneeded) * 100);
            Double percenttoaa = Math.floor((solplayer.getAAExperience() / Utils.getMaxAAXP()) * 100);
            int ipercenttolevel = percenttolevel.intValue();
            int ipercenttoaa = percenttoaa.intValue();
            player.sendMessage("Level progress: " + ipercenttolevel + "% into level - Have: " + solplayer.getExperience().longValue() + " Need: " + xpneededfornextlevel.longValue());
            player.sendMessage("AA points: " + solplayer.getAAPoints());
            player.sendMessage("Next AA progress: " + ipercenttoaa + "% into AA - Have: " + solplayer.getAAExperience().longValue() + " Need: " + Utils.getMaxAAXP().longValue());
        } catch (CoreStateInitException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 19 with ISoliniaLivingEntity

use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.

the class SoliniaActiveSpell method applyCurrentHpOnceSpellEffect.

private void applyCurrentHpOnceSpellEffect(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int caster_level) {
    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;
    int instrument_mod = 0;
    try {
        ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
        if (sourceSoliniaLivingEntity != null) {
            instrument_mod = sourceSoliniaLivingEntity.getInstrumentMod(this.getSpell());
        }
    } catch (CoreStateInitException e) {
    // just skip it
    }
    // HP spells also get calculated based on the caster and the recipient
    int hpToAdd = soliniaSpell.calcSpellEffectValue(spellEffect, sourceLivingEntity, getLivingEntity(), caster_level, getTicksLeft(), instrument_mod);
    // hpToRemove should really be called hpToAdd
    if (hpToAdd < 0) {
        // Criticals
        try {
            ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
            ISoliniaLivingEntity targetSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
            if (sourceSoliniaLivingEntity != null && targetSoliniaLivingEntity != null) {
                // reverse to positive then pass it back reversed
                hpToAdd = (sourceSoliniaLivingEntity.getActSpellDamage(soliniaSpell, (hpToAdd * -1), spellEffect, targetSoliniaLivingEntity) * -1);
            }
        } catch (CoreStateInitException e) {
        // just carry on without the crit bonus
        }
        hpToAdd = hpToAdd * -1;
        EntityDamageSource source = new EntityDamageSource("thorns", ((CraftEntity) Bukkit.getEntity(getSourceUuid())).getHandle());
        source.setMagic();
        source.ignoresArmor();
        ((CraftEntity) getLivingEntity()).getHandle().damageEntity(source, hpToAdd);
        // getLivingEntity().damage(hpToRemove, Bukkit.getEntity(getSourceUuid()));
        if (soliniaSpell.isLifetapSpell()) {
            if (!(sourceEntity instanceof LivingEntity))
                return;
            int amount = (int) Math.round(sourceLivingEntity.getHealth()) + hpToAdd;
            if (amount > sourceLivingEntity.getMaxHealth()) {
                amount = (int) Math.round(sourceLivingEntity.getMaxHealth());
            }
            if (amount < 0)
                amount = 0;
            sourceLivingEntity.setHealth(amount);
        }
    } else // Heal
    {
        // Criticals
        try {
            ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
            ISoliniaLivingEntity targetSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
            if (sourceSoliniaLivingEntity != null && targetSoliniaLivingEntity != null) {
                hpToAdd = sourceSoliniaLivingEntity.getActSpellHealing(soliniaSpell, hpToAdd, spellEffect, targetSoliniaLivingEntity);
            }
        } catch (CoreStateInitException e) {
        // just carry on without the crit bonus
        }
        int amount = (int) Math.round(getLivingEntity().getHealth()) + hpToAdd;
        if (amount > getLivingEntity().getMaxHealth()) {
            amount = (int) Math.round(getLivingEntity().getMaxHealth());
        }
        if (amount < 0)
            amount = 0;
        getLivingEntity().setHealth(amount);
    }
}
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) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) EntityDamageSource(net.minecraft.server.v1_12_R1.EntityDamageSource)

Example 20 with ISoliniaLivingEntity

use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.

the class SoliniaActiveSpell method apply.

public void apply(Plugin plugin) {
    try {
        ISoliniaSpell soliniaSpell = StateManager.getInstance().getConfigurationManager().getSpell(getSpellId());
        if (soliniaSpell == null) {
            System.out.print("Spell not found");
            return;
        }
        Entity sourceEntity = Bukkit.getEntity(this.getSourceUuid());
        if (sourceEntity == null || (!(sourceEntity instanceof LivingEntity)))
            return;
        ISoliniaLivingEntity solsource = SoliniaLivingEntityAdapter.Adapt((LivingEntity) sourceEntity);
        if (solsource == null)
            return;
        if (isFirstRun) {
            if (soliniaSpell.getCastOnYou() != null && !soliniaSpell.getCastOnYou().equals("") && isOwnerPlayer) {
                Player player = Bukkit.getPlayer(getOwnerUuid());
                player.sendMessage("* " + ChatColor.GRAY + soliniaSpell.getCastOnYou());
            }
            if (soliniaSpell.getCastOnOther() != null && !soliniaSpell.getCastOnOther().equals(""))
                SoliniaLivingEntityAdapter.Adapt((LivingEntity) Bukkit.getEntity(getOwnerUuid())).emote(ChatColor.GRAY + "* " + this.getLivingEntity().getName() + soliniaSpell.getCastOnOther());
        }
        for (ActiveSpellEffect spellEffect : getActiveSpellEffects()) {
            applySpellEffect(plugin, spellEffect, soliniaSpell, isFirstRun, solsource.getLevel());
        }
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
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) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException)

Aggregations

ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)38 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)32 LivingEntity (org.bukkit.entity.LivingEntity)24 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)20 Player (org.bukkit.entity.Player)18 Entity (org.bukkit.entity.Entity)16 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)8 ArrayList (java.util.ArrayList)7 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)7 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)7 Creature (org.bukkit.entity.Creature)7 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)6 SoliniaLivingEntity (com.solinia.solinia.Models.SoliniaLivingEntity)6 Timestamp (java.sql.Timestamp)6 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)5 Wolf (org.bukkit.entity.Wolf)5 EventHandler (org.bukkit.event.EventHandler)5 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)4 LocalDateTime (java.time.LocalDateTime)3 TextComponent (net.md_5.bungee.api.chat.TextComponent)3