diff --git a/scripts/lootPools/colorcrystals.py b/scripts/lootPools/colorcrystals.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/lootPools/jediholocrons.py b/scripts/lootPools/jediholocrons.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/lootPools/junk.py b/scripts/lootPools/junk.py new file mode 100644 index 00000000..3a139e37 --- /dev/null +++ b/scripts/lootPools/junk.py @@ -0,0 +1,8 @@ + +def itemTemplates(): + + templates=['1','2','3'] + return templates + +def itemChances(): + return [1,2,3] \ No newline at end of file diff --git a/scripts/lootPools/kraytpearls.py b/scripts/lootPools/kraytpearls.py new file mode 100644 index 00000000..8463ef39 --- /dev/null +++ b/scripts/lootPools/kraytpearls.py @@ -0,0 +1,8 @@ + +def itemTemplates(): + + templates=['1','2','3','Flawless'] + return templates + +def itemChances(): + return [60,20,10,5] \ No newline at end of file diff --git a/scripts/lootPools/rareloot.py b/scripts/lootPools/rareloot.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/lootPools/rifles.py b/scripts/lootPools/rifles.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/lootPools/sithholocrons.py b/scripts/lootPools/sithholocrons.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/object/mobile/tusken_raider.py b/scripts/object/mobile/tusken_raider.py index 8c20d758..3a133a38 100644 --- a/scripts/object/mobile/tusken_raider.py +++ b/scripts/object/mobile/tusken_raider.py @@ -11,14 +11,14 @@ def setup(core, object): lootPoolNames_1 = ['Junk','Rifles'] lootPoolChances_1 = [90,70] lootGroupChance_1 = 80 - core.lootService.saveLootData(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) - #object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + #core.lootService.saveLootData(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) lootPoolNames2 = ['Colorcrystal'] lootPoolChances2 = [50] lootGroupChance2 = 60 #core.lootService.saveLootData(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) - #object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) #core.lootService.test3(allLootPoolNames) - return \ No newline at end of file + return \ No newline at end of file diff --git a/src/resources/objects/loot/LootGroup.java b/src/resources/objects/loot/LootGroup.java index 1558a624..efedc799 100644 --- a/src/resources/objects/loot/LootGroup.java +++ b/src/resources/objects/loot/LootGroup.java @@ -46,4 +46,16 @@ public class LootGroup { this.lootPoolChances = lootPoolChances; this.lootGroupChance = lootGroupChance; } + + public String[] getLootPoolNames() { + return lootPoolNames; + } + + public int[] getLootPoolChances() { + return lootPoolChances; + } + + public int getLootGroupChance() { + return lootGroupChance; + } } diff --git a/src/resources/objects/loot/LootPool.java b/src/resources/objects/loot/LootPool.java new file mode 100644 index 00000000..2e74cf8b --- /dev/null +++ b/src/resources/objects/loot/LootPool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.objects.loot; + +/** + * @author Charon + */ + +public class LootPool { + + public LootPool(){ + + } +} diff --git a/src/resources/objects/loot/LootRollSession.java b/src/resources/objects/loot/LootRollSession.java new file mode 100644 index 00000000..d2416102 --- /dev/null +++ b/src/resources/objects/loot/LootRollSession.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.objects.loot; + +/** + * @author Charon + */ + +public class LootRollSession { + + public LootRollSession(){ + + } +} diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 69dc7d65..be7d869e 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -453,6 +453,15 @@ public class TangibleObject extends SWGObject { } } + public List getLootGroups() { + return lootGroups; + } + + public void addToLootGroups(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance) { + LootGroup lootGroup = new LootGroup(lootPoolName, lootPoolChance, lootGroupChance); + this.lootGroups.add(lootGroup); + } + @Override public void sendBaselines(Client destination) { @@ -477,13 +486,4 @@ public class TangibleObject extends SWGObject { } - - public List getLootGroups() { - return lootGroups; - } - - public void addToLootGroups(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance) { - LootGroup lootGroup = new LootGroup(lootPoolName, lootPoolChance, lootGroupChance); - this.lootGroups.add(lootGroup); - } } diff --git a/src/services/LootService.java b/src/services/LootService.java index 32039cb5..04d44feb 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -35,6 +35,8 @@ import java.util.TreeSet; 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.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.tool.SurveyTool; @@ -89,32 +91,27 @@ public class LootService implements INetworkDispatch { } + CreatureObject lootedCreature = (CreatureObject) lootedObject; + List lootDrops = new ArrayList(); List lootElements = new ArrayList(); - TreeSet> lootSpec = lootedObject.getLootSpecification(); - Iterator> iterator = lootSpec.iterator(); + //TreeSet> lootSpec = lootedObject.getLootSpecification(); + List lootGroups = lootedCreature.getLootGroups(); + Iterator iterator = lootGroups.iterator(); while (iterator.hasNext()){ - TreeMap lootPool = iterator.next(); - int poolProbability = lootPool.lastEntry().getValue(); - int lootPoolRoll = new Random().nextInt(100); - if (lootPoolRoll <= poolProbability){ - lootElements = handleLootPool(lootPool); //this lootPool will drop + LootGroup lootGroup = iterator.next(); + int groupChance = lootGroup.getLootGroupChance(); + int lootGroupRoll = new Random().nextInt(100); + if (lootGroupRoll <= groupChance){ + handleLootGroup(lootGroup); //this lootGroup will drop something } } - - // Now handle the chosen pools and determine the according items - - for (String element : lootElements){ - lootDrops = handleLootPoolElement(element); - } - + // ********** Phase 1 complete, loot items determined ********** - // Distribute the loot drops according to group loot rules - - + // Distribute the loot drops according to group loot rules // For now just spawn items into requester's inventory for (LootDrop dropElem : lootDrops){ PlayerObject requesterObj = (PlayerObject) requester.getSlottedObject("ghost"); @@ -125,49 +122,42 @@ public class LootService implements INetworkDispatch { requesterInventory.add(droppedItem); } } - - - // ToDo: Group loot settings etc. - - // [20:35] <@_Light> your actual loot chance was lootgroupchance*lootchance - long leaderGroupId = requester.getGroupId(); - GroupObject group = (GroupObject) core.objectService.getObject(leaderGroupId); - if(group.getMemberList().size() == 1) { - // looter is alone - } + + // ToDo: Group loot settings etc. } - private List handleLootPool(TreeMap lootPool){ + private List handleLootGroup(LootGroup lootGroup){ List lootElements = new ArrayList(); - for(Map.Entry entry : lootPool.entrySet()) { - String poolElementName = entry.getKey(); - int poolElementProbability = entry.getValue(); + int[] lootPoolChances = lootGroup.getLootPoolChances(); + String[] lootPoolNames = lootGroup.getLootPoolNames(); + for(int i=0;i handleLootPoolElement(String element){ + private List handleLootPool(String poolName){ List lootDropList = new ArrayList(); - // This is just a random element from the python + LootDrop lootDrop = new LootDrop(); + // Fetch the loot pool data from the poolName.py script + + String path = "scripts/lootPools/"+poolName; // + ".py"; + //Vector quantityList = (Vector)core.scriptService.fetchStringVector(path,"resourceQuantities"); + +// for (String s : quantityList){ +// System.out.println("OOO: " + s); +// } + + //LootPool lootPool = loadfrompyreturn(); return lootDropList; } - - - public void test(TreeSet test1){ - - } - - public void test2(String test2){ - System.out.println(test2); - } - + public void saveLootData(String[] lootPoolName, int[] lootPoolChance, int lootGroupChance){ for (String ui : lootPoolName){ System.out.println(ui); @@ -178,8 +168,12 @@ public class LootService implements INetworkDispatch { System.out.println(lootGroupChance); - } - - - + } } + +////[20:35] <@_Light> your actual loot chance was lootgroupchance*lootchance +// long leaderGroupId = requester.getGroupId(); +// GroupObject group = (GroupObject) core.objectService.getObject(leaderGroupId); +// if(group.getMemberList().size() == 1) { +// // looter is alone +// }