vm

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: 9 Imported by: 0

Documentation

Index

Constants

View Source
const MaxLevel = 713

MaxLevel is the highest achievable level in Elden Ring (all 8 stats at 99).

View Source
const PlayerGameDataOffset = 0x15420
View Source
const PresetFormatVersion = 1

Variables

This section is empty.

Functions

func ApplyVMToParsedSlot

func ApplyVMToParsedSlot(vm *CharacterViewModel, slot *core.SaveSlot) error

func ApplyVMToSlot

func ApplyVMToSlot(vm *CharacterViewModel, slotData []byte) error

func ApplyWorldState

func ApplyWorldState(slot *core.SaveSlot, world *WorldPresetData) []string

func ClearInventoryItems

func ClearInventoryItems(slot *core.SaveSlot) (int, error)

func ClearStorageItems

func ClearStorageItems(slot *core.SaveSlot) (int, error)

func PresetItemToFinalID

func PresetItemToFinalID(item PresetItem) uint32

func PresetItemsToItemsToAdd

func PresetItemsToItemsToAdd(items []PresetItem, isInventory bool) ([]core.ItemToAdd, []string)

func UpdateMatchmakingLevel

func UpdateMatchmakingLevel(slotData []byte, maxUpgrade uint8)

UpdateMatchmakingLevel scans the inventory and updates the matchmaking weapon level. Located at PlayerGameDataOffset + 0x93 (0x154B3).

func ValidatePreset

func ValidatePreset(preset *CharacterPreset) []string

Types

type AoWAvailabilityEntry added in v1.0.0

type AoWAvailabilityEntry struct {
	ItemID                  uint32   `json:"itemId"`
	TotalCopies             int      `json:"totalCopies"`
	AvailableCopies         int      `json:"availableCopies"`
	UsedCopies              int      `json:"usedCopies"`
	UsedByWeaponHandles     []uint32 `json:"usedByWeaponHandles"`
	IsMissing               bool     `json:"isMissing"`
	HasSharedHandleConflict bool     `json:"hasSharedHandleConflict"`
}

AoWAvailabilityEntry aggregates per-itemID availability for a single Ash of War. Returned by App.GetAoWAvailability; one entry per distinct AoW itemID present in the slot. AoW items absent from the slot have no entry — the frontend treats absence as IsMissing.

type ApplyOptions

type ApplyOptions struct {
	ReplaceStats     bool `json:"replaceStats"`
	ReplaceInventory bool `json:"replaceInventory"`
	ReplaceStorage   bool `json:"replaceStorage"`
	ReplaceWorld     bool `json:"replaceWorld"`
	KeepName         bool `json:"keepName"`
	KeepClass        bool `json:"keepClass"`
}

type CharacterPreset

type CharacterPreset struct {
	FormatVersion int                 `json:"formatVersion"`
	ExportedAt    string              `json:"exportedAt"`
	AppVersion    string              `json:"appVersion"`
	Character     CharacterPresetCore `json:"character"`
	Inventory     []PresetItem        `json:"inventory"`
	Storage       []PresetItem        `json:"storage"`
	AddSettings   *PresetAddSettings  `json:"addSettings,omitempty"`
	World         *WorldPresetData    `json:"world,omitempty"`
}

func VMToPreset

func VMToPreset(vm *CharacterViewModel, appVersion string) *CharacterPreset

type CharacterPresetCore

type CharacterPresetCore struct {
	Name          string `json:"name"`
	Class         uint8  `json:"class"`
	ClassName     string `json:"className"`
	Level         uint32 `json:"level"`
	Souls         uint32 `json:"souls"`
	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"`
	TalismanSlots uint8  `json:"talismanSlots"`
	ClearCount    uint32 `json:"clearCount"`
	MemoryStones  uint32 `json:"memoryStones"`
}

type CharacterViewModel

type CharacterViewModel struct {
	Name                string                `json:"name"`
	Level               uint32                `json:"level"`
	Souls               uint32                `json:"souls"`
	Class               uint8                 `json:"class"`
	ClassName           string                `json:"className"`
	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"`
	TalismanSlots       uint8                 `json:"talismanSlots"`
	ClearCount          uint32                `json:"clearCount"`
	ScadutreeBlessing   uint8                 `json:"scadutreeBlessing"`
	ShadowRealmBlessing uint8                 `json:"shadowRealmBlessing"`
	MemoryStones        uint32                `json:"memoryStones"`
	Gender              uint8                 `json:"gender"`
	SoulMemory          uint32                `json:"soulMemory"`
	Inventory           []ItemViewModel       `json:"inventory"`
	Storage             []ItemViewModel       `json:"storage"`
	Warnings            []string              `json:"warnings"`
	StatValidation      *StatValidationResult `json:"statValidation,omitempty"`
	EventFlagsAvailable bool                  `json:"eventFlagsAvailable"`
	ClassBaseStats      map[string]uint32     `json:"classBaseStats"`
}

func MapParsedSlotToVM

func MapParsedSlotToVM(slot *core.SaveSlot) (*CharacterViewModel, error)

func MapSlotToVM

func MapSlotToVM(slotData []byte) (*CharacterViewModel, error)

func PresetToVM

