mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
新增任务触发条件
This commit is contained in:
@@ -79,7 +79,7 @@ func (g *Game) SceneRegionTriggerCheck(player *model.Player, scene *Scene, oldPo
|
||||
}
|
||||
for _, triggerDataConfig := range gdconf.GetTriggerDataMap() {
|
||||
if triggerDataConfig.TriggerName == triggerConfig.Name {
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_TRIGGER_FIRE, triggerDataConfig.TriggerId)
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_TRIGGER_FIRE, "", triggerDataConfig.TriggerId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,6 +436,7 @@ func (g *Game) EvtDoSkillSuccNotify(player *model.Player, payloadMsg pb.Message)
|
||||
logger.Debug("EvtDoSkillSuccNotify: %v", req)
|
||||
// 处理技能开始的耐力消耗
|
||||
g.SkillStartStamina(player, req.CasterId, req.SkillId)
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_SKILL, "", int32(req.SkillId))
|
||||
}
|
||||
|
||||
func (g *Game) EvtAvatarEnterFocusNotify(player *model.Player, payloadMsg pb.Message) {
|
||||
|
||||
@@ -147,8 +147,20 @@ func (g *Game) AcceptQuest(player *model.Player, notifyClient bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func matchParamEqual(param1 []int32, param2 []int32, num int) bool {
|
||||
if len(param1) != num || len(param2) != num {
|
||||
return false
|
||||
}
|
||||
for i := 0; i < num; i++ {
|
||||
if param1[i] != param2[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// TriggerQuest 触发任务
|
||||
func (g *Game) TriggerQuest(player *model.Player, cond int32, param ...int32) {
|
||||
func (g *Game) TriggerQuest(player *model.Player, cond int32, complexParam string, param ...int32) {
|
||||
dbQuest := player.GetDbQuest()
|
||||
updateQuestIdList := make([]uint32, 0)
|
||||
for _, quest := range dbQuest.GetQuestMap() {
|
||||
@@ -163,29 +175,31 @@ func (g *Game) TriggerQuest(player *model.Player, cond int32, param ...int32) {
|
||||
switch cond {
|
||||
case constant.QUEST_FINISH_COND_TYPE_TRIGGER_FIRE:
|
||||
// 场景触发器跳了 参数1:触发器id
|
||||
if len(questCond.Param) != 1 {
|
||||
continue
|
||||
}
|
||||
if len(param) != 1 {
|
||||
continue
|
||||
}
|
||||
if questCond.Param[0] != param[0] {
|
||||
ok := matchParamEqual(questCond.Param, param, 1)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
dbQuest.ForceFinishQuest(quest.QuestId)
|
||||
updateQuestIdList = append(updateQuestIdList, quest.QuestId)
|
||||
case constant.QUEST_FINISH_COND_TYPE_UNLOCK_TRANS_POINT:
|
||||
// 解锁传送锚点 参数1:场景id 参数2:传送锚点id
|
||||
if len(questCond.Param) != 2 {
|
||||
ok := matchParamEqual(questCond.Param, param, 2)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if len(param) != 2 {
|
||||
dbQuest.ForceFinishQuest(quest.QuestId)
|
||||
updateQuestIdList = append(updateQuestIdList, quest.QuestId)
|
||||
case constant.QUEST_FINISH_COND_TYPE_COMPLETE_TALK:
|
||||
// 与NPC对话 参数1:对话id
|
||||
ok := matchParamEqual(questCond.Param, param, 1)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if questCond.Param[0] != param[0] {
|
||||
continue
|
||||
}
|
||||
if questCond.Param[1] != param[1] {
|
||||
dbQuest.ForceFinishQuest(quest.QuestId)
|
||||
updateQuestIdList = append(updateQuestIdList, quest.QuestId)
|
||||
case constant.QUEST_FINISH_COND_TYPE_LUA_NOTIFY:
|
||||
// LUA侧通知 复杂参数
|
||||
if questCond.ComplexParam != complexParam {
|
||||
continue
|
||||
}
|
||||
dbQuest.ForceFinishQuest(quest.QuestId)
|
||||
|
||||
@@ -69,7 +69,7 @@ func (g *Game) UnlockTransPointReq(player *model.Player, payloadMsg pb.Message)
|
||||
}
|
||||
dbScene.UnlockPoint(req.PointId)
|
||||
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_UNLOCK_TRANS_POINT, int32(req.SceneId), int32(req.PointId))
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_UNLOCK_TRANS_POINT, "", int32(req.SceneId), int32(req.PointId))
|
||||
|
||||
g.SendMsg(cmd.ScenePointUnlockNotify, player.PlayerID, player.ClientSeq, &proto.ScenePointUnlockNotify{
|
||||
SceneId: req.SceneId,
|
||||
@@ -206,6 +206,7 @@ func (g *Game) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Message) {
|
||||
|
||||
func (g *Game) NpcTalkReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.NpcTalkReq)
|
||||
g.TriggerQuest(player, constant.QUEST_FINISH_COND_TYPE_COMPLETE_TALK, "", int32(req.TalkId))
|
||||
rsp := &proto.NpcTalkRsp{
|
||||
CurTalkId: req.TalkId,
|
||||
NpcEntityId: req.NpcEntityId,
|
||||
|
||||
Reference in New Issue
Block a user