Save endgame progress, team presets, technique support and camera controls

This commit is contained in:
CAtlas0784 committed 2026-10-17 23:44:36 +07:00
1 parent a681affdb3
commit 639cef7d19
52 files changed
+11940 -766

No files matched your search

+204 -13
View File
@@ -3,6 +3,7 @@ package gameserver
import (
"encoding/json"
"fmt"
"gac-hkrpg-go/internal/common"
"os"
"sort"
"sync"
@@ -12,12 +13,14 @@ import (
// ChallengeDataConfig mirrors challenge_data.json (Rust: ChallengeConfigData).
type ChallengeDataConfig struct {
StagesList []uint32 `json:"stages_list"`
GroupsList []uint32 `json:"groups_list"`
Challenges map[uint32]ChallengeStageData `json:"challenges"`
Tierce map[uint32]ChallengeTierceStageData `json:"tierce"`
Stages map[uint32]StageBattleData `json:"stages"`
Peak map[string]PeakStageData `json:"peak"`
TargetRules map[uint32]ChallengeTargetRule `json:"-"`
Countdowns map[uint32]uint32 `json:"-"`
StagesList []uint32 `json:"stages_list"`
GroupsList []uint32 `json:"groups_list"`
Challenges map[uint32]ChallengeStageData `json:"challenges"`
Tierce map[uint32]ChallengeTierceStageData `json:"tierce"`
Stages map[uint32]StageBattleData `json:"stages"`
Peak map[string]PeakStageData `json:"peak"`
}
type ChallengeStageData struct {
@@ -33,13 +36,22 @@ type ChallengeStageData struct {
Buff uint32 `json:"buff"`
}
type ChallengeTargetRule struct {
ID uint32 `json:"ID"`
Type uint32 `json:"ChallengeTargetType"`
Param uint32 `json:"ChallengeTargetParam1"`
}
type ChallengeTierceStageData struct {
Entrance uint32 `json:"entrance"`
Group uint32 `json:"group"`
Monster uint32 `json:"monster"`
Event uint32 `json:"event"`
Targets []uint32 `json:"targets"`
Score uint32 `json:"score"`
SpecialTarget uint32 `json:"-"`
ClearScore uint32 `json:"-"`
PreChallengeID uint32 `json:"-"`
Entrance uint32 `json:"entrance"`
Group uint32 `json:"group"`
Monster uint32 `json:"monster"`
Event uint32 `json:"event"`
Targets []uint32 `json:"targets"`
Score uint32 `json:"score"`
}
type StageBattleData struct {
@@ -48,6 +60,11 @@ type StageBattleData struct {
}
type PeakStageData struct {
Entrance uint32 `json:"-"`
Group uint32 `json:"-"`
GroupID uint32 `json:"-"`
Buffs []uint32 `json:"-"`
HardBuffs []uint32 `json:"-"`
EventID uint32 `json:"event_id"`
HardEventID uint32 `json:"hard_event_id"`
MonsterID uint32 `json:"monster_id"`
@@ -73,10 +90,166 @@ func getChallengeData() *ChallengeDataConfig {
Log("Failed to parse challenge_data.json: " + err.Error())
challengeData = ChallengeDataConfig{}
}
challengeData.Countdowns = map[uint32]uint32{}
challengeData.TargetRules = map[uint32]ChallengeTargetRule{}
if raw, err := common.ReadResourceFile("resources/ChallengeTargetConfig.json"); err == nil {
var table struct {
Entries []ChallengeTargetRule `json:"challenge_targets"`
}
if json.Unmarshal(raw, &table) == nil {
for _, entry := range table.Entries {
challengeData.TargetRules[entry.ID] = entry
}
}
}
if challengeData.Challenges == nil {
challengeData.Challenges = map[uint32]ChallengeStageData{}
}
if challengeData.Tierce == nil {
challengeData.Tierce = map[uint32]ChallengeTierceStageData{}
}
if challengeData.Stages == nil {
challengeData.Stages = map[uint32]StageBattleData{}
}
if raw, err := common.ReadResourceFile("resources/ChallengeMazeConfig.json"); err == nil {
var table struct {
Entries []struct {
ID uint32 `json:"ID"`
Countdown uint32 `json:"ChallengeCountDown"`
GroupID uint32 `json:"GroupID"`
Entrance uint32 `json:"MapEntranceID"`
Entrance2 uint32 `json:"MapEntranceID2"`
Group1 uint32 `json:"MazeGroupID1"`
Group2 uint32 `json:"MazeGroupID2"`
Monsters1 []uint32 `json:"NpcMonsterIDList1"`
Monsters2 []uint32 `json:"NpcMonsterIDList2"`
Events1 []uint32 `json:"EventIDList1"`
Events2 []uint32 `json:"EventIDList2"`
Buff uint32 `json:"MazeBuffID"`
} `json:"challenge_config"`
}
if err := json.Unmarshal(raw, &table); err == nil {
for _, entry := range table.Entries {
challengeData.Countdowns[entry.ID] = entry.Countdown
challengeData.Challenges[entry.ID] = ChallengeStageData{GroupID: entry.GroupID, Entrance: entry.Entrance, Entrance2: entry.Entrance2, Group1: entry.Group1, Group2: entry.Group2, Monster1: lastResourceID(entry.Monsters1), Monster2: lastResourceID(entry.Monsters2), Event1: lastResourceID(entry.Events1), Event2: lastResourceID(entry.Events2), Buff: entry.Buff}
}
}
}
if raw, err := common.ReadResourceFile("resources/ChallengeMazeTierceConfig.json"); err == nil {
var table struct {
Entries []struct {
ID uint32 `json:"ID"`
PreChallengeID uint32 `json:"PreChallengeMazeID"`
Entrance uint32 `json:"MapEntranceID"`
Group uint32 `json:"MazeGroupID"`
Monsters []uint32 `json:"NpcMonsterIDList"`
Events []uint32 `json:"EventIDList"`
Targets []uint32 `json:"ChallengeTargetID"`
SpecialTarget uint32 `json:"ChallengeTierceTargetID"`
ClearScore uint32 `json:"IDBJENCBJHM"`
} `json:"challenge_tierce_config"`
}
if err := json.Unmarshal(raw, &table); err == nil {
for _, entry := range table.Entries {
value := challengeData.Tierce[entry.ID]
value.PreChallengeID, value.Entrance, value.Group = entry.PreChallengeID, entry.Entrance, entry.Group
value.SpecialTarget, value.ClearScore = entry.SpecialTarget, entry.ClearScore
value.Monster, value.Event, value.Targets = lastResourceID(entry.Monsters), lastResourceID(entry.Events), entry.Targets
challengeData.Tierce[entry.ID] = value
}
}
}
if raw, err := common.ReadResourceFile("resources/StageConfig.json"); err == nil {
var table struct {
Entries []struct {
ID uint32 `json:"StageID"`
Level uint32 `json:"Level"`
Monsters [][]uint32 `json:"MonsterList"`
} `json:"stage_config"`
}
if err := json.Unmarshal(raw, &table); err == nil {
for _, entry := range table.Entries {
challengeData.Stages[entry.ID] = StageBattleData{Level: entry.Level, Monsters: entry.Monsters}
}
}
}
loadPeakResources(&challengeData)
})
return &challengeData
}
func loadPeakResources(data *ChallengeDataConfig) {
if data.Peak == nil {
data.Peak = map[string]PeakStageData{}
}
if raw, err := common.ReadResourceFile("resources/ChallengePeakConfig.json"); err == nil {
var table struct {
Rows []struct {
ID uint32 `json:"ID"`
Entrance uint32 `json:"MapEntranceID"`
Group uint32 `json:"MazeGroupID"`
Events []uint32 `json:"EventIDList"`
Monsters []uint32 `json:"NpcMonsterIDList"`
Buffs []uint32 `json:"TagList"`
Targets []uint32 `json:"NormalTargetList"`
} `json:"challenge_peak_config"`
}
if err := json.Unmarshal(raw, &table); err == nil {
for _, row := range table.Rows {
value := data.Peak[itoa(int(row.ID))]
value.Entrance, value.Group, value.EventID, value.MonsterID = row.Entrance, row.Group, lastResourceID(row.Events), lastResourceID(row.Monsters)
value.Buffs, value.Targets = row.Buffs, row.Targets
data.Peak[itoa(int(row.ID))] = value
}
}
}
if raw, err := common.ReadResourceFile("resources/ChallengePeakBossConfig.json"); err == nil {
var table struct {
Rows []struct {
ID uint32 `json:"ID"`
Events []uint32 `json:"HardEventIDList"`
Buffs []uint32 `json:"HardTagList"`
Target uint32 `json:"HardTarget"`
} `json:"challenge_peak_boss_config"`
}
if err := json.Unmarshal(raw, &table); err == nil {
for _, row := range table.Rows {
value := data.Peak[itoa(int(row.ID))]
value.IsBoss = true
value.HardEventID, value.HardBuffs, value.HardTarget = lastResourceID(row.Events), row.Buffs, row.Target
data.Peak[itoa(int(row.ID))] = value
}
}
}
if raw, err := common.ReadResourceFile("resources/ChallengePeakGroupConfig.json"); err == nil {
var table struct {
Rows []struct {
ID uint32 `json:"ID"`
Pre []uint32 `json:"PreLevelIDList"`
Boss uint32 `json:"BossLevelID"`
} `json:"challenge_peak_group_config"`
}
if err := json.Unmarshal(raw, &table); err == nil {
for _, row := range table.Rows {
for _, id := range append(row.Pre, row.Boss) {
key := itoa(int(id))
value := data.Peak[key]
value.GroupID = row.ID
data.Peak[key] = value
}
}
}
}
}
func lastResourceID(ids []uint32) uint32 {
if len(ids) == 0 {
return 0
}
return ids[len(ids)-1]
}
func getChallengeStagesList() []uint32 {
cd := getChallengeData()
if len(cd.StagesList) > 0 {
@@ -206,6 +379,10 @@ func init() {
handle("GetCurChallenge", func(s *Session, req *goproto.GetCurChallengeCsReq, rsp *goproto.GetCurChallengeScRsp) error {
rsp.Retcode = 0
if run := s.ChallengeRun; run != nil && !run.Tierce && !run.Peak {
rsp.CurChallenge = run.Cur
rsp.LineupList = []*goproto.LineupInfo{run.activeLineup(0)}
}
return nil
})
@@ -274,8 +451,22 @@ func init() {
})
handle("GetCurChallengePeak", func(s *Session, req *goproto.GetCurChallengePeakCsReq, rsp *goproto.GetCurChallengePeakScRsp) error {
// Match upstream's empty current-state response until a Peak is active.
rsp.Retcode = 0
if run := s.ChallengeRun; run != nil && run.Peak {
rsp.PeakId, rsp.BossBuffId, rsp.HasPassed = run.ID, run.PeakBuff, run.Finished && run.Win
}
return nil
})
handle("SetChallengePeakBossHardMode", func(s *Session, req *goproto.SetChallengePeakBossHardModeCsReq, rsp *goproto.SetChallengePeakBossHardModeScRsp) error {
if s.PeakHardModes == nil {
s.PeakHardModes = map[uint32]bool{}
}
s.PeakHardModes[req.PeakGroupId] = req.IsHardMode
rsp.PeakGroupId, rsp.IsHardMode = req.PeakGroupId, req.IsHardMode
return nil
})
handle("ConfirmChallengePeakSettle", func(s *Session, req *goproto.ConfirmChallengePeakSettleCsReq, rsp *goproto.ConfirmChallengePeakSettleScRsp) error {
rsp.PeakId, rsp.IOBCIMIPEOM = req.PeakId, req.IOBCIMIPEOM
return nil
})