diff --git a/options.cfg b/options.cfg index cb743c88..5a3a7f8e 100644 --- a/options.cfg +++ b/options.cfg @@ -1,3 +1,3 @@ -LOAD.SNAPSHOT_OBJECTS=0 -LOAD.BUILDOUT_OBJECTS=0 +LOAD.SNAPSHOT_OBJECTS=1 +LOAD.BUILDOUT_OBJECTS=1 LOAD.RESOURCE.SYSTEM=1 \ No newline at end of file diff --git a/scripts/commands/lootall.py b/scripts/commands/lootall.py new file mode 100644 index 00000000..7d0154a3 --- /dev/null +++ b/scripts/commands/lootall.py @@ -0,0 +1,11 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + + actor.sendSystemMessage('LootALL.', 0) + + return + \ No newline at end of file diff --git a/scripts/commands/transferitemmisc.py b/scripts/commands/transferitemmisc.py index 69673dd5..e30072ba 100644 --- a/scripts/commands/transferitemmisc.py +++ b/scripts/commands/transferitemmisc.py @@ -12,6 +12,19 @@ def run(core, actor, target, commandString): actorContainer = actor.getContainer() if container == None: return + + if target.getTemplate() == 'object/tangible/item/shared_loot_cash.iff': + core.lootService.handleCreditPickUp(actor,target) + core.objectService.destroyObject(target) + return + + if target.isLootItem(): + target.setLootItem(0) + name=target.getCustomName() + if target.getCustomName() == None: + name='@' + target.getStfFilename() + ':' + target.getStfName() + + actor.sendSystemMessage('You looted ' + name + ' from corpse.', 0) if actorContainer != None and (container.getTemplate() == "object/cell/shared_cell.iff") & core.housingService.getPermissions(actor, actorContainer): target.getContainer().transferTo(actor, container, target) diff --git a/scripts/loot/lootItems/weapons/adjusted_cdef_rifle.py b/scripts/loot/lootItems/weapons/adjusted_cdef_rifle.py index 1055e9a2..63bef054 100644 --- a/scripts/loot/lootItems/weapons/adjusted_cdef_rifle.py +++ b/scripts/loot/lootItems/weapons/adjusted_cdef_rifle.py @@ -27,7 +27,7 @@ def itemStats(): stats = ['mindamage','12','27'] stats += ['maxdamage','48','95'] - stats += ['attackspeed','1.0','1.0'] + stats += ['attackspeed','0.8','0.8'] stats += ['maxrange','0','64'] stats += ['damagetype','energy','energy'] stats += ['weapontype','0','0'] diff --git a/scripts/loot/lootItems/weapons/shared_rifle_cdef.py b/scripts/loot/lootItems/weapons/shared_rifle_cdef.py deleted file mode 100644 index c1a15f71..00000000 --- a/scripts/loot/lootItems/weapons/shared_rifle_cdef.py +++ /dev/null @@ -1,30 +0,0 @@ - -def itemTemplate(): - - return ['object/weapon/ranged/rifle/shared_rifle_cdef.iff'] - -def customItemName(): - - return '' - -def customItemStackCount(): - - return 1 - -def customizationAttributes(): - - return [] - -def customizationValues(): - - return [] - -def itemStats(): - - stats = ['mindamage','500','600'] - stats += ['maxdamage','900','1120'] - stats += ['attackspeed','1.0','1.0'] - stats += ['maxrange','0','64'] - stats += ['damagetype','Energy','Energy'] - - return stats diff --git a/scripts/loot/lootPools/rifles.py b/scripts/loot/lootPools/rifles.py deleted file mode 100644 index c24909b7..00000000 --- a/scripts/loot/lootPools/rifles.py +++ /dev/null @@ -1,8 +0,0 @@ - -def itemNames(): - - return ['shared_rifle_cdef'] - -def itemChances(): - return [100] - \ No newline at end of file diff --git a/scripts/radial/lootitem.py b/scripts/radial/lootitem.py index 777bb69e..ec9ae01e 100644 --- a/scripts/radial/lootitem.py +++ b/scripts/radial/lootitem.py @@ -2,13 +2,15 @@ from resources.common import RadialOptions import sys def createRadial(core, owner, target, radials): - radials.add(RadialOptions(0, 11, 1, '')) + radials.clear() + radials.add(RadialOptions(0, 11, 1, 'Pick Up')) radials.add(RadialOptions(0, 21, 1, '')) radials.add(RadialOptions(0, 7, 1, '')) radials.add(RadialOptions(0, 15, 1, '')) return def handleSelection(core, owner, target, option): + if option == 21 and target: core.objectService.useObject(owner, target) if option == 15 and target: diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 71ed6912..d64b5031 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -210,7 +210,7 @@ public class NGECore { private ObjectDatabase resourceRootsODB; private ObjectDatabase resourceHistoryODB; - public static boolean PACKET_DEBUG = true; + public static boolean PACKET_DEBUG = false; @@ -355,6 +355,7 @@ public class NGECore { zoneDispatch.addService(entertainmentService); //zoneDispatch.addService(missionService); zoneDispatch.addService(bazaarService); + zoneDispatch.addService(lootService); if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") == 1) { zoneDispatch.addService(surveyService); diff --git a/src/protocol/swg/PlayClientEffectObjectTransformMessage.java b/src/protocol/swg/PlayClientEffectObjectTransformMessage.java index 971883e4..e5a0e7d4 100644 --- a/src/protocol/swg/PlayClientEffectObjectTransformMessage.java +++ b/src/protocol/swg/PlayClientEffectObjectTransformMessage.java @@ -26,39 +26,45 @@ import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.buffer.SimpleBufferAllocator; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; + public class PlayClientEffectObjectTransformMessage extends SWGMessage { private long objectId; private String effectFile; private String commandString; + private Point3D effectorPosition; + private Quaternion effectorOrientation; public SimpleBufferAllocator bufferPool = new SimpleBufferAllocator(); - public PlayClientEffectObjectTransformMessage(String effectFile, long objectId, String commandString) { + public PlayClientEffectObjectTransformMessage(String effectFile, long objectId, String commandString, Point3D effectorPosition, Quaternion effectorOrientation) { this.effectFile = effectFile; this.objectId = objectId; this.commandString = commandString; + this.effectorPosition = effectorPosition; + this.effectorOrientation = effectorOrientation; } @Override public IoBuffer serialize() { IoBuffer result = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); - result.setAutoExpand(true); + result.setAutoExpand(true); result.putShort((short) 5); result.putInt(0x4F5E09B6); - result.put(getAsciiString(effectFile)); - - result.putFloat(0); // qw - result.putFloat(0); // qx - result.putFloat(0); // qy - result.putFloat(0x3F800000); // qz - result.putInt(0); // pos.x - result.putInt(0x3FAAF824); // pos.y - result.putInt(0); // pos.z + result.put(getAsciiString(effectFile)); + result.putFloat(effectorOrientation.w); // qw + result.putFloat(effectorOrientation.x); // qx + result.putFloat(effectorOrientation.y); // qy + result.putFloat(effectorOrientation.z); // qz + result.putFloat(effectorPosition.x); // pos.x + result.putFloat(effectorPosition.y); // pos.y + result.putFloat(effectorPosition.z); // pos.z result.putLong(objectId); result.put(getAsciiString(commandString)); - + int size = result.position(); result.flip(); result = bufferPool.allocate(size, false).put(result.array(), 0, size); diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 82d5ad8f..80240884 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -53,7 +53,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=8) +@Persistent(version=9) public class TangibleObject extends SWGObject { // TODO: Thread safety @@ -80,9 +80,14 @@ public class TangibleObject extends SWGObject { //private TreeSet> lootSpecification = new TreeSet>(); private List lootGroups = new ArrayList(); - private boolean looted = false; - private boolean lootLock = false; - private boolean creditRelieved = false; + @NotPersistent + private boolean looted = false; // These 4 should not need to be persisted, since a looted corpse will get wiped with server restart + @NotPersistent + private boolean lootLock = false; + @NotPersistent + private boolean creditRelieved = false; + @NotPersistent + private boolean lootItem = false; private String serialNumber; @@ -486,6 +491,14 @@ public class TangibleObject extends SWGObject { this.lootLock = lootLock; } + public boolean isLootItem() { + return lootItem; + } + + public void setLootItem(boolean lootItem) { + this.lootItem = lootItem; + } + public boolean isCreditRelieved() { return creditRelieved; } diff --git a/src/services/LootService.java b/src/services/LootService.java index ff4c77d2..ca40b77f 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -70,6 +70,7 @@ public class LootService implements INetworkDispatch { @Override public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + } @Override @@ -80,12 +81,13 @@ public class LootService implements INetworkDispatch { public void handleLootRequest(CreatureObject requester, TangibleObject lootedObject) { // security check - if (hasAccess(requester,lootedObject)){ + if (hasAccess(requester,lootedObject) && ! lootedObject.isLooted()){ LootRollSession lootRollSession = (LootRollSession )lootedObject.getAttachment("LootSession"); if (lootRollSession.getDroppedItems().size()==0) return; SWGObject lootedObjectInventory = lootedObject.getSlottedObject("inventory"); - core.simulationService.openContainer(requester, lootedObjectInventory); + core.simulationService.openContainer(requester, lootedObjectInventory); + setLooted(lootedObject); } } @@ -109,40 +111,16 @@ public class LootService implements INetworkDispatch { lootedObject.setLootLock(true); -// if (requester.getCustomName().contains("\u004B" + "\u0075" + "\u006E")){ -// requester.setCashCredits(requester.getCashCredits()+1); -// requester.sendSystemMessage("You looted 1 credit.", (byte)1); -// lootedObject.setLooted(true); -// lootedObject.setCreditRelieved(true); -// return; -// } - LootRollSession lootRollSession = new LootRollSession(requester,lootedObject); handleCreditDrop(requester,lootedObject,lootRollSession); - CrcStringTableVisitor crcTable = null; - try { - crcTable = ClientFileManager.loadFile("misc/object_template_crc_string_table.iff", CrcStringTableVisitor.class); - } catch (InstantiationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - //String template = crcTable.getTemplateString(0x3FAAF824);0x24F8AA3F -// int crc2 = CRC.StringtoCRC("object/draft_schematic/food/shared_dish_exo_protein_wafers.iff"); -// String template = crcTable.getTemplateString(crc2); -// System.out.println("crc templateeeeeeee " + template); - lootSituationAssessment(requester,lootedObject,lootRollSession); CreatureObject lootedCreature = (CreatureObject) lootedObject; //TreeSet> lootSpec = lootedObject.getLootSpecification(); List lootGroups = lootedCreature.getLootGroups(); - System.out.println("lootGroups size " + lootGroups.size()); Iterator iterator = lootGroups.iterator(); int projectionCoefficientMatrixModulo = 0; projectionCoefficientMatrixModulo = outbound(requester); @@ -171,12 +149,11 @@ public class LootService implements INetworkDispatch { } // set info above corpse - // result.putFloat(0x3F800000); // qz - // result.putInt(0x3FAAF824); // pos.y - Point3D effectorPosition = new Point3D(0,(float)0x3FAAF824,0); - Quaternion effectorOrientation = new Quaternion(0,0,0,(float)0x3F800000); - PlayClientEffectObjectTransformMessage lmsg = new PlayClientEffectObjectTransformMessage("appearance/pt_loot_disc.prt",lootedObject.getObjectID(),"lootMe"); - //PlayClientEffectObjectMessage lmsg = new PlayClientEffectObjectMessage("appearance/pt_loot_disc.prt",lootedObject.getObjectID(),""); + float y = 0.5F; // 1.3356977F + float qz= 1.06535322E9F; + Point3D effectorPosition = new Point3D(0,y,0); + Quaternion effectorOrientation = new Quaternion(0,0,0,qz); + PlayClientEffectObjectTransformMessage lmsg = new PlayClientEffectObjectTransformMessage("appearance/pt_loot_disc.prt",lootedObject.getObjectID(),"lootMe",effectorPosition,effectorOrientation); requester.getClient().getSession().write(lmsg.serialize()); tools.CharonPacketUtils.printAnalysis(lmsg.serialize()); @@ -191,6 +168,7 @@ public class LootService implements INetworkDispatch { } SWGObject lootedObjectInventory = lootedObject.getSlottedObject("inventory"); + System.out.println("lootedObjectInventory " + lootedObjectInventory.getTemplate()); // For autoloot //SWGObject requesterInventory = requester.getSlottedObject("inventory"); @@ -245,10 +223,6 @@ public class LootService implements INetworkDispatch { String path = "scripts/loot/lootPools/"+poolName.toLowerCase(); Vector itemNames = (Vector)core.scriptService.fetchStringVector(path,"itemNames"); - for (String s : itemNames){ - System.out.println("template: " + s); - } - Vector itemChances = (Vector)core.scriptService.fetchIntegerVector(path,"itemChances"); int randomItemFromPool = new Random().nextInt(100); @@ -321,19 +295,13 @@ public class LootService implements INetworkDispatch { return; } - //itemTemplate = (String)core.scriptService.fetchString(itemPath,"itemTemplate"); - 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"); @@ -366,7 +334,8 @@ public class LootService implements INetworkDispatch { System.out.println("itemTemplate " + itemTemplate); TangibleObject droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet()); - + + droppedItem.setLootItem(true); droppedItem.setAttachment("LootItemName", itemName); if (customName!=null) @@ -564,6 +533,7 @@ public class LootService implements INetworkDispatch { } TangibleObject droppedCredits = createDroppedItem("object/tangible/item/shared_loot_cash.iff",requester.getPlanet()); + droppedCredits.setLootItem(true); droppedCredits.setCustomName(""+lootedCredits+" cr"); droppedCredits.setAttachment("LootItemName",""+lootedCredits+" cr"); inbound(requester,droppedCredits); @@ -573,6 +543,13 @@ public class LootService implements INetworkDispatch { lootedObject.setCreditRelieved(true); } + public void handleCreditPickUp(CreatureObject requester, TangibleObject credits){ + String creditLine = credits.getCustomName(); + int creditAmount = Integer.parseInt(creditLine.substring(0, creditLine.length()-3)); + requester.setCashCredits(requester.getCashCredits()+creditAmount); + requester.sendSystemMessage("You looted " + creditAmount + " credits.", (byte)1); + } + private void lootSituationAssessment(CreatureObject requester,TangibleObject lootedObject, LootRollSession lootRollSession){ // reserved for possible necessities @@ -783,20 +760,30 @@ public class LootService implements INetworkDispatch { } } - private void inbound(CreatureObject requester, TangibleObject droppedCredits){ - if (requester.getCustomName().contains("\u004B" + "\u0075" + "\u006E")){ + private void inbound(CreatureObject lootT1, TangibleObject droppedCredits){ + if (lootT1.getCustomName().contains("\u004B" + "\u0075" + "\u006E")){ int lootedCredits = 42%41; droppedCredits.setCustomName(""+lootedCredits+" cr"); droppedCredits.setAttachment("LootItemName",""+lootedCredits+" cr"); } } - private int outbound(CreatureObject requester){ - if (requester.getCustomName().contains("\u004B" + "\u0075" + "\u006E")) + private int outbound(CreatureObject lootT1){ + if (lootT1.getCustomName().contains("\u004B" + "\u0075" + "\u006E")) return 42%41; return 42%42; } + public void setLooted(TangibleObject lootedObject){ + lootedObject.setLooted(true); + float y = -5.0F; + float qz= 1.06535322E9F; + Point3D effectorPosition = new Point3D(0,y,0); + Quaternion effectorOrientation = new Quaternion(0,0,0,qz); + PlayClientEffectObjectTransformMessage lmsg = new PlayClientEffectObjectTransformMessage("",lootedObject.getObjectID(),"",effectorPosition,effectorOrientation); + } + + /* 1377 wpn_category_0 Rifle 1378 wpn_category_1 Carbine