mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 15:22:16 +00:00
Switch to using quest excels
This commit is contained in:
parent
9b26426e8a
commit
631a53030c
@ -12,7 +12,7 @@ import emu.grasscutter.data.custom.AbilityEmbryoEntry;
|
||||
import emu.grasscutter.data.custom.AbilityModifier;
|
||||
import emu.grasscutter.data.custom.AbilityModifierEntry;
|
||||
import emu.grasscutter.data.custom.OpenConfigEntry;
|
||||
import emu.grasscutter.data.custom.QuestConfig;
|
||||
import emu.grasscutter.data.custom.MainQuestData;
|
||||
import emu.grasscutter.data.custom.ScenePointEntry;
|
||||
import emu.grasscutter.data.def.*;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
|
||||
@ -28,7 +28,7 @@ public class GameData {
|
||||
private static final Map<String, AbilityModifierEntry> abilityModifiers = new HashMap<>();
|
||||
private static final Map<String, OpenConfigEntry> openConfigEntries = new HashMap<>();
|
||||
private static final Map<String, ScenePointEntry> scenePointEntries = new HashMap<>();
|
||||
private static final Int2ObjectMap<QuestConfig> questConfigs = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<MainQuestData> mainQuestData = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
// ExcelConfigs
|
||||
private static final Int2ObjectMap<PlayerLevelData> playerLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
@ -70,6 +70,7 @@ public class GameData {
|
||||
private static final Int2ObjectMap<WorldLevelData> worldLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<DailyDungeonData> dailyDungeonDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<DungeonData> dungeonDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<QuestData> questDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ShopGoodsData> shopGoodsDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CombineData> combineDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<RewardPreviewData> rewardPreviewDataMap = new Int2ObjectOpenHashMap<>();
|
||||
@ -124,8 +125,8 @@ public class GameData {
|
||||
return getScenePointEntries().get(sceneId + "_" + pointId);
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<QuestConfig> getQuestConfigs() {
|
||||
return questConfigs;
|
||||
public static Int2ObjectMap<MainQuestData> getMainQuestDataMap() {
|
||||
return mainQuestData;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarData> getAvatarDataMap() {
|
||||
@ -337,4 +338,8 @@ public class GameData {
|
||||
public static Int2ObjectMap<TowerScheduleData> getTowerScheduleDataMap(){
|
||||
return towerScheduleDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<QuestData> getQuestDataMap() {
|
||||
return questDataMap;
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,7 @@ import emu.grasscutter.data.custom.AbilityModifier.AbilityModifierAction;
|
||||
import emu.grasscutter.data.custom.AbilityModifier.AbilityModifierActionType;
|
||||
import emu.grasscutter.data.custom.AbilityModifierEntry;
|
||||
import emu.grasscutter.data.custom.OpenConfigEntry;
|
||||
import emu.grasscutter.data.custom.QuestConfig;
|
||||
import emu.grasscutter.data.custom.QuestConfigData;
|
||||
import emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData;
|
||||
import emu.grasscutter.data.custom.MainQuestData;
|
||||
import emu.grasscutter.data.custom.ScenePointEntry;
|
||||
import emu.grasscutter.game.world.SpawnDataEntry.*;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
@ -407,24 +405,19 @@ public class ResourceLoader {
|
||||
}
|
||||
|
||||
for (File file : folder.listFiles()) {
|
||||
QuestConfigData mainQuest = null;
|
||||
MainQuestData mainQuest = null;
|
||||
|
||||
try (FileReader fileReader = new FileReader(file)) {
|
||||
mainQuest = Grasscutter.getGsonFactory().fromJson(fileReader, QuestConfigData.class);
|
||||
mainQuest = Grasscutter.getGsonFactory().fromJson(fileReader, MainQuestData.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mainQuest.getSubQuests() != null) {
|
||||
for (SubQuestConfigData subQuest : mainQuest.getSubQuests()) {
|
||||
QuestConfig quest = new QuestConfig(mainQuest, subQuest);
|
||||
GameData.getQuestConfigs().put(quest.getId(), quest);
|
||||
}
|
||||
}
|
||||
GameData.getMainQuestDataMap().put(mainQuest.getId(), mainQuest);
|
||||
}
|
||||
|
||||
Grasscutter.getLogger().info("Loaded " + GameData.getQuestConfigs().size() + " Quest Configs");
|
||||
Grasscutter.getLogger().info("Loaded " + GameData.getMainQuestDataMap().size() + " MainQuestDatas.");
|
||||
}
|
||||
|
||||
// BinOutput configs
|
||||
|
53
src/main/java/emu/grasscutter/data/custom/MainQuestData.java
Normal file
53
src/main/java/emu/grasscutter/data/custom/MainQuestData.java
Normal file
@ -0,0 +1,53 @@
|
||||
package emu.grasscutter.data.custom;
|
||||
|
||||
import emu.grasscutter.game.quest.enums.LogicType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
import emu.grasscutter.game.quest.enums.QuestType;
|
||||
|
||||
public class MainQuestData {
|
||||
private int id;
|
||||
private int series;
|
||||
private QuestType type;
|
||||
|
||||
private long titleTextMapHash;
|
||||
private int[] suggestTrackMainQuestList;
|
||||
private int[] rewardIdList;
|
||||
|
||||
private SubQuestData[] subQuests;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getSeries() {
|
||||
return series;
|
||||
}
|
||||
|
||||
public QuestType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public long getTitleTextMapHash() {
|
||||
return titleTextMapHash;
|
||||
}
|
||||
|
||||
public int[] getSuggestTrackMainQuestList() {
|
||||
return suggestTrackMainQuestList;
|
||||
}
|
||||
|
||||
public int[] getRewardIdList() {
|
||||
return rewardIdList;
|
||||
}
|
||||
|
||||
public SubQuestData[] getSubQuests() {
|
||||
return subQuests;
|
||||
}
|
||||
|
||||
public static class SubQuestData {
|
||||
private int subId;
|
||||
|
||||
public int getSubId() {
|
||||
return subId;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package emu.grasscutter.data.custom;
|
||||
|
||||
import emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData;
|
||||
|
||||
public class QuestConfig {
|
||||
private final QuestConfigData mainQuest;
|
||||
private final SubQuestConfigData subQuest;
|
||||
|
||||
public QuestConfig(QuestConfigData mainQuest, SubQuestConfigData subQuest) {
|
||||
this.mainQuest = mainQuest;
|
||||
this.subQuest = subQuest;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return subQuest.getSubId();
|
||||
}
|
||||
|
||||
public QuestConfigData getMainQuest() {
|
||||
return mainQuest;
|
||||
}
|
||||
|
||||
public SubQuestConfigData getSubQuest() {
|
||||
return subQuest;
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
package emu.grasscutter.data.custom;
|
||||
|
||||
import emu.grasscutter.game.quest.enums.LogicType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTriggerType;
|
||||
import emu.grasscutter.game.quest.enums.QuestType;
|
||||
|
||||
public class QuestConfigData {
|
||||
private int id;
|
||||
private int series;
|
||||
private QuestType type;
|
||||
|
||||
private long titleTextMapHash;
|
||||
private int[] suggestTrackMainQuestList;
|
||||
private int[] rewardIdList;
|
||||
|
||||
private SubQuestConfigData[] subQuests;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getSeries() {
|
||||
return series;
|
||||
}
|
||||
|
||||
public QuestType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public long getTitleTextMapHash() {
|
||||
return titleTextMapHash;
|
||||
}
|
||||
|
||||
public int[] getSuggestTrackMainQuestList() {
|
||||
return suggestTrackMainQuestList;
|
||||
}
|
||||
|
||||
public int[] getRewardIdList() {
|
||||
return rewardIdList;
|
||||
}
|
||||
|
||||
public SubQuestConfigData[] getSubQuests() {
|
||||
return subQuests;
|
||||
}
|
||||
|
||||
public class SubQuestConfigData {
|
||||
private int subId;
|
||||
private int mainId;
|
||||
|
||||
private LogicType acceptCondComb;
|
||||
private QuestCondition[] acceptCond;
|
||||
|
||||
private LogicType finishCondComb;
|
||||
private QuestCondition[] finishCond;
|
||||
|
||||
private LogicType failCondComb;
|
||||
private QuestCondition[] failCond;
|
||||
|
||||
public int getSubId() {
|
||||
return subId;
|
||||
}
|
||||
|
||||
public int getMainId() {
|
||||
return mainId;
|
||||
}
|
||||
|
||||
public LogicType getAcceptCondComb() {
|
||||
return acceptCondComb;
|
||||
}
|
||||
|
||||
public QuestCondition[] getAcceptCond() {
|
||||
return acceptCond;
|
||||
}
|
||||
|
||||
public LogicType getFinishCondComb() {
|
||||
return finishCondComb;
|
||||
}
|
||||
|
||||
public QuestCondition[] getFinishCond() {
|
||||
return finishCond;
|
||||
}
|
||||
|
||||
public LogicType getFailCondComb() {
|
||||
return failCondComb;
|
||||
}
|
||||
|
||||
public QuestCondition[] getFailCond() {
|
||||
return failCond;
|
||||
}
|
||||
}
|
||||
|
||||
public class QuestCondition {
|
||||
private QuestTriggerType type;
|
||||
private int[] param;
|
||||
|
||||
public QuestTriggerType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int[] getParam() {
|
||||
return param;
|
||||
}
|
||||
}
|
||||
}
|
115
src/main/java/emu/grasscutter/data/def/QuestData.java
Normal file
115
src/main/java/emu/grasscutter/data/def/QuestData.java
Normal file
@ -0,0 +1,115 @@
|
||||
package emu.grasscutter.data.def;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import emu.grasscutter.data.GameResource;
|
||||
import emu.grasscutter.data.ResourceType;
|
||||
import emu.grasscutter.game.quest.enums.LogicType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
|
||||
@ResourceType(name = "QuestExcelConfigData.json")
|
||||
public class QuestData extends GameResource {
|
||||
private int SubId;
|
||||
private int MainId;
|
||||
private int Order;
|
||||
private long DescTextMapHash;
|
||||
|
||||
private LogicType AcceptCondComb;
|
||||
private QuestCondition[] acceptConditons;
|
||||
private LogicType FinishCondComb;
|
||||
private QuestCondition[] finishConditons;
|
||||
private LogicType FailCondComb;
|
||||
private QuestCondition[] failConditons;
|
||||
|
||||
private List<QuestParam> AcceptCond;
|
||||
private List<QuestParam> FinishCond;
|
||||
private List<QuestParam> FailCond;
|
||||
private List<QuestExecParam> BeginExec;
|
||||
private List<QuestExecParam> FinishExec;
|
||||
private List<QuestExecParam> FailExec;
|
||||
|
||||
public int getId() {
|
||||
return SubId;
|
||||
}
|
||||
|
||||
public int getMainId() {
|
||||
return MainId;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return Order;
|
||||
}
|
||||
|
||||
public long getDescTextMapHash() {
|
||||
return DescTextMapHash;
|
||||
}
|
||||
|
||||
public LogicType getAcceptCondComb() {
|
||||
return AcceptCondComb;
|
||||
}
|
||||
|
||||
public QuestCondition[] getAcceptCond() {
|
||||
return acceptConditons;
|
||||
}
|
||||
|
||||
public LogicType getFinishCondComb() {
|
||||
return FinishCondComb;
|
||||
}
|
||||
|
||||
public QuestCondition[] getFinishCond() {
|
||||
return finishConditons;
|
||||
}
|
||||
|
||||
public LogicType getFailCondComb() {
|
||||
return FailCondComb;
|
||||
}
|
||||
|
||||
public QuestCondition[] getFailCond() {
|
||||
return failConditons;
|
||||
}
|
||||
|
||||
public void onLoad() {
|
||||
this.acceptConditons = AcceptCond.stream().filter(p -> p.Type != null).map(QuestCondition::new).toArray(QuestCondition[]::new);
|
||||
AcceptCond = null;
|
||||
this.finishConditons = FinishCond.stream().filter(p -> p.Type != null).map(QuestCondition::new).toArray(QuestCondition[]::new);
|
||||
FinishCond = null;
|
||||
this.failConditons = FailCond.stream().filter(p -> p.Type != null).map(QuestCondition::new).toArray(QuestCondition[]::new);
|
||||
FailCond = null;
|
||||
}
|
||||
|
||||
public class QuestParam {
|
||||
QuestTrigger Type;
|
||||
int[] Param;
|
||||
String count;
|
||||
}
|
||||
|
||||
public class QuestExecParam {
|
||||
QuestTrigger Type;
|
||||
String[] Param;
|
||||
String count;
|
||||
}
|
||||
|
||||
public static class QuestCondition {
|
||||
private QuestTrigger type;
|
||||
private int[] param;
|
||||
private String count;
|
||||
|
||||
public QuestCondition(QuestParam param) {
|
||||
this.type = param.Type;
|
||||
this.param = param.Param;
|
||||
}
|
||||
|
||||
public QuestTrigger getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int[] getParam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
public String getCount() {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@ import dev.morphia.annotations.Id;
|
||||
import dev.morphia.annotations.Indexed;
|
||||
import dev.morphia.annotations.Transient;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.custom.QuestConfig;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.quest.enums.ParentQuestState;
|
||||
|
@ -2,9 +2,11 @@ package emu.grasscutter.game.quest;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Transient;
|
||||
import emu.grasscutter.data.custom.QuestConfig;
|
||||
import emu.grasscutter.data.custom.QuestConfigData.QuestCondition;
|
||||
import emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.custom.MainQuestData;
|
||||
import emu.grasscutter.data.custom.MainQuestData.SubQuestData;
|
||||
import emu.grasscutter.data.def.QuestData;
|
||||
import emu.grasscutter.data.def.QuestData.QuestCondition;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.quest.enums.LogicType;
|
||||
import emu.grasscutter.game.quest.enums.QuestState;
|
||||
@ -16,7 +18,7 @@ import emu.grasscutter.utils.Utils;
|
||||
@Entity
|
||||
public class GameQuest {
|
||||
@Transient private GameMainQuest mainQuest;
|
||||
@Transient private QuestConfig config;
|
||||
@Transient private QuestData questData;
|
||||
|
||||
private int questId;
|
||||
private int mainQuestId;
|
||||
@ -32,21 +34,21 @@ public class GameQuest {
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameQuest() {}
|
||||
|
||||
public GameQuest(GameMainQuest mainQuest, QuestConfig config) {
|
||||
public GameQuest(GameMainQuest mainQuest, QuestData questData) {
|
||||
this.mainQuest = mainQuest;
|
||||
this.questId = config.getId();
|
||||
this.mainQuestId = config.getMainQuest().getId();
|
||||
this.config = config;
|
||||
this.questId = questData.getId();
|
||||
this.mainQuestId = questData.getMainId();
|
||||
this.questData = questData;
|
||||
this.acceptTime = Utils.getCurrentSeconds();
|
||||
this.startTime = this.acceptTime;
|
||||
this.state = QuestState.QUEST_STATE_UNFINISHED;
|
||||
|
||||
if (config.getSubQuest().getFinishCond() != null) {
|
||||
this.finishProgressList = new int[config.getSubQuest().getFinishCond().length];
|
||||
if (questData.getFinishCond()!= null) {
|
||||
this.finishProgressList = new int[questData.getFinishCond().length];
|
||||
}
|
||||
|
||||
if (config.getSubQuest().getFailCond() != null) {
|
||||
this.failProgressList = new int[config.getSubQuest().getFailCond().length];
|
||||
if (questData.getFailCond() != null) {
|
||||
this.failProgressList = new int[questData.getFailCond().length];
|
||||
}
|
||||
|
||||
this.mainQuest.getChildQuests().put(this.questId, this);
|
||||
@ -72,13 +74,13 @@ public class GameQuest {
|
||||
return mainQuestId;
|
||||
}
|
||||
|
||||
public QuestConfig getConfig() {
|
||||
return config;
|
||||
public QuestData getData() {
|
||||
return questData;
|
||||
}
|
||||
|
||||
public void setConfig(QuestConfig config) {
|
||||
public void setConfig(QuestData config) {
|
||||
if (this.getQuestId() != config.getId()) return;
|
||||
this.config = config;
|
||||
this.questData = config;
|
||||
}
|
||||
|
||||
public QuestState getState() {
|
||||
@ -148,16 +150,23 @@ public class GameQuest {
|
||||
|
||||
public boolean tryAcceptQuestLine() {
|
||||
try {
|
||||
for (SubQuestConfigData questData : getConfig().getMainQuest().getSubQuests()) {
|
||||
GameQuest quest = getMainQuest().getChildQuestById(questData.getSubId());
|
||||
MainQuestData questConfig = GameData.getMainQuestDataMap().get(this.getMainQuestId());
|
||||
for (SubQuestData subQuest : questConfig.getSubQuests()) {
|
||||
GameQuest quest = getMainQuest().getChildQuestById(subQuest.getSubId());
|
||||
|
||||
if (quest == null) {
|
||||
QuestData questData = GameData.getQuestDataMap().get(subQuest.getSubId());
|
||||
|
||||
if (questData == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int[] accept = new int[questData.getAcceptCond().length];
|
||||
|
||||
// TODO
|
||||
for (int i = 0; i < questData.getAcceptCond().length; i++) {
|
||||
QuestCondition condition = questData.getAcceptCond()[i];
|
||||
boolean result = getOwner().getServer().getQuestHandler().triggerCondition(this, condition);
|
||||
boolean result = getOwner().getServer().getQuestHandler().triggerCondition(this, condition, condition.getParam());
|
||||
|
||||
accept[i] = result ? 1 : 0;
|
||||
}
|
||||
@ -165,7 +174,7 @@ public class GameQuest {
|
||||
boolean shouldAccept = LogicType.calculate(questData.getAcceptCondComb(), accept);
|
||||
|
||||
if (shouldAccept) {
|
||||
this.getOwner().getQuestManager().addQuest(questData.getSubId());
|
||||
this.getOwner().getQuestManager().addQuest(questData.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,11 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.custom.QuestConfig;
|
||||
import emu.grasscutter.data.custom.QuestConfigData.QuestCondition;
|
||||
import emu.grasscutter.data.custom.QuestConfigData.SubQuestConfigData;
|
||||
import emu.grasscutter.data.def.QuestData;
|
||||
import emu.grasscutter.data.def.QuestData.QuestCondition;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.quest.enums.QuestTriggerType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
import emu.grasscutter.game.quest.enums.LogicType;
|
||||
import emu.grasscutter.game.quest.enums.QuestState;
|
||||
import emu.grasscutter.server.packet.send.PacketFinishedParentQuestUpdateNotify;
|
||||
@ -46,12 +45,12 @@ public class QuestManager {
|
||||
}
|
||||
|
||||
public GameQuest getQuestById(int questId) {
|
||||
QuestConfig questConfig = GameData.getQuestConfigs().get(questId);
|
||||
QuestData questConfig = GameData.getQuestDataMap().get(questId);
|
||||
if (questConfig == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GameMainQuest mainQuest = getQuests().get(questConfig.getMainQuest().getId());
|
||||
GameMainQuest mainQuest = getQuests().get(questConfig.getMainId());
|
||||
|
||||
if (mainQuest == null) {
|
||||
return null;
|
||||
@ -79,8 +78,8 @@ public class QuestManager {
|
||||
}
|
||||
}
|
||||
|
||||
public GameMainQuest addMainQuest(QuestConfig questConfig) {
|
||||
GameMainQuest mainQuest = new GameMainQuest(getPlayer(), questConfig.getMainQuest().getId());
|
||||
public GameMainQuest addMainQuest(QuestData questConfig) {
|
||||
GameMainQuest mainQuest = new GameMainQuest(getPlayer(), questConfig.getMainId());
|
||||
getQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
|
||||
getPlayer().sendPacket(new PacketFinishedParentQuestUpdateNotify(mainQuest));
|
||||
@ -89,13 +88,13 @@ public class QuestManager {
|
||||
}
|
||||
|
||||
public GameQuest addQuest(int questId) {
|
||||
QuestConfig questConfig = GameData.getQuestConfigs().get(questId);
|
||||
QuestData questConfig = GameData.getQuestDataMap().get(questId);
|
||||
if (questConfig == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Main quest
|
||||
GameMainQuest mainQuest = this.getMainQuestById(questConfig.getMainQuest().getId());
|
||||
GameMainQuest mainQuest = this.getMainQuestById(questConfig.getMainId());
|
||||
|
||||
// Create main quest if it doesnt exist
|
||||
if (mainQuest == null) {
|
||||
@ -122,11 +121,11 @@ public class QuestManager {
|
||||
return quest;
|
||||
}
|
||||
|
||||
public void triggerEvent(QuestTriggerType condType, int... params) {
|
||||
public void triggerEvent(QuestTrigger condType, int... params) {
|
||||
Set<GameQuest> changedQuests = new HashSet<>();
|
||||
|
||||
this.forEachActiveQuest(quest -> {
|
||||
SubQuestConfigData data = quest.getConfig().getSubQuest();
|
||||
QuestData data = quest.getData();
|
||||
|
||||
for (int i = 0; i < data.getFinishCond().length; i++) {
|
||||
if (quest.getFinishProgressList()[i] == 1) {
|
||||
@ -150,7 +149,7 @@ public class QuestManager {
|
||||
});
|
||||
|
||||
for (GameQuest quest : changedQuests) {
|
||||
LogicType logicType = quest.getConfig().getSubQuest().getFailCondComb();
|
||||
LogicType logicType = quest.getData().getFailCondComb();
|
||||
int[] progress = quest.getFinishProgressList();
|
||||
|
||||
// Handle logical comb
|
||||
@ -174,7 +173,7 @@ public class QuestManager {
|
||||
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
quest.setMainQuest(mainQuest);
|
||||
quest.setConfig(GameData.getQuestConfigs().get(quest.getQuestId()));
|
||||
quest.setConfig(GameData.getQuestDataMap().get(quest.getQuestId()));
|
||||
}
|
||||
|
||||
this.getQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
|
@ -3,9 +3,9 @@ package emu.grasscutter.game.quest;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import emu.grasscutter.game.quest.enums.QuestTriggerType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface QuestValue {
|
||||
QuestTriggerType value();
|
||||
QuestTrigger value();
|
||||
}
|
||||
|
@ -4,11 +4,9 @@ import java.util.Set;
|
||||
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import emu.grasscutter.data.custom.QuestConfigData.QuestCondition;
|
||||
import emu.grasscutter.game.quest.enums.QuestTriggerType;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.def.QuestData.QuestCondition;
|
||||
import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
@ -62,7 +60,7 @@ public class ServerQuestHandler {
|
||||
public boolean triggerCondition(GameQuest quest, QuestCondition condition, int... params) {
|
||||
QuestBaseHandler handler = condHandlers.get(condition.getType().getValue());
|
||||
|
||||
if (handler == null || quest.getConfig() == null) {
|
||||
if (handler == null || quest.getData() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -72,7 +70,7 @@ public class ServerQuestHandler {
|
||||
public boolean triggerContent(GameQuest quest, QuestCondition condition, int... params) {
|
||||
QuestBaseHandler handler = contHandlers.get(condition.getType().getValue());
|
||||
|
||||
if (handler == null || quest.getConfig() == null) {
|
||||
if (handler == null || quest.getData() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -82,7 +80,7 @@ public class ServerQuestHandler {
|
||||
public boolean triggerExec(GameQuest quest, QuestCondition condition, int... params) {
|
||||
QuestBaseHandler handler = execHandlers.get(condition.getType().getValue());
|
||||
|
||||
if (handler == null || quest.getConfig() == null) {
|
||||
if (handler == null || quest.getData() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package emu.grasscutter.game.quest.conditions;
|
||||
|
||||
import emu.grasscutter.data.custom.QuestConfigData.QuestCondition;
|
||||
import emu.grasscutter.data.def.QuestData.QuestCondition;
|
||||
import emu.grasscutter.game.quest.QuestValue;
|
||||
import emu.grasscutter.game.quest.GameQuest;
|
||||
import emu.grasscutter.game.quest.enums.QuestTriggerType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
|
||||
@QuestValue(QuestTriggerType.QUEST_CONTENT_NONE)
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_NONE)
|
||||
public class BaseCondition extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
|
@ -1,17 +1,17 @@
|
||||
package emu.grasscutter.game.quest.conditions;
|
||||
|
||||
import emu.grasscutter.data.custom.QuestConfigData.QuestCondition;
|
||||
import emu.grasscutter.data.def.QuestData.QuestCondition;
|
||||
import emu.grasscutter.game.quest.QuestValue;
|
||||
import emu.grasscutter.game.quest.GameQuest;
|
||||
import emu.grasscutter.game.quest.enums.QuestTriggerType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
|
||||
@QuestValue(QuestTriggerType.QUEST_COND_PLAYER_LEVEL_EQUAL_GREATER)
|
||||
@QuestValue(QuestTrigger.QUEST_COND_PLAYER_LEVEL_EQUAL_GREATER)
|
||||
public class ConditionPlayerLevelEqualGreater extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, int... params) {
|
||||
return quest.getOwner().getLevel() >= condition.getParam()[0];
|
||||
return quest.getOwner().getLevel() >= params[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
package emu.grasscutter.game.quest.conditions;
|
||||
|
||||
import emu.grasscutter.data.custom.QuestConfigData.QuestCondition;
|
||||
import emu.grasscutter.data.def.QuestData.QuestCondition;
|
||||
import emu.grasscutter.game.quest.QuestValue;
|
||||
import emu.grasscutter.game.quest.GameQuest;
|
||||
import emu.grasscutter.game.quest.enums.QuestTriggerType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
|
||||
@QuestValue(QuestTriggerType.QUEST_COND_STATE_EQUAL)
|
||||
@QuestValue(QuestTrigger.QUEST_COND_STATE_EQUAL)
|
||||
public class ConditionStateEqual extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, int... params) {
|
||||
GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(condition.getParam()[0]);
|
||||
GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(params[0]);
|
||||
|
||||
if (checkQuest != null) {
|
||||
return checkQuest.getState().getValue() == condition.getParam()[1];
|
||||
return checkQuest.getState().getValue() == params[1];
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1,12 +1,12 @@
|
||||
package emu.grasscutter.game.quest.content;
|
||||
|
||||
import emu.grasscutter.data.custom.QuestConfigData.QuestCondition;
|
||||
import emu.grasscutter.data.def.QuestData.QuestCondition;
|
||||
import emu.grasscutter.game.quest.QuestValue;
|
||||
import emu.grasscutter.game.quest.GameQuest;
|
||||
import emu.grasscutter.game.quest.enums.QuestTriggerType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
|
||||
@QuestValue(QuestTriggerType.QUEST_CONTENT_NONE)
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_NONE)
|
||||
public class BaseContent extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
|
@ -1,12 +1,12 @@
|
||||
package emu.grasscutter.game.quest.content;
|
||||
|
||||
import emu.grasscutter.data.custom.QuestConfigData.QuestCondition;
|
||||
import emu.grasscutter.data.def.QuestData.QuestCondition;
|
||||
import emu.grasscutter.game.quest.QuestValue;
|
||||
import emu.grasscutter.game.quest.GameQuest;
|
||||
import emu.grasscutter.game.quest.enums.QuestTriggerType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
|
||||
@QuestValue(QuestTriggerType.QUEST_CONTENT_COMPLETE_TALK)
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_COMPLETE_TALK)
|
||||
public class ContentCompleteTalk extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,6 @@
|
||||
package emu.grasscutter.game.quest.enums;
|
||||
|
||||
public enum QuestTriggerType {
|
||||
public enum QuestTrigger {
|
||||
QUEST_COND_NONE (0),
|
||||
QUEST_COND_STATE_EQUAL (1),
|
||||
QUEST_COND_STATE_NOT_EQUAL (2),
|
||||
@ -225,7 +225,7 @@ public enum QuestTriggerType {
|
||||
|
||||
private final int value;
|
||||
|
||||
QuestTriggerType(int id) {
|
||||
QuestTrigger(int id) {
|
||||
this.value = id;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package emu.grasscutter.game.quest.handlers;
|
||||
|
||||
import emu.grasscutter.data.custom.QuestConfigData.QuestCondition;
|
||||
import emu.grasscutter.data.def.QuestData.QuestCondition;
|
||||
import emu.grasscutter.game.quest.GameQuest;
|
||||
|
||||
public abstract class QuestBaseHandler {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.quest.enums.QuestTriggerType;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.NpcTalkReqOuterClass.NpcTalkReq;
|
||||
@ -16,7 +16,7 @@ public class HandlerNpcTalkReq extends PacketHandler {
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
NpcTalkReq req = NpcTalkReq.parseFrom(payload);
|
||||
|
||||
session.getPlayer().getQuestManager().triggerEvent(QuestTriggerType.QUEST_CONTENT_COMPLETE_TALK, req.getTalkId());
|
||||
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_COMPLETE_TALK, req.getTalkId());
|
||||
|
||||
session.send(new PacketNpcTalkRsp(req.getNpcEntityId(), req.getTalkId(), req.getEntityId()));
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.custom.QuestConfig;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.quest.GameMainQuest;
|
||||
import emu.grasscutter.game.quest.GameQuest;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
|
@ -19,10 +19,11 @@ import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandMap;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.ResourceLoader;
|
||||
import emu.grasscutter.data.custom.QuestConfig;
|
||||
import emu.grasscutter.data.custom.MainQuestData;
|
||||
import emu.grasscutter.data.def.AvatarData;
|
||||
import emu.grasscutter.data.def.ItemData;
|
||||
import emu.grasscutter.data.def.MonsterData;
|
||||
import emu.grasscutter.data.def.QuestData;
|
||||
import emu.grasscutter.data.def.SceneData;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
@ -149,13 +150,16 @@ final class ToolsWithLanguageOption {
|
||||
writer.println(data.getId() + " : " + data.getScriptData());
|
||||
}
|
||||
|
||||
writer.println();
|
||||
|
||||
writer.println("// Quests");
|
||||
list = new ArrayList<>(GameData.getQuestConfigs().keySet());
|
||||
list = new ArrayList<>(GameData.getQuestDataMap().keySet());
|
||||
Collections.sort(list);
|
||||
|
||||
for (Integer id : list) {
|
||||
QuestConfig data = GameData.getQuestConfigs().get(id);
|
||||
writer.println(data.getId() + " : " + map.get(data.getMainQuest().getTitleTextMapHash()));
|
||||
QuestData data = GameData.getQuestDataMap().get(id);
|
||||
MainQuestData mainQuest = GameData.getMainQuestDataMap().get(data.getMainId());
|
||||
writer.println(data.getId() + " : " + map.get(mainQuest.getTitleTextMapHash()) + " - " + map.get(data.getDescTextMapHash()));
|
||||
}
|
||||
|
||||
writer.println();
|
||||
|
Loading…
Reference in New Issue
Block a user