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

and misc bug fixes

parent 02a56fce
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.player.Player.SceneLoadState;
import emu.grasscutter.game.quest.QuestGroupSuite;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketHandler;
......@@ -16,7 +18,7 @@ public class HandlerEnterSceneDoneReq extends PacketHandler {
session.getPlayer().setSceneLoadState(SceneLoadState.LOADED);
// Done
session.send(new PacketEnterSceneDoneRsp(session.getPlayer()));
session.send(new PacketPlayerTimeNotify(session.getPlayer())); // Probably not the right place
// Spawn player in world
......@@ -35,11 +37,15 @@ public class HandlerEnterSceneDoneReq extends PacketHandler {
// notify client to load the npc for quest
var questGroupSuites = session.getPlayer().getQuestManager().getSceneGroupSuite(session.getPlayer().getSceneId());
session.getPlayer().getScene().loadGroupForQuest(questGroupSuites);
Grasscutter.getLogger().debug("Loaded Scene {} Quest(s) Groupsuite(s): {}", session.getPlayer().getSceneId(), questGroupSuites);
session.send(new PacketGroupSuiteNotify(questGroupSuites));
// Reset timer for sending player locations
session.getPlayer().resetSendPlayerLocTime();
//Rsp
session.send(new PacketEnterSceneDoneRsp(session.getPlayer()));
}
}
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.quest.GameMainQuest;
import emu.grasscutter.game.quest.enums.ParentQuestState;
import emu.grasscutter.game.quest.enums.QuestTrigger;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
......@@ -15,10 +19,22 @@ public class HandlerNpcTalkReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
NpcTalkReq req = NpcTalkReq.parseFrom(payload);
//Check if mainQuest exists
int talkId = req.getTalkId();
//remove last 2 digits to get a mainQuestId
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());
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_FINISH_PLOT, req.getTalkId());
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()));
}
......
......@@ -14,7 +14,7 @@ public class HandlerPostEnterSceneReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
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()));
......
......@@ -2,6 +2,7 @@ package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.quest.enums.ParentQuestState;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.FinishedParentQuestNotifyOuterClass.FinishedParentQuestNotify;
......@@ -13,8 +14,11 @@ public class PacketFinishedParentQuestNotify extends BasePacket {
FinishedParentQuestNotify.Builder proto = FinishedParentQuestNotify.newBuilder();
for (GameMainQuest mainQuest : player.getQuestManager().getQuests().values()) {
for (GameMainQuest mainQuest : player.getQuestManager().getMainQuests().values()) {
//Canceled Quests do not appear in this packet
if(mainQuest.getState() != ParentQuestState.PARENT_QUEST_STATE_CANCELED) {
proto.addParentQuestList(mainQuest.toProto());
}
}
this.setData(proto);
......
......@@ -5,6 +5,8 @@ import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.FinishedParentQuestUpdateNotifyOuterClass.FinishedParentQuestUpdateNotify;
import java.util.List;
public class PacketFinishedParentQuestUpdateNotify extends BasePacket {
public PacketFinishedParentQuestUpdateNotify(GameMainQuest quest) {
......@@ -16,4 +18,16 @@ public class PacketFinishedParentQuestUpdateNotify extends BasePacket {
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 {
.map(GameMainQuest::getChildQuests)
.map(Map::values)
.flatMap(Collection::stream)
.map(GameQuest::getQuestId)
.map(GameQuest::getSubQuestId)
.collect(Collectors.toSet());
GameData.getPersonalLineDataMap().values().stream()
......
......@@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.quest.QuestManager;
import emu.grasscutter.game.quest.enums.QuestState;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.QuestListNotifyOuterClass.QuestListNotify;
......@@ -15,7 +16,9 @@ public class PacketQuestListNotify extends BasePacket {
QuestListNotify.Builder proto = QuestListNotify.newBuilder();
player.getQuestManager().forEachQuest(quest -> {
if(quest.getState() != QuestState.QUEST_STATE_UNSTARTED) {
proto.addQuestList(quest.toProto());
}
});
this.setData(proto);
......
......@@ -6,6 +6,8 @@ import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.QuestListUpdateNotifyOuterClass.QuestListUpdateNotify;
import java.util.List;
public class PacketQuestListUpdateNotify extends BasePacket {
public PacketQuestListUpdateNotify(GameQuest quest) {
......@@ -17,4 +19,15 @@ public class PacketQuestListUpdateNotify extends BasePacket {
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