From 9e1d19d5255f838a9ac9e916e6ecd34f1a6ca1c8 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Thu, 5 Jun 2014 15:20:28 +0200 Subject: [PATCH] custom attributes added to loot scripts loot scripts can now have custom attribute arrays for better customization of drops --- src/main/NGECore.java | 10 +++- src/services/DevService.java | 2 +- src/services/LootService.java | 91 +++++++++++++++++--------------- src/services/TerrainService.java | 28 +++++----- 4 files changed, 75 insertions(+), 56 deletions(-) diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 95a4ecb7..92dde2db 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -260,7 +260,7 @@ public class NGECore { options.setFilePath("options.cfg"); boolean optionsConfigLoaded = options.loadConfigFile(); - if (optionsConfigLoaded && options.getInt("CLEAN.ODB.FOLDERS") > 0) { + if (optionsConfigLoaded && options.getInt("CLEAN.ODB.FOLDERS") > 0 || getExcludedDevelopers().contains(System.getProperty("user.name"))){ File baseFolder = new File("./odb"); if (baseFolder.isDirectory()) { @@ -790,5 +790,13 @@ public class NGECore { public void setMotd(String motd) { this.motd = motd; } + + public Vector getExcludedDevelopers(){ + Vector excludedDevelopers = new Vector(); + excludedDevelopers.add("Charon"); + // Feel free to add your OS user account name here to exclude yourself from loading buildouts and snapshots + // without having to change options.cfg all the time + return excludedDevelopers; + } } diff --git a/src/services/DevService.java b/src/services/DevService.java index 18a090fa..c7a7381f 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -1049,7 +1049,7 @@ public class DevService implements INetworkDispatch { colorCrystal.getAttributes().put("@obj_attr_n:condition", "100/100"); colorCrystal.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF "); colorCrystal.setAttachment("radial_filename", "item/tunable"); - core.lootService.setCustomization(colorCrystal, "colorcrystal"); + core.lootService.setCustomization(colorCrystal, "colorcrystal",null,null); inventory.add(colorCrystal); TangibleObject lavaCrystal = (TangibleObject) core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_lava_crystal.iff", planet); diff --git a/src/services/LootService.java b/src/services/LootService.java index 93d543dd..4f4dd549 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -39,7 +39,9 @@ import java.util.Map; import java.util.Random; import java.util.Vector; import java.util.concurrent.atomic.AtomicInteger; + import protocol.swg.PlayClientEffectObjectTransformMessage; +import protocol.swg.StopClientEffectObjectByLabel; import resources.objects.craft.DraftSchematic; import resources.common.OutOfBand; import resources.datatables.DisplayType; @@ -214,7 +216,7 @@ public class LootService implements INetworkDispatch { // For autoloot //SWGObject requesterInventory = requester.getSlottedObject("inventory"); - System.out.println("lootRollSession.getDroppedItems() " + (lootRollSession.getDroppedItems())); + //System.out.println("lootRollSession.getDroppedItems() " + (lootRollSession.getDroppedItems())); for (TangibleObject droppedItem : lootRollSession.getDroppedItems()){ //droppedItem.setAttachment("radial_filename", "lootitem"); @@ -223,12 +225,9 @@ public class LootService implements INetworkDispatch { // RLS chest effect if (droppedItem.getAttachment("LootItemName").toString().contains("Loot Chest")){ + requester.playEffectObject("appearance/pt_rare_chest.prt", ""); - - requester.playMusic("sound/rare_loot_chest.snd"); - if (requester.getClient().isGM()) { - requester.sendSystemMessage("GM Message: Played rlc effect due to RLC dropping.", DisplayType.Broadcast); - } + requester.playMusic("sound/rare_loot_chest.snd"); } } @@ -511,7 +510,7 @@ public class LootService implements INetworkDispatch { else remainder += span; if (randomItemFromGroup <= remainder){ - System.out.println("this loot pool will drop something"); // e.g. kraytpearl_range + //System.out.println("this loot pool will drop something"); // e.g. kraytpearl_range handleLootPool(lootPoolNames[i],lootRollSession); // This loot pool will drop something test = true; break; @@ -522,7 +521,7 @@ public class LootService implements INetworkDispatch { } private void handleLootPool(String poolName,LootRollSession lootRollSession){ - System.err.println("poolName.toLowerCase() " + poolName.toLowerCase()); + //System.err.println("poolName.toLowerCase() " + poolName.toLowerCase()); // Fetch the loot pool data from the poolName.py script String path = "scripts/loot/lootPools/"+poolName.toLowerCase(); Vector itemNames = (Vector)core.scriptService.fetchStringVector(path,"itemNames"); @@ -729,7 +728,7 @@ public class LootService implements INetworkDispatch { // if (customizationValues!=null) // setCustomization(droppedItem, itemName); - setCustomization(droppedItem, itemName); // for now + setCustomization(droppedItem, itemName, customizationAttributes, customizationValues); // for now handleSpecialItems(droppedItem, itemName); @@ -992,6 +991,7 @@ public class LootService implements INetworkDispatch { remainder += span; if (randomItemFromPool<=remainder){ fillChest4(itemNames.get(i), owner, chest); + //fillChest4("colorcrystal", owner, chest); //break; return; } @@ -1050,6 +1050,7 @@ public class LootService implements INetworkDispatch { Vector itemStats = null; Vector itemSkillMods = null; Vector STFparams = null; + Vector addToCollections = null; if(core.scriptService.getMethod(itemPath,"","itemTemplate")==null){ String errorMessage = "Loot item '" + itemName + "' has no template function assigned in its script. Please contact Charon about this issue."; @@ -1115,6 +1116,9 @@ public class LootService implements INetworkDispatch { if(core.scriptService.getMethod(itemPath,"","STFparams")!=null) STFparams = (Vector)core.scriptService.fetchStringVector(itemPath,"STFparams"); + if(core.scriptService.getMethod(itemPath,"","AddToCollections")!=null) + addToCollections = (Vector)core.scriptService.fetchStringVector(itemPath,"AddToCollections"); + System.out.println("itemTemplate " + itemTemplate); @@ -1166,7 +1170,7 @@ public class LootService implements INetworkDispatch { setSTFParams(droppedItem, STFparams); } - setCustomization(droppedItem, itemName); // for now + setCustomization(droppedItem, itemName, customizationAttributes, customizationValues); // for now handleSpecialItems(droppedItem, itemName); @@ -1197,7 +1201,7 @@ public class LootService implements INetworkDispatch { droppedItem.getAttributes().put("@obj_attr_n:rare_loot_category", "\\#D1F56F Rare Item \\#FFFFFF "); SWGObject inventory = owner.getSlottedObject("inventory"); inventory.add(droppedItem); - System.out.println("ACTUAL DROP " + droppedItem.getTemplate()); + // System.out.println("ACTUAL DROP " + droppedItem.getTemplate()); } else { DraftSchematic droppedSchematic = createDroppedSchematic(itemTemplate,owner.getPlanet()); @@ -1205,7 +1209,7 @@ public class LootService implements INetworkDispatch { droppedSchematic.getAttributes().put("@obj_attr_n:rare_loot_category", "\\#D1F56F Rare Item \\#FFFFFF "); SWGObject inventory = owner.getSlottedObject("inventory"); inventory.add(droppedSchematic); - System.out.println("ACTUAL DROP " + droppedSchematic.getTemplate()); + //System.out.println("ACTUAL DROP " + droppedSchematic.getTemplate()); } } @@ -1215,20 +1219,28 @@ public class LootService implements INetworkDispatch { } - public void setCustomization(TangibleObject droppedItem,String itemName) { + public void setCustomization(TangibleObject droppedItem,String itemName, Vector customizationAttributes, Vector customizationValues) { // Example color crystal if (itemName.contains("colorcrystal")) { System.out.println("colorcrystal"); - int crystalColor = new Random().nextInt(11); - - droppedItem.setCustomizationVariable("/private/index_color_1", (byte) crystalColor); - droppedItem.getAttributes().put("@obj_attr_n:condition", "100/100"); - droppedItem.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF "); - droppedItem.getAttributes().put("@obj_attr_n:color", resources.datatables.LightsaberColors.get(crystalColor)); - droppedItem.setAttachment("radial_filename", "item/tunable"); - //droppedItem.getAttributes().put("@obj_attr_n:color", "@jedi_spam:saber_color_" + crystalColor); // Commented out for now + if (customizationAttributes==null){ + int crystalColor = new Random().nextInt(11); + + droppedItem.setCustomizationVariable("/private/index_color_1", (byte) crystalColor); + droppedItem.getAttributes().put("@obj_attr_n:condition", "100/100"); + droppedItem.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF "); + droppedItem.getAttributes().put("@obj_attr_n:color", resources.datatables.LightsaberColors.get(crystalColor)); + droppedItem.setAttachment("radial_filename", "item/tunable"); + //droppedItem.getAttributes().put("@obj_attr_n:color", "@jedi_spam:saber_color_" + crystalColor); // Commented out for now + } else { + for (int i=0; i customizationPaths = (Vector)core.scriptService.fetchStringVector(path,"itemCustomizationPaths"); -// Vector customizationValues = (Vector)core.scriptService.fetchIntegerVector(path,"itemCustomizationValues"); -// for (int i=0;i 0) { - try { - core.objectService.loadSnapshotObjects(planet); - } catch (Exception e) { - e.printStackTrace(); + if (!core.getExcludedDevelopers().contains(System.getProperty("user.name"))){ + try { + core.objectService.loadSnapshotObjects(planet); + } catch (Exception e) { + e.printStackTrace(); + } } } if (loaded && config.getInt("LOAD.BUILDOUT_OBJECTS") > 0) { - if (! config.keyExists("LOAD.BUILDOUT_ONLY_FOR")){ - try { - core.objectService.loadBuildoutObjects(planet); - } catch (InstantiationException | IllegalAccessException e) { - e.printStackTrace(); - } - } else { - if (planet.getName().equals(config.getString("LOAD.BUILDOUT_ONLY_FOR"))){ + if (!core.getExcludedDevelopers().contains(System.getProperty("user.name"))){ + if (! config.keyExists("LOAD.BUILDOUT_ONLY_FOR")){ try { core.objectService.loadBuildoutObjects(planet); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } + } else { + if (planet.getName().equals(config.getString("LOAD.BUILDOUT_ONLY_FOR"))){ + try { + core.objectService.loadBuildoutObjects(planet); + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + } } } }