Loot updates

- Color crystals now get elemental attachment values for combat service.
- Armor drops can have random stat mods now
- Script fixes
This commit is contained in:
CharonInferar
2014-06-08 01:09:41 +02:00
parent 34cc605533
commit 08f1b52f97
8 changed files with 126 additions and 17 deletions
+120 -11
View File
@@ -42,7 +42,6 @@ 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;
import resources.loot.LootGroup;
@@ -76,7 +75,7 @@ public class LootService implements INetworkDispatch {
private NGECore core;
private static int prepInvCnt = 0;
String testDropTemplate = null;
//String testDropTemplate = "sunriders_destiny";
//String testDropTemplate = "composite_armor_bracer_left";
public LootService(NGECore core) {
this.core = core;
@@ -544,7 +543,8 @@ public class LootService implements INetworkDispatch {
if (randomItemFromPool<=remainder){
// this element has been chosen e.g. kraytpearl_flawless
//System.err.println("CHOSEN ITEM " + itemNames.get(i));
handleLootPoolItems(itemNames.get(i), lootRollSession);
handleLootPoolItems(itemNames.get(i), lootRollSession);
//handleLootPoolItems(testDropTemplate, lootRollSession);
//break;
return;
}
@@ -564,6 +564,7 @@ public class LootService implements INetworkDispatch {
rollSession.setSessionPlanet(requester.getPlanet());
handleLootPoolItems(template, rollSession);
if(rollSession.getDroppedItems().get(0) != null) return rollSession.getDroppedItems().get(0);
return null;
@@ -615,9 +616,12 @@ public class LootService implements INetworkDispatch {
String requiredFaction = "";
Vector<String> customizationAttributes = null;
Vector<Integer> customizationValues = null;
int customColor1 = 0;
String lootDescriptor = "";
Vector<String> itemStats = null;
Vector<String> itemSkillMods = null;
Vector<String> STFparams = null;
String addToCollection = 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.";
@@ -645,6 +649,12 @@ public class LootService implements INetworkDispatch {
if(core.scriptService.getMethod(itemPath,"","customizationValues")!=null)
customizationValues = (Vector<Integer>)core.scriptService.fetchIntegerVector(itemPath,"customizationValues");
if(core.scriptService.getMethod(itemPath,"","customColor1")!=null)
customColor1 = (Integer)core.scriptService.fetchInteger(itemPath,"customColor1");
if(core.scriptService.getMethod(itemPath,"","lootDescriptor")!=null)
lootDescriptor = (String)core.scriptService.fetchString(itemPath,"lootDescriptor");
if(core.scriptService.getMethod(itemPath,"","itemStats")!=null)
itemStats = (Vector<String>)core.scriptService.fetchStringVector(itemPath,"itemStats");
@@ -675,6 +685,9 @@ public class LootService implements INetworkDispatch {
if(core.scriptService.getMethod(itemPath,"","STFparams")!=null)
STFparams = (Vector<String>)core.scriptService.fetchStringVector(itemPath,"STFparams");
if(core.scriptService.getMethod(itemPath,"","AddToCollection")!=null)
addToCollection = (String)core.scriptService.fetchString(itemPath,"AddToCollection");
System.out.println("itemTemplate " + itemTemplate);
@@ -683,6 +696,10 @@ public class LootService implements INetworkDispatch {
droppedItem.setLootItem(true);
droppedItem.setAttachment("LootItemName", itemName);
droppedItem.setAttachment("customColor1", customColor1);
droppedItem.setAttachment("lootDescriptor", lootDescriptor);
droppedItem.setAttachment("customName", customName);
if(core.scriptService.getMethod(itemPath,"","randomStatJewelry")!=null){
customName = setRandomStatsJewelry(droppedItem, lootRollSession);
@@ -716,7 +733,7 @@ public class LootService implements INetworkDispatch {
lootRollSession.addErrorMessage(errorMessage);
return;
}
handleStats(droppedItem, itemStats);
handleStats(droppedItem, itemStats, lootRollSession);
}
if (itemSkillMods!=null){
@@ -727,6 +744,12 @@ public class LootService implements INetworkDispatch {
setSTFParams(droppedItem, STFparams);
}
if (addToCollection!=null){
droppedItem.getAttributes().put("@obj_attr_n:collection_name", "@collection_n:"+addToCollection);
//droppedItem.getAttributes().put("@obj_attr_n:collection_name", "\\#FFFF00 @collection_n:"+addToCollection + " \\#FFFFFF ");
//core.collectionService.addCollection(actor, "new_prof_officer_master")
}
// if (customizationValues!=null)
@@ -1171,7 +1194,7 @@ public class LootService implements INetworkDispatch {
String errorMessage = "Loot item '" + itemName + "' has a wrong number of itemstats. Please contact Charon about this issue.";
return;
}
handleStats(droppedItem, itemStats);
handleStats(droppedItem, itemStats,null);
}
if (itemSkillMods!=null){
@@ -1183,7 +1206,8 @@ public class LootService implements INetworkDispatch {
}
if (addToCollection!=null){
droppedItem.getAttributes().put("@obj_attr_n:collection_name", addToCollection);
droppedItem.getAttributes().put("@obj_attr_n:collection_name", "@collection_n:"+addToCollection);
//droppedItem.getAttributes().put("@obj_attr_n:collection_name", "\\#FFFF00 @collection_n:"+addToCollection + " \\#FFFFFF ");
//core.collectionService.addCollection(actor, "new_prof_officer_master")
}
@@ -1252,6 +1276,10 @@ public class LootService implements INetworkDispatch {
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
String[] crystalColorElementalMapping = new String[]{"heat","heat","acid","acid","cold","cold","cold","acid","electricity","electricity","heat","heat"};
setCrystalStat(droppedItem, "elemtype", crystalColorElementalMapping[crystalColor],crystalColorElementalMapping[crystalColor]);
setCrystalStat(droppedItem, "elemdamage", "2", "2");
} else {
for (int i=0; i<customizationAttributes.size();i++){
int intValue = customizationValues.get(i);
@@ -1304,7 +1332,7 @@ public class LootService implements INetworkDispatch {
}
}
private void handleStats(TangibleObject droppedItem, Vector<String> itemStats) {
private void handleStats(TangibleObject droppedItem, Vector<String> itemStats, LootRollSession lootRollSession) {
if (droppedItem.getTemplate().contains("object/weapon")){
WeaponObject weaponObject = (WeaponObject) droppedItem;
@@ -1321,8 +1349,10 @@ public class LootService implements INetworkDispatch {
String statName = itemStats.get(3*i);
String minValue = itemStats.get(3*i+1);
String maxValue = itemStats.get(3*i+2);
setArmorStat(droppedItem, statName, minValue, maxValue);
setArmorStat(droppedItem, statName, minValue, maxValue);
}
if (lootRollSession != null)
setRandomAttributes(droppedItem,lootRollSession);
}
String lootDescriptor = (String)droppedItem.getAttachment("lootDescriptor");
@@ -1334,6 +1364,7 @@ public class LootService implements INetworkDispatch {
String minValue = itemStats.get(3*i+1);
String maxValue = itemStats.get(3*i+2);
setCrystalStat(droppedItem, statName, minValue, maxValue);
return;
}
}
@@ -1343,11 +1374,89 @@ public class LootService implements INetworkDispatch {
String minValue = itemStats.get(3*i+1);
String maxValue = itemStats.get(3*i+2);
setBuffItemStat(droppedItem, statName, minValue, maxValue);
return;
}
}
}
}
private void setRandomAttributes(TangibleObject droppedItem, LootRollSession lootRollSession){
//determine number of stats #20 yt
int statNumber = 1;
int levelOfDrop = lootRollSession.getLootedObjectLevel();
int difficultyLevel = lootRollSession.getLootedObjectDifficulty(); // better for calculation
int statRoll = new Random().nextInt(100);
int difficultyBonus = 0;
// // stage 1
// if (difficultyLevel==1)
// difficultyBonus = 60;
// if (difficultyLevel>=2)
// difficultyBonus = 75;
//
// if (statRoll<20+difficultyBonus) // diff 3 95% diff 2 70 diff1 20
// statNumber++;
//
// // stage 2
// difficultyBonus = 0;
// if (difficultyLevel==1)
// difficultyBonus = 20;
// if (difficultyLevel>=2)
// difficultyBonus = 60;
//
// if (statRoll<10+difficultyBonus) // diff 3 70% diff 2 30 diff1 10
// statNumber++;
//
// // stage 3
// difficultyBonus = 0;
// if (difficultyLevel==1)
// difficultyBonus = 3;
// if (difficultyLevel>=2)
// difficultyBonus = 5;
//
// if (statRoll<1+difficultyBonus)
// statNumber++;
if (levelOfDrop>60 && levelOfDrop<=90 && difficultyLevel<1){
statNumber=2;
}
if (levelOfDrop>84 && difficultyLevel>=1){
statNumber=3;
}
int primaryAttribute = new Random().nextInt(7); // 0-6
int maxValue = (int) (levelOfDrop*25/90);
int minValue = (int) (0.75*maxValue);
minValue = Math.max(1, minValue);
maxValue = Math.max(2, maxValue);
droppedItem.setIntAttribute(getAttributeSTF(primaryAttribute), getStatValue(minValue,maxValue));
//maxValue -= 2; //secondary attributes must have less maxValue
minValue = (int) (0.75*maxValue);
minValue = Math.max(1, minValue);
maxValue = Math.max(2, maxValue);
String prefix = getJewelryPrefix(droppedItem);
String suffix = getJewelrySuffix(primaryAttribute, statNumber);
String itemName = prefix + suffix;
Vector<Integer> alreadyUsedStats = new Vector<Integer>();
alreadyUsedStats.add(primaryAttribute);
int attribute = primaryAttribute;
List<Integer> statList = new ArrayList<Integer>();
for (int i=0;i<7;i++)
statList.add(i);
statList.remove(primaryAttribute);
for (int i=0;i<statNumber-1;i++){
int attributeIndex = new Random().nextInt(statList.size());
droppedItem.setIntAttribute(getAttributeSTF(statList.get(attributeIndex)), getStatValue(minValue,maxValue));
statList.remove(attributeIndex);
}
}
private void handleSkillMods(TangibleObject droppedItem, Vector<String> skillMods) {
for (int i=0;i<skillMods.size()/2;i++){
String skillMod = skillMods.get(2*i);
@@ -2392,7 +2501,7 @@ public class LootService implements INetworkDispatch {
System.err.println(errorMessage);
return;
}
handleStats(droppedItem, itemStats);
handleStats(droppedItem, itemStats, lootRollSession);
}
if (itemSkillMods!=null){