diff --git a/scripts/constructor_build_phase.py b/scripts/constructor_build_phase.py new file mode 100644 index 00000000..62755eac --- /dev/null +++ b/scripts/constructor_build_phase.py @@ -0,0 +1,7 @@ +import sys +import time + +def buildConstructor(core): + time.sleep(10) + return + \ No newline at end of file diff --git a/src/services/DevService.java b/src/services/DevService.java index 79b3feca..d0b1f39e 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -1243,6 +1243,10 @@ public class DevService implements INetworkDispatch { deed.setIntAttribute("examine_maintenance_rate", 15); inventory.add(deed); + deed = (TangibleObject) core.objectService.createObject("object/tangible/deed/guild_deed/shared_tatooine_guild_deed.iff", planet); + deed.setIntAttribute("examine_maintenance_rate", 15); + inventory.add(deed); + return; case 121: diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index 63860a89..fd079196 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -113,8 +113,10 @@ public class HousingService implements INetworkDispatch { HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate()); int structureLotCost = houseTemplate.getLotCost(); String structureTemplate = houseTemplate.getBuildingTemplate(); - PlayerCity city = core.playerCityService.getCityPositionIsIn(new Point3D(positionX, 0, positionZ)); - + //PlayerCity city = core.playerCityService.getCityPositionIsIn(new Point3D(positionX, 0, positionZ)); + // This function is not implemented, so it had to be commented out, because it resulted in an error + // Whoever wrote this, should still add the method to playerCityService, then it can be uncommented here. + PlayerCity city = null; if (!houseTemplate.canBePlacedOn(actor.getPlanet().getName())) { actor.sendSystemMessage("You may not place this structure on this planet.", (byte) 0); // should probably load this from an stf return null; @@ -142,6 +144,12 @@ public class HousingService implements INetworkDispatch { float positionY = core.terrainService.getHeight(actor.getPlanetId(), positionX, positionZ) + 2f; + String constructorTemplate = mapConstructor(structureTemplate); + InstallationObject constructors = (InstallationObject) core.objectService.createObject(constructorTemplate, 0, actor.getPlanet(), new Point3D(positionX, positionY, positionZ), quaternion); + core.simulationService.add(constructors, positionX, positionZ, true); + core.scriptService.callScript("scripts/", "constructor_build_phase", "buildConstructor", core); + core.objectService.destroyObject(constructors); + // Create the building BuildingObject building = (BuildingObject) core.objectService.createObject(structureTemplate, 0, actor.getPlanet(), new Point3D(positionX, positionY, positionZ), quaternion); @@ -196,6 +204,27 @@ public class HousingService implements INetworkDispatch { return building; } + public String mapConstructor(String structureTemplate) { + String mappedConstructorTemplate = "object/building/player/construction/shared_construction_player_house_generic_small_style_01.iff"; + if (structureTemplate.contains("small")){ + mappedConstructorTemplate = "object/building/player/construction/shared_construction_player_house_generic_small_style_01.iff"; + } else if (structureTemplate.contains("medium")){ + mappedConstructorTemplate = "object/building/player/construction/shared_construction_player_house_generic_medium_style_01.iff"; + } else if (structureTemplate.contains("large")){ + mappedConstructorTemplate = "object/building/player/construction/shared_construction_player_house_generic_large_style_01.iff"; + } + + if (structureTemplate.contains("guildhall") || structureTemplate.contains("cityhall")){ + mappedConstructorTemplate = "object/building/player/construction/shared_construction_player_guildhall_corellia_style_01.iff"; + } else if (structureTemplate.contains("hangar")){ + mappedConstructorTemplate = "object/building/player/construction/shared_construction_player_house_hangar.iff"; + } else if (structureTemplate.contains("meditation")){ + mappedConstructorTemplate = "object/building/player/construction/shared_construction_player_jedi_meditation_room.iff"; + } + // Probably more could be added + return mappedConstructorTemplate; + } + public void startMaintenanceTask(BuildingObject building) { if(building.getAttachment("isCivicStructure") != null && (boolean) building.getAttachment("isCivicStructure")) diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 475f7155..54fa70e3 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -291,6 +291,12 @@ public class ObjectService implements INetworkDispatch { object = new WeaponObject(objectID, planet, position, orientation, Template); + } else if(Template.startsWith("object/building/player/construction")) { + + float positionY = core.terrainService.getHeight(planet.getID(), position.x, position.z)-1f; + Point3D newpoint = new Point3D(position.x,positionY,position.z); + object = new InstallationObject(objectID, planet, newpoint, orientation, Template); + } else if(Template.startsWith("object/building") || Template.startsWith("object/static/worldbuilding/structures") || Template.startsWith("object/static/structure")){ object = new BuildingObject(objectID, planet, position, orientation, Template);