func PresetToVM(preset *CharacterPreset) *CharacterViewModel

func (*CharacterViewModel) ClampToClassMinimums

func (vm *CharacterViewModel) ClampToClassMinimums(classID uint8)

ClampToClassMinimums ensures no attribute is below the starting class minimum. If classID is unknown, only applies the global [1, 99] clamp.

func (*CharacterViewModel) RecalculateLevel

func (vm *CharacterViewModel) RecalculateLevel()

RecalculateLevel updates the character level based on current attributes. Formula: Level = Vigor + Mind + Endurance + Strength + Dexterity + Intelligence + Faith + Arcane - 79

func (*CharacterViewModel) ValidateStats

func (vm *CharacterViewModel) ValidateStats()

ValidateStats ensures all attributes are within legal game limits (1-99).

func (*CharacterViewModel) ValidateStatsConsistency

func (vm *CharacterViewModel) ValidateStatsConsistency(classID uint8) StatValidationResult

ValidateStatsConsistency performs class-aware validation of character stats. It checks:

  • Each attribute >= starting class base stat
  • Level == sum(attributes) - 79
  • Level in [1, 713]
  • Class ID is valid (0-9)

Returns validation result with errors (hard violations) and warnings (soft issues).

type ItemViewModel

type ItemViewModel struct {
	Handle           uint32   `json:"handle"`
	ID               uint32   `json:"id"`
	BaseID           uint32   `json:"baseId"`
	FamilyID         uint32   `json:"familyId"` // ownership/counting family override (Crimson/Cerulean flask +0 base); 0 = none
	Name             string   `json:"name"`
	Category         string   `json:"category"`    // broad type from handle prefix: "Weapon"/"Armor"/"Talisman"/"Item"/"Ash of War"
	SubCategory      string   `json:"subCategory"` // main game tab: "tools", "key_items", "melee_armaments", ...
	SubGroup         string   `json:"subGroup"`    // sub-grouping within tab: "Sacred Flasks", "Daggers", ...
	Quantity         uint32   `json:"quantity"`
	MaxInventory     uint32   `json:"maxInventory"`
	MaxStorage       uint32   `json:"maxStorage"`
	MaxUpgrade       uint32   `json:"maxUpgrade"`
	CurrentUpgrade   uint32   `json:"currentUpgrade"`
	IconPath         string   `json:"iconPath"`
	Flags            []string `json:"flags"`
	ReadOnly         bool     `json:"readOnly"`
	AoWID            uint32   `json:"aowId"`            // item ID of the AoW gem attached to this weapon (0 = none / not a weapon)
	CanMountAoW      bool     `json:"canMountAoW"`      // true iff gemMountType==2 (standard infusable weapon)
	WepType          uint16   `json:"wepType"`          // weapon category integer from EquipParamWeapon (0 for non-weapons)
	AoWCompatBitmask uint64   `json:"aowCompatBitmask"` // 36-bit canMountWep bitmask (non-zero for AoWs only)
}

type PresetAddSettings

type PresetAddSettings struct {
	Upgrade25            int  `json:"upgrade25"`
	Upgrade10            int  `json:"upgrade10"`
	InfuseOffset         int  `json:"infuseOffset"`
	UpgradeAsh           int  `json:"upgradeAsh"`
	TalismansHighestOnly bool `json:"talismansHighestOnly"`
}

type PresetApplyResult

type PresetApplyResult struct {
	StatsApplied bool     `json:"statsApplied"`
	WorldApplied bool     `json:"worldApplied"`
	ItemsAdded   int      `json:"itemsAdded"`
	ItemsSkipped int      `json:"itemsSkipped"`
	ItemsRemoved int      `json:"itemsRemoved"`
	Warnings     []string `json:"warnings"`
}

type PresetItem

type PresetItem struct {
	BaseID         uint32 `json:"baseId"`
	Name           string `json:"name"`
	Quantity       uint32 `json:"quantity"`
	CurrentUpgrade uint32 `json:"upgrade"`
	InfuseOffset   uint32 `json:"infuse,omitempty"`
}

type StatValidationResult

type StatValidationResult struct {
	Valid    bool     `json:"valid"`
	Errors   []string `json:"errors"`
	Warnings []string `json:"warnings"`
}

StatValidationResult holds the results of class-aware stat validation.

type WorldPresetData

type WorldPresetData struct {
	Graces         []uint32 `json:"graces,omitempty"`
	Bosses         []uint32 `json:"bosses,omitempty"`
	SummoningPools []uint32 `json:"summoningPools,omitempty"`
	Colosseums     []uint32 `json:"colosseums,omitempty"`
	MapFlags       []uint32 `json:"mapFlags,omitempty"`
	Cookbooks      []uint32 `json:"cookbooks,omitempty"`
	BellBearings   []uint32 `json:"bellBearings,omitempty"`
	Whetblades     []uint32 `json:"whetblades,omitempty"`
	Gestures       []uint32 `json:"gestures,omitempty"`
	Regions        []uint32 `json:"regions,omitempty"`
	WorldPickups   []uint32 `json:"worldPickups,omitempty"`
}

func ExportWorldState

func ExportWorldState(slot *core.SaveSlot) (*WorldPresetData, error)

Jump to

Keyboard shortcuts

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