mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-12 02:13:48 -04:00
Refined the loot system
Added more py scripts for krayt pearls and junk Made system more flexible
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
|
||||
def customItemStackCount():
|
||||
|
||||
return 1
|
||||
|
||||
def customizationAttributes():
|
||||
|
||||
return []
|
||||
|
||||
def customizationValues():
|
||||
|
||||
return []
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/loot/misc/shared_damaged_datapad.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
|
||||
def customItemStackCount():
|
||||
|
||||
return 1
|
||||
|
||||
def customizationAttributes():
|
||||
|
||||
return []
|
||||
|
||||
def customizationValues():
|
||||
|
||||
return []
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/component/weapon/shared_lightsaber_module_krayt_dragon_pearl.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/loot/npc_loot/shared_red_wiring_generic.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
|
||||
def customItemStackCount():
|
||||
|
||||
return 1
|
||||
|
||||
def customizationAttributes():
|
||||
|
||||
return []
|
||||
|
||||
def customizationValues():
|
||||
|
||||
return []
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/weapon/ranged/rifle/shared_rifle_cdef.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
|
||||
def customItemStackCount():
|
||||
|
||||
return 1
|
||||
|
||||
def customizationAttributes():
|
||||
|
||||
return []
|
||||
|
||||
def customizationValues():
|
||||
|
||||
return []
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
def itemTemplate():
|
||||
|
||||
return 'object/tangible/loot/npc_loot/shared_worklight_generic.iff'
|
||||
|
||||
def customItemName():
|
||||
|
||||
return ''
|
||||
|
||||
def customItemStackCount():
|
||||
|
||||
return 1
|
||||
|
||||
def customizationAttributes():
|
||||
|
||||
return []
|
||||
|
||||
def customizationValues():
|
||||
|
||||
return []
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemNames():
|
||||
|
||||
return ['colorCrystal']
|
||||
|
||||
def itemChances():
|
||||
|
||||
return [70]
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemNames():
|
||||
|
||||
templates=['damaged_datapad','red_wiring','worklight_generic']
|
||||
return templates
|
||||
|
||||
def itemChances():
|
||||
return [70,50,40]
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemNames():
|
||||
|
||||
return ['kraytpearl_cracked','kraytpearl_scratched','kraytpearl_poor']
|
||||
|
||||
def itemChances():
|
||||
|
||||
return [33,33,34]
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
def itemTemplates():
|
||||
return ['kraytpearl_fair','kraytpearl_good','kraytpearl_quality','kraytpearl_select','kraytpearl_premium','kraytpearl_flawless']
|
||||
|
||||
def itemChances():
|
||||
return [10,20,30,34,5,1] #= 100%
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
def itemTemplates():
|
||||
def itemNames():
|
||||
|
||||
templates=['object/tangible/item/shared_rare_loot_chest_3.iff']
|
||||
return templates
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
def itemNames():
|
||||
|
||||
return ['shared_rifle_cdef']
|
||||
|
||||
def itemChances():
|
||||
return [100]
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
|
||||
def itemTemplates():
|
||||
|
||||
templates=['object/tangible/component/weapon/lightsaber/lightsaber_module_force_crystal.iff']
|
||||
return templates
|
||||
|
||||
def itemChances():
|
||||
return [70]
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
def itemTemplates():
|
||||
|
||||
templates=['object/tangible/loot/misc/shared_damaged_datapad.iff','object/tangible/loot/npc_loot/shared_red_wiring_generic.iff','object/tangible/loot/npc_loot/shared_worklight_generic.iff']
|
||||
return templates
|
||||
|
||||
def itemChances():
|
||||
return [70,50,40]
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
def itemTemplates():
|
||||
|
||||
templates=['1','2','3','Flawless']
|
||||
return templates
|
||||
|
||||
def itemChances():
|
||||
return [60,20,10,5]
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
|
||||
def itemTemplates():
|
||||
|
||||
templates=['object/weapon/ranged/rifle/shared_rifle_cdef.iff']
|
||||
return templates
|
||||
|
||||
def itemChances():
|
||||
return [70]
|
||||
@@ -1,4 +1,15 @@
|
||||
import sys
|
||||
|
||||
def setup(core, object):
|
||||
return
|
||||
|
||||
lootPoolNames_1 = ['Junk']
|
||||
lootPoolChances_1 = [100]
|
||||
lootGroupChance_1 = 65
|
||||
object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1)
|
||||
|
||||
lootPoolNames_2 = ['kraytpearl_loq']
|
||||
lootPoolChances_2 = [100]
|
||||
lootGroupChance_2 = 35
|
||||
object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2)
|
||||
|
||||
return
|
||||
@@ -4,12 +4,12 @@ def setup(core, object):
|
||||
|
||||
lootPoolNames_1 = ['Junk','Rifles']
|
||||
lootPoolChances_1 = [90,70]
|
||||
lootGroupChance_1 = 80
|
||||
lootGroupChance_1 = 90
|
||||
object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1)
|
||||
|
||||
lootPoolNames_2 = ['Colorcrystals']
|
||||
lootPoolChances_2 = [50]
|
||||
lootGroupChance_2 = 60
|
||||
lootPoolChances_2 = [100]
|
||||
lootGroupChance_2 = 20
|
||||
object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2)
|
||||
|
||||
lootPoolNames_3 = ['Rareloot']
|
||||
|
||||
@@ -24,9 +24,11 @@ package resources.objects.loot;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import engine.resources.scene.Planet;
|
||||
import main.NGECore;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.group.GroupObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
@@ -36,7 +38,8 @@ public class LootRollSession {
|
||||
|
||||
private String SessionID; // leaderName-SystemTime
|
||||
private GroupObject playerGroup;
|
||||
private List<String> droppedItemTemplates;
|
||||
private List<TangibleObject> droppedItems;
|
||||
private Planet sessionPlanet;
|
||||
|
||||
public LootRollSession(){
|
||||
}
|
||||
@@ -49,15 +52,16 @@ public class LootRollSession {
|
||||
} else {
|
||||
this.SessionID = requester.getCustomName()+"-"+System.currentTimeMillis();
|
||||
}
|
||||
droppedItemTemplates = new ArrayList<String>();
|
||||
droppedItems = new ArrayList<TangibleObject>();
|
||||
sessionPlanet = requester.getPlanet();
|
||||
}
|
||||
|
||||
public List<String> getDroppedItemTemplates() {
|
||||
return droppedItemTemplates;
|
||||
public List<TangibleObject> getDroppedItems() {
|
||||
return droppedItems;
|
||||
}
|
||||
|
||||
public void addDroppedItemTemplate(String droppedItemTemplate) {
|
||||
this.droppedItemTemplates.add(droppedItemTemplate);
|
||||
public void addDroppedItem(TangibleObject droppedItem) {
|
||||
this.droppedItems.add(droppedItem);
|
||||
}
|
||||
|
||||
public String getSessionID() {
|
||||
@@ -71,4 +75,8 @@ public class LootRollSession {
|
||||
public void generateSessionID(String sessionID) {
|
||||
SessionID = sessionID;
|
||||
}
|
||||
|
||||
public Planet getSessionPlanet() {
|
||||
return sessionPlanet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=2)
|
||||
@Persistent(version=3)
|
||||
public class TangibleObject extends SWGObject {
|
||||
|
||||
// TODO: Thread safety
|
||||
|
||||
+119
-36
@@ -21,29 +21,18 @@
|
||||
******************************************************************************/
|
||||
package services;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.group.GroupObject;
|
||||
import resources.objects.loot.LootDrop;
|
||||
import resources.objects.loot.LootGroup;
|
||||
import resources.objects.loot.LootPool;
|
||||
import resources.objects.loot.LootRollSession;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import resources.objects.tool.SurveyTool;
|
||||
import main.NGECore;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
|
||||
@@ -110,27 +99,23 @@ public class LootService implements INetworkDispatch {
|
||||
int lootGroupRoll = new Random().nextInt(100);
|
||||
if (lootGroupRoll <= groupChance){
|
||||
System.out.println("this lootGroup will drop something");
|
||||
handleLootGroup(lootGroup,lootRollSession); //this lootGroup will drop something
|
||||
handleLootGroup(lootGroup,lootRollSession); //this lootGroup will drop something e.g. {kraytpearl_range,krayt_tissue_rare}
|
||||
}
|
||||
}
|
||||
|
||||
for (String s : lootRollSession.getDroppedItemTemplates()){
|
||||
System.out.println("lootRollSession template: " + s);
|
||||
}
|
||||
|
||||
|
||||
// ********** Phase 1 complete, loot items determined **********
|
||||
// stored in the lootSession
|
||||
|
||||
// Distribute the loot drops according to group loot rules
|
||||
// For now just spawn items into requester's inventory
|
||||
SWGObject requesterInventory = requester.getSlottedObject("inventory");
|
||||
System.out.println("requesterInventory " + requesterInventory);
|
||||
for (String template : lootRollSession.getDroppedItemTemplates()){
|
||||
TangibleObject droppedItem = (TangibleObject) core.objectService.createObject(template, requester.getPlanet());
|
||||
System.out.println("droppedItem " + droppedItem);
|
||||
|
||||
for (TangibleObject droppedItem : lootRollSession.getDroppedItems()){
|
||||
|
||||
requesterInventory.add(droppedItem);
|
||||
}
|
||||
|
||||
|
||||
// ToDo: Group loot settings etc. actual loot chance was lootgroupchance*lootchance
|
||||
}
|
||||
@@ -148,33 +133,131 @@ public class LootService implements INetworkDispatch {
|
||||
System.err.println("No Lootpools in Lootgroup!");
|
||||
return;
|
||||
}
|
||||
|
||||
int randomItemFromGroup = new Random().nextInt(100);
|
||||
int remainder = 0; // [10,20,30,34,5,1]
|
||||
|
||||
for(int i=0;i<lootPoolChances.length;i++) {
|
||||
int lootPoolElementRoll = new Random().nextInt(100);
|
||||
if (lootPoolElementRoll <= lootPoolChances[i]){
|
||||
System.out.println("this loot pool will drop something");
|
||||
handleLootPool(lootPoolNames[i],lootRollSession); // This loot pool will drop something
|
||||
}
|
||||
}
|
||||
remainder += lootPoolChances[i];
|
||||
if (randomItemFromGroup <= remainder){
|
||||
System.out.println("this loot pool will drop something"); // e.g. kraytpearl_range
|
||||
handleLootPool(lootPoolNames[i],lootRollSession); // This loot pool will drop something
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleLootPool(String poolName,LootRollSession lootRollSession){
|
||||
|
||||
// Fetch the loot pool data from the poolName.py script
|
||||
String path = "scripts/lootPools/"+poolName.toLowerCase();
|
||||
Vector<String> itemTemplates = (Vector<String>)core.scriptService.fetchStringVector(path,"itemTemplates");
|
||||
String path = "scripts/loot/lootPools/"+poolName.toLowerCase();
|
||||
Vector<String> itemNames = (Vector<String>)core.scriptService.fetchStringVector(path,"itemNames");
|
||||
|
||||
for (String s : itemTemplates){
|
||||
for (String s : itemNames){
|
||||
System.out.println("template: " + s);
|
||||
}
|
||||
|
||||
Vector<Integer> itemChances = (Vector<Integer>)core.scriptService.fetchIntegerVector(path,"itemChances");
|
||||
|
||||
// Now here maybe all items in pool have an equal chance to spawn
|
||||
// or they have percentages assigned to them as well
|
||||
|
||||
|
||||
int randomItemFromPool = new Random().nextInt(100);
|
||||
int itemIndex = (int)Math.floor(randomItemFromPool/100*itemTemplates.size()); // 5 Elements,rnd is 83 -> 0.83*5=
|
||||
int remainder = 0; // [10,20,30,34,5,1]
|
||||
|
||||
lootRollSession.addDroppedItemTemplate(itemTemplates.get(itemIndex));
|
||||
for (int i=0;i<itemNames.size();i++){
|
||||
remainder += itemChances.get(i);
|
||||
if (randomItemFromPool<=remainder){
|
||||
// this element has been chosen e.g. kraytpearl_flawless
|
||||
handleLootPoolItems(itemNames.get(i), lootRollSession);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleLootPoolItems(String itemName,LootRollSession lootRollSession){
|
||||
|
||||
String path = "scripts/loot/lootItems/"+itemName.toLowerCase();
|
||||
System.out.println("path: " + path);
|
||||
String itemTemplate = (String)core.scriptService.fetchString(path,"itemTemplate");
|
||||
String customName = (String)core.scriptService.fetchString(path,"customItemName");
|
||||
int stackCount = (Integer)core.scriptService.fetchInteger(path,"customItemStackCount");
|
||||
Vector<String> customizationAttributes = (Vector<String>)core.scriptService.fetchStringVector(path,"customizationAttributes");
|
||||
Vector<Integer> customizationValues = (Vector<Integer>)core.scriptService.fetchIntegerVector(path,"customizationValues");
|
||||
|
||||
System.out.println("itemTemplate " + itemTemplate);
|
||||
|
||||
/*
|
||||
craftingValues = {
|
||||
{"mindamage",25,35,0},
|
||||
{"maxdamage",40,50,0},
|
||||
{"attackspeed",1,-1,5},
|
||||
{"woundchance",4,8,5},
|
||||
{"hitpoints",800,1200,0},
|
||||
{"attackhealthcost",0,9,0},
|
||||
{"attackactioncost",0,9,0},
|
||||
{"attackmindcost",0,9,0},
|
||||
{"forcecost",0,9.9,0},
|
||||
{"color",31,31,0},
|
||||
{"quality",6,6,0},
|
||||
},
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TangibleObject droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet());
|
||||
|
||||
handleCustomDropName(droppedItem);
|
||||
handleStats(droppedItem);
|
||||
setCustomization(droppedItem);
|
||||
|
||||
lootRollSession.addDroppedItem(droppedItem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void handleCustomDropName(TangibleObject droppedItem) {
|
||||
String customName = droppedItem.getCustomName();
|
||||
|
||||
if (customName!=null) {
|
||||
if (customName.charAt(0) == '@' || customName.contains("_n:")) {
|
||||
customName = ""; // Look the name up in some tre table
|
||||
}
|
||||
}
|
||||
droppedItem.setCustomName(customName);
|
||||
}
|
||||
|
||||
private TangibleObject createDroppedItem(String template,Planet planet){
|
||||
TangibleObject droppedItem = (TangibleObject) core.objectService.createObject(template, planet);
|
||||
System.out.println("droppedItem " + droppedItem);
|
||||
return droppedItem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setCustomization(TangibleObject droppedItem) {
|
||||
|
||||
// Example color crystal
|
||||
droppedItem.setCustomizationVariable("/private/index_color_1", (byte) new Random().nextInt(7)); // 4 blue
|
||||
|
||||
// More general
|
||||
// String path = "scripts/loot/lootItems/"+droppedItem.getCustomName().toLowerCase();
|
||||
// Vector<String> customizationPaths = (Vector<String>)core.scriptService.fetchStringVector(path,"itemCustomizationPaths");
|
||||
// Vector<Integer> customizationValues = (Vector<Integer>)core.scriptService.fetchIntegerVector(path,"itemCustomizationValues");
|
||||
// for (int i=0;i<customizationPaths.size();i++){
|
||||
// String attributePath = customizationPaths.get(i);
|
||||
// int attributeValue = customizationValues.get(i);
|
||||
// droppedItem.setCustomizationVariable(attributePath, (byte)attributeValue);
|
||||
// }
|
||||
}
|
||||
|
||||
private void handleStats(TangibleObject droppedItem) {
|
||||
// ToDo: Min,Max for weapons , Dots on weapons etc.
|
||||
// This must be considered for the python scripts as well
|
||||
// So basically every item needs to have loot-related data in their py scripts as well
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -110,6 +110,16 @@ public class ScriptService {
|
||||
return func;
|
||||
}
|
||||
|
||||
public String fetchString(String path, String method) {
|
||||
PyObject result = core.scriptService.callScript(path, "", method);
|
||||
return ((PyObject)result).asString();
|
||||
}
|
||||
|
||||
public int fetchInteger(String path, String method) {
|
||||
PyObject result = core.scriptService.callScript(path, "", method);
|
||||
return ((PyObject)result).asInt();
|
||||
}
|
||||
|
||||
public Vector<String> fetchStringVector(String path, String method) {
|
||||
Vector<String> vector = new Vector<String>();
|
||||
PyObject result = core.scriptService.callScript(path, "", method);
|
||||
|
||||
Reference in New Issue
Block a user