Better SceneTags (#2361)

* Add scene tag handling

* Move warns to debug

* Move to PlayerProgressManager

* Add success message

* Inline check

* Improve per-scene handling

* Update src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java

Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com>

* Update src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java

Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com>

* Fix types

* Small fix

* Update ScriptLib.java

---------

Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com>
This commit is contained in:
Thoronium
2023-09-16 15:31:59 -06:00
committed by GitHub
Unverified
parent 5bd8f532c1
commit 0e44d18ae9
17 changed files with 221 additions and 61 deletions
@@ -17,7 +17,7 @@ public class HandlerSceneInitFinishReq extends PacketHandler {
session.send(new PacketServerTimeNotify());
session.send(new PacketWorldPlayerInfoNotify(world));
session.send(new PacketWorldDataNotify(world));
session.send(new PacketPlayerWorldSceneInfoListNotify());
session.send(new PacketPlayerWorldSceneInfoListNotify(player));
session.send(new BasePacket(PacketOpcodes.SceneForceUnlockNotify));
session.send(new PacketHostPlayerNotify(world));
@@ -1,46 +1,48 @@
package emu.grasscutter.server.packet.send;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.scene.SceneTagData;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.*;
import emu.grasscutter.net.proto.MapLayerInfoOuterClass;
import emu.grasscutter.net.proto.PlayerWorldSceneInfoListNotifyOuterClass.PlayerWorldSceneInfoListNotify;
import emu.grasscutter.net.proto.PlayerWorldSceneInfoOuterClass.PlayerWorldSceneInfo;
import java.util.stream.IntStream;
import java.util.Map;
public class PacketPlayerWorldSceneInfoListNotify extends BasePacket {
public PacketPlayerWorldSceneInfoListNotify() {
public PacketPlayerWorldSceneInfoListNotify(Player player) {
super(PacketOpcodes.PlayerWorldSceneInfoListNotify); // Rename opcode later
var sceneTags = player.getSceneTags();
PlayerWorldSceneInfoListNotify.Builder proto =
PlayerWorldSceneInfoListNotify.newBuilder()
.addInfoList(PlayerWorldSceneInfo.newBuilder().setSceneId(1).setIsLocked(false).build())
.addInfoList(
PlayerWorldSceneInfo.newBuilder()
.setSceneId(3)
.setIsLocked(false)
.addInfoList(PlayerWorldSceneInfo.newBuilder().setSceneId(1).setIsLocked(false).build());
// Iterate over all scenes
for (int scene : GameData.getSceneDataMap().keySet()) {
var worldInfoBuilder = PlayerWorldSceneInfo.newBuilder()
.setSceneId(scene)
.setIsLocked(false);
/** Add scene-specific data */
// Scenetags
if (sceneTags.keySet().contains(scene)) {
worldInfoBuilder
.addAllSceneTagIdList(
GameData.getSceneTagDataMap().values().stream()
.filter(sceneTag -> sceneTag.getSceneId() == 3)
.filter(
sceneTag ->
sceneTag.isDefaultValid()
|| sceneTag.getCond().get(0).getCondType() != null)
.map(SceneTagData::getId)
.toList())
// .addSceneTagIdList(102) // Jade chamber (alr added)
// .addSceneTagIdList(113)
// .addSceneTagIdList(117)
// .addSceneTagIdList(1093) // 3.0 Vana_real
.addSceneTagIdList(1094) // 3.0 Vana_dream
// .addSceneTagIdList(1095) // 3.0 Vana_first
// .addSceneTagIdList(1096) // 3.0 Vana_festival
.addSceneTagIdList(152) // 3.1 event
.addSceneTagIdList(153) // 3.1 event
.addSceneTagIdList(1164) // Desert Arena (XMSM_CWLTop)
.addSceneTagIdList(1166) // Desert Pyramid (CWL_Trans_02)
.setMapLayerInfo(
sceneTags.entrySet().stream()
.filter(e -> e.getKey().equals(scene))
.map(Map.Entry::getValue)
.toList()
.get(0)
);
}
// Map layer information (Big world)
if (scene == 3) {
worldInfoBuilder.setMapLayerInfo(
MapLayerInfoOuterClass.MapLayerInfo.newBuilder()
.addAllUnlockedMapLayerIdList(
GameData.getMapLayerDataMap().keySet()) // MapLayer Ids
@@ -49,31 +51,11 @@ public class PacketPlayerWorldSceneInfoListNotify extends BasePacket {
.addAllUnlockedMapLayerGroupIdList(
GameData.getMapLayerGroupDataMap()
.keySet()) // will show MapLayer options when hovered over
.build()) // map layer test
.build())
.addInfoList(
PlayerWorldSceneInfo.newBuilder()
.setSceneId(4)
.setIsLocked(false)
.addSceneTagIdList(106)
.addSceneTagIdList(109)
.addSceneTagIdList(117)
.build())
.addInfoList(PlayerWorldSceneInfo.newBuilder().setSceneId(5).setIsLocked(false).build())
.addInfoList(PlayerWorldSceneInfo.newBuilder().setSceneId(6).setIsLocked(false).build())
.addInfoList(PlayerWorldSceneInfo.newBuilder().setSceneId(7).setIsLocked(false).build())
.addInfoList(
PlayerWorldSceneInfo.newBuilder()
.setSceneId(9)
.setIsLocked(false)
.addAllSceneTagIdList(IntStream.range(0, 3000).boxed().toList())
.build())
.addInfoList(
PlayerWorldSceneInfo.newBuilder()
.setSceneId(10)
.setIsLocked(false)
.addAllSceneTagIdList(IntStream.range(0, 3000).boxed().toList())
.build()); // 3.8
.build()); // map layer test
}
proto.addInfoList(worldInfoBuilder.build());
}
this.setData(proto);
}