use of com.solinia.solinia.Interfaces.ISoliniaLootDropEntry in project solinia3-core by mixxit.
the class MythicMobsNPCEntityProvider method createNpcFile.
public String createNpcFile(ISoliniaNPC npc) {
String mob = "";
String uniquename = "NPCID_" + npc.getId();
if (npc.getMctype() == null)
return "";
mob = uniquename + ":\r\n";
mob = mob + " Type: " + npc.getMctype() + "\r\n";
if (npc.isUpsidedown() == true) {
mob = mob + " Display: Dinnerbone\r\n";
} else {
mob = mob + " Display: " + npc.getName() + "\r\n";
}
double hp = Utils.getStatMaxHP(npc.getClassObj(), npc.getLevel(), 75);
double damage = Utils.getMaxDamage(npc.getLevel(), 75);
if (npc.isHeroic()) {
hp += (Utils.getHeroicHPMultiplier() * npc.getLevel());
damage += (Utils.getHeroicDamageMultiplier() * npc.getLevel());
}
if (npc.isBoss()) {
hp += (Utils.getBossHPMultiplier() * npc.getLevel());
damage += (Utils.getBossDamageMultiplier() * npc.getLevel());
}
if (npc.isRaidheroic()) {
hp += (Utils.getRaidHeroicHPMultiplier() * npc.getLevel());
damage += (Utils.getRaidHeroicDamageMultiplier() * npc.getLevel());
}
if (npc.isRaidboss()) {
hp += (Utils.getRaidBossHPMultiplier() * npc.getLevel());
damage += (Utils.getRaidBossDamageMultiplier() * npc.getLevel());
}
float movementSpeed = 0.3f;
if (npc.isHeroic()) {
movementSpeed = Utils.getHeroicRunSpeed();
}
if (npc.isBoss()) {
movementSpeed = Utils.getBossRunSpeed();
}
if (npc.isRaidheroic()) {
movementSpeed = Utils.getRaidHeroicRunSpeed();
}
if (npc.isRaidboss()) {
movementSpeed = Utils.getRaidBossRunSpeed();
}
mob = mob + " Health: " + hp + "\r\n";
mob = mob + " Damage: " + damage + "\r\n";
mob = mob + " MaxCombatDistance: 25\r\n";
mob = mob + " PreventOtherDrops: true\r\n";
mob = mob + " PreventRandomEquipment: true\r\n";
mob = mob + " Options:\r\n";
mob = mob + " MovementSpeed: " + movementSpeed + "\r\n";
mob = mob + " KnockbackResistance: 0.75\r\n";
mob = mob + " PreventMobKillDrops: true\r\n";
mob = mob + " PreventOtherDrops: true\r\n";
mob = mob + " Silent: true\r\n";
mob = mob + " ShowHealth: true\r\n";
mob = mob + " PreventRenaming: true\r\n";
mob = mob + " PreventRandomEquipment: true\r\n";
mob = mob + " AlwaysShowName: true\r\n";
mob = mob + " Modules:\r\n";
mob = mob + " ThreatTable: false\r\n";
if (npc.isPet()) {
mob = mob + " Faction: FACTIONID_-1\r\n";
} else {
mob = mob + " Faction: FACTIONID_" + npc.getFactionid() + "\r\n";
}
// Act as normal mob if without faction
if (npc.getFactionid() > 0 || npc.isPet()) {
mob = mob + " AIGoalSelectors:\r\n";
mob = mob + " - 0 clear\r\n";
mob = mob + " - 1 skeletonbowattack\r\n";
mob = mob + " - 2 meleeattack\r\n";
mob = mob + " - 3 lookatplayers\r\n";
if (npc.isRoamer()) {
mob = mob + " - 4 randomstroll\r\n";
}
mob = mob + " AITargetSelectors:\r\n";
mob = mob + " - 0 clear\r\n";
mob = mob + " - 1 attacker\r\n";
// NPC attack players
if (!npc.isPet()) {
try {
ISoliniaFaction npcfaction = StateManager.getInstance().getConfigurationManager().getFaction(npc.getFactionid());
if (npcfaction.getBase() == -1500) {
mob = mob + " - 2 players\r\n";
}
} catch (CoreStateInitException e) {
// skip
}
}
// NPC attack NPCs
if (npc.isGuard() || npc.isPet()) {
// Always attack mobs with factionid 0
mob = mob + " - 3 SpecificFaction FACTIONID_0\r\n";
// Attack all mobs with -1500 faction
try {
int curnum = 4;
for (ISoliniaFaction faction : StateManager.getInstance().getConfigurationManager().getFactions()) {
if (faction.getBase() == -1500 && faction.getId() != npc.getFactionid()) {
mob = mob + " - " + curnum + " SpecificFaction FACTIONID_" + faction.getId() + "\r\n";
curnum++;
}
}
} catch (CoreStateInitException e) {
// skip
}
}
}
// then go ahead and use it! Better than that crap we have right?
if (npc.getLoottableid() > 0) {
try {
ISoliniaLootTable lootTable = StateManager.getInstance().getConfigurationManager().getLootTable(npc.getLoottableid());
if (lootTable != null) {
List<ISoliniaItem> potentialChestArmour = new ArrayList<ISoliniaItem>();
List<ISoliniaItem> potentialLegsArmour = new ArrayList<ISoliniaItem>();
List<ISoliniaItem> potentialFeetArmour = new ArrayList<ISoliniaItem>();
List<ISoliniaItem> potentialWeapons = new ArrayList<ISoliniaItem>();
List<ISoliniaItem> potentialBows = new ArrayList<ISoliniaItem>();
List<ISoliniaItem> potentialShields = new ArrayList<ISoliniaItem>();
for (ISoliniaLootTableEntry loottableentry : lootTable.getEntries()) {
ISoliniaLootDrop lootdrop = StateManager.getInstance().getConfigurationManager().getLootDrop(loottableentry.getLootdropid());
for (ISoliniaLootDropEntry lootdropentry : lootdrop.getEntries()) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(lootdropentry.getItemid());
if (ConfigurationManager.ArmourMaterials.contains(item.getBasename().toUpperCase())) {
if (item.getAllowedClassNames().size() == 0) {
if (item.getBasename().contains("CHESTPLATE"))
potentialChestArmour.add(item);
if (item.getBasename().contains("LEGGINGS"))
potentialLegsArmour.add(item);
if (item.getBasename().contains("BOOTS"))
potentialFeetArmour.add(item);
continue;
}
if (npc.getClassObj() != null) {
if (item.getAllowedClassNames().contains(npc.getClassObj().getName())) {
if (item.getBasename().contains("CHESTPLATE"))
potentialChestArmour.add(item);
if (item.getBasename().contains("LEGGINGS"))
potentialLegsArmour.add(item);
if (item.getBasename().contains("BOOTS"))
potentialFeetArmour.add(item);
continue;
}
}
}
if (ConfigurationManager.WeaponMaterials.contains(item.getBasename().toUpperCase())) {
if (item.getAllowedClassNames().size() == 0) {
if (item.getBasename().contains("SHIELD"))
potentialShields.add(item);
else if (item.getBasename().contains("BOW"))
potentialBows.add(item);
else
potentialWeapons.add(item);
continue;
}
if (npc.getClassObj() != null) {
if (item.getAllowedClassNames().contains(npc.getClassObj().getName())) {
if (item.getBasename().contains("SHIELD"))
potentialShields.add(item);
else
potentialWeapons.add(item);
continue;
}
}
}
if (ConfigurationManager.HandMaterials.contains(item.getBasename().toUpperCase())) {
if (item.getAllowedClassNames().size() == 0) {
if (item.getBasename().contains("SHIELD"))
potentialShields.add(item);
else if (item.getBasename().contains("BOW"))
potentialBows.add(item);
else
potentialWeapons.add(item);
continue;
}
if (npc.getClassObj() != null) {
if (item.getAllowedClassNames().contains(npc.getClassObj().getName())) {
if (item.getBasename().contains("SHIELD"))
potentialShields.add(item);
else
potentialWeapons.add(item);
continue;
}
}
}
}
mob = mob + " Equipment:\r\n";
if (potentialShields.size() > 0) {
Collections.sort(potentialShields, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialShields);
System.out.println("Found better shield in lootdrop (" + potentialWeapons.get(0).getDisplayname() + "), using as shield");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialWeapons.get(0).getId() + ".yml", potentialWeapons.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialWeapons.get(0).getId() + ":5\r\n";
} else {
if (npc.getOffhanditem() != null)
mob = mob + " - " + npc.getOffhanditem() + ":5\r\n";
}
if (npc.isCustomhead() == true) {
if (npc.getCustomheaddata() != null) {
mob = mob + " - CUSTOMHEADNPCID_" + npc.getId() + ":4\r\n";
} else {
if (npc.getHeaditem() != null)
mob = mob + " - " + npc.getHeaditem() + ":4\r\n";
}
} else {
if (npc.getHeaditem() != null)
mob = mob + " - " + npc.getHeaditem() + ":4\r\n";
}
if (potentialChestArmour.size() > 0) {
Collections.sort(potentialChestArmour, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialChestArmour);
System.out.println("Found better chest in lootdrop (" + potentialChestArmour.get(0).getDisplayname() + "), using as chest");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialChestArmour.get(0).getId() + ".yml", potentialChestArmour.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialChestArmour.get(0).getId() + ":3\r\n";
} else {
if (npc.getChestitem() != null)
mob = mob + " - " + npc.getChestitem() + ":3\r\n";
}
if (potentialLegsArmour.size() > 0) {
Collections.sort(potentialLegsArmour, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialLegsArmour);
System.out.println("Found better legs in lootdrop (" + potentialLegsArmour.get(0).getDisplayname() + "), using as weapon");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialLegsArmour.get(0).getId() + ".yml", potentialLegsArmour.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialLegsArmour.get(0).getId() + ":2\r\n";
} else {
if (npc.getLegsitem() != null)
mob = mob + " - " + npc.getLegsitem() + ":2\r\n";
}
if (potentialFeetArmour.size() > 0) {
Collections.sort(potentialFeetArmour, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialFeetArmour);
System.out.println("Found better feet in lootdrop (" + potentialFeetArmour.get(0).getDisplayname() + "), using as feet");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialFeetArmour.get(0).getId() + ".yml", potentialFeetArmour.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialFeetArmour.get(0).getId() + ":1\r\n";
} else {
if (npc.getFeetitem() != null)
mob = mob + " - " + npc.getFeetitem() + ":1\r\n";
}
if (npc.getClassObj() != null && npc.getClassObj().getName().toUpperCase().equals("RANGER") && potentialBows.size() > 0) {
Collections.sort(potentialBows, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialBows);
System.out.println("Found better weapon (bow) in lootdrop (" + potentialBows.get(0).getDisplayname() + "), using as weapon");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialBows.get(0).getId() + ".yml", potentialBows.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialBows.get(0).getId() + ":0\r\n";
} else {
if (potentialWeapons.size() > 0) {
Collections.sort(potentialWeapons, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialWeapons);
System.out.println("Found better weapon in lootdrop (" + potentialWeapons.get(0).getDisplayname() + "), using as weapon");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialWeapons.get(0).getId() + ".yml", potentialWeapons.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialWeapons.get(0).getId() + ":0\r\n";
} else {
if (npc.getHanditem() != null)
mob = mob + " - " + npc.getHanditem() + ":0\r\n";
}
}
}
}
} catch (CoreStateInitException e) {
// skip
}
} else {
if (npc.getHeaditem() != null || npc.getChestitem() != null || npc.getLegsitem() != null || npc.getFeetitem() != null || npc.getHanditem() != null || npc.getOffhanditem() != null) {
mob = mob + " Equipment:\r\n";
if (npc.getOffhanditem() != null)
mob = mob + " - " + npc.getOffhanditem() + ":5\r\n";
if (npc.isCustomhead() == true) {
if (npc.getCustomheaddata() != null) {
mob = mob + " - CUSTOMHEADNPCID_" + npc.getId() + ":4\r\n";
} else {
if (npc.getHeaditem() != null)
mob = mob + " - " + npc.getHeaditem() + ":4\r\n";
}
} else {
if (npc.getHeaditem() != null)
mob = mob + " - " + npc.getHeaditem() + ":4\r\n";
}
if (npc.getChestitem() != null)
mob = mob + " - " + npc.getChestitem() + ":3\r\n";
if (npc.getLegsitem() != null)
mob = mob + " - " + npc.getLegsitem() + ":2\r\n";
if (npc.getFeetitem() != null)
mob = mob + " - " + npc.getFeetitem() + ":1\r\n";
if (npc.getHanditem() != null)
mob = mob + " - " + npc.getHanditem() + ":0\r\n";
}
}
if (npc.isUsedisguise() == true) {
mob = mob + " Disguise:\r\n";
if (npc.getDisguisetype().toLowerCase().contains("player-")) {
mob = mob + " Type: player\r\n";
} else {
mob = mob + " Type: " + npc.getDisguisetype() + "\r\n";
}
if (npc.isBurning() == true) {
mob = mob + " Burning: true\r\n";
}
if (npc.getDisguisetype().toLowerCase().contains("player-")) {
String[] disguisedata = npc.getDisguisetype().split("-");
mob = mob + " Player: " + npc.getName() + "\r\n";
mob = mob + " Skin: '" + disguisedata[1] + "'\r\n";
}
}
if (npc.isBoss() == true || npc.isRaidboss()) {
/*
mob = mob + " BossBar:\r\n";
mob = mob + " Enabled: true\r\n";
mob = mob + " Title: " + npc.getName() + "\r\n";
mob = mob + " Range: 200\r\n";
mob = mob + " CreateFog: true\r\n";
mob = mob + " DarkenSky: true\r\n";
mob = mob + " PlayMusic: true\r\n";
*/
if (npc.getDisguisetype() != null)
if (npc.getDisguisetype().toLowerCase().contains("player-")) {
String[] disguisedata = npc.getDisguisetype().split("-");
mob = mob + " Player: " + npc.getName() + "\r\n";
mob = mob + " Skin: '" + disguisedata[1] + "'\r\n";
}
}
mob = mob + " Skills:\r\n";
if (npc.isInvisible() == true) {
mob = mob + " - potion{t=INVISIBILITY;d=2147483647;l=1} @self ~onSpawn\r\n";
}
return mob;
}
use of com.solinia.solinia.Interfaces.ISoliniaLootDropEntry in project solinia3-core by mixxit.
the class SoliniaLootTable method sendLootTableSettingsToSender.
@Override
public void sendLootTableSettingsToSender(CommandSender sender) {
try {
for (ISoliniaLootTableEntry le : getEntries()) {
ISoliniaLootDrop ld = StateManager.getInstance().getConfigurationManager().getLootDrop(le.getLootdropid());
sender.sendMessage("- " + ChatColor.GOLD + ld.getName().toUpperCase() + ChatColor.RESET + "[" + ld.getId() + "]:");
for (ISoliniaLootDropEntry lde : ld.getEntries()) {
ISoliniaItem i = StateManager.getInstance().getConfigurationManager().getItem(lde.getItemid());
sender.sendMessage(" - " + ChatColor.GOLD + i.getDisplayname() + ChatColor.RESET + "[" + i.getId() + "] - " + lde.getChance() + "% chance Count: " + lde.getCount() + " Always: " + lde.isAlways());
}
}
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
}
use of com.solinia.solinia.Interfaces.ISoliniaLootDropEntry 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);
}
use of com.solinia.solinia.Interfaces.ISoliniaLootDropEntry in project solinia3-core by mixxit.
the class SoliniaLootDrop method sendLootDropSettingsToSender.
@Override
public void sendLootDropSettingsToSender(CommandSender sender) {
try {
sender.sendMessage(ChatColor.GOLD + getName().toUpperCase() + ChatColor.RESET + "[" + getId() + "]:");
for (ISoliniaLootDropEntry lde : getEntries()) {
ISoliniaItem i = StateManager.getInstance().getConfigurationManager().getItem(lde.getItemid());
sender.sendMessage("- [" + lde.getId() + "] " + ChatColor.GOLD + i.getDisplayname() + ChatColor.RESET + "[" + i.getId() + "] - " + lde.getChance() + "% chance Count: " + lde.getCount() + " Always: " + lde.isAlways());
}
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
}
use of com.solinia.solinia.Interfaces.ISoliniaLootDropEntry in project solinia3-core by mixxit.
the class SoliniaLootDrop method editSetting.
@Override
public void editSetting(String setting, String value) throws InvalidLootDropSettingException, NumberFormatException, CoreStateInitException {
switch(setting.toLowerCase()) {
case "name":
if (value.equals(""))
throw new InvalidLootDropSettingException("Name is empty");
if (value.length() > 25)
throw new InvalidLootDropSettingException("Name is longer than 25 characters");
setName(value);
break;
case "remove":
int itemIdToRemove = Integer.parseInt(value);
if (itemIdToRemove < 1)
throw new InvalidLootDropSettingException("Invalid item id to remove");
for (int i = 0; i < getEntries().size(); i++) {
if (getEntries().get(i).getLootdropid() == itemIdToRemove)
getEntries().remove(i);
}
break;
case "setallchance":
int newChance = Integer.parseInt(value);
for (int i = 0; i < getEntries().size(); i++) {
getEntries().get(i).setChance(newChance);
}
break;
case "setallitemminlevel":
int minLevel = Integer.parseInt(value);
if (minLevel < 1 || minLevel > Utils.getMaxLevel())
throw new InvalidLootDropSettingException("Invalid minlevel");
for (int i = 0; i < getEntries().size(); i++) {
int itemId = getEntries().get(i).getItemid();
StateManager.getInstance().getConfigurationManager().getItem(itemId).setMinLevel(minLevel);
}
break;
case "setallitemfireresist":
int fireresist = Integer.parseInt(value);
if (fireresist < 0 || fireresist > ((Utils.getMaxLevel() / 10) * 5))
throw new InvalidLootDropSettingException("Invalid fireresist value is it too low or too high?");
for (int i = 0; i < getEntries().size(); i++) {
int itemId = getEntries().get(i).getItemid();
StateManager.getInstance().getConfigurationManager().getItem(itemId).setFireResist(fireresist);
}
break;
case "setallitemcoldresist":
int coldresist = Integer.parseInt(value);
if (coldresist < 0 || coldresist > ((Utils.getMaxLevel() / 10) * 5))
throw new InvalidLootDropSettingException("Invalid coldresist value is it too low or too high?");
for (int i = 0; i < getEntries().size(); i++) {
int itemId = getEntries().get(i).getItemid();
StateManager.getInstance().getConfigurationManager().getItem(itemId).setColdResist(coldresist);
}
break;
case "setallitemmagicresist":
int magicresist = Integer.parseInt(value);
if (magicresist < 0 || magicresist > ((Utils.getMaxLevel() / 10) * 5))
throw new InvalidLootDropSettingException("Invalid magicresist value is it too low or too high?");
for (int i = 0; i < getEntries().size(); i++) {
int itemId = getEntries().get(i).getItemid();
StateManager.getInstance().getConfigurationManager().getItem(itemId).setMagicResist(magicresist);
}
break;
case "setallitempoisonresist":
int poisonresist = Integer.parseInt(value);
if (poisonresist < 0 || poisonresist > ((Utils.getMaxLevel() / 10) * 5))
throw new InvalidLootDropSettingException("Invalid poisonresist value is it too low or too high?");
for (int i = 0; i < getEntries().size(); i++) {
int itemId = getEntries().get(i).getItemid();
StateManager.getInstance().getConfigurationManager().getItem(itemId).setPoisonResist(poisonresist);
}
break;
case "setallitemdiseaseresist":
int diseaseresist = Integer.parseInt(value);
if (diseaseresist < 0 || diseaseresist > ((Utils.getMaxLevel() / 10) * 5))
throw new InvalidLootDropSettingException("Invalid diseaseresist value is it too low or too high?");
for (int i = 0; i < getEntries().size(); i++) {
int itemId = getEntries().get(i).getItemid();
StateManager.getInstance().getConfigurationManager().getItem(itemId).setDiseaseResist(diseaseresist);
}
break;
case "setallitemchance":
int chance = Integer.parseInt(value);
if (chance < 1 || chance > 100)
throw new InvalidLootDropSettingException("Invalid chance");
for (ISoliniaLootDropEntry entry : getEntries()) {
entry.setChance(chance);
}
break;
case "setallcount":
int count = Integer.parseInt(value);
if (count < 0 || count > 100)
throw new InvalidLootDropSettingException("Invalid count");
for (ISoliniaLootDropEntry entry : getEntries()) {
entry.setCount(count);
}
break;
default:
throw new InvalidLootDropSettingException("Invalid LootDrop setting. Valid Options are: name,remove,setallchance,setallitemchance,setallcount,setallitemminlevel,setallitemfireresist,setallitemcoldresist,setallitemmagicresist,setallitempoisonresist,setallitemdiseaseresist");
}
}
Aggregations