Added Rarity attribute to RLS items, added reward UI to RLS chest

This commit is contained in:
seefo
2018-05-19 07:07:13 -04:00
parent af60b08cb8
commit beec3bbdc2
3 changed files with 83 additions and 9 deletions
@@ -1229,6 +1229,42 @@ public class loot extends script.base_script
}
return boolMadeLoot;
}
public static obj_id makeRareLootItem(obj_id objContainer, String strTable) throws InterruptedException
{
String strRootItems = "datatables/loot/loot_items/";
String[] parse = split(strTable, ':');
strTable = parse[0];
strTable = "datatables/loot/loot_types/" + strTable + ".iff";
String strItemsHeader = "strItems";
if (parse.length == 2) {
strItemsHeader = parse[1];
}
String[] strLootTypes = dataTableGetStringColumnNoDefaults(strTable, strItemsHeader);
String strItemTable = strLootTypes[rand(0, strLootTypes.length - 1)];
String[] parseItem = split(strItemTable, ':');
strItemTable = parseItem[0];
strItemTable = strRootItems + strItemTable + ".iff";
String strItemTypeHeader = "strItemType";
if (parseItem.length == 2)
{
strItemTypeHeader = parseItem[1];
}
if (dataTableOpen(strItemTable)) {
String[] strItems = dataTableGetStringColumnNoDefaults(strItemTable, strItemTypeHeader);
if (strItems != null && strItems.length > 0)
{
String strLootToMake = strItems[rand(0, strItems.length - 1)];
obj_id lootItem = createLootItem(objContainer, strLootToMake, 1);
attachScript(lootItem, "systems.loot.rare_item");
return lootItem;
}
}
return null;
}
public static obj_id createLootItem(obj_id objContainer, String strLootToMake, int intLevel) throws InterruptedException
{
int intIndex = strLootToMake.indexOf(".iff");
@@ -0,0 +1,30 @@
package script.systems.loot;
import script.library.badge;
import script.library.collection;
import script.library.loot;
import script.library.utils;
import script.menu_info;
import script.menu_info_types;
import script.obj_id;
import script.string_id;
public class rare_item extends script.base_script {
public int OnGetAttributes(obj_id self, obj_id player, String[] names, String[] attribs) throws InterruptedException
{
if ((names == null) || (attribs == null) || (names.length != attribs.length))
{
return SCRIPT_CONTINUE;
}
if (player != null)
{
final int firstFreeIndex = getFirstFreeIndex(names);
if ((firstFreeIndex >= 0) && (firstFreeIndex < names.length))
{
names[firstFreeIndex] = "rare_loot_category";
attribs[firstFreeIndex] = "\\#ed8d16Rare";
}
}
return SCRIPT_CONTINUE;
}
}
@@ -9,6 +9,10 @@ import script.menu_info_types;
import script.obj_id;
import script.string_id;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
public class rare_loot_chest extends script.base_script {
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException {
if (utils.getContainingPlayer(self) == player) {
@@ -19,19 +23,23 @@ public class rare_loot_chest extends script.base_script {
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException {
sendDirtyObjectMenuNotification(self);
if (item == menu_info_types.ITEM_USE) {
if (item == menu_info_types.ITEM_USE)
{
String template = getTemplateName(self);
int rarity = 0;
for (int i = 2; i < 4; i++) {
if (template.equals("object/tangible/item/rare_loot_chest_" + i + ".iff")) {
rarity = i - 1;
int rarity = Integer.parseInt(template.replace("object/tangible/item/rare_loot_chest_", "").replace(".iff", "")) - 1;
List<obj_id> items = new ArrayList<>();
int numberOfItems = rand(1, 2);
while(items.size() < numberOfItems) {
obj_id rareItem = loot.makeRareLootItem(utils.getInventoryContainer(player), "rls/" + loot.CHEST_TYPES[rand(0,rarity)] + "_loot");
if(rareItem != null) {
items.add(rareItem);
}
}
int numberOfItems = rand(1, 2);
for (int i = 0; i < numberOfItems; i++) {
loot.makeLootInContainer(utils.getInventoryContainer(player), "rls/" + loot.CHEST_TYPES[rand(0,rarity)] + "_loot", 1, 1);
}
obj_id[] lootedItems = new obj_id[items.size()];
items.toArray(lootedItems);
showLootBox(player, lootedItems);
destroyObject(self);
handleRareLootCollection(player, rarity + 1);