Search in sources :

Example 46 with ISoliniaNPC

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

the class SoliniaLivingEntity method getDexterity.

@Override
public int getDexterity() {
    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(), "DEXTERITY");
            if (stat > getMaxStat("DEXTERITY"))
                stat = getMaxStat("DEXTERITY");
            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().getDexterity();
            stat += solplayer.getTotalItemStat("DEXTERITY");
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "DEXTERITY");
            stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "DEXTERITY");
            if (stat > getMaxStat("DEXTERITY"))
                stat = getMaxStat("DEXTERITY");
            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 47 with ISoliniaNPC

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

the class SoliniaLivingEntity method getDodgeCheck.

@Override
public boolean getDodgeCheck() {
    if (getNpcid() < 1 && !isPlayer())
        return false;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc == null)
                return false;
            boolean result = npc.getDodgeCheck();
            return result;
        }
        if (isPlayer()) {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
            if (solplayer == null)
                return false;
            boolean result = solplayer.getDodgeCheck();
            return solplayer.getDodgeCheck();
        }
    } catch (CoreStateInitException e) {
        return false;
    }
    return false;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 48 with ISoliniaNPC

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

the class SoliniaLivingEntity method doSpellCast.

@Override
public void doSpellCast(Plugin plugin, LivingEntity castingAtEntity) {
    if (isPlayer())
        return;
    if (!isNPC())
        return;
    if (castingAtEntity == null || this.livingentity == null)
        return;
    ISoliniaNPC npc;
    try {
        npc = StateManager.getInstance().getConfigurationManager().getNPC(this.getNpcid());
        if (npc.getClassid() < 1)
            return;
        this.setMana(this.getMana() + Utils.getDefaultNPCManaRegen(npc));
        aiEngagedCastCheck(plugin, npc, castingAtEntity);
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC)

Example 49 with ISoliniaNPC

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

the class SoliniaLivingEntity method aiCheckCloseBeneficialSpells.

@Override
public boolean aiCheckCloseBeneficialSpells(Plugin plugin, ISoliniaNPC npc, int iChance, int iRange, int iSpellTypes) throws CoreStateInitException {
    if (((iSpellTypes & SpellType.Detrimental)) == SpellType.Detrimental) {
        Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " cannot cast a close beneficial spell as I have a detrimental in my list");
        return false;
    }
    if (this.getClassObj() == null) {
        Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " cannot cast a close beneficial spell as I have no class");
        return false;
    }
    if (iChance < 100) {
        if (Utils.RandomBetween(0, 99) >= iChance) {
            Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " cannot cast a close beneficial spell as i rolled less than the chance");
            return false;
        }
    }
    if (npc.getFactionid() == 0) {
        Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " cannot cast a close beneficial spell as I have no faction");
        return false;
    }
    // Only iterate through NPCs
    for (Entity nearbyEntity : getBukkitLivingEntity().getNearbyEntities(iRange, iRange, iRange)) {
        if (!(nearbyEntity instanceof LivingEntity))
            continue;
        if (nearbyEntity.isDead())
            continue;
        ISoliniaLivingEntity mob = SoliniaLivingEntityAdapter.Adapt((LivingEntity) nearbyEntity);
        if (!mob.isNPC())
            continue;
        ISoliniaNPC mobNpc = StateManager.getInstance().getConfigurationManager().getNPC(mob.getNpcid());
        if (mobNpc.getFactionid() != npc.getFactionid())
            continue;
        if (((iSpellTypes & SpellType.Buff) == SpellType.Buff)) {
            iSpellTypes = SpellType.Heal;
        }
        if (aiCastSpell(plugin, npc, mob.getBukkitLivingEntity(), 100, iSpellTypes))
            return true;
    }
    return false;
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) 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) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC)

Example 50 with ISoliniaNPC

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

the class SoliniaLivingEntity method getIntelligence.

@Override
public int getIntelligence() {
    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(), "INTELLIGENCE");
            if (stat > getMaxStat("INTELLIGENCE"))
                stat = getMaxStat("INTELLIGENCE");
            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().getIntelligence();
            stat += solplayer.getTotalItemStat("INTELLIGENCE");
            stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "INTELLIGENCE");
            stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "INTELLIGENCE");
            if (stat > getMaxStat("INTELLIGENCE"))
                stat = getMaxStat("INTELLIGENCE");
            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

ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)50 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)43 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)19 Player (org.bukkit.entity.Player)16 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)7 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)7 CommandSender (org.bukkit.command.CommandSender)6 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)6 LivingEntity (org.bukkit.entity.LivingEntity)6 ISoliniaNPCEventHandler (com.solinia.solinia.Interfaces.ISoliniaNPCEventHandler)5 ArrayList (java.util.ArrayList)5 InvalidNpcSettingException (com.solinia.solinia.Exceptions.InvalidNpcSettingException)4 Entity (org.bukkit.entity.Entity)4 ISoliniaFaction (com.solinia.solinia.Interfaces.ISoliniaFaction)3 ItemStack (org.bukkit.inventory.ItemStack)3 InvalidNPCEventSettingException (com.solinia.solinia.Exceptions.InvalidNPCEventSettingException)2 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)2 ISoliniaLootTable (com.solinia.solinia.Interfaces.ISoliniaLootTable)2 SoliniaNPC (com.solinia.solinia.Models.SoliniaNPC)2 SoliniaNPCEventHandler (com.solinia.solinia.Models.SoliniaNPCEventHandler)2