db

package
v1.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ItemFlaskWondrousPhysickFilled uint32 = 0x400000FA
	ItemFlaskWondrousPhysickEmpty  uint32 = 0x400000FB

	// +0 family base rows for the two upgradeable Tears flasks. Each family
	// spans 13 odd level rows (base + level*2, level 0..12); the DB picker only
	// exposes the +0 row, so every upgraded variant must count under it.
	ItemFlaskCrimsonBase  uint32 = 0x400003E9
	ItemFlaskCeruleanBase uint32 = 0x4000041B
)

Variables

View Source
var InfuseTypes = []InfuseType{
	{"Standard", 0},
	{"Heavy", 100},
	{"Keen", 200},
	{"Quality", 300},
	{"Fire", 400},
	{"Flame Art", 500},
	{"Lightning", 600},
	{"Sacred", 700},
	{"Magic", 800},
	{"Cold", 900},
	{"Poison", 1000},
	{"Blood", 1100},
	{"Occult", 1200},
}

InfuseTypes lists all weapon infusion types in Elden Ring order.

View Source
var StartingClasses = map[uint8]ClassStats{
	0: {ID: 0, Name: "Vagabond", Level: 9, Vigor: 15, Mind: 10, Endurance: 11, Strength: 14, Dexterity: 13, Intelligence: 9, Faith: 9, Arcane: 7},
	1: {ID: 1, Name: "Warrior", Level: 8, Vigor: 11, Mind: 12, Endurance: 11, Strength: 10, Dexterity: 16, Intelligence: 10, Faith: 8, Arcane: 9},
	2: {ID: 2, Name: "Hero", Level: 7, Vigor: 14, Mind: 9, Endurance: 12, Strength: 16, Dexterity: 9, Intelligence: 7, Faith: 8, Arcane: 11},
	3: {ID: 3, Name: "Bandit", Level: 5, Vigor: 10, Mind: 11, Endurance: 10, Strength: 9, Dexterity: 13, Intelligence: 9, Faith: 8, Arcane: 14},
	4: {ID: 4, Name: "Astrologer", Level: 6, Vigor: 9, Mind: 15, Endurance: 9, Strength: 8, Dexterity: 12, Intelligence: 16, Faith: 7, Arcane: 9},
	5: {ID: 5, Name: "Prophet", Level: 7, Vigor: 10, Mind: 14, Endurance: 8, Strength: 11, Dexterity: 10, Intelligence: 7, Faith: 16, Arcane: 10},
	6: {ID: 6, Name: "Samurai", Level: 9, Vigor: 12, Mind: 11, Endurance: 13, Strength: 12, Dexterity: 15, Intelligence: 9, Faith: 8, Arcane: 8},
	7: {ID: 7, Name: "Prisoner", Level: 9, Vigor: 11, Mind: 12, Endurance: 11, Strength: 11, Dexterity: 14, Intelligence: 14, Faith: 6, Arcane: 9},
	8: {ID: 8, Name: "Confessor", Level: 10, Vigor: 10, Mind: 13, Endurance: 10, Strength: 12, Dexterity: 12, Intelligence: 9, Faith: 14, Arcane: 9},
	9: {ID: 9, Name: "Wretch", Level: 1, Vigor: 10, Mind: 10, Endurance: 10, Strength: 10, Dexterity: 10, Intelligence: 10, Faith: 10, Arcane: 10},
}

StartingClasses maps Class ID (0-9) to base stats. Source: Elden Ring game data (regulation.bin), cross-referenced with soulsmods.github.io and ClayAmore/EldenRingSaveTemplate.

Functions

func CanWeaponMountAoW added in v1.0.0

func CanWeaponMountAoW(baseItemID uint32) bool

CanWeaponMountAoW returns true if the weapon (by base item ID) supports standard AoW mounting (gemMountType == 2). Returns false for unique/somber weapons (gemMountType == 1) and weapons that cannot mount AoW at all (gemMountType == 0 or not found in data).

func FlaskFamilyBaseID added in v1.2.0

func FlaskFamilyBaseID(id uint32) (uint32, bool)

