Search in sources :

Example 11 with ISoliniaNPC

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

the class SoliniaLivingEntity method doRandomChat.

@Override
public void doRandomChat() {
    if (isPlayer())
        return;
    if (this.getNpcid() < 1)
        return;
    try {
        ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(this.getNpcid());
        if (npc.getRandomchatTriggerText() == null || npc.getRandomchatTriggerText().equals(""))
            return;
        // 2% chance of saying something
        int random = Utils.RandomBetween(1, 100);
        if (random < 2) {
            this.say(npc.getRandomchatTriggerText());
        }
    } 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 12 with ISoliniaNPC

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

the class SoliniaLivingEntity method getDefenseByDefenseSkill.

@Override
public int getDefenseByDefenseSkill() {
    double defense = getSkill("DEFENSE") * 400 / 225;
    defense += (8000 * (getAgility() - 40)) / 36000;
    // defense += itembonuses.AvoidMeleeChance; // item mod2
    if (isNPC()) {
        try {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(this.getNpcid());
            defense += npc.getAvoidanceRating();
        } catch (CoreStateInitException e) {
        // no bonus
        }
    }
    if (isPlayer()) {
        double reduction = getIntoxication() / 2.0;
        if (reduction > 20.0) {
            reduction = Math.min((110 - reduction) / 100.0, 1.0);
            defense = reduction * (double) (defense);
        }
    }
    return (int) Math.max(1, defense);
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC)

Example 13 with ISoliniaNPC

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

the class SoliniaLivingEntity method getStrength.

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

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

the class SoliniaLivingEntity method ACSum.

@Override
public int ACSum() {
    double ac = 0;
    ac += getTotalItemAC();
    double shield_ac = 0;
    // EQ math
    ac = (ac * 4) / 3;
    // anti-twink
    if (isPlayer() && getLevel() < 50)
        ac = Math.min(ac, 25 + 6 * getLevel());
    ac = Math.max(0, ac + getClassRaceACBonus());
    if (isNPC()) {
        try {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            ac += npc.getAC();
        } catch (CoreStateInitException e) {
        // dont get ac from npc type
        }
        // TODO Pet avoidance
        ac += getSkill("DEFENSE") / 5;
        double spell_aa_ac = 0;
        // TODO AC AA and Spell bonuses
        spell_aa_ac += getSpellBonuses(SpellEffectType.ArmorClass);
        spell_aa_ac += Utils.getTotalAAEffectEffectType(getBukkitLivingEntity(), SpellEffectType.ArmorClass);
        if (getClassObj() != null) {
            if (getClassObj().getName().equals("ENCHANTER") || getClassObj().getName().equals("ENCHANTER")) {
                ac += spell_aa_ac / 3;
            } else {
                ac += spell_aa_ac / 4;
            }
        } else {
            ac += spell_aa_ac / 4;
        }
    } else {
        double spell_aa_ac = 0;
        // TODO AC AA and Spell bonuses
        spell_aa_ac += getSpellBonuses(SpellEffectType.ArmorClass);
        spell_aa_ac += Utils.getTotalAAEffectEffectType(getBukkitLivingEntity(), SpellEffectType.ArmorClass);
        if (getClassObj() != null) {
            if (getClassObj().getName().equals("ENCHANTER") || getClassObj().getName().equals("ENCHANTER")) {
                ac += getSkill("DEFENSE") / 2 + spell_aa_ac / 3;
            } else {
                ac += getSkill("DEFENSE") / 3 + spell_aa_ac / 4;
            }
        } else {
            ac += getSkill("DEFENSE") / 3 + spell_aa_ac / 4;
        }
    }
    if (getAgility() > 70)
        ac += getAgility() / 20;
    if (ac < 0)
        ac = 0;
    if (isPlayer()) {
        double softcap = getACSoftcap();
        double returns = getSoftcapReturns();
        // TODO itembonuses
        int total_aclimitmod = 0;
        total_aclimitmod += getSpellBonuses(SpellEffectType.CombatStability);
        total_aclimitmod += Utils.getTotalAAEffectEffectType(getBukkitLivingEntity(), SpellEffectType.CombatStability);
        if (total_aclimitmod > 0)
            softcap = (softcap * (100 + total_aclimitmod)) / 100;
        softcap += shield_ac;
        if (ac > softcap) {
            double over_cap = ac - softcap;
            ac = softcap + (over_cap * returns);
        }
    }
    return (int) ac;
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC)

Example 15 with ISoliniaNPC

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

the class CommandLoot method sendLootListToSender.

private void sendLootListToSender(CommandSender sender, String itemMatch) {
    try {
        if (itemMatch.length() < 3) {
            sender.sendMessage("Item search must be at least 3 characters: " + itemMatch);
            return;
        }
        List<ISoliniaItem> items = StateManager.getInstance().getConfigurationManager().getItemsByPartialName(itemMatch);
        int itemIdLookup = 0;
        try {
            itemIdLookup = Integer.parseInt(itemMatch);
            ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemIdLookup);
            items.add(item);
        } catch (Exception e) {
        }
        if (items.size() < 1) {
            sender.sendMessage("Could not find item: " + itemMatch);
            return;
        }
        if (items.size() > 1) {
            sender.sendMessage("More than one item found with this string, please be more specific: " + itemMatch);
            return;
        }
        String itemname = "";
        for (ISoliniaItem item : items) {
            itemname = item.getDisplayname();
            List<Integer> lootDropIds = StateManager.getInstance().getConfigurationManager().getLootDropIdsWithItemId(item.getId());
            if (lootDropIds.size() < 1) {
                sender.sendMessage("Item [" + itemname + "] not found in any loot drops");
                return;
            }
            List<Integer> lootTableIds = StateManager.getInstance().getConfigurationManager().getLootTablesWithLootDrops(lootDropIds);
            if (lootTableIds.size() < 1) {
                sender.sendMessage("Item [" + itemname + "] not found in any loot tables");
                return;
            }
            List<String> matchingNpcList = new ArrayList<String>();
            String currentLine = "";
            for (ISoliniaNPC npc : StateManager.getInstance().getConfigurationManager().getNPCs()) {
                if (!lootTableIds.contains(npc.getLoottableid()))
                    continue;
                if ((currentLine + npc.getName() + " ").length() > 2000) {
                    matchingNpcList.add(currentLine);
                    currentLine = "";
                }
                currentLine += npc.getName() + " ";
            }
            if (!currentLine.equals("")) {
                matchingNpcList.add(currentLine);
            }
            for (String line : matchingNpcList) {
                sender.sendMessage("Item [" + itemname + "] found on: " + line);
            }
        }
    } catch (CoreStateInitException e) {
    // ignore it
    }
}
Also used : ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ArrayList(java.util.ArrayList) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException)

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