Commit 8050f0cc authored by akatatsu27's avatar akatatsu27
Browse files

and misc bug fixes

parent 02a56fce
package emu.grasscutter.server.packet.recv; package emu.grasscutter.server.packet.recv;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.player.Player.SceneLoadState; import emu.grasscutter.game.player.Player.SceneLoadState;
import emu.grasscutter.game.quest.QuestGroupSuite;
import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
...@@ -16,7 +18,7 @@ public class HandlerEnterSceneDoneReq extends PacketHandler { ...@@ -16,7 +18,7 @@ public class HandlerEnterSceneDoneReq extends PacketHandler {
session.getPlayer().setSceneLoadState(SceneLoadState.LOADED); session.getPlayer().setSceneLoadState(SceneLoadState.LOADED);
// Done // Done
session.send(new PacketEnterSceneDoneRsp(session.getPlayer()));
session.send(new PacketPlayerTimeNotify(session.getPlayer())); // Probably not the right place session.send(new PacketPlayerTimeNotify(session.getPlayer())); // Probably not the right place
// Spawn player in world // Spawn player in world
...@@ -35,11 +37,15 @@ public class HandlerEnterSceneDoneReq extends PacketHandler { ...@@ -35,11 +37,15 @@ public class HandlerEnterSceneDoneReq extends PacketHandler {
// notify client to load the npc for quest // notify client to load the npc for quest
var questGroupSuites = session.getPlayer().getQuestManager().getSceneGroupSuite(session.getPlayer().getSceneId()); var questGroupSuites = session.getPlayer().getQuestManager().getSceneGroupSuite(session.getPlayer().getSceneId());
session.getPlayer().getScene().loadGroupForQuest(questGroupSuites); session.getPlayer().getScene().loadGroupForQuest(questGroupSuites);
Grasscutter.getLogger().debug("Loaded Scene {} Quest(s) Groupsuite(s): {}", session.getPlayer().getSceneId(), questGroupSuites);
session.send(new PacketGroupSuiteNotify(questGroupSuites)); session.send(new PacketGroupSuiteNotify(questGroupSuites));
// Reset timer for sending player locations // Reset timer for sending player locations
session.getPlayer().resetSendPlayerLocTime(); session.getPlayer().resetSendPlayerLocTime();
//Rsp
session.send(new PacketEnterSceneDoneRsp(session.getPlayer()));
} }
} }
package emu.grasscutter.server.packet.recv; package emu.grasscutter.server.packet.recv;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.binout.MainQuestData;
import emu.grasscutter.game.inventory.GameItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.quest.enums.ParentQuestState;
import emu.grasscutter.game.quest.enums.QuestTrigger; import emu.grasscutter.game.quest.enums.QuestTrigger;
import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
...@@ -11,16 +15,28 @@ import emu.grasscutter.server.packet.send.PacketNpcTalkRsp; ...@@ -11,16 +15,28 @@ import emu.grasscutter.server.packet.send.PacketNpcTalkRsp;
@Opcodes(PacketOpcodes.NpcTalkReq) @Opcodes(PacketOpcodes.NpcTalkReq)
public class HandlerNpcTalkReq extends PacketHandler { public class HandlerNpcTalkReq extends PacketHandler {
@Override @Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
NpcTalkReq req = NpcTalkReq.parseFrom(payload); NpcTalkReq req = NpcTalkReq.parseFrom(payload);
//Check if mainQuest exists
// Why are there 2 quest triggers that do the same thing... int talkId = req.getTalkId();
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_COMPLETE_TALK, req.getTalkId()); //remove last 2 digits to get a mainQuestId
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_FINISH_PLOT, req.getTalkId()); int mainQuestId = talkId/100;
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(mainQuestId);
if(mainQuestData != null) {
MainQuestData.TalkData talk = mainQuestData.getTalks().stream().filter(p -> p.getId() == talkId).toList().get(0);
if(talk != null) {
//talk is finished
session.getPlayer().getQuestManager().getMainQuestById(mainQuestId).getTalks().put(Integer.valueOf(talkId),talk);
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_COMPLETE_ANY_TALK,String.valueOf(req.getTalkId()), 0, 0);
// Why are there 2 quest triggers that do the same thing...
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_COMPLETE_TALK, req.getTalkId(),0);
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_FINISH_PLOT, req.getTalkId(),0);
}
}
session.send(new PacketNpcTalkRsp(req.getNpcEntityId(), req.getTalkId(), req.getEntityId())); session.send(new PacketNpcTalkRsp(req.getNpcEntityId(), req.getTalkId(), req.getEntityId()));
} }
} }
\ No newline at end of file
...@@ -14,7 +14,7 @@ public class HandlerPostEnterSceneReq extends PacketHandler { ...@@ -14,7 +14,7 @@ public class HandlerPostEnterSceneReq extends PacketHandler {
@Override @Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
if(session.getPlayer().getScene().getSceneType() == SceneType.SCENE_ROOM){ if(session.getPlayer().getScene().getSceneType() == SceneType.SCENE_ROOM){
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_ENTER_ROOM, session.getPlayer().getSceneId()); session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_ENTER_ROOM, session.getPlayer().getSceneId(),0);
} }
session.send(new PacketPostEnterSceneRsp(session.getPlayer())); session.send(new PacketPostEnterSceneRsp(session.getPlayer()));
......
...@@ -2,21 +2,25 @@ package emu.grasscutter.server.packet.send; ...@@ -2,21 +2,25 @@ package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.GameMainQuest; import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.quest.enums.ParentQuestState;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.FinishedParentQuestNotifyOuterClass.FinishedParentQuestNotify; import emu.grasscutter.net.proto.FinishedParentQuestNotifyOuterClass.FinishedParentQuestNotify;
public class PacketFinishedParentQuestNotify extends BasePacket { public class PacketFinishedParentQuestNotify extends BasePacket {
public PacketFinishedParentQuestNotify(Player player) { public PacketFinishedParentQuestNotify(Player player) {
super(PacketOpcodes.FinishedParentQuestNotify, true); super(PacketOpcodes.FinishedParentQuestNotify, true);
FinishedParentQuestNotify.Builder proto = FinishedParentQuestNotify.newBuilder(); FinishedParentQuestNotify.Builder proto = FinishedParentQuestNotify.newBuilder();
for (GameMainQuest mainQuest : player.getQuestManager().getQuests().values()) { for (GameMainQuest mainQuest : player.getQuestManager().getMainQuests().values()) {
proto.addParentQuestList(mainQuest.toProto()); //Canceled Quests do not appear in this packet
if(mainQuest.getState() != ParentQuestState.PARENT_QUEST_STATE_CANCELED) {
proto.addParentQuestList(mainQuest.toProto());
}
} }
this.setData(proto); this.setData(proto);
} }
} }
...@@ -5,15 +5,29 @@ import emu.grasscutter.net.packet.BasePacket; ...@@ -5,15 +5,29 @@ import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.FinishedParentQuestUpdateNotifyOuterClass.FinishedParentQuestUpdateNotify; import emu.grasscutter.net.proto.FinishedParentQuestUpdateNotifyOuterClass.FinishedParentQuestUpdateNotify;
import java.util.List;
public class PacketFinishedParentQuestUpdateNotify extends BasePacket { public class PacketFinishedParentQuestUpdateNotify extends BasePacket {
public PacketFinishedParentQuestUpdateNotify(GameMainQuest quest) { public PacketFinishedParentQuestUpdateNotify(GameMainQuest quest) {
super(PacketOpcodes.FinishedParentQuestUpdateNotify); super(PacketOpcodes.FinishedParentQuestUpdateNotify);
FinishedParentQuestUpdateNotify proto = FinishedParentQuestUpdateNotify.newBuilder() FinishedParentQuestUpdateNotify proto = FinishedParentQuestUpdateNotify.newBuilder()
.addParentQuestList(quest.toProto()) .addParentQuestList(quest.toProto())
.build(); .build();
this.setData(proto); this.setData(proto);
} }
public PacketFinishedParentQuestUpdateNotify(List<GameMainQuest> quests) {
super(PacketOpcodes.FinishedParentQuestUpdateNotify);
var proto = FinishedParentQuestUpdateNotify.newBuilder();
for(GameMainQuest mainQuest : quests) {
proto.addParentQuestList(mainQuest.toProto());
}
proto.build();
this.setData(proto);
}
} }
...@@ -23,7 +23,7 @@ public class PacketPersonalLineAllDataRsp extends BasePacket { ...@@ -23,7 +23,7 @@ public class PacketPersonalLineAllDataRsp extends BasePacket {
.map(GameMainQuest::getChildQuests) .map(GameMainQuest::getChildQuests)
.map(Map::values) .map(Map::values)
.flatMap(Collection::stream) .flatMap(Collection::stream)
.map(GameQuest::getQuestId) .map(GameQuest::getSubQuestId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
GameData.getPersonalLineDataMap().values().stream() GameData.getPersonalLineDataMap().values().stream()
......
...@@ -3,21 +3,24 @@ package emu.grasscutter.server.packet.send; ...@@ -3,21 +3,24 @@ package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.GameMainQuest; import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.quest.QuestManager; import emu.grasscutter.game.quest.QuestManager;
import emu.grasscutter.game.quest.enums.QuestState;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.QuestListNotifyOuterClass.QuestListNotify; import emu.grasscutter.net.proto.QuestListNotifyOuterClass.QuestListNotify;
public class PacketQuestListNotify extends BasePacket { public class PacketQuestListNotify extends BasePacket {
public PacketQuestListNotify(Player player) { public PacketQuestListNotify(Player player) {
super(PacketOpcodes.QuestListNotify, true); super(PacketOpcodes.QuestListNotify, true);
QuestListNotify.Builder proto = QuestListNotify.newBuilder(); QuestListNotify.Builder proto = QuestListNotify.newBuilder();
player.getQuestManager().forEachQuest(quest -> { player.getQuestManager().forEachQuest(quest -> {
proto.addQuestList(quest.toProto()); if(quest.getState() != QuestState.QUEST_STATE_UNSTARTED) {
proto.addQuestList(quest.toProto());
}
}); });
this.setData(proto); this.setData(proto);
} }
} }
...@@ -6,15 +6,28 @@ import emu.grasscutter.net.packet.BasePacket; ...@@ -6,15 +6,28 @@ import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.QuestListUpdateNotifyOuterClass.QuestListUpdateNotify; import emu.grasscutter.net.proto.QuestListUpdateNotifyOuterClass.QuestListUpdateNotify;
import java.util.List;
public class PacketQuestListUpdateNotify extends BasePacket { public class PacketQuestListUpdateNotify extends BasePacket {
public PacketQuestListUpdateNotify(GameQuest quest) { public PacketQuestListUpdateNotify(GameQuest quest) {
super(PacketOpcodes.QuestListUpdateNotify); super(PacketOpcodes.QuestListUpdateNotify);
QuestListUpdateNotify proto = QuestListUpdateNotify.newBuilder() QuestListUpdateNotify proto = QuestListUpdateNotify.newBuilder()
.addQuestList(quest.toProto()) .addQuestList(quest.toProto())
.build(); .build();
this.setData(proto); this.setData(proto);
} }
public PacketQuestListUpdateNotify(List<GameQuest> quests) {
super(PacketOpcodes.QuestListUpdateNotify);
var proto = QuestListUpdateNotify.newBuilder();
for(GameQuest quest : quests) {
proto.addQuestList(quest.toProto());
}
proto.build();
this.setData(proto);
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment