Search in sources :

Example 11 with ISoliniaLivingEntity

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

the class SoliniaLivingEntity method checkHitChance.

@Override
public boolean checkHitChance(SoliniaLivingEntity attacker, DamageHitInfo hit) {
    ISoliniaLivingEntity defender = this;
    if (defender.isPlayer()) {
        try {
            ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) defender.getBukkitLivingEntity());
            if (player.isMeditating()) {
                return true;
            }
        } catch (CoreStateInitException e) {
        // ignore it
        }
    }
    int avoidance = defender.getTotalDefense();
    int accuracy = hit.tohit;
    // if (accuracy == -1)
    // return true;
    double hitRoll = Utils.RandomBetween(0, (int) Math.floor(accuracy));
    double avoidRoll = Utils.RandomBetween(0, (int) Math.floor(avoidance));
    // tie breaker? Don't want to be biased any one way
    return hitRoll > avoidRoll;
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 12 with ISoliniaLivingEntity

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

the class SoliniaLivingEntity method meleeMitigation.

@Override
public DamageHitInfo meleeMitigation(SoliniaLivingEntity attacker, DamageHitInfo hit) {
    if (hit.damage_done < 0 || hit.base_damage == 0)
        return hit;
    ISoliniaLivingEntity defender = this;
    int mitigation = defender.getMitigationAC();
    if (isPlayer() && attacker.isPlayer())
        // PvP
        mitigation = mitigation * 80 / 100;
    int roll = (int) rollD20(hit.offense, mitigation);
    // +0.5 for rounding, min to 1 dmg
    hit.damage_done = Math.max((int) (roll * (double) (hit.base_damage) + 0.5), 1);
    return hit;
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity)

Example 13 with ISoliniaLivingEntity

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

the class SoliniaPlayer method updateMaxHp.

@Override
public void updateMaxHp() {
    if (getBukkitPlayer() != null && getExperience() != null) {
        try {
            ISoliniaLivingEntity solentity = SoliniaLivingEntityAdapter.Adapt(getBukkitPlayer());
            double calculatedhp = solentity.getMaxHP();
            getBukkitPlayer().setMaxHealth(calculatedhp);
            getBukkitPlayer().setHealthScaled(true);
            getBukkitPlayer().setHealthScale(40D);
        } catch (CoreStateInitException e) {
        }
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException)

Example 14 with ISoliniaLivingEntity

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

the class SoliniaEntitySpells method removeSpell.

public void removeSpell(Plugin plugin, Integer spellId) {
    // Effect has worn off
    SoliniaActiveSpell activeSpell = activeSpells.get(spellId);
    if (activeSpell == null)
        return;
    boolean updateMaxHp = false;
    boolean updateDisguise = false;
    // Handle any effect removals needed
    for (ActiveSpellEffect effect : activeSpell.getActiveSpellEffects()) {
        switch(effect.getSpellEffectType()) {
            case TotalHP:
                updateMaxHp = true;
                break;
            case STA:
                updateMaxHp = true;
                break;
            case Illusion:
            case IllusionCopy:
            case IllusionOther:
            case IllusionPersistence:
            case IllusionaryTarget:
                updateDisguise = true;
                break;
        }
    }
    activeSpells.remove(spellId);
    if (updateMaxHp == true) {
        if (getLivingEntity() != null && getLivingEntity() instanceof Player) {
            try {
                ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getLivingEntity());
                if (solplayer != null)
                    solplayer.updateMaxHp();
            } catch (CoreStateInitException e) {
            }
        }
    }
    if (updateDisguise == true) {
        if (getLivingEntity() != null)
            DisguiseAPI.undisguiseToAll(getLivingEntity());
    }
    // Check if bard song, may need to keep singing
    if (activeSpell.getSpell().isBardSong()) {
        if (getLivingEntityUUID().equals(activeSpell.getSourceUuid())) {
            try {
                if (getLivingEntity() != null) {
                    if (StateManager.getInstance().getEntityManager().getEntitySinging(getLivingEntity().getUniqueId()) != null) {
                        Integer singingId = StateManager.getInstance().getEntityManager().getEntitySinging(getLivingEntity().getUniqueId());
                        if (singingId != activeSpell.getSpellId()) {
                            ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
                            solEntity.emote(getLivingEntity().getCustomName() + "'s song comes to a close [" + activeSpell.getSpell().getName() + "]");
                        } else {
                            // Continue singing!
                            if (Bukkit.getEntity(activeSpell.getOwnerUuid()) instanceof LivingEntity && Bukkit.getEntity(activeSpell.getSourceUuid()) instanceof LivingEntity) {
                                boolean itemUseSuccess = activeSpell.getSpell().tryApplyOnEntity(plugin, (LivingEntity) Bukkit.getEntity(activeSpell.getSourceUuid()), (LivingEntity) Bukkit.getEntity(activeSpell.getOwnerUuid()));
                                return;
                            }
                        }
                    } else {
                    // skip
                    }
                }
            } catch (CoreStateInitException e) {
            // ignore
            }
        }
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) 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 15 with ISoliniaLivingEntity

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

the class SoliniaActiveSpell method applySenseSummoned.

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

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