diff --git a/src/main/java/emu/grasscutter/data/GameData.java b/src/main/java/emu/grasscutter/data/GameData.java index 43195e99a..1009de3fd 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -30,7 +30,7 @@ public class GameData { // ExcelConfigs private static final Int2ObjectMap playerLevelDataMap = new Int2ObjectOpenHashMap<>(); - + private static final Int2ObjectMap avatarDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap avatarLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap avatarSkillDepotDataMap = new Int2ObjectOpenHashMap<>(); @@ -40,7 +40,7 @@ public class GameData { private static final Int2ObjectMap avatarPromoteDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap avatarTalentDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap proudSkillDataMap = new Int2ObjectOpenHashMap<>(); - + private static final Int2ObjectMap itemDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap reliquaryLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap reliquaryAffixDataMap = new Int2ObjectOpenHashMap<>(); @@ -57,11 +57,11 @@ public class GameData { private static final Int2ObjectMap gadgetDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap monsterCurveDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap monsterDescribeDataMap = new Int2ObjectOpenHashMap<>(); - + private static final Int2ObjectMap avatarFlycloakDataMap = new Int2ObjectLinkedOpenHashMap<>(); private static final Int2ObjectMap avatarCostumeDataMap = new Int2ObjectLinkedOpenHashMap<>(); private static final Int2ObjectMap avatarCostumeDataItemIdMap = new Int2ObjectLinkedOpenHashMap<>(); - + private static final Int2ObjectMap sceneDataMap = new Int2ObjectLinkedOpenHashMap<>(); private static final Int2ObjectMap fetterDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap codexQuestDataMap = new Int2ObjectOpenHashMap<>(); @@ -76,7 +76,7 @@ public class GameData { private static final ArrayList codexReliquaryArrayList = new ArrayList<>(); private static final Int2ObjectMap fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap rewardDataMap = new Int2ObjectOpenHashMap<>(); - + private static final Int2ObjectMap worldAreaDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap worldLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap dailyDungeonDataMap = new Int2ObjectOpenHashMap<>(); @@ -108,33 +108,35 @@ public class GameData { @Getter private static final Int2ObjectMap musicGameBasicDataMap = new Int2ObjectOpenHashMap<>(); @Getter private static final Int2ObjectMap personalLineDataMap = new Int2ObjectOpenHashMap<>(); @Getter private static final Int2ObjectMap chapterDataMap = new Int2ObjectOpenHashMap<>(); + @Getter private static final Int2ObjectMap triggerExcelConfigDataMap = new Int2ObjectOpenHashMap<>(); + @Getter private static final Map scriptSceneDataMap = new HashMap<>(); // Cache private static Map> fetters = new HashMap<>(); private static Map> shopGoods = new HashMap<>(); private static final IntList scenePointIdList = new IntArrayList(); - + public static Int2ObjectMap getMapByResourceDef(Class resourceDefinition) { Int2ObjectMap map = null; - + try { Field field = GameData.class.getDeclaredField(Utils.lowerCaseFirstChar(resourceDefinition.getSimpleName()) + "Map"); field.setAccessible(true); - + map = (Int2ObjectMap) field.get(null); - + field.setAccessible(false); } catch (Exception e) { Grasscutter.getLogger().error("Error fetching resource map for " + resourceDefinition.getSimpleName(), e); } - + return map; } public static Int2ObjectMap getAbilityHashes() { return abilityHashes; } - + public static Map getAbilityEmbryoInfo() { return abilityEmbryos; } @@ -150,7 +152,7 @@ public class GameData { public static Map getScenePointEntries() { return scenePointEntries; } - + // TODO optimize public static ScenePointEntry getScenePointEntryById(int sceneId, int pointId) { return getScenePointEntries().get(sceneId + "_" + pointId); @@ -163,15 +165,15 @@ public class GameData { public static Int2ObjectMap getHomeworldDefaultSaveData() { return homeworldDefaultSaveData; } - + public static Int2ObjectMap getSceneNpcBornData() { return npcBornData; } - + public static Int2ObjectMap getAvatarDataMap() { return avatarDataMap; } - + public static Int2ObjectMap getItemDataMap() { return itemDataMap; } @@ -179,7 +181,7 @@ public class GameData { public static Int2ObjectMap getAvatarSkillDepotDataMap() { return avatarSkillDepotDataMap; } - + public static Int2ObjectMap getAvatarSkillDataMap() { return avatarSkillDataMap; } @@ -203,11 +205,11 @@ public class GameData { public static Int2ObjectMap getWeaponLevelDataMap() { return weaponLevelDataMap; } - + public static Int2ObjectMap getReliquaryAffixDataMap() { return reliquaryAffixDataMap; } - + public static Int2ObjectMap getReliquaryMainPropDataMap() { return reliquaryMainPropDataMap; } @@ -219,7 +221,7 @@ public class GameData { public static Int2ObjectMap getWeaponCurveDataMap() { return weaponCurveDataMap; } - + public static Int2ObjectMap getAvatarCurveDataMap() { return avatarCurveDataMap; } @@ -228,11 +230,11 @@ public class GameData { ReliquaryLevelData levelData = reliquaryLevelDataMap.get((rankLevel << 8) + level); return levelData != null ? levelData.getExp() : 0; } - + public static ReliquaryLevelData getRelicLevelData(int rankLevel, int level) { return reliquaryLevelDataMap.get((rankLevel << 8) + level); } - + public static WeaponPromoteData getWeaponPromoteData(int promoteId, int promoteLevel) { return weaponPromoteDataMap.get((promoteId << 8) + promoteLevel); } @@ -248,7 +250,7 @@ public class GameData { return 0; } } - + public static AvatarPromoteData getAvatarPromoteData(int promoteId, int promoteLevel) { return avatarPromoteDataMap.get((promoteId << 8) + promoteLevel); } @@ -262,7 +264,7 @@ public class GameData { AvatarFetterLevelData levelData = avatarFetterLevelDataMap.get(level); return levelData != null ? levelData.getExp() : 0; } - + public static Int2ObjectMap getProudSkillDataMap() { return proudSkillDataMap; } @@ -309,7 +311,7 @@ public class GameData { public static Int2ObjectMap getAvatarCostumeDataMap() { return avatarCostumeDataMap; } - + public static Int2ObjectMap getAvatarCostumeDataItemIdMap() { return avatarCostumeDataItemIdMap; } @@ -350,7 +352,7 @@ public class GameData { public static Int2ObjectMap getWorldAreaDataMap() { return worldAreaDataMap; } - + public static Int2ObjectMap getWorldLevelDataMap() { return worldLevelDataMap; } @@ -358,7 +360,7 @@ public class GameData { public static Int2ObjectMap getDungeonDataMap() { return dungeonDataMap; } - + public static Int2ObjectMap getDailyDungeonDataMap() { return dailyDungeonDataMap; } @@ -394,11 +396,11 @@ public class GameData { public static Int2ObjectMap getTowerFloorDataMap(){ return towerFloorDataMap; } - + public static Int2ObjectMap getTowerLevelDataMap(){ return towerLevelDataMap; } - + public static Int2ObjectMap getTowerScheduleDataMap(){ return towerScheduleDataMap; } @@ -410,19 +412,19 @@ public class GameData { public static Int2ObjectMap getForgeDataMap() { return forgeDataMap; } - + public static Int2ObjectMap getHomeWorldLevelDataMap() { return homeWorldLevelDataMap; } - + public static Int2ObjectMap getFurnitureMakeConfigDataMap() { return furnitureMakeConfigDataMap; } - + public static Int2ObjectMap getGatherDataMap() { return gatherDataMap; } - + public static Int2ObjectMap getInvestigationMonsterDataMap() { return investigationMonsterDataMap; } diff --git a/src/main/java/emu/grasscutter/data/binout/ScriptSceneData.java b/src/main/java/emu/grasscutter/data/binout/ScriptSceneData.java new file mode 100644 index 000000000..5634f61f0 --- /dev/null +++ b/src/main/java/emu/grasscutter/data/binout/ScriptSceneData.java @@ -0,0 +1,23 @@ +package emu.grasscutter.data.binout; + +import com.google.gson.annotations.SerializedName; +import emu.grasscutter.scripts.data.SceneGroup; +import emu.grasscutter.utils.Position; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +public class ScriptSceneData { + Map scriptObjectList; + + @Data + public static class ScriptObject { + //private SceneGroup groups; + @SerializedName("dummy_points") + private Map> dummyPoints; + + + } +} diff --git a/src/main/java/emu/grasscutter/data/excels/TriggerExcelConfigData.java b/src/main/java/emu/grasscutter/data/excels/TriggerExcelConfigData.java new file mode 100644 index 000000000..e284ab273 --- /dev/null +++ b/src/main/java/emu/grasscutter/data/excels/TriggerExcelConfigData.java @@ -0,0 +1,13 @@ +package emu.grasscutter.data.excels; + +import emu.grasscutter.data.GameResource; +import emu.grasscutter.data.ResourceType; +import lombok.Getter; + +@ResourceType(name = "TriggerExcelConfigData.json") @Getter +public class TriggerExcelConfigData extends GameResource { + @Getter private int id; + private int sceneId; + private int groupId; + private String triggerName; +} diff --git a/src/main/java/emu/grasscutter/game/entity/EntityRegion.java b/src/main/java/emu/grasscutter/game/entity/EntityRegion.java index 20c135fba..32fac1343 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityRegion.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityRegion.java @@ -15,6 +15,7 @@ import java.util.concurrent.ConcurrentHashMap; public class EntityRegion extends GameEntity{ private final Position position; private boolean hasNewEntities; + private boolean entityLeave; private final Set entities; // Ids of entities inside this region private final SceneRegion metaRegion; @@ -45,10 +46,17 @@ public class EntityRegion extends GameEntity{ hasNewEntities = false; } - public void removeEntity(GameEntity entity) { - this.getEntities().remove(entity.getId()); + public void removeEntity(int entityId) { + this.getEntities().remove(entityId); + this.entityLeave = true; } + public void removeEntity(GameEntity entity) { + this.getEntities().remove(entity.getId()); + this.entityLeave = true; + } + public boolean entityLeave() {return this.entityLeave;} + public void resetEntityLeave() {this.entityLeave = false;} @Override public Int2FloatOpenHashMap getFightProperties() { return null; diff --git a/src/main/java/emu/grasscutter/game/quest/QuestSystem.java b/src/main/java/emu/grasscutter/game/quest/QuestSystem.java index 16167b010..ad5349cef 100644 --- a/src/main/java/emu/grasscutter/game/quest/QuestSystem.java +++ b/src/main/java/emu/grasscutter/game/quest/QuestSystem.java @@ -65,8 +65,8 @@ public class QuestSystem extends BaseGameSystem { public boolean triggerCondition(GameQuest quest, QuestCondition condition, String paramStr, int... params) { QuestBaseHandler handler = condHandlers.get(condition.getType().getValue()); - if (handler == null || quest.getData() == null) { - Grasscutter.getLogger().debug("Could not trigger condition {} at {}", condition.getType().getValue(), quest.getData()); + if (handler == null || quest.getQuestData() == null) { + Grasscutter.getLogger().debug("Could not trigger condition {} at {}", condition.getType().getValue(), quest.getQuestData()); return false; } @@ -76,8 +76,8 @@ public class QuestSystem extends BaseGameSystem { public boolean triggerContent(GameQuest quest, QuestCondition condition, String paramStr, int... params) { QuestBaseHandler handler = contHandlers.get(condition.getType().getValue()); - if (handler == null || quest.getData() == null) { - Grasscutter.getLogger().debug("Could not trigger content {} at {}", condition.getType().getValue(), quest.getData()); + if (handler == null || quest.getQuestData() == null) { + Grasscutter.getLogger().debug("Could not trigger content {} at {}", condition.getType().getValue(), quest.getQuestData()); return false; } @@ -87,8 +87,8 @@ public class QuestSystem extends BaseGameSystem { public boolean triggerExec(GameQuest quest, QuestExecParam execParam, String... params) { QuestExecHandler handler = execHandlers.get(execParam.getType().getValue()); - if (handler == null || quest.getData() == null) { - Grasscutter.getLogger().debug("Could not trigger exec {} at {}", execParam.getType().getValue(), quest.getData()); + if (handler == null || quest.getQuestData() == null) { + Grasscutter.getLogger().debug("Could not trigger exec {} at {}", execParam.getType().getValue(), quest.getQuestData()); return false; } diff --git a/src/main/java/emu/grasscutter/game/quest/RewindData.java b/src/main/java/emu/grasscutter/game/quest/RewindData.java new file mode 100644 index 000000000..48267a771 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/RewindData.java @@ -0,0 +1,28 @@ +package emu.grasscutter.game.quest; + +import lombok.Data; +import lombok.Getter; + +import java.util.List; +@Data +public class RewindData { + AvatarData avatar; + List npcs; + + @Data + public static class AvatarData { + @Getter private String pos; + } + + @Data + private static class Npc { + private String script; + private int room_id; + private int data_index; + private int id; + private String pos; + private int scene_id; + private String alias; + } +} + diff --git a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionCompleteTalk.java b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionCompleteTalk.java new file mode 100644 index 000000000..6439fec7d --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionCompleteTalk.java @@ -0,0 +1,27 @@ +package emu.grasscutter.game.quest.conditions; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.GameData; +import emu.grasscutter.data.binout.MainQuestData; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameMainQuest; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_COND_COMPLETE_TALK) +public class ConditionCompleteTalk extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + GameMainQuest checkMainQuest = quest.getOwner().getQuestManager().getMainQuestById(condition.getParam()[0]/100); + if (checkMainQuest == null || GameData.getMainQuestDataMap().get(checkMainQuest.getParentQuestId()).getTalks() == null) { + Grasscutter.getLogger().debug("Warning: mainQuest {} hasn't been started yet, or has no talks", condition.getParam()[0]/100); + return false; + } + MainQuestData.TalkData talkData = checkMainQuest.getTalks().get(Integer.valueOf(params[0])); + return talkData != null || checkMainQuest.getChildQuestById(params[0]) != null; + } + +} diff --git a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestGlobalVarEqual.java b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestGlobalVarEqual.java new file mode 100644 index 000000000..94c565333 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestGlobalVarEqual.java @@ -0,0 +1,20 @@ +package emu.grasscutter.game.quest.conditions; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.player.Player; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_COND_QUEST_GLOBAL_VAR_EQUAL) +public class ConditionQuestGlobalVarEqual extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + Integer questGlobalVarValue = quest.getMainQuest().getQuestManager().getQuestGlobalVarValue(Integer.valueOf(params[0])); + Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue); + return questGlobalVarValue.intValue() == params[1]; + } +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestGlobalVarGreater.java b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestGlobalVarGreater.java new file mode 100644 index 000000000..cdd5a3c24 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestGlobalVarGreater.java @@ -0,0 +1,20 @@ +package emu.grasscutter.game.quest.conditions; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.player.Player; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_COND_QUEST_GLOBAL_VAR_GREATER) +public class ConditionQuestGlobalVarGreater extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + Integer questGlobalVarValue = quest.getMainQuest().getQuestManager().getQuestGlobalVarValue(Integer.valueOf(params[0])); + Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue); + return questGlobalVarValue.intValue() > params[1]; + } +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestGlobalVarLess.java b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestGlobalVarLess.java new file mode 100644 index 000000000..826598d45 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestGlobalVarLess.java @@ -0,0 +1,20 @@ +package emu.grasscutter.game.quest.conditions; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.player.Player; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_COND_QUEST_GLOBAL_VAR_LESS) +public class ConditionQuestGlobalVarLess extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + Integer questGlobalVarValue = quest.getMainQuest().getQuestManager().getQuestGlobalVarValue(Integer.valueOf(params[0])); + Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue); + return questGlobalVarValue.intValue() < params[1]; + } +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestVarEqual.java b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestVarEqual.java new file mode 100644 index 000000000..90e7b0e27 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestVarEqual.java @@ -0,0 +1,20 @@ +package emu.grasscutter.game.quest.conditions; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameMainQuest; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_COND_QUEST_VAR_EQUAL) +public class ConditionQuestVarEqual extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + int questVarValue = quest.getMainQuest().getQuestVars()[params[0]]; + Grasscutter.getLogger().debug("questVar {} : {}", params[0],questVarValue); + return questVarValue == params[1]; + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestVarGreater.java b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestVarGreater.java new file mode 100644 index 000000000..f4a55a58c --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestVarGreater.java @@ -0,0 +1,20 @@ +package emu.grasscutter.game.quest.conditions; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameMainQuest; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_COND_QUEST_VAR_GREATER) +public class ConditionQuestVarGreater extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + int questVarValue = quest.getMainQuest().getQuestVars()[params[0]]; + Grasscutter.getLogger().debug("questVar {} : {}", params[0],questVarValue); + return questVarValue > params[1]; + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestVarLess.java b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestVarLess.java new file mode 100644 index 000000000..5993d586a --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionQuestVarLess.java @@ -0,0 +1,20 @@ +package emu.grasscutter.game.quest.conditions; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameMainQuest; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_COND_QUEST_VAR_LESS) +public class ConditionQuestVarLess extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + int questVarValue = quest.getMainQuest().getQuestVars()[params[0]]; + Grasscutter.getLogger().debug("questVar {} : {}", params[0],questVarValue); + return questVarValue < params[1]; + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/conditions/ConditionStateNotEqual.java b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionStateNotEqual.java new file mode 100644 index 000000000..21c7f5c99 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/conditions/ConditionStateNotEqual.java @@ -0,0 +1,27 @@ +package emu.grasscutter.game.quest.conditions; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_COND_STATE_NOT_EQUAL) +public class ConditionStateNotEqual extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(condition.getParam()[0]); + if (checkQuest == null) { + /* + Will spam the console + //Grasscutter.getLogger().debug("Warning: quest {} hasn't been started yet!", condition.getParam()[0]); + + */ + return false; + } + return checkQuest.getState().getValue() != condition.getParam()[1]; + } + +} diff --git a/src/main/java/emu/grasscutter/game/quest/content/ContentCompleteAnyTalk.java b/src/main/java/emu/grasscutter/game/quest/content/ContentCompleteAnyTalk.java new file mode 100644 index 000000000..494076c38 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/content/ContentCompleteAnyTalk.java @@ -0,0 +1,22 @@ +package emu.grasscutter.game.quest.content; + +import emu.grasscutter.data.binout.MainQuestData; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameMainQuest; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_CONTENT_COMPLETE_ANY_TALK) +public class ContentCompleteAnyTalk extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + GameMainQuest checkMainQuest = quest.getOwner().getQuestManager().getMainQuestById(params[0]/100); + if (checkMainQuest == null) {return false;} + MainQuestData.TalkData talkData = checkMainQuest.getTalks().get(Integer.valueOf(paramStr)); + return talkData == null || condition.getParamStr().contains(paramStr) || checkMainQuest.getChildQuestById(params[0]) != null; + } + +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/game/quest/content/ContentLeaveScene.java b/src/main/java/emu/grasscutter/game/quest/content/ContentLeaveScene.java new file mode 100644 index 000000000..dc3b9698c --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/content/ContentLeaveScene.java @@ -0,0 +1,18 @@ +package emu.grasscutter.game.quest.content; + +import emu.grasscutter.data.excels.QuestData.QuestCondition; +import emu.grasscutter.game.player.Player; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_CONTENT_LEAVE_SCENE) +public class ContentLeaveScene extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) { + return quest.getOwner().getScene().getPrevScene() == params[0]; + } + +} diff --git a/src/main/java/emu/grasscutter/game/quest/content/ContentNotFinishPlot.java b/src/main/java/emu/grasscutter/game/quest/content/ContentNotFinishPlot.java new file mode 100644 index 000000000..f48c4945e --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/content/ContentNotFinishPlot.java @@ -0,0 +1,22 @@ +package emu.grasscutter.game.quest.content; + +import emu.grasscutter.data.binout.MainQuestData; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameMainQuest; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_CONTENT_NOT_FINISH_PLOT) +public class ContentNotFinishPlot extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + GameMainQuest checkMainQuest = quest.getOwner().getQuestManager().getMainQuestById(params[0]/100); + if (checkMainQuest == null) {return false;} + MainQuestData.TalkData talkData = checkMainQuest.getTalks().get(Integer.valueOf(params[0])); + return talkData == null; + } + +} diff --git a/src/main/java/emu/grasscutter/game/quest/content/ContentQuestStateNotEqual.java b/src/main/java/emu/grasscutter/game/quest/content/ContentQuestStateNotEqual.java new file mode 100644 index 000000000..85ff204ab --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/content/ContentQuestStateNotEqual.java @@ -0,0 +1,23 @@ +package emu.grasscutter.game.quest.content; + +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_CONTENT_QUEST_STATE_NOT_EQUAL) +public class ContentQuestStateNotEqual extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(params[0]); + + if (checkQuest != null) { + return checkQuest.getState().getValue() != params[1]; + } + + return false; + } + +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/game/quest/content/ContentQuestVarEqual.java b/src/main/java/emu/grasscutter/game/quest/content/ContentQuestVarEqual.java new file mode 100644 index 000000000..f56de74ab --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/content/ContentQuestVarEqual.java @@ -0,0 +1,19 @@ +package emu.grasscutter.game.quest.content; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_CONTENT_QUEST_VAR_EQUAL) +public class ContentQuestVarEqual extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + int questVarValue = quest.getMainQuest().getQuestVars()[params[0]]; + Grasscutter.getLogger().debug("questVar {} : {}", params[0],questVarValue); + return questVarValue == params[1]; + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/content/ContentQuestVarGreater.java b/src/main/java/emu/grasscutter/game/quest/content/ContentQuestVarGreater.java new file mode 100644 index 000000000..7eafa3bfa --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/content/ContentQuestVarGreater.java @@ -0,0 +1,19 @@ +package emu.grasscutter.game.quest.content; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_CONTENT_QUEST_VAR_GREATER) +public class ContentQuestVarGreater extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + int questVarValue = quest.getMainQuest().getQuestVars()[params[0]]; + Grasscutter.getLogger().debug("questVar {} : {}", params[0],questVarValue); + return questVarValue > params[1]; + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/content/ContentQuestVarLess.java b/src/main/java/emu/grasscutter/game/quest/content/ContentQuestVarLess.java new file mode 100644 index 000000000..6994eeb99 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/content/ContentQuestVarLess.java @@ -0,0 +1,19 @@ +package emu.grasscutter.game.quest.content; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_CONTENT_QUEST_VAR_LESS) +public class ContentQuestVarLess extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + int questVarValue = quest.getMainQuest().getQuestVars()[params[0]]; + Grasscutter.getLogger().debug("questVar {} : {}", params[0],questVarValue); + return questVarValue < params[1]; + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/content/ContentTriggerFire.java b/src/main/java/emu/grasscutter/game/quest/content/ContentTriggerFire.java new file mode 100644 index 000000000..a2eb784e9 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/content/ContentTriggerFire.java @@ -0,0 +1,25 @@ +package emu.grasscutter.game.quest.content; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.data.GameData; +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.data.excels.TriggerExcelConfigData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_CONTENT_TRIGGER_FIRE) +public class ContentTriggerFire extends QuestBaseHandler { + + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + if(quest.getTriggers().containsKey(quest.getTriggerNameById(params[0]))) { + //We don't want to put a new key here + return quest.getTriggers().get(quest.getTriggerNameById(params[0])); + } else { + Grasscutter.getLogger().error("quest {} doesn't have trigger {}", quest.getSubQuestId(), params[0]); + return false; + } + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/content/ContentUnlockTransPoint.java b/src/main/java/emu/grasscutter/game/quest/content/ContentUnlockTransPoint.java new file mode 100644 index 000000000..5ae674c55 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/content/ContentUnlockTransPoint.java @@ -0,0 +1,15 @@ +package emu.grasscutter.game.quest.content; + +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestBaseHandler; + +@QuestValue(QuestTrigger.QUEST_CONTENT_UNLOCK_TRANS_POINT) +public class ContentUnlockTransPoint extends QuestBaseHandler { + @Override + public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) { + return true; + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestGlobalVar.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestGlobalVar.java new file mode 100644 index 000000000..56a62106c --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestGlobalVar.java @@ -0,0 +1,17 @@ +package emu.grasscutter.game.quest.exec; + + +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestExecHandler; + +@QuestValue(QuestTrigger.QUEST_EXEC_DEC_QUEST_GLOBAL_VAR) +public class ExecDecQuestGlobalVar extends QuestExecHandler { + @Override + public boolean execute(GameQuest quest, QuestData.QuestExecParam condition, String... paramStr) { + quest.getOwner().getQuestManager().decQuestGlobalVarValue(Integer.valueOf(paramStr[0]),Integer.valueOf(paramStr[1])); + return true; + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestVar.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestVar.java new file mode 100644 index 000000000..7cfd54d22 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestVar.java @@ -0,0 +1,16 @@ +package emu.grasscutter.game.quest.exec; + +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestExecHandler; + +@QuestValue(QuestTrigger.QUEST_EXEC_DEC_QUEST_VAR) +public class ExecDecQuestVar extends QuestExecHandler { + @Override + public boolean execute(GameQuest quest, QuestData.QuestExecParam condition, String... paramStr) { + quest.getMainQuest().decQuestVar(Integer.parseInt(paramStr[0]), Integer.parseInt(paramStr[1])); + return true; + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestGlobalVar.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestGlobalVar.java new file mode 100644 index 000000000..327248750 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestGlobalVar.java @@ -0,0 +1,16 @@ +package emu.grasscutter.game.quest.exec; + +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestExecHandler; + +@QuestValue(QuestTrigger.QUEST_EXEC_INC_QUEST_GLOBAL_VAR) +public class ExecIncQuestGlobalVar extends QuestExecHandler { + @Override + public boolean execute(GameQuest quest, QuestData.QuestExecParam condition, String... paramStr) { + quest.getOwner().getQuestManager().incQuestGlobalVarValue(Integer.valueOf(paramStr[0]),Integer.valueOf(paramStr[1])); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestVar.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestVar.java new file mode 100644 index 000000000..3919b1e38 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestVar.java @@ -0,0 +1,16 @@ +package emu.grasscutter.game.quest.exec; + +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestExecHandler; + +@QuestValue(QuestTrigger.QUEST_EXEC_INC_QUEST_VAR) +public class ExecIncQuestVar extends QuestExecHandler { + @Override + public boolean execute(GameQuest quest, QuestData.QuestExecParam condition, String... paramStr) { + quest.getMainQuest().incQuestVar(Integer.parseInt(paramStr[0]), Integer.parseInt(paramStr[1])); + return true; + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestGlobalVar.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestGlobalVar.java new file mode 100644 index 000000000..2142f4cff --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestGlobalVar.java @@ -0,0 +1,16 @@ +package emu.grasscutter.game.quest.exec; + +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestExecHandler; + +@QuestValue(QuestTrigger.QUEST_EXEC_SET_QUEST_GLOBAL_VAR) +public class ExecSetQuestGlobalVar extends QuestExecHandler { + @Override + public boolean execute(GameQuest quest, QuestData.QuestExecParam condition, String... paramStr) { + quest.getOwner().getQuestManager().setQuestGlobalVarValue(Integer.valueOf(paramStr[0]),Integer.valueOf(paramStr[1])); + return true; + } +} diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestVar.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestVar.java new file mode 100644 index 000000000..6219d913f --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestVar.java @@ -0,0 +1,16 @@ +package emu.grasscutter.game.quest.exec; + +import emu.grasscutter.data.excels.QuestData; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValue; +import emu.grasscutter.game.quest.enums.QuestTrigger; +import emu.grasscutter.game.quest.handlers.QuestExecHandler; + +@QuestValue(QuestTrigger.QUEST_EXEC_SET_QUEST_VAR) +public class ExecSetQuestVar extends QuestExecHandler { + @Override + public boolean execute(GameQuest quest, QuestData.QuestExecParam condition, String... paramStr) { + quest.getMainQuest().setQuestVar(Integer.parseInt(paramStr[0]), Integer.parseInt(paramStr[1])); + return true; + } +} diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 2646edf87..da6a5965c 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -627,8 +627,14 @@ public class Scene { .flatMap(Collection::stream) .toList(); - onLoadGroup(groups); - Grasscutter.getLogger().info("Scene {} Block {} loaded.", this.getId(), block.id); + onLoadGroup(groups); + Grasscutter.getLogger().info("Scene {} Block {} loaded.", this.getId(), block.id); + } + public void loadTriggerFromGroup(SceneGroup group, String triggerName) { + //Load triggers and regions + getScriptManager().registerTrigger(group.triggers.values().stream().filter(p -> p.name.contains(triggerName)).toList()); + group.regions.values().stream().filter(q -> q.config_id == Integer.parseInt(triggerName.substring(13))).map(region -> new EntityRegion(this, region)) + .forEach(getScriptManager()::registerRegion); } public void onLoadGroup(List groups) { diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPersonalLineAllDataReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPersonalLineAllDataReq.java index 5552e63f2..4db560c00 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPersonalLineAllDataReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPersonalLineAllDataReq.java @@ -11,7 +11,7 @@ public class HandlerPersonalLineAllDataReq extends PacketHandler { @Override public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { - session.send(new PacketPersonalLineAllDataRsp(session.getPlayer().getQuestManager().getQuests().values())); + session.send(new PacketPersonalLineAllDataRsp(session.getPlayer().getQuestManager().getMainQuests().values())); } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerQuestUpdateQuestVarReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerQuestUpdateQuestVarReq.java new file mode 100644 index 000000000..4e804f422 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerQuestUpdateQuestVarReq.java @@ -0,0 +1,48 @@ +package emu.grasscutter.server.packet.recv; + +import emu.grasscutter.game.quest.GameMainQuest; +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketHandler; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.PacketHeadOuterClass; +import emu.grasscutter.net.proto.PlayerSetPauseReqOuterClass; +import emu.grasscutter.net.proto.QuestUpdateQuestVarReqOuterClass; +import emu.grasscutter.net.proto.QuestVarOpOuterClass; +import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketPlayerSetPauseRsp; +import emu.grasscutter.server.packet.send.PacketQuestUpdateQuestVarRsp; + +import java.util.List; + +@Opcodes(PacketOpcodes.QuestUpdateQuestVarReq) +public class HandlerQuestUpdateQuestVarReq extends PacketHandler { + + @Override + public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + //Client sends packets. One with the value, and one with the index and the new value to set/inc/dec + var req = QuestUpdateQuestVarReqOuterClass.QuestUpdateQuestVarReq.parseFrom(payload); + GameMainQuest mainQuest = session.getPlayer().getQuestManager().getMainQuestById(req.getQuestId()/100); + List questVars = req.getQuestVarOpListList(); + if (mainQuest.getQuestVarsUpdate().size() == 0) { + for (QuestVarOpOuterClass.QuestVarOp questVar : questVars) { + mainQuest.getQuestVarsUpdate().add(questVar.getValue()); + } + } else { + for (QuestVarOpOuterClass.QuestVarOp questVar : questVars) { + if (questVar.getIsAdd()) { + if (questVar.getValue() >= 0) { + mainQuest.incQuestVar(questVar.getIndex(), questVar.getValue()); + } else { + mainQuest.decQuestVar(questVar.getIndex(), questVar.getValue()); + } + } else { + mainQuest.setQuestVar(questVar.getIndex(), mainQuest.getQuestVarsUpdate().get(0)); + } + //remove the first element from the update list + mainQuest.getQuestVarsUpdate().remove(0); + } + } + session.send(new PacketQuestUpdateQuestVarRsp(req.getQuestId())); + } + +} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketQuestProgressUpdateNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketQuestProgressUpdateNotify.java index 76ee56316..70ba30f36 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketQuestProgressUpdateNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketQuestProgressUpdateNotify.java @@ -7,24 +7,24 @@ import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.QuestProgressUpdateNotifyOuterClass.QuestProgressUpdateNotify; public class PacketQuestProgressUpdateNotify extends BasePacket { - + public PacketQuestProgressUpdateNotify(GameQuest quest) { super(PacketOpcodes.QuestProgressUpdateNotify); - - QuestProgressUpdateNotify.Builder proto = QuestProgressUpdateNotify.newBuilder().setQuestId(quest.getQuestId()); - + + QuestProgressUpdateNotify.Builder proto = QuestProgressUpdateNotify.newBuilder().setQuestId(quest.getSubQuestId()); + if (quest.getFinishProgressList() != null) { for (int i : quest.getFinishProgressList()) { proto.addFinishProgressList(i); } } - + if (quest.getFailProgressList() != null) { for (int i : quest.getFailProgressList()) { proto.addFailProgressList(i); } } - + this.setData(proto); } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketQuestUpdateQuestVarRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketQuestUpdateQuestVarRsp.java new file mode 100644 index 000000000..22f672d28 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketQuestUpdateQuestVarRsp.java @@ -0,0 +1,19 @@ +package emu.grasscutter.server.packet.send; + +import emu.grasscutter.net.packet.BasePacket; +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.QuestUpdateQuestVarReqOuterClass; +import emu.grasscutter.net.proto.QuestUpdateQuestVarRspOuterClass; + +@Opcodes(PacketOpcodes.QuestUpdateQuestVarReq) +public class PacketQuestUpdateQuestVarRsp extends BasePacket { + + + public PacketQuestUpdateQuestVarRsp(int questId) { + super(PacketOpcodes.QuestUpdateQuestVarRsp); + var rsp = QuestUpdateQuestVarRspOuterClass.QuestUpdateQuestVarRsp.newBuilder() + .setQuestId(questId).build(); + this.setData(rsp); + } +} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketServerCondMeetQuestListUpdateNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketServerCondMeetQuestListUpdateNotify.java index 278d4b04b..bd40e3226 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketServerCondMeetQuestListUpdateNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketServerCondMeetQuestListUpdateNotify.java @@ -6,8 +6,11 @@ import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.ServerCondMeetQuestListUpdateNotifyOuterClass.ServerCondMeetQuestListUpdateNotify; +import java.util.List; +import java.util.Set; + public class PacketServerCondMeetQuestListUpdateNotify extends BasePacket { - + public PacketServerCondMeetQuestListUpdateNotify(Player player) { super(PacketOpcodes.ServerCondMeetQuestListUpdateNotify); @@ -23,13 +26,24 @@ public class PacketServerCondMeetQuestListUpdateNotify extends BasePacket { this.setData(proto); } - - public PacketServerCondMeetQuestListUpdateNotify(GameQuest quest) { + + public PacketServerCondMeetQuestListUpdateNotify(List quests) { super(PacketOpcodes.ServerCondMeetQuestListUpdateNotify); - ServerCondMeetQuestListUpdateNotify proto = ServerCondMeetQuestListUpdateNotify.newBuilder() - //.addAddQuestIdList(quest.getQuestId()) - .build(); + ServerCondMeetQuestListUpdateNotify.Builder proto = ServerCondMeetQuestListUpdateNotify.newBuilder(); + for (GameQuest quest : quests) { + proto.addAddQuestIdList(quest.getSubQuestId()); + } + proto.build(); + + this.setData(proto); + } + + public PacketServerCondMeetQuestListUpdateNotify() { + super(PacketOpcodes.ServerCondMeetQuestListUpdateNotify); + + ServerCondMeetQuestListUpdateNotify.Builder proto = ServerCondMeetQuestListUpdateNotify.newBuilder(); + proto.build(); this.setData(proto); }