FlaskFamilyBaseID maps any Crimson/Cerulean Flask of Tears variant to its +0 family base (0x400003E9 / 0x4000041B). It accepts a raw item ID, a goods handle (0xB0…), or a technical even-ID "empty flask" variant already listed in data.TechnicalItemAliases — all of them resolve to the family the DB picker exposes, so upgraded flasks a save carries group under the +0 row for ownership/counting. This is a metadata-only grouping key; it never rewrites the raw inventory ID. Wondrous Physick is intentionally excluded — it is a distinct single-item flask handled by IsWondrousPhysick.

func GetAllQuestNPCs

func GetAllQuestNPCs() []string

func GetColosseumFlagSet added in v0.13.0

func GetColosseumFlagSet(id uint32) (data.ColosseumFlagSet, bool)

GetColosseumFlagSet returns the full companion flag set for the given colosseum activate flag ID. Returns false if id is not a known colosseum activate flag.

func GetEventFlag

func GetEventFlag(flags []byte, id uint32) (bool, error)

GetEventFlag checks if a specific event flag is set in the bit array. Resolution order:

  1. Precomputed lookup table (data.EventFlags) — exact byte/bit for known IDs.
  2. BST lookup (data.EventFlagBST) — block-based mapping from game's CSFD4VirtualMemoryFlag.
  3. Fallback formula: byte = id / 8, bit = 7 - (id % 8).

Returns error if the computed byte offset is out of bounds.

func GetItemCategoryFromHandle

func GetItemCategoryFromHandle(handle uint32) string

GetItemCategoryFromHandle returns the category string based on the GaItemHandle prefix.

func GetItemData

func GetItemData(id uint32) data.ItemData

GetItemData returns the full metadata of an item by its ID via the global index.

func GetItemDataFuzzy

func GetItemDataFuzzy(id uint32) (data.ItemData, uint32)

GetItemDataFuzzy returns item metadata for an exact ID, or falls back to:

  • Handle→ItemID conversion: for stackable items read from inventory (0xA0→0x20, 0xB0→0x40)
  • Spirit ashes: finds base (+0) entry so currentUpgrade can be computed from ID difference.
  • Upgraded/infused weapons: byte-masked base search for 0x00... weapon IDs.

The returned ItemData.Name is the base name without "+N" (caller appends "+N" if needed).

func GetItemName

func GetItemName(id uint32, category string) string

GetItemName returns the name of an item by its ID and category.

func GetItemSubCategory

func GetItemSubCategory(id uint32, item data.ItemData, broadCategory string) string

GetItemSubCategory returns the granular category string for an item.

func HandleToItemID

func HandleToItemID(handle uint32) uint32

HandleToItemID converts a GaItem handle prefix to the corresponding item ID prefix. Handles always use GaItem type prefixes (0x80/0x90/0xA0/0xB0/0xC0) while item IDs in the database use item type prefixes (0x00/0x10/0x20/0x40/0x80). For stackable items (talismans, goods) where handle=id with handle prefix, this recovers the DB-compatible item ID.

func IsAoWCompatibleWithWepType added in v1.0.0

func IsAoWCompatibleWithWepType(aowItemID uint32, wepType uint16) (compatible bool, known bool)

IsAoWCompatibleWithWepType returns (compatible, known). known=false means data is insufficient — the caller must block the operation, not assume compatibility. Reasons for known=false: AoW not in compat table (bitmask=0), or wepType not in WepTypeToCanMountBit.

func IsArrowID

func IsArrowID(id uint32) bool

IsArrowID returns true if the given item ID corresponds to an arrow or bolt. Arrows have 0x02.../0x03... item IDs (weapon subtype) but are stackable in inventory.

func IsAshOfWarCompatibleWithWeapon added in v1.0.0

func IsAshOfWarCompatibleWithWeapon(aowItemID uint32, weaponItemID uint32) (compatible bool, known bool)

IsAshOfWarCompatibleWithWeapon checks whether a specific Ash of War can be mounted on a specific weapon, combining the weapon-level GemMountType gate with the per-AoW bitmask check. Returns (compatible, known). known=false means data is insufficient; callers must block, not assume.

func IsKnownColosseumID added in v0.13.0

func IsKnownColosseumID(id uint32) bool

IsKnownColosseumID reports whether id is a recognised colosseum activate flag present in data.ColosseumFlagSets (60350, 60360, 60370).

func IsKnownGraceID added in v0.13.0

func IsKnownGraceID(id uint32) bool

IsKnownGraceID reports whether id is a recognised Site of Grace EventFlag ID in the current database (71000–76960, including DLC 72xxx and 74xxx).

