pre cw with probe and a bunch script to read game behavior
This commit is contained in:
1 parent
5120219ae2
commit
da8a32f60d
310 files changed
+219693
-872
No files matched your search
@@ -0,0 +1,125 @@
|
||||
package gameserver
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"gac-hkrpg-go/internal/common"
|
||||
pb "gac-hkrpg-go/protocol/proto"
|
||||
)
|
||||
|
||||
type cwEnemyPlan struct {
|
||||
Route uint32 `json:"route_id"`
|
||||
Chapter uint32 `json:"chapter_id"`
|
||||
Section uint32 `json:"section_id"`
|
||||
Division uint32 `json:"division_id"`
|
||||
Overclock bool `json:"is_overclock"`
|
||||
Penalty uint32 `json:"penalty_id"`
|
||||
Stage uint32 `json:"stage_id"`
|
||||
Level uint32 `json:"level"`
|
||||
HardLevelGroup uint32 `json:"hard_level_group"`
|
||||
EliteGroup uint32 `json:"elite_group"`
|
||||
ExtraDifficulty uint32 `json:"extra_difficulty"`
|
||||
Waves []struct {
|
||||
ID uint32 `json:"wave_id"`
|
||||
Formation uint32 `json:"formation_wave_id"`
|
||||
Count uint32 `json:"monster_count"`
|
||||
} `json:"waves"`
|
||||
}
|
||||
|
||||
// Only wave parameters are captured. Monster IDs and stars must agree with
|
||||
// the current run's saved layer, so a reference encounter never replaces it.
|
||||
func cwBuildNodeEnemy(catalog *common.CurrencyWarsCatalog, run *pb.MPIMAEMCEFH, stage *pb.BEEFLEJAOCN, node *pb.OHMDHKGAEMM, info *pb.SceneBattleInfo) error {
|
||||
raw, err := common.ReadResourceFile("resources/CurrencyWarsEnemyPlans.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var resource struct {
|
||||
Format uint32 `json:"format_version"`
|
||||
Client string `json:"target_client_version"`
|
||||
Assembly string `json:"target_assembly_sha256"`
|
||||
PlanHash string `json:"source_plan_sha256"`
|
||||
StageHash string `json:"target_stage_capture_sha256"`
|
||||
Entries []cwEnemyPlan `json:"entries"`
|
||||
}
|
||||
if err = json.Unmarshal(raw, &resource); err != nil {
|
||||
return err
|
||||
}
|
||||
if resource.Format != 1 || resource.Client != catalog.ClientVersion || resource.Assembly != catalog.Provenance.GameAssemblySHA256 {
|
||||
return fmt.Errorf("CW enemy plan revision differs")
|
||||
}
|
||||
for _, digest := range []string{resource.PlanHash, resource.StageHash} {
|
||||
value, e := hex.DecodeString(digest)
|
||||
if e != nil || len(value) != sha256.Size {
|
||||
return fmt.Errorf("CW enemy plan provenance missing")
|
||||
}
|
||||
}
|
||||
var recipe *cwEnemyPlan
|
||||
for i := range resource.Entries {
|
||||
r := &resource.Entries[i]
|
||||
if r.Route == stage.EMOHLJHPOPC && r.Chapter == stage.DCAHJELNJNP && r.Section == stage.SectionId && r.Division == run.DivisionId && r.Overclock == run.IsOverlock && r.Stage == node.StageId && r.Penalty == node.IFIIOIIKJHO {
|
||||
if recipe != nil {
|
||||
return fmt.Errorf("CW enemy plan duplicated")
|
||||
}
|
||||
recipe = r
|
||||
}
|
||||
}
|
||||
if recipe == nil || recipe.Level == 0 || recipe.HardLevelGroup == 0 || recipe.EliteGroup == 0 || len(recipe.Waves) == 0 {
|
||||
return fmt.Errorf("CW enemy plan not captured for this node/mode")
|
||||
}
|
||||
layer := stage.IMPNAHBCADN.GetMPOBBIPMNNJ()
|
||||
// This capture is an ordinary combat node with a single selected plan.
|
||||
// Elite branch selection needs a separately mapped identity, not index 0.
|
||||
if layer == nil || len(layer.BPDABHGFBFO) != 1 || layer.MOADBALHMFD != 1 {
|
||||
return fmt.Errorf("CW current enemy layer is not a single selected plan")
|
||||
}
|
||||
plan := layer.BPDABHGFBFO[0]
|
||||
if plan.IFIIOIIKJHO != recipe.Penalty || plan.EPPHOFDAEMI != recipe.ExtraDifficulty || len(plan.MonsterWaveList) != len(recipe.Waves) {
|
||||
return fmt.Errorf("CW saved enemy plan differs from captured wave schema")
|
||||
}
|
||||
camp, err := catalog.MonsterCamp(run.LJNGPCKPJLF, layer.LNDKCPBJDKH)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
allowed := make(map[uint32]bool, len(camp.Season.MonsterList))
|
||||
for _, id := range camp.Season.MonsterList {
|
||||
allowed[id] = true
|
||||
}
|
||||
division, err := catalog.CapturedStage(run.DivisionId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Additional difficulty sources are not resolved by this base recipe.
|
||||
if stage.ANJBLBEOJND != nil {
|
||||
for _, delta := range stage.ANJBLBEOJND.PIFNOKAMBLL {
|
||||
if delta != 0 {
|
||||
return fmt.Errorf("CW modified enemy difficulty requires its own resolver")
|
||||
}
|
||||
}
|
||||
}
|
||||
waves := make([]*pb.SceneMonsterWave, 0, len(recipe.Waves))
|
||||
for i, config := range recipe.Waves {
|
||||
current := plan.MonsterWaveList[i]
|
||||
if config.ID == 0 || config.Formation == 0 || current.OCPEPEMNNEK != config.ID || uint64(len(current.PBLBBDBDLEK)) != uint64(config.Count) {
|
||||
return fmt.Errorf("CW current wave identity/count differs")
|
||||
}
|
||||
wave := &pb.SceneMonsterWave{BattleStageId: node.StageId, WaveId: config.ID, WaveParam: &pb.SceneMonsterWaveParam{Level: recipe.Level, HardLevelGroup: recipe.HardLevelGroup, EliteGroup: recipe.EliteGroup, CPHIINKIDEB: config.Formation}}
|
||||
for _, monster := range current.PBLBBDBDLEK {
|
||||
if !allowed[monster.MonsterId] || monster.RoleStar == 0 {
|
||||
return fmt.Errorf("CW saved monster identity/star differs from current season camp")
|
||||
}
|
||||
wave.MonsterList = append(wave.MonsterList, &pb.SceneMonster{MonsterId: monster.MonsterId, ExtraInfo: &pb.MNDMNDKLKIE{TeleportNice: &pb.MNDMNDKLKIE_EIGMKOJOEEI{EIGMKOJOEEI: &pb.HNEBODEBELG{RoleStar: monster.RoleStar}}}})
|
||||
}
|
||||
waves = append(waves, wave)
|
||||
}
|
||||
info.StageId = node.StageId
|
||||
info.MonsterWaveList = waves
|
||||
grid := info.EIGMKOJOEEI
|
||||
grid.IOCKDJCDMAH = &pb.MIPDJDJLGPL{EMOHLJHPOPC: stage.EMOHLJHPOPC, DCAHJELNJNP: stage.DCAHJELNJNP, SectionId: stage.SectionId, CJCCMAACJDB: node.CJCCMAACJDB}
|
||||
grid.IFIIOIIKJHO = node.IFIIOIIKJHO
|
||||
grid.LODNFLMBIEH = division.EnemyHardLevel
|
||||
grid.BattleWaveId = recipe.Waves[0].ID
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user