Search in sources :

Example 6 with ISoliniaLootDrop

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

the class SoliniaLootFactory method CreateLootDropFromMerchant.

public static void CreateLootDropFromMerchant(ISoliniaNPCMerchant merchant, String name, int count, boolean always, int chance, boolean operatorCreated) throws CoreStateInitException {
    if (merchant.getEntries().size() == 0)
        return;
    if (StateManager.getInstance().getConfigurationManager().getLootDrop(name.toUpperCase()) != null)
        return;
    CreateLootDrop(name, operatorCreated);
    ISoliniaLootDrop lootdrop = StateManager.getInstance().getConfigurationManager().getLootDrop(name.toUpperCase());
    for (ISoliniaNPCMerchantEntry item : merchant.getEntries()) {
        CreateLootDropItem(lootdrop.getId(), item.getItemid(), count, always, chance, operatorCreated);
    }
}
Also used : ISoliniaNPCMerchantEntry(com.solinia.solinia.Interfaces.ISoliniaNPCMerchantEntry) ISoliniaLootDrop(com.solinia.solinia.Interfaces.ISoliniaLootDrop)

Example 7 with ISoliniaLootDrop

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

the class SoliniaLootFactory method CreateLootDropItem.

public static void CreateLootDropItem(int lootdropid, int itemid, int count, boolean always, int chance, boolean operatorCreated) throws CoreStateInitException {
    ISoliniaLootDrop lootdroptable = StateManager.getInstance().getConfigurationManager().getLootDrop(lootdropid);
    SoliniaLootDropEntry lootdrop = new SoliniaLootDropEntry();
    int id = 1;
    for (ISoliniaLootDropEntry entry : lootdroptable.getEntries()) {
        if (entry.getId() > id)
            id = entry.getId() + 1;
    }
    lootdrop.setId(id);
    lootdrop.setLootdropid(lootdropid);
    lootdrop.setItemid(itemid);
    lootdrop.setCount(count);
    lootdrop.setAlways(always);
    lootdrop.setChance(chance);
    lootdrop.setOperatorCreated(operatorCreated);
    StateManager.getInstance().getConfigurationManager().getLootDrop(lootdropid).getEntries().add(lootdrop);
}
Also used : ISoliniaLootDropEntry(com.solinia.solinia.Interfaces.ISoliniaLootDropEntry) ISoliniaLootDropEntry(com.solinia.solinia.Interfaces.ISoliniaLootDropEntry) SoliniaLootDropEntry(com.solinia.solinia.Models.SoliniaLootDropEntry) ISoliniaLootDrop(com.solinia.solinia.Interfaces.ISoliniaLootDrop)

Example 8 with ISoliniaLootDrop

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

the class SoliniaNPC method sendNpcSettingsToSender.