func IsKnownMapFlagID added in v0.13.0

func IsKnownMapFlagID(id uint32) bool

IsKnownMapFlagID reports whether id is a recognised map flag ID across all four map datasets: MapVisible (62xxx), MapSystem (62xxx/82xxx), MapAcquired (63xxx), and MapUnsafe (62xxx/63xxx).

func IsKnownRegionID added in v0.13.0

func IsKnownRegionID(id uint32) bool

IsKnownRegionID reports whether id is part of the curated invasion-region allowlist (data.Regions) — the subset of regulation.bin PlayRegionParam rows that are valid standard invasion / blue-summon targets. It is membership-based, not range-based: the curated DLC IDs are non-contiguous, and many real PlayRegionParam rows (internal sub-areas, network-only rows) are deliberately excluded. Used to distinguish curated IDs from raw save-side region IDs.

func IsKnownSummoningPoolID added in v0.13.0

func IsKnownSummoningPoolID(id uint32) bool

IsKnownSummoningPoolID reports whether id is a recognised summoning pool flag in the current database (670xxx range, game >= v1.12).

func IsWondrousPhysick added in v1.0.0

func IsWondrousPhysick(id uint32) bool

IsWondrousPhysick reports whether id is either raw save-state variant of the single logical Flask of Wondrous Physick item.

func ItemIDToHandlePrefix

func ItemIDToHandlePrefix(id uint32) uint32

ItemIDToHandlePrefix returns the GaItem handle prefix for a given item ID. Item ID prefix (0x00/0x10/0x20/0x40/0x80) → handle prefix (0x80/0x90/0xA0/0xB0/0xC0).

func ItemIDToMagicParamID added in v1.0.0

func ItemIDToMagicParamID(itemID uint32) uint32

ItemIDToMagicParamID extracts the raw MagicParam ID from a full DB-style spell item ID by stripping the 4-bit type prefix (0x40000000 for both sorceries and incantations in this codebase). Example: Catch Flame 0x40001770 → raw 0x1770.

The 28-bit payload mask 0x0FFFFFFF mirrors ItemIDToHandlePrefix's 4-bit prefix convention — NOT a 16-bit mask. Spell IDs can carry payload bits above 0xFFFF (e.g. DLC sorceries with IDs in the high four-digit range once shifted), and a narrower mask would silently drop them.

The function is prefix-agnostic by design: callers (the Phase 7d.3 spells apply resolver) are expected to validate the prefix before invoking this helper. The Phase 7d.1 schema validator already rejects non-0x40 prefixes at template ingest time, so a templates → apply pipeline never feeds a non-spell ID through this conversion.

func SetEventFlag

func SetEventFlag(flags []byte, id uint32, value bool) error

SetEventFlag sets or clears a specific event flag in the bit array. Uses the same resolution order as GetEventFlag (lookup table → BST → fallback). Returns error if the computed byte offset is out of bounds.

func WondrousPhysickDisplayID added in v1.0.0

func WondrousPhysickDisplayID(id uint32) uint32

WondrousPhysickDisplayID returns the database item ID used for metadata. It does not imply the raw save item should be rewritten.

Types

type BellBearingEntry

type BellBearingEntry struct {
	ID       uint32 `json:"id"`
	Name     string `json:"name"`
	Category string `json:"category"` // "npc", "merchant", "smithing", "peddler", "dlc"
	Unlocked bool   `json:"unlocked"`
}

BellBearingEntry represents a bell bearing with its current state.

func GetAllBellBearings

func GetAllBellBearings() []BellBearingEntry

type BossEntry

type BossEntry struct {
	ID          uint32 `json:"id"`
	Name        string `json:"name"`
	Region      string `json:"region"`
	Type        string `json:"type"`        // "main" or "field"
	Remembrance bool   `json:"remembrance"` // drops Remembrance item
	Defeated    bool   `json:"defeated"`
}

BossEntry represents a boss encounter with defeat state.

func GetAllBosses

func GetAllBosses() []BossEntry

type ClassStats

