diff --git a/scripts/object/mobile/respec_seller_f_1.py b/scripts/object/mobile/respec_seller_f_1.py index c7327815..4facad13 100644 --- a/scripts/object/mobile/respec_seller_f_1.py +++ b/scripts/object/mobile/respec_seller_f_1.py @@ -4,4 +4,5 @@ from resources.datatables import Options def setup(core, object): object.setAttachment('radial_filename', 'object/conversation') object.setAttachment('conversationFile', 'respec') + object.setOptionsBitmask(Options.CONVERSABLE | Options.INVULNERABLE) return \ No newline at end of file diff --git a/scripts/static_spawns/tatooine.py b/scripts/static_spawns/tatooine.py index 8b4a389c..1d7b383b 100644 --- a/scripts/static_spawns/tatooine.py +++ b/scripts/static_spawns/tatooine.py @@ -3,16 +3,26 @@ from resources.datatables import Options from resources.datatables import StateStatus def addPlanetSpawns(core, planet): - + stcSvc = core.staticService - #this script is no longer for NPC spawning usage. - Levarris - #stcSvc.spawnObject('object/mobile/shared_3po_protocol_droid_red.iff', 'tatooine', long(26582), float(-14.3), float(2.0), float(47.4), float(0.70), float(0.71)) + # Objects + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_character_builder.iff', 'tatooine', long(0), float(3525), float(4), float(-4801), float(0.70), float(0.71)) - #object = stcSvc.spawnObject('object/mobile/shared_respec_seller_f_1.iff', 'tatooine', long(0), float(3533.14), float(5), float(-4788.86), float(-0.3327), float(0.9288)) - #object.setOptionsBitmask(264) - junkdealer = stcSvc.spawnObject('object/mobile/shared_junk_dealer_m_01.iff', 'tatooine', long(0), float(3525), float(4), float(-4804), float(0.70), float(0.71)) + # Buildings + + # Example + #building = stcSvc.spawnObject('object/building/myThatchedHut.iff', 'tatooine', long(0), float(3525), float(4), float(-4804), float(0.70), float(0.71)) + #stcSvc.spawnObject('object/mobile/shared_my_npc.iff', 'tatooine', building.getCellByCellNumber(7), float(3525), float(4), float(-4804), float(0.70), float(0.71)) + + # NPCs + + stcSvc.spawnObject('object/mobile/shared_respec_seller_f_1.iff', 'tatooine', long(0), float(3533.14), float(5), float(-4788.86), float(-0.3327), float(0.9288)) + + stcSvc.spawnObject('object/mobile/shared_junk_dealer_m_01.iff', 'tatooine', long(0), float(3525), float(4), float(-4804), float(0.70), float(0.71)) + + #stcSvc.spawnObject('object/mobile/shared_3po_protocol_droid_red.iff', 'tatooine', long(26582), float(-14.3), float(2.0), float(47.4), float(0.70), float(0.71)) return diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index 6b4fd8fa..5d276fc8 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -61,15 +61,15 @@ public class BuildingObject extends TangibleObject implements IPersistent { private short maximumStorageCapacity=0; private Vector entryList = new Vector(); // Preferably the OIDs should be stored, because of name changes private Vector banList = new Vector(); - - public BuildingObject() { - super(); + + public BuildingObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) { + super(objectID, planet, Template, position, orientation); messageBuilder = new BuildingMessageBuilder(this); this.setConditionDamage(100); } - - public BuildingObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) { - super(objectID, planet, Template, position, orientation); + + public BuildingObject() { + super(); messageBuilder = new BuildingMessageBuilder(this); this.setConditionDamage(100); } @@ -89,6 +89,18 @@ public class BuildingObject extends TangibleObject implements IPersistent { } + public int getCellNumberByObjectId(long objectId) { + Vector cells = getCells(); + + for (CellObject cell : cells) { + if (cell.getObjectID() == objectId) { + return cell.getCellNumber(); + } + } + + return 0; + } + public float getMaintenanceAmount() { return maintenanceAmount; } diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 4a5f11c3..d11c3644 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -54,7 +54,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=12) +@Persistent(version=13) public class TangibleObject extends SWGObject { // TODO: Thread safety diff --git a/src/services/StaticService.java b/src/services/StaticService.java index 7dbe7d97..380ec762 100644 --- a/src/services/StaticService.java +++ b/src/services/StaticService.java @@ -28,9 +28,7 @@ import java.util.Map; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; import resources.objects.tangible.TangibleObject; - import main.NGECore; - import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; @@ -72,26 +70,39 @@ public class StaticService implements INetworkDispatch { } public SWGObject spawnObject(String template, String planetName, long cellId, float x, float y, float z, float qW, float qX, float qY, float qZ) { - return spawnObject(template, 0, planetName, cellId, x, y, z, qW, qX, qY, qZ); - } - - public SWGObject spawnObject(String template, long objectId, String planetName, long cellId, float x, float y, float z, float qW, float qX, float qY, float qZ) { Planet planet = core.terrainService.getPlanetByName(planetName); if (planet == null) { - System.out.println("StaticService: Can't spawn static object because planet is null."); + System.err.println("StaticService: Can't spawn static object because planet is null."); return null; } - SWGObject object = core.objectService.createObject(template, objectId, planet, new Point3D(x, y, z), new Quaternion(qW, qX, qY, qZ)); + int cellNumber = 0; + + SWGObject container = core.objectService.getObject(cellId); + + if (container != null && container.getContainer() != null && container.getContainer() instanceof BuildingObject) { + cellNumber = ((BuildingObject) container.getContainer()).getCellNumberByObjectId(cellId); + } + + long objectId = core.objectService.getDOId(planetName, template, 0, cellId, cellNumber, x, y, z); + + SWGObject object; + + // Temp fix while objects with custom ids don't appear to spawn despite there being no errors... + if (template.contains("character_builder")) { + object = core.objectService.createObject(template, 0, planet, new Point3D(x, y, z), new Quaternion(qW, qX, qY, qZ)); + } else { + object = core.objectService.createObject(template, objectId, planet, new Point3D(x, y, z), new Quaternion(qW, qX, qY, qZ)); + } if (object == null) { - System.out.println("Static object is null with id " + objectId + " and template " + template + "."); + System.err.println("Static object is null with id " + objectId + " and template " + template + "."); return null; } if (objectId != 0 && object.getObjectID() != objectId) { - System.out.println("StaticService: ObjectId " + objectId + " was taken for object with template " + object.getTemplate() + ". Replacement: " + object.getObjectID()); + System.err.println("StaticService: ObjectId " + objectId + " was taken for object with template " + object.getTemplate() + ". Replacement: " + object.getObjectID()); } if (object instanceof CreatureObject) { @@ -99,16 +110,14 @@ public class StaticService implements INetworkDispatch { } if (cellId == 0) { - boolean add = core.simulationService.add(object, (float) x, (float) z, true); - - if (!add) { - System.out.println("StaticService: Quadtree insert failed for: " + template); + if (!core.simulationService.add(object, (float) x, (float) z, true)) { + System.err.println("StaticService: Quadtree insert failed for: " + template); } } else { SWGObject parent = core.objectService.getObject(cellId); if (parent == null) { - System.out.println("StaticService: Cell not found"); + System.err.println("StaticService: Cell not found"); return object; } @@ -128,8 +137,8 @@ public class StaticService implements INetworkDispatch { cloners.add(obj); } } - return cloners; + return cloners; } @Override