Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic structure support #707

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 0 additions & 201 deletions serverdata/housing/housing_datatable.sdb

This file was deleted.

201 changes: 201 additions & 0 deletions serverdata/structures/structure_info.sdb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/***********************************************************************************
* Copyright (c) 2022 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* --------------------------------------------------------------------------------*
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore 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 Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
***********************************************************************************/

/***********************************************************************************
* Copyright (c) 2022 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* --------------------------------------------------------------------------------*
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore 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 Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
***********************************************************************************/

package com.projectswg.holocore.intents.gameplay.structures

import com.projectswg.common.data.location.Location
import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject
import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleObject
import me.joshlarson.jlcommon.control.Intent

data class UseStructureDeedIntent(val creature: CreatureObject, val deed: TangibleObject): Intent()
data class PlaceStructureIntent(val creature: CreatureObject, val deed: TangibleObject, val location: Location): Intent()
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ object ServerData {
val zoneInsertions by SoftDataLoaderDelegate(::TerrainZoneInsertionLoader)
val terrains by SoftDataLoaderDelegate(::TerrainHeightLoader)

val housing by SoftDataLoaderDelegate(::StructureInfoLoader)

val commands by SoftDataLoaderDelegate(::CommandLoader)
val travelCosts by SoftDataLoaderDelegate(::TravelCostLoader)
val vehicles by SoftDataLoaderDelegate(::VehicleLoader)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/***********************************************************************************
* Copyright (c) 2022 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* --------------------------------------------------------------------------------*
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore 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 Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
***********************************************************************************/

package com.projectswg.holocore.resources.support.data.server_info.loader

import com.projectswg.holocore.resources.support.data.server_info.SdbLoader
import com.projectswg.holocore.resources.support.data.server_info.SdbLoader.SdbResultSet
import java.io.File
import java.io.IOException
import java.util.*
import java.util.stream.Collectors

class StructureInfoLoader : DataLoader() {

private var structureInfo: Map<String, StructureInfo> = HashMap()

val structures: Map<String, StructureInfo>
get() = Collections.unmodifiableMap(structureInfo)

fun getStructureInfo(structureTemplate: String): StructureInfo? {
return structureInfo[structureTemplate]
}

@Throws(IOException::class)
override fun load() {
SdbLoader.load(File("serverdata/structures/structure_info.sdb")).use { set ->
structureInfo = set.stream { StructureInfo(it) }.collect(Collectors.toMap({ it.structureTemplate }, { it }))
}
}

class StructureInfo(set: SdbResultSet) {

val structureTemplate = set.getText("structure")
val deedTemplate = set.getText("deed")
val constructionTemplate = set.getText("construction_template")
val footprintTemplate = set.getText("footprint_template")
val signTemplate = set.getText("sign_template")
val lotsNeeded = set.getInt("lots_needed")
val ejectRange = set.getInt("eject_range")
val sign = set.getBoolean("sign")
val signX = set.getReal("sign_x")
val signY = set.getReal("sign_y")
val signZ = set.getReal("sign_z")
val signHeading = set.getReal("sign_heading")
val signAltX = set.getReal("sign_alt_x")
val signAltY = set.getReal("sign_alt_y")
val signAltZ = set.getReal("sign_alt_z")
val signAltHeading = set.getReal("sign_alt_heading")
val civic = set.getBoolean("civic")
val cityRank = set.getInt("city_rank")
val cityCost = set.getInt("city_cost")
val type = set.getText("type")
val shuttleport = set.getBoolean("shuttleport")
val cloning = set.getBoolean("cloning")
val garage = set.getBoolean("garage")
val reclaim = set.getBoolean("reclaim")
val maintenanceRage = set.getInt("maintenance_rate")
val decayRate = set.getInt("decay_rate")
val condition = set.getInt("condition")
val costRedeed = set.getInt("cost_redeed")
val powerRate = set.getInt("power_rate")
val hopperMin = set.getInt("hopper_min")
val hopperMax = set.getInt("hopper_max")
val skillmod = set.getText("skillmod")
val skillmodValue = set.getInt("skillmod_value")
val skillmodMessage = set.getText("skillmod_message")

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/***********************************************************************************
* Copyright (c) 2018 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* --------------------------------------------------------------------------------*
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore 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 Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http:></http:>//www.gnu.org/licenses/>. *
*/
package com.projectswg.holocore.resources.support.global.commands.callbacks

import com.projectswg.common.data.location.Location
import com.projectswg.holocore.intents.gameplay.structures.PlaceStructureIntent
import com.projectswg.holocore.resources.support.data.server_info.StandardLog
import com.projectswg.holocore.resources.support.data.server_info.loader.ServerData
import com.projectswg.holocore.resources.support.global.player.Player
import com.projectswg.holocore.resources.support.objects.swg.SWGObject
import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleObject
import com.projectswg.holocore.services.support.objects.ObjectStorageService
import kotlin.math.max
import kotlin.math.min

class PlaceStructureCmdCallback : StartDanceCallback() {

override fun execute(player: Player, target: SWGObject?, args: String) {
val argumentsSplit = args.split(' ', limit=4)
if (argumentsSplit.size != 4)
return

val creature = player.creatureObject ?: return

try {
val deed = ObjectStorageService.ObjectLookup.getObjectById(argumentsSplit[0].toLong()) as? TangibleObject
if (deed == null) {
StandardLog.onPlayerError(this, player, "Invalid deed ID in placestructure: %s", argumentsSplit[0])
return
}
val terrain = creature.terrain
val locationX = argumentsSplit[1].toDouble()
val locationZ = argumentsSplit[2].toDouble()
val direction = min(3, max(0, argumentsSplit[3].toInt()))
val location = Location.builder()
.setTerrain(terrain)
.setX(locationX)
.setY(ServerData.terrains.getHeight(terrain, locationX, locationZ))
.setZ(locationZ)
.setHeading(direction * 90.0)
.build()

PlaceStructureIntent(creature, deed, location).broadcast()
} catch (e: NumberFormatException) {
StandardLog.onPlayerError(this, player, "Invalid arguments to placestructure: %s", args)
}
StandardLog.onPlayerTrace(this, player, "Requested structure placement: %s", args)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.projectswg.common.data.objects.GameObjectType;
import com.projectswg.common.data.radial.RadialItem;
import com.projectswg.common.data.radial.RadialOption;
import com.projectswg.holocore.resources.support.data.server_info.loader.StructureInfoLoader;
import com.projectswg.holocore.resources.support.data.server_info.loader.ServerData;
import com.projectswg.holocore.resources.support.global.player.Player;
import com.projectswg.holocore.resources.support.objects.radial.object.*;
import com.projectswg.holocore.resources.support.objects.radial.object.survey.ObjectSurveyToolRadial;
Expand Down Expand Up @@ -37,6 +39,7 @@ public enum RadialHandler {
initializeContainerRadials();
initializeSpecialEditionGoggleRadials();
initializeMeleeWeaponRadials();
initializeDeedRadials();

RadialHandlerInterface aiHandler = new AIObjectRadial();

Expand Down Expand Up @@ -125,4 +128,12 @@ private void initializeSpecialEditionGoggleRadials() {
registerHandler("object/tangible/wearables/goggles/shared_goggles_s03.iff", new SpecialEditionGogglesRadial(false));
registerHandler("object/tangible/wearables/goggles/shared_goggles_s06.iff", new SpecialEditionGogglesRadial(false));
}

private void initializeDeedRadials() {
for (StructureInfoLoader.StructureInfo structureInfo : ServerData.INSTANCE.getHousing().getStructures().values()) {
if (structureInfo.getDeedTemplate().isEmpty())
continue;
registerHandler(structureInfo.getDeedTemplate(), new StructureDeedRadial());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/***********************************************************************************
* Copyright (c) 2022 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* --------------------------------------------------------------------------------*
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore 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 Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
***********************************************************************************/

package com.projectswg.holocore.resources.support.objects.radial.`object`

import com.projectswg.common.data.radial.RadialItem
import com.projectswg.common.data.radial.RadialOption
import com.projectswg.holocore.intents.gameplay.structures.UseStructureDeedIntent
import com.projectswg.holocore.resources.support.global.player.Player
import com.projectswg.holocore.resources.support.objects.radial.RadialHandlerInterface
import com.projectswg.holocore.resources.support.objects.swg.SWGObject
import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleObject

class StructureDeedRadial : RadialHandlerInterface {

override fun getOptions(options: MutableCollection<RadialOption>, player: Player, target: SWGObject) {
options.add(RadialOption.create(RadialItem.ITEM_USE))
options.add(RadialOption.create(RadialItem.ITEM_DESTROY))
options.add(RadialOption.create(RadialItem.EXAMINE))
}

override fun handleSelection(player: Player, target: SWGObject, selection: RadialItem) {
if (selection != RadialItem.ITEM_USE)
return
if (target !is TangibleObject)
return
UseStructureDeedIntent(player.creatureObject ?: return, target).broadcast()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public enum ServerAttribute {
SURVEY_TOOL_RANGE ("survey_tool.range", PredefinedDataType.INT),
SET_BONUS_ID ("set_bonus.id", PredefinedDataType.INT),
LINK_OBJECT_ID ("link.object.id", PredefinedDataType.LONG),
ITEM_VALUE ("item.value", PredefinedDataType.INT);
ITEM_VALUE ("item.value", PredefinedDataType.INT),
DEED_GEN_TEMPLATE ("deed.generated_template", PredefinedDataType.STRING);

private static final EnumLookup<String, ServerAttribute> KEY_LOOKUP = new EnumLookup<>(ServerAttribute.class, ServerAttribute::getKey);

Expand Down
Loading