Implement ExecUnlockPlayerWorldScene (#171)
Some checks failed
Build / Build-Server-Jar (push) Has been cancelled

* Implement ExecUnlockPlayerWorldScene
This commit is contained in:
Nazrin 2024-11-07 04:14:06 -08:00 committed by GitHub
parent 95b26b5ba4
commit 98ec49a0d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 43 additions and 6 deletions

View File

@ -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;

View File

@ -150,6 +150,7 @@ public class Player {
@Getter private Map<Integer, Integer> questGlobalVariables;
@Getter private Map<Integer, Integer> openStates;
@Getter private Map<Integer, Map<Integer, Boolean>> sceneTags;
@Getter @Setter private Map<Integer, Boolean> unlockedScenes;
@Getter @Setter private Map<Integer, Set<Integer>> unlockedSceneAreas;
@Getter @Setter private Map<Integer, Set<Integer>> unlockedScenePoints;
@Getter @Setter private List<Integer> 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<>();

View File

@ -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)
*/

View File

@ -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;
}
}

View File

@ -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<Player
if (scene.getSceneType() != SceneType.SCENE_WORLD) continue;
var worldInfoBuilder = new PlayerWorldSceneInfo();
var isSceneUnlocked = player.getWorld().getHost().getUnlockedScenes()
.getOrDefault(scene.getId(), Configuration.GAME_OPTIONS.unlockScenesByDefault);
worldInfoBuilder.setLocked(!isSceneUnlocked);
worldInfoBuilder.setSceneId(scene.getId());
worldInfoBuilder.setSceneTagIdList(player.getSceneTagList(scene.getId()));