diff --git a/scripts/commands/kneel.py b/scripts/commands/kneel.py index 7a48df18..696877a4 100644 --- a/scripts/commands/kneel.py +++ b/scripts/commands/kneel.py @@ -1,13 +1,45 @@ import sys +from engine.resources.scene import Point3D +from resources.common import MathUtilities def setup(): return def run(core, actor, target, commandString): - #actor.sendSystemMessage('Cell ID %s' % actor.getContainer().getTemplate(), 0) - #actor.sendSystemMessage('Cell ID ' + actor.getContainer().getTemplate(), 0) - #actor.sendSystemMessage('CellNumber: ' + str(actor.getGrandparent().getCellNumberByObjectId(actor.getContainer().getObjectID())), 0) - actor.sendSystemMessage('CellNumber: ' + str(actor.getContainer().getObjectID()), 0) + + actor.sendSystemMessage('CellNumber: ' + str(actor.getContainer().getObjectID()), 0) + actor.sendSystemMessage('x: ' + str(actor.getPosition().x) , 0) + actor.sendSystemMessage('y: ' + str(actor.getPosition().y) , 0) + actor.sendSystemMessage('z: ' + str(actor.getPosition().z) , 0) + actor.sendSystemMessage('qy: ' + str(actor.getOrientation().y) , 0) + actor.sendSystemMessage('qw: ' + str(actor.getOrientation().w) , 0) + actor.sendSystemMessage('targetID: ' + str(actor.getTargetId()) , 0) # 200336 + + stcSvc = core.staticService + #hunter1 = stcSvc.spawnObject('force_sensitive_crypt_crawler', 'dantooine', long(8535484), float(26), float(-41), float(-68), float(2.77), float(1.82)) + #hunter2 = stcSvc.spawnObject('untrained_wielder_of_the_dark_side', 'dantooine', long(8535484), float(23), float(-41), float(-65), float(1.52), float(2.94)) + #hunter3 = stcSvc.spawnObject('untrained_wielder_of_the_dark_side', 'dantooine', long(8535484), float(47), float(-48), float(-65), float(0.72), float(-0.68)) + #hunter4 = stcSvc.spawnObject('untrained_wielder_of_the_dark_side', 'dantooine', long(8535484), float(49.12), float(-47.48), float(-13.41), float(1), float(-0.05)) + #hunter5 = stcSvc.spawnObject('dark_force_crystal_hunter', 'dantooine', long(8535485), float(93.10), float(-61.87), float(-14.25), float(-0.7), float(0.7)) + #hunter6 = stcSvc.spawnObject('force_sensitive_crypt_crawler', 'dantooine', long(8535485), float(62.2), float(-69.0), float(-37.8), float(0.68), float(0.72)) + #hunter7 = stcSvc.spawnObject('dark_force_crystal_hunter', 'dantooine', long(8535484), float(52.14), float(-67.8), float(-42.9), float(0.51), float(0.86)) + #hunter8 = stcSvc.spawnObject('force_sensitive_crypt_crawler', 'dantooine', long(8535486), float(84.94), float(-77.09), float(-63.28), float(-0.19), float(0.98)) + #hunter9 = stcSvc.spawnObject('force_sensitive_crypt_crawler', 'dantooine', long(8535486), float(65.30), float(-76.16), float(-70.15), float(0.38), float(0.92)) + #hunter10 = stcSvc.spawnObject('untrained_wielder_of_the_dark_side', 'dantooine', long(8535486), float(65.636), float(-76.87), float(-81.40), float(-0.123), float(0.99)) + #hunter11 = stcSvc.spawnObject('dark_force_crystal_hunter', 'dantooine', long(8535487), float(80.34), float(-77.29), float(-92.77), float(-0.2), float(0.97)) + #hunter12 = stcSvc.spawnObject('dark_force_crystal_hunter', 'dantooine', long(8535487), float(80.34), float(-77.29), float(-92.77), float(-0.2), float(0.97)) + + #objSvc = core.objectService + #lotSvc = core.lootService + #magSeal1 = objSvc.getObject(200336); + #magSeal1Inv = magSeal1.getSlottedObject("inventory"); + #lotSvc.getContainerContent() + #magSeal1Inv. + + lotSvc = core.lootService + lotSvc.handleContainer(200336,'crystalcave1') + + if actor.getPosture() == 13 or actor.getPosture() == 14: return diff --git a/scripts/static_spawns/dantooine/force_crystal_hunters_cave.py b/scripts/static_spawns/dantooine/force_crystal_hunters_cave.py index fabf90da..c44e147f 100644 --- a/scripts/static_spawns/dantooine/force_crystal_hunters_cave.py +++ b/scripts/static_spawns/dantooine/force_crystal_hunters_cave.py @@ -3,15 +3,17 @@ from resources.datatables import State def addPlanetSpawns(core, planet): - stcSvc = core.staticService - objSvc = core.objectService - - hunter1 = stcSvc.spawnObject('object/mobile/shared_dressed_dark_force_crystal_hunter.iff', 'dantooine', long(8535483), float(0), float(0), float(2), float(0.71), float(0.71)) - hunter2 = stcSvc.spawnObject('object/mobile/shared_dressed_dark_force_crystal_hunter.iff', 'dantooine', long(8535483), float(3), float(2), float(4), float(0.71), float(0.71)) - - wuher = stcSvc.spawnObject('object/mobile/shared_dressed_dark_force_crystal_hunter.iff', 'dantooine', long(8535483), float(8.6), float(-0.9), float(7), float(0.71), float(0.71)) - wuher.setCustomName2('Wuher') - wuher.setOptionsBitmask(256) - - #hunter1.setCustomName2('Reelo Baruk') - #hunter1.setOptionsBitmask(264) \ No newline at end of file + stcSvc = core.staticService + hunter1 = stcSvc.spawnObject('force_sensitive_crypt_crawler', 'dantooine', long(8535484), float(26), float(-41), float(-68), float(2.77), float(1.82)) + #hunter1.setattachment('RespawnTimer',300) + hunter2 = stcSvc.spawnObject('untrained_wielder_of_the_dark_side', 'dantooine', long(8535484), float(23), float(-41), float(-65), float(1.52), float(2.94)) + hunter3 = stcSvc.spawnObject('untrained_wielder_of_the_dark_side', 'dantooine', long(8535484), float(47), float(-48), float(-65), float(0.72), float(-0.68)) + hunter4 = stcSvc.spawnObject('untrained_wielder_of_the_dark_side', 'dantooine', long(8535484), float(49.12), float(-47.48), float(-13.41), float(1), float(-0.05)) + hunter5 = stcSvc.spawnObject('dark_force_crystal_hunter', 'dantooine', long(8535485), float(93.10), float(-61.87), float(-14.25), float(-0.7), float(0.7)) + hunter6 = stcSvc.spawnObject('force_sensitive_crypt_crawler', 'dantooine', long(8535485), float(62.2), float(-69.0), float(-37.8), float(0.68), float(0.72)) + hunter7 = stcSvc.spawnObject('dark_force_crystal_hunter', 'dantooine', long(8535484), float(52.14), float(-67.8), float(-42.9), float(0.51), float(0.86)) + hunter8 = stcSvc.spawnObject('force_sensitive_crypt_crawler', 'dantooine', long(8535486), float(84.94), float(-77.09), float(-63.28), float(-0.19), float(0.98)) + hunter9 = stcSvc.spawnObject('force_sensitive_crypt_crawler', 'dantooine', long(8535486), float(65.30), float(-76.16), float(-70.15), float(0.38), float(0.92)) + hunter10 = stcSvc.spawnObject('untrained_wielder_of_the_dark_side', 'dantooine', long(8535486), float(65.636), float(-76.87), float(-81.40), float(-0.123), float(0.99)) + hunter11 = stcSvc.spawnObject('dark_force_crystal_hunter', 'dantooine', long(8535487), float(80.34), float(-77.29), float(-92.77), float(-0.2), float(0.97)) + hunter12 = stcSvc.spawnObject('dark_force_crystal_hunter', 'dantooine', long(8535487), float(80.34), float(-77.29), float(-92.77), float(-0.2), float(0.97)) \ No newline at end of file diff --git a/src/resources/loot/LootRollSession.java b/src/resources/loot/LootRollSession.java index d6f26ad4..addd0af8 100644 --- a/src/resources/loot/LootRollSession.java +++ b/src/resources/loot/LootRollSession.java @@ -113,6 +113,10 @@ public class LootRollSession { public Planet getSessionPlanet() { return sessionPlanet; } + + public void setSessionPlanet(Planet planet) { + sessionPlanet = planet; + } public List getErrorMessages() { return errorMessages; diff --git a/src/services/LootService.java b/src/services/LootService.java index a23d367b..c005cda4 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -1167,6 +1167,266 @@ public class LootService implements INetworkDispatch { return suffix; } + public void handleContainer(long containerID, String lootPool, String planetName){ + SWGObject containerObject = core.objectService.getObject(200336); + LootRollSession lootRollSession = new LootRollSession(); + Planet planet = core.terrainService.getPlanetByName(planetName); + lootRollSession.setSessionPlanet(planet); + lootRollSession.setLootedObjectLevel(70); + lootRollSession.setLootedObjectDifficulty(0); + + System.out.println("containerObject " + containerObject.getClass().getName() ); + + //handleContainerDrops(containerObject, lootRollSession); + } + /* + private void handleContainerDrops(SWGObject containerObject, LootRollSession lootRollSession){ + List lootGroups = containerObject.getLootGroups(); + Iterator iterator = lootGroups.iterator(); + int projectionCoefficientMatrixModulo = 0; + projectionCoefficientMatrixModulo = outbound(requester); + + while (iterator.hasNext()){ + LootGroup lootGroup = iterator.next(); + double groupChance = lootGroup.getLootGroupChance(); + double lootGroupRoll = new Random().nextDouble()*100; + if (projectionCoefficientMatrixModulo!=0) + lootGroupRoll=groupChance+1; + if (lootGroupRoll <= groupChance){ + System.out.println("this lootGroup will drop something"); + handleContainerLootGroup(lootGroup,lootRollSession); //this lootGroup will drop something e.g. {kraytpearl_range,krayt_tissue_rare} + } + System.out.println("While Loop Stuck check"); + } + } + + private void handleContainerLootGroup(LootGroup lootGroup,LootRollSession lootRollSession){ + + double[] lootPoolChances = lootGroup.getLootPoolChances(); + String[] lootPoolNames = lootGroup.getLootPoolNames(); + if (lootPoolChances==null || lootPoolNames==null){ + System.err.println("Lootpools are null!"); + return; + } + if (lootPoolChances.length==0 || lootPoolNames.length==0){ + System.err.println("No Lootpools in Lootgroup!"); + return; + } + + double randomItemFromGroup = new Random().nextDouble()*100; + double remainder = 0; // [10,20,30,34,5,1] + double span = 100/lootPoolNames.length; + + boolean test = false; + + for(int i=0;i itemNames = (Vector)core.scriptService.fetchStringVector(path,"itemNames"); + + Vector itemChances = (Vector)core.scriptService.fetchDoubleVector(path,"itemChances"); + + double randomItemFromPool = new Random().nextDouble()*100; + double remainder = 0.0; // [10,20,30,34,5,1] + double span = 100.0/(double)itemNames.size(); + + for (int i=0;i foundPath = new Vector(); + Path p = Paths.get("scripts/loot/lootItems/"); + FileVisitor fv = new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + String actualFileName = file.getFileName().toString(); + actualFileName = actualFileName.substring(0, actualFileName.length()-3); + if (actualFileName.equals(itemName.toLowerCase())){ + foundPath.add(file.toString()); + } + return FileVisitResult.CONTINUE; + } + }; + try { + Files.walkFileTree(p, fv); + } catch (IOException e) { + e.printStackTrace(); + } + + + if (foundPath.size()==0){ + String errorMessage = "Loot item '" + itemName + "' not found in file system. Please contact Charon about this issue."; + System.err.println(errorMessage); + return; + + } + String itemPath = foundPath.get(0); + + itemPath = itemPath.substring(0, itemPath.length()-3); // remove the file type + + String customName = ""; + String itemTemplate = ""; + Vector itemTemplates = null; + int stackCount = 1; + int biolink = 0; + int requiredCL = 1; + int stackable = -1; + int junkDealerPrice = 0; + byte junkType = -1; + String requiredProfession = ""; + String requiredFaction = ""; + Vector customizationAttributes = null; + Vector customizationValues = null; + Vector itemStats = null; + Vector itemSkillMods = 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."; + System.err.println(errorMessage); + return; + } + + itemTemplates = (Vector)core.scriptService.fetchStringVector(itemPath,"itemTemplate"); + if (itemTemplates.size()==1) + itemTemplate = itemTemplates.get(0); + if (itemTemplates.size()>1){ + itemTemplate = itemTemplates.get(new Random().nextInt(itemTemplates.size()-1)); + } + + // only consider the following variables, if they are in the python-script file + if(core.scriptService.getMethod(itemPath,"","customItemName")!=null) + customName = (String)core.scriptService.fetchString(itemPath,"customItemName"); + + if(core.scriptService.getMethod(itemPath,"","customItemStackCount")!=null) + stackCount = (Integer)core.scriptService.fetchInteger(itemPath,"customItemStackCount"); + + if(core.scriptService.getMethod(itemPath,"","customizationAttributes")!=null) + customizationAttributes = (Vector)core.scriptService.fetchStringVector(itemPath,"customizationAttributes"); + + if(core.scriptService.getMethod(itemPath,"","customizationValues")!=null) + customizationValues = (Vector)core.scriptService.fetchIntegerVector(itemPath,"customizationValues"); + + if(core.scriptService.getMethod(itemPath,"","itemStats")!=null) + itemStats = (Vector)core.scriptService.fetchStringVector(itemPath,"itemStats"); + + if(core.scriptService.getMethod(itemPath,"","itemSkillMods")!=null) + itemSkillMods = (Vector)core.scriptService.fetchStringVector(itemPath,"itemSkillMods"); + + if(core.scriptService.getMethod(itemPath,"","biolink")!=null) + biolink = (Integer)core.scriptService.fetchInteger(itemPath,"biolink"); + + if(core.scriptService.getMethod(itemPath,"","requiredCL")!=null) + requiredCL = (Integer)core.scriptService.fetchInteger(itemPath,"requiredCL"); + + if(core.scriptService.getMethod(itemPath,"","requiredProfession")!=null) + requiredProfession = (String)core.scriptService.fetchString(itemPath,"requiredProfession"); + + if(core.scriptService.getMethod(itemPath,"","requiredFaction")!=null) + requiredFaction = (String)core.scriptService.fetchString(itemPath,"requiredFaction"); + + if(core.scriptService.getMethod(itemPath,"","stackable")!=null) + stackable = (Integer)core.scriptService.fetchInteger(itemPath,"stackable"); + + if(core.scriptService.getMethod(itemPath,"","junkDealerPrice")!=null) + junkDealerPrice = (Integer)core.scriptService.fetchInteger(itemPath,"junkDealerPrice"); + + if(core.scriptService.getMethod(itemPath,"","junkType")!=null) + junkType = (byte)core.scriptService.fetchInteger(itemPath,"junkType"); + + + System.out.println("itemTemplate " + itemTemplate); + + TangibleObject droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet()); + + droppedItem.setLootItem(true); + droppedItem.setAttachment("LootItemName", itemName); + + if(core.scriptService.getMethod(itemPath,"","randomStatJewelry")!=null){ + customName = setRandomStatsJewelry(droppedItem, lootRollSession); + } + + if (customName!=null) + handleCustomDropName(droppedItem, customName); + + if (stackable!=-1){ + if(stackable==1) + droppedItem.setStackable(true); + else + droppedItem.setStackable(false); + } + + if (junkDealerPrice!=0){ + droppedItem.setJunkDealerPrice(junkDealerPrice); + } + + if (junkType!=-1){ + droppedItem.setJunkType(junkType); + } + + if (itemStats!=null){ + if (itemStats.size()%3!=0){ + String errorMessage = "Loot item '" + itemName + "' has a wrong number of itemstats. Please contact Charon about this issue."; + System.err.println(errorMessage); + return; + } + handleStats(droppedItem, itemStats); + } + + if (itemSkillMods!=null){ + handleSkillMods(droppedItem, itemSkillMods); + } + + setCustomization(droppedItem, itemName); // for now + + handleSpecialItems(droppedItem, itemName); + + if (requiredCL>1){ + droppedItem.setIntAttribute("required_combat_level", requiredCL); + } + + if (requiredProfession.length()>0){ + droppedItem.setStringAttribute("class_required", requiredProfession); + } + + if (requiredFaction.length()>0){ + droppedItem.setStringAttribute("required_faction", requiredFaction); + } + + + containerObject.add(droppedItem); + + } + */ // ********* Junk-dealer related ********* diff --git a/src/services/StaticService.java b/src/services/StaticService.java index a2445c33..e15ca781 100644 --- a/src/services/StaticService.java +++ b/src/services/StaticService.java @@ -37,6 +37,7 @@ import java.util.Random; import resources.common.FileUtilities; import resources.objects.building.BuildingObject; import resources.objects.cell.CellObject; +import services.spawn.MobileTemplate; import main.NGECore; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.PortalVisitor; @@ -116,8 +117,11 @@ public class StaticService implements INetworkDispatch { SWGObject object; - if (core.spawnService.getMobileTemplate(template) != null) { - object = core.spawnService.spawnCreature(core.spawnService.getMobileTemplate(template).getTemplates().get(new Random().nextInt(core.spawnService.getMobileTemplate(template).getTemplates().size())), planetName, cellId, x, y, z, qW, qX, qY, qZ, (short) -1); + MobileTemplate mobileTemplate = core.spawnService.getMobileTemplate(template); + if (mobileTemplate != null) { + System.out.println("SPAWN MOBILE TEMPLATE " + mobileTemplate.getTemplates().get(new Random().nextInt(mobileTemplate.getTemplates().size()))); + object = core.spawnService.spawnCreature(template, planetName, cellId, x, y, z, qW, qX, qY, qZ, (short) -1); + System.out.println("objectid " + object.getObjectID()); } else { object = core.objectService.createObject(template, objectId, planet, new Point3D(x, y, z), new Quaternion(qW, qX, qY, qZ), null, true, true); }