type ClassStats struct {
	ID           uint8  `json:"id"`
	Name         string `json:"name"`
	Level        uint32 `json:"level"`
	Vigor        uint32 `json:"vigor"`
	Mind         uint32 `json:"mind"`
	Endurance    uint32 `json:"endurance"`
	Strength     uint32 `json:"strength"`
	Dexterity    uint32 `json:"dexterity"`
	Intelligence uint32 `json:"intelligence"`
	Faith        uint32 `json:"faith"`
	Arcane       uint32 `json:"arcane"`
}

ClassStats holds the base stats for a starting class in Elden Ring. These are used for stat consistency validation — no attribute can be edited below the starting class minimum, and Level must match the sum formula relative to the class starting level.

func GetAllClassStats added in v0.9.4

func GetAllClassStats() []ClassStats

GetAllClassStats returns all starting classes sorted by ID.

func GetClassStats

func GetClassStats(classID uint8) *ClassStats

GetClassStats returns the starting stats for a given class ID. Returns nil if the class ID is not recognized.

type ColosseumEntry

type ColosseumEntry struct {
	ID       uint32 `json:"id"`
	Name     string `json:"name"`
	Region   string `json:"region"`
	Unlocked bool   `json:"unlocked"`
}

ColosseumEntry represents a PvP colosseum with unlock state.

func GetAllColosseums

func GetAllColosseums() []ColosseumEntry

type CookbookEntry

type CookbookEntry struct {
	ID       uint32 `json:"id"` // event flag ID
	Name     string `json:"name"`
	Category string `json:"category"` // series name for grouping
	Unlocked bool   `json:"unlocked"`
}

CookbookEntry represents a cookbook with its unlock state.

func GetAllCookbooks

func GetAllCookbooks() []CookbookEntry

type GestureEntry

type GestureEntry struct {
	ID       uint32   `json:"id"`
	Name     string   `json:"name"`
	Category string   `json:"category"`
	Unlocked bool     `json:"unlocked"`
	Flags    []string `json:"flags"` // "cut_content" | "pre_order" | "dlc_duplicate" | "ban_risk"
}

GestureEntry represents a gesture with its unlock state.

func GetAllGestureSlots

func GetAllGestureSlots() []GestureEntry

type GraceEntry

type GraceEntry struct {
	ID          uint32 `json:"id"`
	Name        string `json:"name"`
	Region      string `json:"region"`
	Visited     bool   `json:"visited"`
	IsBossArena bool   `json:"isBossArena"`
	DungeonType string `json:"dungeonType,omitempty"`
}

GraceEntry represents a Site of Grace.

func GetAllGraces

func GetAllGraces() []GraceEntry

type InfuseType

type InfuseType struct {
	Name   string `json:"name"`
	Offset int    `json:"offset"`
}

InfuseType represents a weapon infusion type and its ID offset.

func GetInfuseTypes

func GetInfuseTypes() []InfuseType

GetInfuseTypes returns all weapon infusion types.

type ItemEntry

type ItemEntry struct {
	ID                    uint32            `json:"id"`
	Name                  string            `json:"name"`
	Category              string            `json:"category"`
	SubCategory           string            `json:"subCategory,omitempty"`
	MaxInventory          uint32            `json:"maxInventory"`
	MaxStorage            uint32            `json:"maxStorage"`
	GameMaxInventory      uint32            `json:"gameMaxInventory"`
	GameMaxStorage        uint32            `json:"gameMaxStorage"`
	GameMaxInventoryKnown bool              `json:"gameMaxInventoryKnown"`
	GameMaxStorageKnown   bool              `json:"gameMaxStorageKnown"`
	MaxUpgrade            uint32            `json:"maxUpgrade"`
	IconPath              string            `json:"iconPath"`
	Flags                 []string          `json:"flags"`
	Description           string            `json:"description,omitempty"`
	Location              string            `json:"location,omitempty"`
	Weight                float64           `json:"weight,omitempty"`
	Weapon                *data.WeaponStats `json:"weapon,omitempty"`
	Armor                 *data.ArmorStats  `json:"armor,omitempty"`
	Spell                 *data.SpellStats  `json:"spell,omitempty"`
	AoWCompatBitmask      uint64            `json:"aowCompatBitmask,omitempty"`
	// Text is the generated Phase 3B.1 text payload (display + canonical
	// name, caption, description, location, per-field provenance).
	// Read-only for the frontend; nil when the item ID has no ItemTexts
	// entry. Legacy Description / Location remain populated independently
	// so existing UI bindings keep working unchanged.
	Text *data.ItemTextData `json:"text,omitempty"`
	// Stats is the generated Phase 3C.3 stats payload. For weapon-like
	// items it wraps a copy of the WeaponStatsV1 record (kind="weapon");
	// for non-weapon items, or weapon-like items without a V1 entry, it
	// is nil. Legacy `Weapon` / `Armor` / `Spell` pointers remain
	// populated independently so existing UI bindings keep working
	// unchanged — Phase 3C.3 only adds a new payload field.
	Stats *data.ItemStatsData `json:"stats,omitempty"`
	// FlagID is the event flag ID used by World-tab unlock endpoints
	// (SetCookbookUnlocked, SetWhetbladeUnlocked, SetBellBearingUnlocked).
	// Zero for items managed via standard AddItemsToCharacter.
	FlagID uint32 `json:"flagId,omitempty"`
	// UnlockCategory identifies items whose add/remove must go through
	// the World-tab unlock endpoints instead of AddItemsToCharacter.
	// Values: "cookbook" | "whetblade" | "bell_bearing" | "" (standard).
	UnlockCategory string `json:"unlockCategory,omitempty"`
}