@Override
public void sendNpcSettingsToSender(CommandSender sender) throws CoreStateInitException {
    sender.sendMessage(ChatColor.RED + "NPC Settings for " + ChatColor.GOLD + getName() + ChatColor.RESET);
    sender.sendMessage("----------------------------");
    sender.sendMessage("- id: " + ChatColor.GOLD + getId() + ChatColor.RESET);
    sender.sendMessage("- name: " + ChatColor.GOLD + getName() + ChatColor.RESET);
    sender.sendMessage("- raceid: " + ChatColor.GOLD + getRaceid() + ChatColor.RESET);
    sender.sendMessage("- professionid: " + ChatColor.GOLD + getClassid() + ChatColor.RESET);
    sender.sendMessage(ChatColor.RED + "STATS" + ChatColor.RESET);
    sender.sendMessage("- level: " + ChatColor.GOLD + getLevel() + ChatColor.RESET);
    sender.sendMessage("- avoidancerating: " + ChatColor.GOLD + getAvoidanceRating() + ChatColor.RESET);
    sender.sendMessage("- accuracyrating: " + ChatColor.GOLD + getAccuracyRating() + ChatColor.RESET);
    sender.sendMessage("- ac: " + ChatColor.GOLD + getAC() + ChatColor.RESET);
    sender.sendMessage("- deathgrantstitle: " + ChatColor.GOLD + getDeathGrantsTitle() + ChatColor.RESET);
    sender.sendMessage("----------------------------");
    sender.sendMessage(ChatColor.RED + "SPAWNING" + ChatColor.RESET);
    sender.sendMessage("- randomspawn: " + ChatColor.GOLD + isRandomSpawn() + ChatColor.RESET);
    sender.sendMessage("----------------------------");
    sender.sendMessage(ChatColor.RED + "AI" + ChatColor.RESET);
    sender.sendMessage("- pet: " + ChatColor.GOLD + isPet() + ChatColor.RESET);
    sender.sendMessage("- guard: " + ChatColor.GOLD + isGuard() + ChatColor.RESET);
    sender.sendMessage("- roamer: " + ChatColor.GOLD + isRoamer() + ChatColor.RESET);
    sender.sendMessage("- killtriggertext: " + ChatColor.GOLD + getKillTriggerText());
    sender.sendMessage("- summoner: " + ChatColor.GOLD + isSummoner() + ChatColor.RESET);
    sender.sendMessage("- randomchattriggertext: " + ChatColor.GOLD + getRandomchatTriggerText());
    sender.sendMessage("----------------------------");
    sender.sendMessage(ChatColor.RED + "APPEARANCE" + ChatColor.RESET);
    sender.sendMessage("- mctype: " + ChatColor.GOLD + getMctype() + ChatColor.RESET);
    sender.sendMessage("- usedisguise: " + ChatColor.GOLD + isUsedisguise() + ChatColor.RESET);
    sender.sendMessage("- disguisetype: " + ChatColor.GOLD + getDisguisetype() + ChatColor.RESET);
    sender.sendMessage("- customhead: " + ChatColor.GOLD + isCustomhead() + ChatColor.RESET);
    sender.sendMessage("- customheaddata: " + ChatColor.GOLD + getCustomheaddata() + ChatColor.RESET);
    sender.sendMessage("- upsidedown: " + ChatColor.GOLD + isUpsidedown() + ChatColor.RESET);
    sender.sendMessage("- burning: " + ChatColor.GOLD + isBurning() + ChatColor.RESET);
    sender.sendMessage("- invisible: " + ChatColor.GOLD + isInvisible() + ChatColor.RESET);
    sender.sendMessage("- isundead: " + ChatColor.GOLD + isUndead() + ChatColor.RESET);
    sender.sendMessage("- isanimal: " + ChatColor.GOLD + isAnimal() + ChatColor.RESET);
    sender.sendMessage(ChatColor.RED + "EQUIPMENT" + ChatColor.RESET);
    if (getLoottableid() != 0) {
        sender.sendMessage("- loottableid: " + ChatColor.GOLD + getLoottableid() + " (" + StateManager.getInstance().getConfigurationManager().getLootTable(getLoottableid()).getName() + ")" + ChatColor.RESET);
    } else {
        sender.sendMessage("- loottableid: " + ChatColor.GOLD + getLoottableid() + " (No Loot Table)" + ChatColor.RESET);
    }
    sender.sendMessage("- handitem: " + ChatColor.GOLD + getHanditem() + ChatColor.RESET);
    sender.sendMessage("- offhanditem: " + ChatColor.GOLD + getOffhanditem() + ChatColor.RESET);
    sender.sendMessage("- headitem: " + ChatColor.GOLD + getHeaditem() + ChatColor.RESET);
    sender.sendMessage("- chestitem: " + ChatColor.GOLD + getChestitem() + ChatColor.RESET);
    sender.sendMessage("- legsitem: " + ChatColor.GOLD + getLegsitem() + ChatColor.RESET);
    sender.sendMessage("- feetitem: " + ChatColor.GOLD + getFeetitem() + ChatColor.RESET);
    sender.sendMessage(ChatColor.RED + "FACTION & MERCHANT" + ChatColor.RESET);
    if (getFactionid() != 0) {
        sender.sendMessage("- factionid: " + ChatColor.GOLD + getFactionid() + " (" + StateManager.getInstance().getConfigurationManager().getFaction(getFactionid()).getName() + ")" + ChatColor.RESET);
    } else {
        sender.sendMessage("- factionid: " + ChatColor.GOLD + getFactionid() + " (No Faction)" + ChatColor.RESET);
    }
    if (getMerchantid() != 0) {
        sender.sendMessage("- merchantid: " + ChatColor.GOLD + getMerchantid() + " (" + StateManager.getInstance().getConfigurationManager().getNPCMerchant(getMerchantid()).getName() + ")" + ChatColor.RESET);
    } else {
        sender.sendMessage("- merchantid: " + ChatColor.GOLD + getMerchantid() + " (No Merchant Table)" + ChatColor.RESET);
    }
    sender.sendMessage(ChatColor.RED + "MISC" + ChatColor.RESET);
    sender.sendMessage("- heroic: " + ChatColor.GOLD + isHeroic());
    sender.sendMessage("- boss: " + ChatColor.GOLD + isBoss());
    sender.sendMessage("- raidheroic: " + ChatColor.GOLD + isRaidheroic());
    sender.sendMessage("- raidboss: " + ChatColor.GOLD + isRaidboss());
    sender.sendMessage("- speaksalllangauges: " + ChatColor.GOLD + isSpeaksAllLanguages());
    sender.sendMessage("----------------------------");
    if (getLoottableid() != 0) {
        sender.sendMessage(ChatColor.RED + "LOOT" + ChatColor.RESET + "[" + getLoottableid() + "] - " + "(" + StateManager.getInstance().getConfigurationManager().getLootTable(getLoottableid()).getName() + ")");
        ISoliniaLootTable loottable = StateManager.getInstance().getConfigurationManager().getLootTable(getLoottableid());
        for (ISoliniaLootTableEntry le : StateManager.getInstance().getConfigurationManager().getLootTable(loottable.getId()).getEntries()) {
            ISoliniaLootDrop ld = StateManager.getInstance().getConfigurationManager().getLootDrop(le.getLootdropid());
            sender.sendMessage("- " + ChatColor.GOLD + ld.getName().toUpperCase() + ChatColor.RESET + "[" + ld.getId() + "]:");
        }
    }
}
Also used : ISoliniaLootTableEntry(com.solinia.solinia.Interfaces.ISoliniaLootTableEntry) ISoliniaLootTable(com.solinia.solinia.Interfaces.ISoliniaLootTable) ISoliniaLootDrop(com.solinia.solinia.Interfaces.ISoliniaLootDrop)

