aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


server/gamedata/types.go (19123B)


      1 package gamedata
      2 
      3 import "slices"
      4 
      5 type ShopItem struct {
      6 	Template uint32 `yaml:"template"`
      7 	Quality  uint32 `yaml:"quality"`
      8 }
      9 
     10 type ShopMachine struct {
     11 	Template  uint32      `yaml:"template"`
     12 	Playfield uint32      `yaml:"playfield"`
     13 	Position  [3]float32  `yaml:"position"`
     14 	Rotation  [4]float32  `yaml:"rotation"`
     15 	Stats     [][2]uint32 `yaml:"stats,omitempty"`
     16 }
     17 
     18 type MissionBooth struct {
     19 	Template  uint32      `yaml:"template"`
     20 	Playfield uint32      `yaml:"playfield"`
     21 	Position  [3]float32  `yaml:"position"`
     22 	Stats     [][2]uint32 `yaml:"stats"`
     23 }
     24 
     25 type MissionTemplate struct {
     26 	Description   string             `yaml:"description"`
     27 	Playfield     uint32             `yaml:"playfield"`
     28 	Entrance      uint32             `yaml:"entrance"`
     29 	Position      [3]float32         `yaml:"position"`
     30 	ObjectiveItem uint32             `yaml:"objective_item"`
     31 	Credits       uint32             `yaml:"credits"` // Per mission level in recipes; concrete amount in offers.
     32 	RewardItem    uint32             `yaml:"-"`       // Concrete choice saved with an advertised contract.
     33 	RewardItems   []uint32           `yaml:"reward_items"`
     34 	RewardQuality uint32             `yaml:"reward_quality"` // Zero selects the mission level.
     35 	Encounters    []MissionEncounter `yaml:"encounters"`
     36 	PassageDoor   uint32             `yaml:"passage_door"`
     37 }
     38 
     39 type MissionEncounter struct {
     40 	Definition string       `yaml:"definition"`
     41 	Level      uint16       `yaml:"level"` // Zero selects the mission level.
     42 	Positions  [][3]float32 `yaml:"positions"`
     43 }
     44 
     45 type ItemCombination struct {
     46 	Result  uint32      `yaml:"result"`
     47 	Skills  [][2]uint32 `yaml:"skills,flow"`
     48 	Consume [2]bool     `yaml:"consume,flow"`
     49 }
     50 
     51 // Evidence retains provenance and uncertainty as searchable data.
     52 type Evidence struct {
     53 	Confidence string `yaml:"confidence"`
     54 	Comment    string `yaml:"comment"`
     55 }
     56 
     57 type NPCData struct {
     58 	Comment            string              `yaml:"comment"`
     59 	AppearanceStatuses map[string]Evidence `yaml:"appearance_statuses"`
     60 	PlacementStatuses  map[string]Evidence `yaml:"placement_statuses"`
     61 	LevelPolicy        Evidence            `yaml:"level_policy"`
     62 	Playfields         []NPCPlayfield      `yaml:"playfields"`
     63 }
     64 
     65 type NPCCombatProfile struct {
     66 	TemplateCodes  []string         `yaml:"template_codes,flow"`
     67 	Groups         []string         `yaml:"groups,omitempty"`
     68 	Health         uint32           `yaml:"health"`
     69 	Experience     uint32           `yaml:"experience"`
     70 	Skills         map[uint32]int32 `yaml:"skills"`
     71 	Modifiers      map[uint32]int32 `yaml:"modifiers"`
     72 	Weapon         [2]uint32        `yaml:"weapon,flow"`
     73 	Initiative     int32            `yaml:"initiative"`
     74 	AggDef         int32            `yaml:"agg_def"`
     75 	RespawnSeconds uint32           `yaml:"respawn_seconds"`
     76 	CorpseSeconds  uint32           `yaml:"corpse_seconds"`
     77 	Credits        [2]uint32        `yaml:"credits,flow"`
     78 	Loot           []NPCLoot        `yaml:"loot"`
     79 }
     80 
     81 type NPCLoot struct {
     82 	Template  uint32    `yaml:"template"`
     83 	Quality   [2]uint32 `yaml:"quality,flow"`
     84 	Chance    uint32    `yaml:"chance"`
     85 	Evidence  string    `yaml:"evidence"`
     86 	Inference string    `yaml:"inference"`
     87 }
     88 
     89 type LootPool struct {
     90 	Items        []uint32            `yaml:"items,flow"`
     91 	MinimumLevel uint16              `yaml:"minimum_level"`
     92 	FixedQuality bool                `yaml:"fixed_quality"`
     93 	Evidence     string              `yaml:"evidence"`
     94 	Inference    string              `yaml:"inference"`
     95 	Candidates   map[uint16][]uint32 `yaml:"-"`
     96 }
     97 
     98 type LootPoolRoll struct {
     99 	Pool   string `yaml:"pool"`
    100 	Chance uint32 `yaml:"chance"`
    101 }
    102 
    103 type LootTable struct {
    104 	Name   string         `yaml:"name"`
    105 	Groups []string       `yaml:"groups"`
    106 	Pools  []LootPoolRoll `yaml:"pools"`
    107 	Drops  []NPCLoot      `yaml:"drops"`
    108 }
    109 
    110 type NPCPlayfield struct {
    111 	Source    *NPCPopulationSource `json:"-" yaml:"source"`
    112 	ID        uint32               `yaml:"id"`
    113 	Name      string               `yaml:"name"`
    114 	Districts []NPCDistrict        `yaml:"districts"`
    115 }
    116 
    117 type NPCDistrict struct {
    118 	SourceIndex *int               `json:"-" yaml:"source_index,omitempty"`
    119 	Source      *NPCDistrictSource `json:"-" yaml:"-"`
    120 	Name        string             `yaml:"name"`
    121 	Groups      []NPCGroup         `yaml:"groups"`
    122 }
    123 
    124 // NPCGroup shares appearance and evidence across its authored spawn positions.
    125 // ID remains stable when YAML records are reordered and identifies Go behavior.
    126 type NPCGroup struct {
    127 	ID               string               `json:"id" yaml:"id"`
    128 	SourceIndex      *int                 `json:"-" yaml:"source_index,omitempty"`
    129 	Source           *NPCSpawnGroupSource `json:"-" yaml:"-"`
    130 	FixedSource      *NPCFixedSpawnSource `json:"-" yaml:"-"`
    131 	TemplateCode     string               `yaml:"template_code"`
    132 	Name             string               `yaml:"name"`
    133 	MonsterData      uint32               `yaml:"monster_data"`
    134 	StaticMesh       uint32               `yaml:"static_mesh,omitempty"`
    135 	Appearance       uint16               `yaml:"appearance"`
    136 	Visual           NPCVisual            `yaml:"visual,omitempty"`
    137 	ShopTemplate     uint32               `yaml:"shop_template,omitempty"`
    138 	Levels           [2]uint16            `yaml:"levels,flow"`
    139 	AppearanceStatus string               `yaml:"appearance_status"`
    140 	PlacementStatus  string               `yaml:"placement_status"`
    141 	Comment          string               `yaml:"comment"`
    142 	Positions        [][3]float32         `yaml:"positions"`
    143 }
    144 
    145 type NPCNameData struct {
    146 	Comment    string                         `yaml:"comment"`
    147 	Sources    map[string]string              `json:"sources" yaml:"sources"`
    148 	Templates  map[string]NPCTemplateEvidence `json:"templates" yaml:"templates"`
    149 	Playfields map[uint32]NPCNameMapping      `json:"playfields" yaml:"playfields"`
    150 }
    151 
    152 // Template evidence can identify a name without establishing an appearance.
    153 type NPCTemplateEvidence struct {
    154 	Name         string `json:"name" yaml:"name"`
    155 	MonsterData  uint32 `json:"monster_data,omitempty" yaml:"monster_data,omitempty"`
    156 	StaticMesh   uint32 `json:"static_mesh,omitempty" yaml:"static_mesh,omitempty"`
    157 	ItemTemplate uint32 `json:"item_template,omitempty" yaml:"item_template,omitempty"`
    158 	Confidence   string `json:"confidence" yaml:"confidence"`
    159 	Source       string `json:"source" yaml:"source"`
    160 	Comment      string `json:"comment" yaml:"comment"`
    161 }
    162 
    163 // An explicit template binding can admit a reviewed uncertain appearance.
    164 // Species-wide profiles never follow best-effort or placeholder bodies.
    165 func (group *NPCGroup) SupportsCombatProfile(monster uint32, profile *NPCCombatProfile) bool {
    166 	if profile == nil || group.MonsterData != monster {
    167 		return false
    168 	}
    169 	if len(profile.Groups) != 0 && !slices.Contains(profile.Groups, group.ID) {
    170 		return false
    171 	}
    172 	if len(profile.TemplateCodes) != 0 {
    173 		return slices.Contains(profile.TemplateCodes, group.TemplateCode) &&
    174 			(group.AppearanceStatus == "inferred_species" || group.AppearanceStatus == "best_effort")
    175 	}
    176 	return group.AppearanceStatus == "inferred_species"
    177 }
    178 
    179 type NPCNameMapping struct {
    180 	Confidence string            `json:"confidence" yaml:"confidence"`
    181 	Source     string            `json:"source" yaml:"source"`
    182 	Comment    string            `json:"comment" yaml:"comment"`
    183 	Names      map[string]string `json:"names" yaml:"names"`
    184 }
    185 
    186 // Source records retain authored values independently of reconstructed gameplay.
    187 type NPCPopulationSource struct {
    188 	Version           uint16              `json:"version" yaml:"version"`
    189 	Districts         []NPCDistrictSource `json:"districts" yaml:"districts"`
    190 	ZoneToDistrictMap []uint16            `json:"zone_to_district_map" yaml:"zone_to_district_map"`
    191 	Playfield         uint32              `json:"playfield" yaml:"playfield"`
    192 	Name              string              `json:"name" yaml:"name"`
    193 	RecordFileOffset  uint64              `json:"record_file_offset" yaml:"record_file_offset"`
    194 	Comment           string              `json:"comment,omitempty" yaml:"comment,omitempty"`
    195 	PayloadSHA256     string              `json:"-" yaml:"payload_sha256"`
    196 }
    197 
    198 type NPCDistrictSource struct {
    199 	PayloadOffset     uint32                `json:"payload_offset" yaml:"payload_offset"`
    200 	Center            [3]float64            `json:"center" yaml:"center"`
    201 	Name              string                `json:"name" yaml:"name"`
    202 	Stats             [9]uint16             `json:"stats" yaml:"stats"`
    203 	Extras            string                `json:"extras,omitempty" yaml:"extras,omitempty"`
    204 	NPCMinLevel       uint16                `json:"npc_min_level" yaml:"npc_min_level"`
    205 	NPCMaxLevel       uint16                `json:"npc_max_level" yaml:"npc_max_level"`
    206 	LandControlLevels *[2]uint16            `json:"land_control_levels,omitempty" yaml:"land_control_levels,omitempty"`
    207 	RespawnChance     uint8                 `json:"respawn_chance" yaml:"respawn_chance"`
    208 	RespawnTime       int32                 `json:"respawn_time" yaml:"respawn_time"`
    209 	FightMode         uint8                 `json:"fight_mode" yaml:"fight_mode"`
    210 	SpawnGroups       []NPCSpawnGroupSource `json:"spawn_groups" yaml:"spawn_groups"`
    211 	ExtraInfos        []string              `json:"extra_infos" yaml:"extra_infos"`
    212 	MusicPairs        [][2]uint16           `json:"music_pairs" yaml:"music_pairs"`
    213 	SpawnPoints       [][4]float64          `json:"spawn_points" yaml:"spawn_points"`
    214 	FixedSpawns       []NPCFixedSpawnSource `json:"fixed_spawns" yaml:"fixed_spawns"`
    215 }
    216 
    217 type NPCSpawnGroupSource struct {
    218 	TemplateHash string `json:"template_hash" yaml:"template_hash"`
    219 	Count        uint16 `json:"count" yaml:"count"`
    220 }
    221 
    222 type NPCFixedSpawnSource struct {
    223 	PayloadOffset uint32     `json:"payload_offset" yaml:"payload_offset"`
    224 	Position      [3]float64 `json:"position" yaml:"position"`
    225 	Radius        float64    `json:"radius" yaml:"radius"`
    226 	Angles        [2]int16   `json:"angles" yaml:"angles"`
    227 	TemplateHash  string     `json:"template_hash" yaml:"template_hash"`
    228 	MinLevel      uint16     `json:"min_level" yaml:"min_level"`
    229 	MaxLevel      uint16     `json:"max_level" yaml:"max_level"`
    230 	RespawnChance uint8      `json:"respawn_chance" yaml:"respawn_chance"`
    231 	Flags         uint8      `json:"flags" yaml:"flags"`
    232 	RespawnTime   uint16     `json:"respawn_time" yaml:"respawn_time"`
    233 	OptionalFlags *[4]uint8  `json:"optional_flags,omitempty" yaml:"optional_flags,omitempty"`
    234 }
    235 
    236 type NPCExtractionEvidence struct {
    237 	Version        string            `json:"version" yaml:"version"`
    238 	Client         string            `json:"client" yaml:"client"`
    239 	IndexSHA256    string            `json:"index_sha256" yaml:"index_sha256"`
    240 	PayloadSHA256  map[uint32]string `json:"payload_sha256" yaml:"payload_sha256"`
    241 	FormatVersions map[uint16]uint32 `json:"format_versions" yaml:"format_versions"`
    242 	Districts      uint32            `json:"districts" yaml:"districts"`
    243 	SpawnGroups    uint32            `json:"spawn_groups" yaml:"spawn_groups"`
    244 	FixedSpawns    uint32            `json:"fixed_spawns" yaml:"fixed_spawns"`
    245 	Checks         []string          `json:"checks" yaml:"checks"`
    246 	Reference      string            `json:"reference" yaml:"reference"`
    247 }
    248 
    249 type Monster struct {
    250 	MonsterData      uint32            `json:"monster_data" yaml:"monster_data"`
    251 	Name             string            `json:"name" yaml:"name"`
    252 	Mesh             uint32            `json:"mesh" yaml:"mesh"`
    253 	MeshFilename     *string           `json:"mesh_filename" yaml:"mesh_filename"`
    254 	DeathAnimations  []uint32          `json:"death_animations,omitempty" yaml:"death_animations,omitempty"`
    255 	Stats            map[uint32]uint32 `json:"stats" yaml:"stats"`
    256 	RecordFileOffset uint64            `json:"record_file_offset" yaml:"record_file_offset"`
    257 	Comment          string            `json:"comment,omitempty" yaml:"comment,omitempty"`
    258 }
    259 
    260 type ItemCatalog struct {
    261 	Evidence     ItemExtractionEvidence `json:"-" yaml:"evidence"`
    262 	Client       string                 `json:"client" yaml:"client"`
    263 	Version      string                 `json:"version" yaml:"version"`
    264 	IndexSHA256  string                 `json:"index_sha256" yaml:"index_sha256"`
    265 	TextEncoding string                 `json:"text_encoding" yaml:"text_encoding"`
    266 	Items        []Item                 `json:"items" yaml:"items"`
    267 	Coverage     ExtractionCoverage     `json:"coverage" yaml:"coverage"`
    268 }
    269 
    270 type ExtractionCoverage struct {
    271 	RecordCounts     map[uint32]uint32 `json:"record_counts" yaml:"record_counts"`
    272 	UndecodedReasons map[string]uint32 `json:"undecoded_reasons" yaml:"undecoded_reasons"`
    273 }
    274 
    275 type Item struct {
    276 	RecordType       uint32             `json:"record_type" yaml:"record_type"`
    277 	ID               uint32             `json:"id" yaml:"id"`
    278 	PayloadSHA256    string             `json:"payload_sha256" yaml:"payload_sha256"`
    279 	HeaderWords      [4]uint32          `json:"header_words" yaml:"header_words"`
    280 	Stats            ItemStats          `json:"stats" yaml:"stats"`
    281 	Quality          *uint32            `json:"quality" yaml:"quality"`
    282 	TextHeader       [2]uint32          `json:"text_header" yaml:"text_header"`
    283 	Name             string             `json:"name" yaml:"name"`
    284 	Description      string             `json:"description" yaml:"description"`
    285 	Sections         []ItemSection      `json:"sections" yaml:"sections"`
    286 	RecordFileOffset uint64             `json:"record_file_offset" yaml:"record_file_offset"`
    287 	Undecoded        *UndecodedItemData `json:"undecoded,omitempty" yaml:"undecoded,omitempty"`
    288 	Comment          string             `json:"comment,omitempty" yaml:"comment,omitempty"`
    289 }
    290 
    291 type UndecodedItemData struct {
    292 	Offset   uint32 `json:"offset" yaml:"offset"`
    293 	Reason   string `json:"reason" yaml:"reason"`
    294 	BytesHex string `json:"bytes_hex" yaml:"bytes_hex"`
    295 }
    296 
    297 type ItemSection struct {
    298 	Type      uint32          `json:"type" yaml:"type"`
    299 	Subtype   uint32          `json:"subtype" yaml:"subtype"`
    300 	Entries   *[]ItemEntry    `json:"entries,omitempty" yaml:"entries,omitempty"`
    301 	Stats     *[][2]uint32    `json:"stats,omitempty" yaml:"stats,omitempty"`
    302 	Functions *[]ItemFunction `json:"functions,omitempty" yaml:"functions,omitempty"`
    303 	Actions   *[]ItemAction   `json:"actions,omitempty" yaml:"actions,omitempty"`
    304 	Offset    uint32          `json:"offset" yaml:"offset"`
    305 	Size      uint32          `json:"size" yaml:"size"`
    306 }
    307 
    308 type ItemEntry struct {
    309 	Type     *uint32      `json:"type,omitempty" yaml:"type,omitempty"`
    310 	Stats    *[][2]uint32 `json:"stats,omitempty" yaml:"stats,omitempty"`
    311 	Values   *[]uint32    `json:"values,omitempty" yaml:"values,omitempty"`
    312 	Code     *string      `json:"code,omitempty" yaml:"code,omitempty"`
    313 	BytePair *[2]uint8    `json:"byte_pair,omitempty" yaml:"byte_pair,omitempty"`
    314 	BytesHex *string      `json:"bytes_hex,omitempty" yaml:"bytes_hex,omitempty"`
    315 }
    316 
    317 type ItemAction struct {
    318 	Type         uint32            `json:"type" yaml:"type"`
    319 	Requirements []ItemRequirement `json:"requirements" yaml:"requirements"`
    320 }
    321 
    322 type ItemRequirement struct {
    323 	Stat     int32 `json:"stat" yaml:"stat"`
    324 	Value    int32 `json:"value" yaml:"value"`
    325 	Operator int32 `json:"operator" yaml:"operator"`
    326 }
    327 
    328 type ItemFunction struct {
    329 	ID             uint32            `json:"id" yaml:"id"`
    330 	HeaderWords    [2]uint32         `json:"header_words" yaml:"header_words"`
    331 	Requirements   []ItemRequirement `json:"requirements" yaml:"requirements"`
    332 	TickCount      uint32            `json:"tick_count" yaml:"tick_count"`
    333 	TickInterval   uint32            `json:"tick_interval" yaml:"tick_interval"`
    334 	Target         uint32            `json:"target" yaml:"target"`
    335 	ArgumentHeader uint32            `json:"argument_header" yaml:"argument_header"`
    336 	Arguments      []ItemArgument    `json:"arguments" yaml:"arguments"`
    337 }
    338 
    339 type ItemArgument struct {
    340 	Integer  *int32  `json:"integer,omitempty" yaml:"integer,omitempty"`
    341 	BytesHex *string `json:"bytes_hex,omitempty" yaml:"bytes_hex,omitempty"`
    342 	String   *string `json:"string,omitempty" yaml:"string,omitempty"`
    343 	Code     *string `json:"code,omitempty" yaml:"code,omitempty"`
    344 }
    345 
    346 type ItemExtractionEvidence struct {
    347 	Client             string             `json:"client" yaml:"client"`
    348 	Version            string             `json:"version" yaml:"version"`
    349 	IndexSHA256        string             `json:"index_sha256" yaml:"index_sha256"`
    350 	TextEncoding       string             `json:"text_encoding" yaml:"text_encoding"`
    351 	Coverage           ExtractionCoverage `json:"coverage" yaml:"coverage"`
    352 	CatalogSHA256      string             `json:"catalog_sha256" yaml:"catalog_sha256"`
    353 	CatalogBytes       uint64             `json:"catalog_bytes" yaml:"catalog_bytes"`
    354 	FullyFramedRecords uint32             `json:"fully_framed_records" yaml:"fully_framed_records"`
    355 	EmptyNames         uint32             `json:"empty_names" yaml:"empty_names"`
    356 	SectionCounts      map[uint32]uint32  `json:"section_counts" yaml:"section_counts"`
    357 }
    358 
    359 type MapCoordinateData struct {
    360 	PlanetBounds [4]int32            `json:"planet_bounds" yaml:"planet_bounds"`
    361 	Playfields   map[uint32][2]int32 `json:"playfields" yaml:"playfields"`
    362 	Source       MapCoordinateSource `json:"source" yaml:"source"`
    363 }
    364 
    365 type MapCoordinateSource struct {
    366 	Module             string   `json:"module" yaml:"module"`
    367 	SHA256             string   `json:"sha256" yaml:"sha256"`
    368 	OriginsConstructor string   `json:"origins_constructor" yaml:"origins_constructor"`
    369 	MarkerTransform    string   `json:"marker_transform" yaml:"marker_transform"`
    370 	Evidence           []string `json:"evidence" yaml:"evidence"`
    371 }
    372 
    373 type TerrainExtractionEvidence struct {
    374 	ClientVersion             string                `json:"client_version" yaml:"client_version"`
    375 	SourceIndexSHA256         string                `json:"source_index_sha256" yaml:"source_index_sha256"`
    376 	TerrainFileSHA256         string                `json:"terrain_file_sha256" yaml:"terrain_file_sha256"`
    377 	Decoded                   []TerrainGridEvidence `json:"decoded" yaml:"decoded"`
    378 	RecordsWithoutHeightTable []uint32              `json:"records_without_height_table" yaml:"records_without_height_table"`
    379 	Checks                    []string              `json:"checks" yaml:"checks"`
    380 }
    381 
    382 type TerrainGridEvidence struct {
    383 	Playfield              uint32   `json:"playfield" yaml:"playfield"`
    384 	Width                  uint32   `json:"width" yaml:"width"`
    385 	Height                 uint32   `json:"height" yaml:"height"`
    386 	DisplayWidth           uint32   `json:"display_width" yaml:"display_width"`
    387 	DisplayHeight          uint32   `json:"display_height" yaml:"display_height"`
    388 	Spacing                float64  `json:"spacing" yaml:"spacing"`
    389 	HeightScale            float64  `json:"height_scale" yaml:"height_scale"`
    390 	Chunks                 uint32   `json:"chunks" yaml:"chunks"`
    391 	BlockCells             uint32   `json:"block_cells" yaml:"block_cells"`
    392 	GridSHA256             string   `json:"grid_sha256" yaml:"grid_sha256"`
    393 	CoarseCornerMismatches []uint32 `json:"coarse_corner_mismatches" yaml:"coarse_corner_mismatches"`
    394 }
    395 
    396 type Playfield struct {
    397 	Name        string     `yaml:"name"`
    398 	Outdoor     bool       `yaml:"outdoor,omitempty"`
    399 	Origin      [2]uint32  `yaml:"origin"`
    400 	Spawn       [3]float32 `yaml:"spawn"`
    401 	Unavailable bool       `yaml:"unavailable"`
    402 }