Kenshi
评价数不足
Kenshi gamedata/mod/save file format
由 Weaver 制作
In the process of creating an analysis tool for Kenshi, i've reconstructed the data format used by the game data and save files. I'm putting it up here now so in case I never get around to finishing my project, this work will hopefully be useful to others.
   
奖励
收藏
已收藏
取消收藏
data_structure.txt
---- Kenshi Gamedata/Mod/Save File Format ---- Accurate as of 0.94.6 For gamedata.base, *.mod, quick.save, *.platoon, at least ---- Datatypes ---- L - 4 Byte int, probably signed C - 1 Byte character ? - 1 Btye boolean F - 4 Byte float String substructure [S: Name]: [L: StrLen] [C: Character] * StrLen Treating as UTF-8 seems reliable so far. ---- Header ---- [L: Filetype] -- 15 for game saved files, 16 for editor saved If filetype is 15: [L: NextID] -- One higher than max id number in file [L: RecordCount] If filetype is 16: [L: Mod Version] [S: Mod Author] [S: Mod Description] [S: Mod Dependencies] -- Comma Separated List [S: Mod References] -- Comma Separated List [L: Unknown] Possibly a flag set? It's in the range of 13 discrete values between 51428 and 54586 (25 samples) for all my data / mod files except one that I saved using the in-game editor (solely created to add a road to the road network), that one has a zero. A platoon file I edited with the FCS has a value of 385924. [L: RecordCount] ---- Record * RecordCount ---- [L: Instance Count Usually] Best guess, occasionally untrue [L: Typecode] From an internal enum, FCS shows INVENTORY_STATE etc [L: ID] Matches beginning of strid in type 15 files, always zero in type 16 files [S: Name] [S: StringID] [L: ModDataType] In type 15 files this should always be 0 In type 16 files this can have 3 values: -2147483646 -- This record is new in this mod -2147483647 -- This record is changed in this mod from a dependancy -2147483645 -- This record is changed as above and also its name has changed Honestly it's probably a flagset but these are the only values i've seen in all the datafiles I've processed. The next seven sections are all the fields that you see in the left side object editor panes in the FCS. All the grouping in there is done by the editor and isn't represented in the file. [L: Bool Fields Count] - For Count: [S: Key] [?: Value] If a record is deleted by a mod, the mod version will contain just one bool field: "REMOVED": True [L: Float Fields Count] - For Count: [S: Key] [F: Value] [L: Long Fields Count] - For Count: [S: Key] [L: Value] [L: Vec3f Fields Count] - For Count: [S: Key] [F: X] [F: Y] [F: Z] (Color or Position) [L: Vec4f Fields Count] - For Count: [S: Key] [F: W] [F: X] [F: Y] [F: Z] (Rotations) [L: String Fields Count] - For Count: [S: Key] [S: Value] [L: Filename Fields Count] - For Count: [S: Key] [S: Value] - No idea how this is different from strings The next two sections are things that show up in the right side editor panes [L: Extra Data Categories Count] - For count: [S: Category Name] [L: Category Item Count] - For count: [S: Item Name] [L: Val0] [L: Val1] [L: Val2] The values you see in the editor. If the entry is deleted in a mod, the deletion will be recorded by setting them all to 2147483647 [L: Instances Count] - For count: [S: Instance strID] [S: Instance Target] [F: tX] [F: tY] [F: tZ] [F: rW] [F: rX] [F: rY] [F: rZ] - posrot [L: Instance State Count] - For count: [S: StateName] ---- Last Value ---- In type 15 files, the last actual data after the records seems to be [L: Last record instances count], and the last record's leading instance count is the one that seems to be zero for some reason. ---- Tail ---- Type 15 files are followed by what seems to be a mostly-increasing stream of longs. Platoon files are have maybe 10, quick.save has more like 10,000. Possibly left over from memory dump saving? Type 16 files do not have any data after the last record. ---- Known record types ---- # These were found in saved data files 9: "NATURE", 21: "RESEARCH", 25: "STATS", 28: "BIOMES", 30: "INSTANCE_COLLECTION", 34: "PLATOON", 36: "GAMESTATE_CHARACTER", 37: "GAMESTATE_FACTION", 38: "GAMESTATE_TOWN_INSTANCE_LIST", 41: "INVENTORY_STATE", 42: "INVENTORY_ITEM_STATE", 56: "CAMERA", 57: "MEDICAL_STATE", 66: "CHARACTER_APPEARANCE", 67: "GAMESTATE_AI", 94: "GAMESTATE_TOWN", # These were found in gamedata.base 0: "BUILDING", 1: "CHARACTER", 2: "WEAPON", 3: "ARMOUR", 4: "ITEM", 5: "ANIMAL_ANIMATION", 6: "ATTACHMENT", 7: "RACE", 10: "FACTION", 13: "TOWN", 16: "LOCATIONAL_DAMAGE", 17: "COMBAT_TECHNIQUE", 18: "DIALOGUE", 19: "DIALOGUE_LINE", 22: "AI_TASK", 24: "ANIMATION", 26: "PERSONALITY", 27: "CONSTANTS", # Global Game Settings Button 29: "BUILDING_PART", 31: "DIALOG_ACTION", # Not findable in editor, name assumed 43: "REPEATABLE_BUILDING_PART_SLOT", 44: "MATERIAL_SPEC", 45: "MATERIAL_SPECS_COLLECTION", # *2 46: "CONTAINER", 47: "MATERIAL_SPECS_CLOTHING", 49: "VENDOR_LIST", 50: "MATERIAL_SPECS_WEAPON", 51: "WEAPON_MANUFACTURER", 52: "SQUAD_TEMPLATE", 53: "ROAD", # *1 55: "COLOR_DATA", 59: "FOLIAGE_LAYER", 60: "FOLIAGE_MESH", 61: "GRASS", 62: "BUILDING_FUNCTIONALITY", 63: "DAY_SCHEDULE", # *4 64: "NEW_GAME_STARTOFF", 68: "WILDLIFE_BIRDS", 69: "MAP_FEATURES", 70: "DIPLOMATIC_ASSAULTS", 71: "SINGLE_DIPLOMATIC_ASSAULT", 72: "AI_PACKAGE", 73: "DIALOGUE_PACKAGE", 74: "GUN_DATA", # found under ranged weapons, used for turrets 76: "ANIMAL_CHARACTER", 77: "UNIQUE_SQUAD_TEMPLATE", 78: "FACTION_TEMPLATE", 80: "WEATHER", 81: "SEASON", 82: "EFFECT", 83: "ITEM_PLACEMENT_GROUP", 84: "WORD_SWAPS", 86: "NEST_ITEM", 87: "CHARACTER_PHYSICS_ATTACHMENT", 88: "LIGHT", 89: "HEAD", 92: "FOLIAGE_BUILDING", 93: "FACTION_CAMPAIGN", 95: "BIOME_GROUP", 96: "EFFECT_FOG_VOLUME", 97: "FARM_DATA", 98: "FARM_PART", # *1 Found via references, is this used? # Doesn't exist with stdmods loaded # *2 Found in reference to 343-gamedata.base building material # Dosen't seem to be used o.o, but exists with stdmods # *3 Referneced to 370-gamedata.base building part # *4 Referenced to 611-gamedata.base building # Not sure if in stdmods # Found in newwworld.mod 99: "ENVIRONMENT_RESOURCES", # Found in rebirth.mod 100: "RACE_GROUP", 101: "ARTIFACTS", # From menu button 102: "MAP_ITEM", 103: "BUILDINGS_SWAP", 104: "ITEMS_CULTURE", 105: "ANIMATION_EVENT", 107: "CROSSBOW",
6 条留言
Wisp Cat 2022 年 11 月 16 日 下午 9:10 
How long is a record?
LMayDev 2021 年 3 月 23 日 下午 5:31 
It totally works with some fiddling!
LMayDev 2021 年 3 月 23 日 下午 1:42 
I've Solved it!
I just figured this out so I'm putting it here for anyone else who comes in from google.
"forgotten construction set.exe" is .Net assembly so you can just add a reference to it.
I haven't got it working yet but it's all there!
Looking at the GameData class currently.
I can't be the first person to realise this?
Depression 2020 年 1 月 1 日 上午 5:01 
Hey man, have you got anywhere with your project? I was thinking about setting up a data crawler on the FCS (to update the wiki) but apprently FCS is a shitty winforms application so all my UI automation knowledge is not really applicable here.
renecane 2018 年 3 月 9 日 上午 12:40 
Neat.