Example 9 with ISoliniaLootDrop

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

the class SoliniaLivingEntity method dropLoot.

@Override
public void dropLoot() {
    if (isPlayer())
        return;
    try {
        if (getNpcid() > 0) {
            ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
            if (npc.getLoottableid() == 0)
                return;
            ISoliniaLootTable table = StateManager.getInstance().getConfigurationManager().getLootTable(npc.getLoottableid());
            List<ISoliniaLootDropEntry> absoluteitems = new ArrayList<ISoliniaLootDropEntry>();
            List<ISoliniaLootDropEntry> rollitems = new ArrayList<ISoliniaLootDropEntry>();
            for (ISoliniaLootTableEntry entry : StateManager.getInstance().getConfigurationManager().getLootTable(table.getId()).getEntries()) {
                ISoliniaLootDrop droptable = StateManager.getInstance().getConfigurationManager().getLootDrop(entry.getLootdropid());
                for (ISoliniaLootDropEntry dropentry : StateManager.getInstance().getConfigurationManager().getLootDrop(droptable.getId()).getEntries()) {
                    if (dropentry.isAlways() == true) {
                        absoluteitems.add(dropentry);
                        continue;
                    }
                    rollitems.add(dropentry);
                }
            }
            if (absoluteitems.size() == 0 && rollitems.size() == 0)
                return;
            int dropcount = StateManager.getInstance().getWorldPerkDropCountModifier();
            Random r = new Random();
            int randomInt = r.nextInt(100) + 1;
            if (rollitems.size() > 0) {
                // Based on the chance attempt to drop this item
                for (int i = 0; i < dropcount; i++) {
                    ISoliniaLootDropEntry droptableentry = rollitems.get(new Random().nextInt(rollitems.size()));
                    ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(droptableentry.getItemid());
                    randomInt = r.nextInt(100) + 1;
                    // Handle unique item checking also
                    if (item.isArtifact() == true && item.isArtifactFound() == true)
                        continue;
                    if (randomInt <= droptableentry.getChance()) {
                        // Handle unique item setting also
                        if (item.isArtifact() == true && item.isArtifactFound() == false)
                            item.setArtifactFound(true);
                        getBukkitLivingEntity().getLocation().getWorld().dropItem(getBukkitLivingEntity().getLocation(), item.asItemStack());
                    }
                }
            }
            // Always drop these items
            if (absoluteitems.size() > 0) {
                for (int i = 0; i < absoluteitems.size(); i++) {
                    ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(absoluteitems.get(i).getItemid());
                    for (int c = 0; c < absoluteitems.get(i).getCount(); c++) {
                        // Handle unique item checking also
                        if (item.isArtifact() == true && item.isArtifactFound() == true)
                            continue;
                        getBukkitLivingEntity().getLocation().getWorld().dropItem(getBukkitLivingEntity().getLocation(), item.asItemStack());
                        // Handle unique item setting also
                        if (item.isArtifact() == true && item.isArtifactFound() == false)
                            item.setArtifactFound(true);
                    }
                }
            }
        } else {
        /*
				 * This is no longer needed now we have loot drops int itemDropMinimum = 95; if
				 * (Utils.RandomChance(itemDropMinimum)) { if (getBukkitLivingEntity()
				 * instanceof Monster)
				 * getBukkitLivingEntity().getWorld().dropItem(this.getBukkitLivingEntity().
				 * getLocation(),SoliniaItemFactory.GenerateRandomLoot().asItemStack()); }
				 */
        }
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ISoliniaLootDropEntry(com.solinia.solinia.Interfaces.ISoliniaLootDropEntry) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) Random(java.util.Random) ISoliniaLootTableEntry(com.solinia.solinia.Interfaces.ISoliniaLootTableEntry) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ArrayList(java.util.ArrayList) ISoliniaLootTable(com.solinia.solinia.Interfaces.ISoliniaLootTable) ISoliniaLootDrop(com.solinia.solinia.Interfaces.ISoliniaLootDrop)

Aggregations

ISoliniaLootDrop (com.solinia.solinia.Interfaces.ISoliniaLootDrop)9 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)5 ISoliniaLootDropEntry (com.solinia.solinia.Interfaces.ISoliniaLootDropEntry)4 ISoliniaLootTableEntry (com.solinia.solinia.Interfaces.ISoliniaLootTableEntry)4 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)3 ISoliniaLootTable (com.solinia.solinia.Interfaces.ISoliniaLootTable)3 ArrayList (java.util.ArrayList)3 SoliniaLootDropEntry (com.solinia.solinia.Models.SoliniaLootDropEntry)2 CommandSender (org.bukkit.command.CommandSender)2 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)2 Player (org.bukkit.entity.Player)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 InvalidLootDropSettingException (com.solinia.solinia.Exceptions.InvalidLootDropSettingException)1 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)1 ISoliniaLootDropEntryTypeAdapterFactory (com.solinia.solinia.Factories.ISoliniaLootDropEntryTypeAdapterFactory)1 ISoliniaClass (com.solinia.solinia.Interfaces.ISoliniaClass)1 ISoliniaFaction (com.solinia.solinia.Interfaces.ISoliniaFaction)1 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)1 ISoliniaNPCMerchantEntry (com.solinia.solinia.Interfaces.ISoliniaNPCMerchantEntry)1