From 98ec49a0d56792d349478864e24799dbaa6aee1c Mon Sep 17 00:00:00 2001 From: Nazrin Date: Thu, 7 Nov 2024 04:14:06 -0800 Subject: [PATCH] Implement ExecUnlockPlayerWorldScene (#171) * Implement ExecUnlockPlayerWorldScene --- .../grasscutter/config/ConfigContainer.java | 1 + .../emu/grasscutter/game/player/Player.java | 2 ++ .../game/player/PlayerProgressManager.java | 22 ++++++++++++++----- .../exec/ExecUnlockPlayerWorldScene.java | 17 ++++++++++++++ .../PacketPlayerWorldSceneInfoListNotify.java | 7 +++++- 5 files changed, 43 insertions(+), 6 deletions(-) create mode 100755 src/main/java/emu/grasscutter/game/quest/exec/ExecUnlockPlayerWorldScene.java diff --git a/src/main/java/emu/grasscutter/config/ConfigContainer.java b/src/main/java/emu/grasscutter/config/ConfigContainer.java index d8acb37f..b19c183b 100644 --- a/src/main/java/emu/grasscutter/config/ConfigContainer.java +++ b/src/main/java/emu/grasscutter/config/ConfigContainer.java @@ -253,6 +253,7 @@ public class ConfigContainer { public ResinOptions resinOptions = new ResinOptions(); public Rates rates = new Rates(); public boolean questing = false; + public boolean unlockScenesByDefault = false; public static class InventoryLimits { public int weapons = 2000; diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index 49639a05..8ab69dee 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -150,6 +150,7 @@ public class Player { @Getter private Map questGlobalVariables; @Getter private Map openStates; @Getter private Map> sceneTags; + @Getter @Setter private Map unlockedScenes; @Getter @Setter private Map> unlockedSceneAreas; @Getter @Setter private Map> unlockedScenePoints; @Getter @Setter private List chatEmojiIdList; @@ -276,6 +277,7 @@ public class Player { this.questGlobalVariables = new HashMap<>(); this.openStates = new HashMap<>(); this.sceneTags = new HashMap<>(); + this.unlockedScenes = new HashMap<>(); this.unlockedSceneAreas = new HashMap<>(); this.unlockedScenePoints = new HashMap<>(); this.chatEmojiIdList = new ArrayList<>(); diff --git a/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java b/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java index 5dc81441..d8101f6f 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java @@ -8,11 +8,7 @@ import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.quest.enums.ParentQuestState; import emu.grasscutter.game.quest.enums.QuestCond; import emu.grasscutter.game.quest.enums.QuestContent; -import emu.grasscutter.server.packet.send.PacketOpenStateChangeNotify; -import emu.grasscutter.server.packet.send.PacketOpenStateUpdateNotify; -import emu.grasscutter.server.packet.send.PacketSceneAreaUnlockNotify; -import emu.grasscutter.server.packet.send.PacketScenePointUnlockNotify; -import emu.grasscutter.server.packet.send.PacketSetOpenStateRsp; +import emu.grasscutter.server.packet.send.*; import lombok.val; import org.anime_game_servers.core.gi.enums.QuestState; import org.anime_game_servers.gi_lua.models.ScriptArgs; @@ -286,6 +282,22 @@ public class PlayerProgressManager extends BasePlayerDataManager { this.player.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_UNLOCK_AREA, sceneId, areaId); } + public void unlockScene(int sceneId) { + //set the scene to locked: false + this.player.getUnlockedScenes().put(sceneId, true); + + //Send packet. + this.player.sendPacket(new PacketPlayerWorldSceneInfoListNotify(this.player)); + } + + public void lockScene(int sceneId) { + //set the scene to locked: true + this.player.getUnlockedScenes().put(sceneId, false); + + //Send packet. + this.player.sendPacket(new PacketPlayerWorldSceneInfoListNotify(this.player)); + } + /** * Give replace costume to player (Ambor, Jean, Mona, Rosaria) */ diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecUnlockPlayerWorldScene.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecUnlockPlayerWorldScene.java new file mode 100755 index 00000000..3f106d24 --- /dev/null +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecUnlockPlayerWorldScene.java @@ -0,0 +1,17 @@ +package emu.grasscutter.game.quest.exec; + +import emu.grasscutter.data.common.quest.SubQuestData.QuestExecParam; +import emu.grasscutter.game.quest.GameQuest; +import emu.grasscutter.game.quest.QuestValueExec; +import emu.grasscutter.game.quest.enums.QuestExec; +import emu.grasscutter.game.quest.handlers.QuestExecHandler; + +@QuestValueExec(QuestExec.QUEST_EXEC_UNLOCK_PLAYER_WORLD_SCENE) +public class ExecUnlockPlayerWorldScene extends QuestExecHandler { + @Override + public boolean execute(GameQuest quest, QuestExecParam condition, String... paramStr) { + int sceneId = Integer.parseInt(paramStr[0]); + quest.getOwner().getProgressManager().unlockScene(sceneId); + return true; + } +} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java index eb27d3ab..bc08f46a 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java @@ -1,11 +1,13 @@ package emu.grasscutter.server.packet.send; +import emu.grasscutter.config.Configuration; import emu.grasscutter.data.GameData; import emu.grasscutter.game.player.Player; import emu.grasscutter.game.props.SceneType; import emu.grasscutter.net.packet.BaseTypedPacket; -import org.anime_game_servers.multi_proto.gi.messages.scene.PlayerWorldSceneInfoListNotify; import org.anime_game_servers.multi_proto.gi.messages.scene.PlayerWorldSceneInfo; +import org.anime_game_servers.multi_proto.gi.messages.scene.PlayerWorldSceneInfoListNotify; + import java.util.ArrayList; import java.util.List; @@ -21,6 +23,9 @@ public class PacketPlayerWorldSceneInfoListNotify extends BaseTypedPacket