Commit 91000821 authored by Akka's avatar Akka Committed by Luke H-W
Browse files

quest fix & personal line impl

parent 7bae35f5
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketPersonalLineAllDataRsp;
@Opcodes(PacketOpcodes.PersonalLineAllDataReq)
public class HandlerPersonalLineAllDataReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
session.send(new PacketPersonalLineAllDataRsp(session.getPlayer().getQuestManager().getQuests().values()));
}
}
package emu.grasscutter.server.packet.recv; package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.props.SceneType;
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;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
...@@ -8,9 +10,13 @@ import emu.grasscutter.server.packet.send.PacketPostEnterSceneRsp; ...@@ -8,9 +10,13 @@ import emu.grasscutter.server.packet.send.PacketPostEnterSceneRsp;
@Opcodes(PacketOpcodes.PostEnterSceneReq) @Opcodes(PacketOpcodes.PostEnterSceneReq)
public class HandlerPostEnterSceneReq extends PacketHandler { 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){
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_ENTER_ROOM, session.getPlayer().getSceneId());
}
session.send(new PacketPostEnterSceneRsp(session.getPlayer())); session.send(new PacketPostEnterSceneRsp(session.getPlayer()));
} }
......
...@@ -3,14 +3,21 @@ package emu.grasscutter.server.packet.recv; ...@@ -3,14 +3,21 @@ package emu.grasscutter.server.packet.recv;
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;
import emu.grasscutter.net.proto.QueryPathReqOuterClass;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketQueryPathRsp;
@Opcodes(PacketOpcodes.QueryPathReq) @Opcodes(PacketOpcodes.QueryPathReq)
public class HandlerQueryPathReq extends PacketHandler { public class HandlerQueryPathReq 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 {
// Auto template var req = QueryPathReqOuterClass.QueryPathReq.parseFrom(payload);
/**
* It is not the actual work
*/
session.send(new PacketQueryPathRsp(req));
} }
} }
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.data.GameData;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.UnlockPersonalLineReqOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketUnlockPersonalLineRsp;
@Opcodes(PacketOpcodes.UnlockPersonalLineReq)
public class HandlerUnlockPersonalLineReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
var req = UnlockPersonalLineReqOuterClass.UnlockPersonalLineReq.parseFrom(payload);
var data = GameData.getPersonalLineDataMap().get(req.getPersonalLineId());
if(data == null){
return;
}
session.getPlayer().getQuestManager().addQuest(data.getStartQuestId());
session.getPlayer().useLegendaryKey(1);
session.send(new PacketUnlockPersonalLineRsp(data.getId(), 1, data.getChapterId()));
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AddQuestContentProgressRspOuterClass;
public class PacketAddQuestContentProgressRsp extends BasePacket {
public PacketAddQuestContentProgressRsp(int contentType) {
super(PacketOpcodes.AddQuestContentProgressRsp);
var proto = AddQuestContentProgressRspOuterClass.AddQuestContentProgressRsp.newBuilder();
proto.setContentType(contentType);
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ChapterStateNotifyOuterClass;
import emu.grasscutter.net.proto.ChapterStateOuterClass;
public class PacketChapterStateNotify extends BasePacket {
public PacketChapterStateNotify(int id, ChapterStateOuterClass.ChapterState state) {
super(PacketOpcodes.ChapterStateNotify);
var proto = ChapterStateNotifyOuterClass.ChapterStateNotify.newBuilder();
proto.setChapterId(id)
.setChapterState(state);
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.EvtEntityRenderersChangedNotifyOuterClass;
public class PacketEvtEntityRenderersChangedNotify extends BasePacket {
public PacketEvtEntityRenderersChangedNotify(EvtEntityRenderersChangedNotifyOuterClass.EvtEntityRenderersChangedNotify req) {
super(PacketOpcodes.EvtEntityRenderersChangedNotify, true);
this.setData(req);
}
}
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.data.binout.SceneNpcBornEntry; import emu.grasscutter.data.binout.SceneNpcBornEntry;
import emu.grasscutter.game.quest.QuestGroupSuite;
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.GroupSuiteNotifyOuterClass; import emu.grasscutter.net.proto.GroupSuiteNotifyOuterClass;
import java.util.Collection;
import java.util.List; import java.util.List;
public class PacketGroupSuiteNotify extends BasePacket { public class PacketGroupSuiteNotify extends BasePacket {
...@@ -27,4 +29,24 @@ public class PacketGroupSuiteNotify extends BasePacket { ...@@ -27,4 +29,24 @@ public class PacketGroupSuiteNotify extends BasePacket {
this.setData(proto); this.setData(proto);
} }
public PacketGroupSuiteNotify(int groupId, int suiteId) {
super(PacketOpcodes.GroupSuiteNotify);
var proto = GroupSuiteNotifyOuterClass.GroupSuiteNotify.newBuilder();
proto.putGroupMap(groupId, suiteId);
this.setData(proto);
}
public PacketGroupSuiteNotify(Collection<QuestGroupSuite> questGroupSuites) {
super(PacketOpcodes.GroupSuiteNotify);
var proto = GroupSuiteNotifyOuterClass.GroupSuiteNotify.newBuilder();
questGroupSuites.forEach(i -> proto.putGroupMap(i.getGroup(), i.getSuite()));
this.setData(proto);
}
} }
package emu.grasscutter.server.packet.send;
import emu.grasscutter.data.GameData;
import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PersonalLineAllDataRspOuterClass;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class PacketPersonalLineAllDataRsp extends BasePacket {
public PacketPersonalLineAllDataRsp(Collection<GameMainQuest> gameMainQuestList) {
super(PacketOpcodes.PersonalLineAllDataRsp);
var proto = PersonalLineAllDataRspOuterClass.PersonalLineAllDataRsp.newBuilder();
var questList = gameMainQuestList.stream()
.map(GameMainQuest::getChildQuests)
.map(Map::values)
.flatMap(Collection::stream)
.map(GameQuest::getQuestId)
.collect(Collectors.toSet());
GameData.getPersonalLineDataMap().values().stream()
.filter(i -> !questList.contains(i.getStartQuestId()))
.forEach(i -> proto.addCanBeUnlockedPersonalLineList(i.getId()));
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.QueryPathReqOuterClass;
import emu.grasscutter.net.proto.QueryPathRspOuterClass;
public class PacketQueryPathRsp extends BasePacket {
public PacketQueryPathRsp(QueryPathReqOuterClass.QueryPathReq req) {
super(PacketOpcodes.QueryPathRsp);
var proto = QueryPathRspOuterClass.QueryPathRsp.newBuilder();
proto.addCorners(req.getSourcePos())
.addCorners(req.getDestinationPos(0))
.setQueryId(req.getQueryId())
.setQueryStatus(QueryPathRspOuterClass.QueryPathRsp.PathStatusType.PATH_STATUS_TYPE_SUCC);
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.UnlockPersonalLineRspOuterClass;
public class PacketUnlockPersonalLineRsp extends BasePacket {
public PacketUnlockPersonalLineRsp(int id, int level, int chapterId) {
super(PacketOpcodes.UnlockPersonalLineRsp);
var proto = UnlockPersonalLineRspOuterClass.UnlockPersonalLineRsp.newBuilder();
proto.setPersonalLineId(id)
.setLevel(level)
.setChapterId(chapterId);
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