diff --git a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CombatIntents.kt b/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CombatIntents.kt new file mode 100644 index 000000000..5fdaf0e7a --- /dev/null +++ b/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CombatIntents.kt @@ -0,0 +1,86 @@ +/*********************************************************************************** + * Copyright (c) 2019 /// 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 . * + ***********************************************************************************/ + +@file:Suppress("NOTHING_TO_INLINE") + +package com.projectswg.holocore.intents.gameplay.combat + +import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject +import me.joshlarson.jlcommon.control.Intent + +/* + * Combat events after the fact + */ +data class CreatureIncapacitatedIntent(val incapper: CreatureObject, val incappee: CreatureObject): Intent() { + companion object { + @JvmStatic inline fun broadcast(incapper: CreatureObject, incapee: CreatureObject) = CreatureIncapacitatedIntent(incapper, incapee).broadcast() + } +} +data class CreatureKilledIntent(val killer: CreatureObject, val corpse: CreatureObject): Intent() { + companion object { + @JvmStatic inline fun broadcast(killer: CreatureObject, corpse: CreatureObject) = CreatureKilledIntent(killer, corpse).broadcast() + } +} +data class CreatureRevivedIntent(val creature: CreatureObject): Intent() { + companion object { + @JvmStatic inline fun broadcast(creature: CreatureObject) = CreatureRevivedIntent(creature).broadcast() + } +} +data class EnterCombatIntent(val source: CreatureObject, val target: CreatureObject): Intent() { + companion object { + @JvmStatic inline fun broadcast(source: CreatureObject, target: CreatureObject) = EnterCombatIntent(source, target).broadcast() + } +} +data class ExitCombatIntent(val source: CreatureObject): Intent() { + companion object { + @JvmStatic inline fun broadcast(source: CreatureObject) = ExitCombatIntent(source).broadcast() + } +} + +/* + * Combat event requests + */ +data class IncapacitateCreatureIntent(val incapper: CreatureObject, val incappee: CreatureObject): Intent() { + companion object { + @JvmStatic inline fun broadcast(incapper: CreatureObject, incapee: CreatureObject) = IncapacitateCreatureIntent(incapper, incapee).broadcast() + } +} +data class KillCreatureIntent(val killer: CreatureObject, val corpse: CreatureObject): Intent() { + companion object { + @JvmStatic inline fun broadcast(killer: CreatureObject, corpse: CreatureObject) = KillCreatureIntent(killer, corpse).broadcast() + } +} +data class DeathblowIntent(val killer: CreatureObject, val corpse: CreatureObject): Intent() { + companion object { + @JvmStatic inline fun broadcast(killer: CreatureObject, corpse: CreatureObject) = DeathblowIntent(killer, corpse).broadcast() + } +} +data class RequestCreatureDeathIntent(val killer: CreatureObject, val corpse: CreatureObject): Intent() { + companion object { + @JvmStatic inline fun broadcast(killer: CreatureObject, corpse: CreatureObject) = RequestCreatureDeathIntent(killer, corpse).broadcast() + } +} diff --git a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CreatureIncapacitatedIntent.java b/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CreatureIncapacitatedIntent.java deleted file mode 100644 index b9c9ef02a..000000000 --- a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CreatureIncapacitatedIntent.java +++ /dev/null @@ -1,51 +0,0 @@ -/*********************************************************************************** - * 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 . * - ***********************************************************************************/ -package com.projectswg.holocore.intents.gameplay.combat; - -import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject; -import me.joshlarson.jlcommon.control.Intent; - -public class CreatureIncapacitatedIntent extends Intent { - - private final CreatureObject incapper; - private final CreatureObject incappee; - - public CreatureIncapacitatedIntent(CreatureObject incapper, CreatureObject incappee) { - this.incapper = incapper; - this.incappee = incappee; - } - - public CreatureObject getIncapper() { - return incapper; - } - - public CreatureObject getIncappee() { - return incappee; - } - -} - diff --git a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CreatureKilledIntent.java b/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CreatureKilledIntent.java deleted file mode 100644 index 1f909cde8..000000000 --- a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CreatureKilledIntent.java +++ /dev/null @@ -1,50 +0,0 @@ -/*********************************************************************************** - * 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 . * - ***********************************************************************************/ -package com.projectswg.holocore.intents.gameplay.combat; - -import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject; -import me.joshlarson.jlcommon.control.Intent; - -public class CreatureKilledIntent extends Intent { - - private final CreatureObject killer; - private final CreatureObject corpse; - - public CreatureKilledIntent(CreatureObject killer, CreatureObject corpse) { - this.killer = killer; - this.corpse = corpse; - } - - public CreatureObject getKiller() { - return killer; - } - - public CreatureObject getCorpse() { - return corpse; - } - -} diff --git a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CreatureRevivedIntent.java b/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CreatureRevivedIntent.java deleted file mode 100644 index 3d8b49cfb..000000000 --- a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/CreatureRevivedIntent.java +++ /dev/null @@ -1,50 +0,0 @@ -/*********************************************************************************** - * 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 . * - ***********************************************************************************/ -package com.projectswg.holocore.intents.gameplay.combat; - -import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject; -import me.joshlarson.jlcommon.control.Intent; -import org.jetbrains.annotations.NotNull; - -public class CreatureRevivedIntent extends Intent { - - private final CreatureObject creature; - - public CreatureRevivedIntent(@NotNull CreatureObject creature) { - this.creature = creature; - } - - @NotNull - public CreatureObject getCreature() { - return creature; - } - - public static void broadcast(@NotNull CreatureObject creature) { - new CreatureRevivedIntent(creature).broadcast(); - } - -} diff --git a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/DeathblowIntent.java b/src/main/java/com/projectswg/holocore/intents/gameplay/combat/DeathblowIntent.java deleted file mode 100644 index 7a94ba967..000000000 --- a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/DeathblowIntent.java +++ /dev/null @@ -1,54 +0,0 @@ -/*********************************************************************************** - * 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 . * - ***********************************************************************************/ -package com.projectswg.holocore.intents.gameplay.combat; - -import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject; -import me.joshlarson.jlcommon.control.Intent; - -public class DeathblowIntent extends Intent { - - private final CreatureObject killer; - private final CreatureObject corpse; - - /** - * @param killer {@code CreatureObject} that's deathblowing - * @param corpse {@code CreatureObject} that's being deathblown - */ - public DeathblowIntent(CreatureObject killer, CreatureObject corpse) { - this.killer = killer; - this.corpse = corpse; - } - - public CreatureObject getKiller() { - return killer; - } - - public CreatureObject getCorpse() { - return corpse; - } - -} diff --git a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/EnterCombatIntent.java b/src/main/java/com/projectswg/holocore/intents/gameplay/combat/EnterCombatIntent.java deleted file mode 100644 index 71a0b89e2..000000000 --- a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/EnterCombatIntent.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.projectswg.holocore.intents.gameplay.combat; - -import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject; -import me.joshlarson.jlcommon.control.Intent; -import org.jetbrains.annotations.NotNull; - -public class EnterCombatIntent extends Intent { - - private final CreatureObject source; - private final CreatureObject target; - - public EnterCombatIntent(@NotNull CreatureObject source, @NotNull CreatureObject target) { - this.source = source; - this.target = target; - } - - @NotNull - public CreatureObject getSource() { - return source; - } - - @NotNull - public CreatureObject getTarget() { - return target; - } - - public static void broadcast(@NotNull CreatureObject source, @NotNull CreatureObject target) { - new EnterCombatIntent(source, target).broadcast(); - } - -} diff --git a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/ExitCombatIntent.java b/src/main/java/com/projectswg/holocore/intents/gameplay/combat/ExitCombatIntent.java deleted file mode 100644 index 0d0ba61b2..000000000 --- a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/ExitCombatIntent.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.projectswg.holocore.intents.gameplay.combat; - -import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject; -import me.joshlarson.jlcommon.control.Intent; -import org.jetbrains.annotations.NotNull; - -public class ExitCombatIntent extends Intent { - - private final CreatureObject source; - - public ExitCombatIntent(@NotNull CreatureObject source) { - this.source = source; - } - - @NotNull - public CreatureObject getSource() { - return source; - } - - public static void broadcast(@NotNull CreatureObject source) { - new ExitCombatIntent(source).broadcast(); - } - -} diff --git a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/IncapacitateCreatureIntent.java b/src/main/java/com/projectswg/holocore/intents/gameplay/combat/IncapacitateCreatureIntent.java deleted file mode 100644 index a8408bac1..000000000 --- a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/IncapacitateCreatureIntent.java +++ /dev/null @@ -1,51 +0,0 @@ -/*********************************************************************************** - * 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 . * - ***********************************************************************************/ -package com.projectswg.holocore.intents.gameplay.combat; - -import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject; -import me.joshlarson.jlcommon.control.Intent; - -public class IncapacitateCreatureIntent extends Intent { - - private final CreatureObject incapper; - private final CreatureObject incappee; - - public IncapacitateCreatureIntent(CreatureObject incapper, CreatureObject incappee) { - this.incapper = incapper; - this.incappee = incappee; - } - - public CreatureObject getIncapper() { - return incapper; - } - - public CreatureObject getIncappee() { - return incappee; - } - -} - diff --git a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/KillCreatureIntent.java b/src/main/java/com/projectswg/holocore/intents/gameplay/combat/KillCreatureIntent.java deleted file mode 100644 index fa3e5482f..000000000 --- a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/KillCreatureIntent.java +++ /dev/null @@ -1,50 +0,0 @@ -/*********************************************************************************** - * 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 . * - ***********************************************************************************/ -package com.projectswg.holocore.intents.gameplay.combat; - -import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject; -import me.joshlarson.jlcommon.control.Intent; - -public class KillCreatureIntent extends Intent { - - private final CreatureObject killer; - private final CreatureObject corpse; - - public KillCreatureIntent(CreatureObject killer, CreatureObject corpse) { - this.killer = killer; - this.corpse = corpse; - } - - public CreatureObject getKiller() { - return killer; - } - - public CreatureObject getCorpse() { - return corpse; - } - -} diff --git a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/RequestCreatureDeathIntent.java b/src/main/java/com/projectswg/holocore/intents/gameplay/combat/RequestCreatureDeathIntent.java deleted file mode 100644 index 22845d8c8..000000000 --- a/src/main/java/com/projectswg/holocore/intents/gameplay/combat/RequestCreatureDeathIntent.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.projectswg.holocore.intents.gameplay.combat; - -import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject; -import me.joshlarson.jlcommon.control.Intent; -import org.jetbrains.annotations.NotNull; - -public class RequestCreatureDeathIntent extends Intent { - - private final CreatureObject corpse; - private final CreatureObject killer; - - public RequestCreatureDeathIntent(@NotNull CreatureObject corpse, @NotNull CreatureObject killer) { - this.corpse = corpse; - this.killer = killer; - } - - @NotNull - public CreatureObject getCorpse() { - return corpse; - } - - @NotNull - public CreatureObject getKiller() { - return killer; - } - - public static void broadcast(@NotNull CreatureObject corpse, @NotNull CreatureObject killer) { - new RequestCreatureDeathIntent(corpse, killer).broadcast(); - } - -} diff --git a/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/npc/NpcCombatProfileLoader.java b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/npc/NpcCombatProfileLoader.java deleted file mode 100644 index 0946ccc28..000000000 --- a/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/npc/NpcCombatProfileLoader.java +++ /dev/null @@ -1,107 +0,0 @@ -/*********************************************************************************** - * Copyright (c) 2019 /// 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 . * - ***********************************************************************************/ - -package com.projectswg.holocore.resources.support.data.server_info.loader.npc; - -import com.projectswg.holocore.resources.support.data.server_info.SdbLoader; -import com.projectswg.holocore.resources.support.data.server_info.SdbLoader.SdbResultSet; -import com.projectswg.holocore.resources.support.data.server_info.loader.DataLoader; -import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureDifficulty; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.File; -import java.io.IOException; -import java.util.*; - -import static java.util.stream.Collectors.groupingBy; - -public final class NpcCombatProfileLoader extends DataLoader { - - private final Map> profiles; - - public NpcCombatProfileLoader() { - this.profiles = new HashMap<>(); - } - - @NotNull - public Set getAbilities(@Nullable String id, @NotNull CreatureDifficulty difficulty, int level) { - List subprofiles = Objects.requireNonNull(profiles.get(id), "unknown profile id"); - Set abilities = new HashSet<>(); - for (CombatProfile profile : subprofiles) { - if (profile.getDifficulty().equals(difficulty) && level >= profile.getMinLevel() && level <= profile.getMaxLevel()) - abilities.addAll(profile.getAbilities()); - } - return abilities; - } - - @Override - public void load() throws IOException { - try (SdbResultSet set = SdbLoader.load(new File("serverdata/spawn/static.msdb"))) { - profiles.putAll(set.stream(CombatProfile::new).collect(groupingBy(CombatProfile::getId))); - } - } - - private static class CombatProfile { - - private final String id; - private final CreatureDifficulty difficulty; - private final int minLevel; - private final int maxLevel; - private final Set abilities; - - public CombatProfile(SdbResultSet set) { - this.id = set.getText("profile_id"); - this.difficulty = CreatureDifficulty.valueOf(set.getText("difficulty")); - this.minLevel = (int) set.getInt("min_cl"); - this.maxLevel = (int) set.getInt("max_cl"); - this.abilities = Set.of(set.getText("action").split(";")); - } - - public String getId() { - return id; - } - - public CreatureDifficulty getDifficulty() { - return difficulty; - } - - public int getMinLevel() { - return minLevel; - } - - public int getMaxLevel() { - return maxLevel; - } - - public Set getAbilities() { - return abilities; - } - - } - -} diff --git a/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/npc/NpcCombatProfileLoader.kt b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/npc/NpcCombatProfileLoader.kt new file mode 100644 index 000000000..f71a3b837 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/npc/NpcCombatProfileLoader.kt @@ -0,0 +1,82 @@ +/*********************************************************************************** + * Copyright (c) 2019 /// 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 //www.gnu.org/licenses/>. * + */ + +package com.projectswg.holocore.resources.support.data.server_info.loader.npc + +import com.projectswg.holocore.resources.support.data.server_info.SdbLoader +import com.projectswg.holocore.resources.support.data.server_info.SdbLoader.SdbResultSet +import com.projectswg.holocore.resources.support.data.server_info.loader.DataLoader +import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureDifficulty + +import java.io.File +import java.io.IOException +import java.util.* + +import java.util.stream.Collectors.groupingBy + +class NpcCombatProfileLoader : DataLoader() { + + private val profiles: MutableMap> + + init { + this.profiles = HashMap() + } + + fun getAbilities(id: String?, difficulty: CreatureDifficulty, level: Int): Set { + val subprofiles = Objects.requireNonNull>(profiles[id], "unknown profile id") + val abilities = HashSet() + for (profile in subprofiles) { + if (profile.difficulty == difficulty && level >= profile.minLevel && level <= profile.maxLevel) + abilities.addAll(profile.abilities) + } + return abilities + } + + @Throws(IOException::class) + public override fun load() { + SdbLoader.load(File("serverdata/spawn/static.msdb")).use { set -> profiles.putAll(set.stream(Function { CombatProfile(it) }).collect>, Any>(groupingBy(Function { it.getId() }))) } + } + + private class CombatProfile(set: SdbResultSet) { + + val id: String + val difficulty: CreatureDifficulty + val minLevel: Int + val maxLevel: Int + val abilities: Set + + init { + this.id = set.getText("profile_id") + this.difficulty = CreatureDifficulty.valueOf(set.getText("difficulty")) + this.minLevel = set.getInt("min_cl").toInt() + this.maxLevel = set.getInt("max_cl").toInt() + this.abilities = Set.of(*set.getText("action").split(";".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()) + } + + } + +} diff --git a/src/main/java/com/projectswg/holocore/services/gameplay/combat/command/CombatCommandAttack.java b/src/main/java/com/projectswg/holocore/services/gameplay/combat/command/CombatCommandAttack.java index 9e19eefe7..89cf4afe0 100644 --- a/src/main/java/com/projectswg/holocore/services/gameplay/combat/command/CombatCommandAttack.java +++ b/src/main/java/com/projectswg/holocore/services/gameplay/combat/command/CombatCommandAttack.java @@ -152,7 +152,7 @@ enum CombatCommandAttack implements CombatCommandHitType { if (incapacitate) { finalDamage = targetHealth; // Target took more damage than they had health left. Final damage becomes the amount of remaining health. - RequestCreatureDeathIntent.broadcast(target, source); + RequestCreatureDeathIntent.broadcast(source, target); } else { target.modifyHealth(-finalDamage); }