ItemEntry represents a single item from the game database.

func GetAllItems

func GetAllItems(platform string) []ItemEntry

GetAllItems returns all items from all categories for the given platform.

func GetItemEntryByID

func GetItemEntryByID(id uint32) *ItemEntry

GetItemEntryByID returns a fully enriched ItemEntry for the given base item ID, or nil if not found.

func GetItemsByCategory

func GetItemsByCategory(category, platform string) []ItemEntry

GetItemsByCategory returns a sorted list of items for a given category. The database stores only PC-style item IDs (0x00=weapon, 0x10=armor, 0x20=talisman, 0x40=goods, 0x80=AoW). Platform conversion to handle prefixes happens at runtime in AddItemsToSlot (writer.go) and MapParsedSlotToVM (character_vm.go).

type MapEntry

type MapEntry struct {
	ID       uint32 `json:"id"`
	Name     string `json:"name"`
	Area     string `json:"area"`
	Category string `json:"category"` // "visible", "acquired", "system"
	Enabled  bool   `json:"enabled"`
}

MapEntry represents a map region flag with its current state.

func GetAllMapEntries

func GetAllMapEntries() []MapEntry

type QuestFlagState

type QuestFlagState struct {
	ID      uint32 `json:"id"`
	Target  uint8  `json:"target"`  // expected value (0 or 1)
	Current bool   `json:"current"` // actual value in save
}

QuestFlagState is a flag with its target and current value.

type QuestNPC

type QuestNPC struct {
	Name  string      `json:"name"`
	Steps []QuestStep `json:"steps"`
}

QuestNPC represents an NPC with their quest progression.

type QuestStep

type QuestStep struct {
	Description string           `json:"description"`
	Location    string           `json:"location,omitempty"`
	Flags       []QuestFlagState `json:"flags"`
	Complete    bool             `json:"complete"` // all flags match target values
}

QuestStep represents one step in an NPC questline with current flag state.

type RegionEntry

type RegionEntry struct {
	ID       uint32 `json:"id"`
	Name     string `json:"name"`
	Area     string `json:"area"`
	Unlocked bool   `json:"unlocked"`
}

RegionEntry represents an "unlocked region" — controls invasion eligibility, blue summons, and the on-screen area label after teleport.

func GetAllRegions

func GetAllRegions() []RegionEntry

type SummoningPoolEntry

type SummoningPoolEntry struct {
	ID        uint32 `json:"id"`
	Name      string `json:"name"`
	Region    string `json:"region"`
	Activated bool   `json:"activated"`
}

SummoningPoolEntry represents a Martyr Effigy with activation state.

func GetAllSummoningPools

func GetAllSummoningPools() []SummoningPoolEntry

type WhetbladeEntry

type WhetbladeEntry struct {
	ID       uint32 `json:"id"`
	Name     string `json:"name"`
	Unlocked bool   `json:"unlocked"`
}

WhetbladeEntry represents a whetblade unlock with its current state.

func GetAllWhetblades

func GetAllWhetblades() []WhetbladeEntry

Directories

Path Synopsis
Code generated by scripts/parse_presets.go — DO NOT EDIT.
Code generated by scripts/parse_presets.go — DO NOT EDIT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL