archive

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package archive contains all the information that is stored in an archive file.

Index

Constants

View Source
const (

	// InventoryWeaponSlots is the number of weapons available to the character.
	InventoryWeaponSlots = 7

	// GrenadeTypeCount is the number of grenades (explosives) available to the character.
	GrenadeTypeCount = 7

	// GrenadeTimerMaximum is the maximum time that can be set for a grenade in game.
	GrenadeTimerMaximum = 571

	// PatchTypeCount is the number of patches available to the character.
	PatchTypeCount = 7

	// AmmoTypeCount is the number of types of ammo available to the character.
	AmmoTypeCount = 15

	// GeneralInventorySlotCount is the number of general inventory slots available.
	GeneralInventorySlotCount = 14

	// HardwareTypeCount is the number of available hardware.
	HardwareTypeCount = 15

	// SoftwareOffenseTypeCount is the number of available offense software.
	SoftwareOffenseTypeCount = 7
	// SoftwareDefenseTypeCount is the number of available defense software.
	SoftwareDefenseTypeCount = 3
	// SoftwareOneshotTypeCount is the number of available one-shot software.
	SoftwareOneshotTypeCount = 4

	// EMailCount is the number of available EMail status slots.
	EMailCount = 47
	// FragmentCount is the number of available fragment (data) status slots.
	FragmentCount = 23
	// PossibleLogsPerLevel is the number of logs slots available per level.
	PossibleLogsPerLevel = 16
	// LevelsWithLogs is the number of levels that can hold logs.
	LevelsWithLogs = 14
	// LogCount is the total number of logs available.
	LogCount = PossibleLogsPerLevel * LevelsWithLogs

	// BooleanVarCount is the number of available boolean variables.
	BooleanVarCount = 512

	// IntegerVarCount is the number of available integer variables.
	IntegerVarCount = 64
)
View Source
const GameStateSize = 0x0595

GameStateSize specifies the byte count of a the GameState in an archive. Note that in the original archive.dat file, the resource only has 0x054D bytes. This does not matter much, as in the original engine the resource was ignored.

View Source
const (
	// MaxLevels describes how many levels the world can hold.
	MaxLevels = 16
)

Variables

This section is empty.

Functions

func IsRandomIntegerVariable added in v1.5.0

func IsRandomIntegerVariable(index int) bool

IsRandomIntegerVariable returns true for the special variables that are randomized.

func IsSavegame added in v1.5.0

func IsSavegame(res resource.BlockProvider) bool

IsSavegame returns true for resources that most likely identify a savegame. This function must be called with a resource from ID 0x0FA1.

func ZeroGameStateData added in v1.5.0

func ZeroGameStateData() []byte

ZeroGameStateData returns the state block reset for default engine behaviour.

Types

type CountedSoftwareState added in v1.5.0

type CountedSoftwareState struct {
	Index int
	State *GameState
	// contains filtered or unexported fields
}

CountedSoftwareState describes software that is expended upon use.

func (CountedSoftwareState) Count added in v1.5.0

func (sw CountedSoftwareState) Count() int

Count returns the available amount of the software.

func (CountedSoftwareState) SetCount added in v1.5.0

func (sw CountedSoftwareState) SetCount(value int)

SetCount sets the installed amount of the software.

type EngineVariables added in v1.5.0

type EngineVariables struct{}

EngineVariables is a collector of engine-specific variable accessors.

func (EngineVariables) BooleanVariable added in v1.5.0

func (vars EngineVariables) BooleanVariable(index int) GameVariableInfo

BooleanVariable returns a variable info for given index.

func (EngineVariables) IntegerVariable added in v1.5.0

func (vars EngineVariables) IntegerVariable(index int) GameVariableInfo

IntegerVariable returns a variable info for given index.

type GameState added in v1.5.0

type GameState struct {
	*interpreters.Instance
}

GameState contains all the necessary information for the current progress of the game. It is a combination of world information, character information, and configuration values.

func DefaultGameState added in v1.5.0

func DefaultGameState() *GameState

DefaultGameState returns a GameState that can be used for any mission.

func NewGameState added in v1.5.0

func NewGameState(raw []byte) *GameState

NewGameState returns a GameState instance for given raw data.

func (GameState) BooleanVar added in v1.5.0

func (state GameState) BooleanVar(index int) bool

BooleanVar returns the state of the boolean variable at given index. Unsupported indices return 0.

func (GameState) CurrentLevel added in v1.5.0

func (state GameState) CurrentLevel() int

CurrentLevel returns the number of the level hacker is currently in.

func (*GameState) EMailState added in v1.5.0

func (state *GameState) EMailState(index int) MessageState

EMailState returns an accessor for the identified EMail status. Index should be within the range of [0..EMailCount[ .

func (*GameState) FragmentState added in v1.5.0

func (state *GameState) FragmentState(index int) MessageState

FragmentState returns an accessor for the identified fragment status. Index should be within the range of [0..FragmentCount[ .

func (*GameState) GeneralInventorySlot added in v1.5.0

func (state *GameState) GeneralInventorySlot(index int) GeneralInventorySlot

GeneralInventorySlot returns an accessor for the identified general slot. Index should be within the range of [0..GeneralInventorySlotCount[ .

func (GameState) HackerMapPosition added in v1.5.0

func (state GameState) HackerMapPosition() (level.Coordinate, level.Coordinate)

HackerMapPosition returns the rough X/Y location on the map.

func (*GameState) HackerName added in v1.5.0

func (state *GameState) HackerName(cp text.Codepage) string

HackerName returns the name interpreted with given codepage.

func (*GameState) HardwareState added in v1.5.0

func (state *GameState) HardwareState(index int) HardwareState

HardwareState returns an accessor for the identified hardware type index. Index should be within the range of [0..HardwareTypeCount[ .

func (*GameState) IntegerVar added in v1.5.0

func (state *GameState) IntegerVar(index int) int16

IntegerVar returns the value of the integer variable at given index. Unsupported indices return 0.

func (*GameState) InventoryAmmo added in v1.5.0

func (state *GameState) InventoryAmmo(index int) InventoryAmmo

InventoryAmmo returns an accessor for the identified ammo type index. Index should be within the range of [0..AmmoTypeCount[ .

func (*GameState) InventoryGrenade added in v1.5.0

func (state *GameState) InventoryGrenade(index int) InventoryGrenade

InventoryGrenade returns an accessor for the identified grenade type index. Index should be within the range of [0..GrenadeTypeCount[ .

func (*GameState) InventoryWeaponSlot added in v1.5.0

func (state *GameState) InventoryWeaponSlot(index int) InventoryWeaponSlot

InventoryWeaponSlot returns an accessor for the identified weapon slot. Index should be within the range of [0..InventoryWeaponSlots[.

func (*GameState) IsDefaulting added in v1.5.0

func (state *GameState) IsDefaulting() bool

IsDefaulting returns true if the state describes an archive from which the engine should initialize the state for a new game.

func (*GameState) IsSavegame added in v1.5.0

func (state *GameState) IsSavegame() bool

IsSavegame returns true if the state describes one during a running game.

func (*GameState) LogState added in v1.5.0

func (state *GameState) LogState(index int) MessageState

LogState returns an accessor for the identified log status. Index should be within the range of [0..LogCount[ .

func (*GameState) OneshotSoftwareState added in v1.5.0

func (state *GameState) OneshotSoftwareState(index int) CountedSoftwareState

OneshotSoftwareState returns an accessor for the identified software status. Index should be within the range of [0..SoftwareOneshotTypeCount[ .

func (*GameState) PatchState added in v1.5.0

func (state *GameState) PatchState(index int) PatchState

PatchState returns an accessor for the identified patch type index. Index should be within the range of [0..PatchTypeCount[ .

func (*GameState) SetBooleanVar added in v1.5.0

func (state *GameState) SetBooleanVar(index int, set bool)

SetBooleanVar sets the state of the boolean variable at given index. Unsupported indices are ignored.

func (*GameState) SetHackerName added in v1.5.0

func (state *GameState) SetHackerName(name string, cp text.Codepage)

SetHackerName stores the given name using given codepage, up to the internal available amount of bytes.

func (*GameState) SetIntegerVar added in v1.5.0

func (state *GameState) SetIntegerVar(index int, value int16)

SetIntegerVar sets the value of the integer variable at given index. Unsupported indices are ignored.

func (*GameState) VersionedDefenseSoftwareState added in v1.5.0

func (state *GameState) VersionedDefenseSoftwareState(index int) VersionedSoftwareState

VersionedDefenseSoftwareState returns an accessor for the identified versioned software status. Index should be within the range of [0..SoftwareDefenseTypeCount[ .

func (*GameState) VersionedOffenseSoftwareState added in v1.5.0

func (state *GameState) VersionedOffenseSoftwareState(index int) VersionedSoftwareState

VersionedOffenseSoftwareState returns an accessor for the identified versioned software status. Index should be within the range of [0..SoftwareOffenseTypeCount[ .

type GameVariableInfo added in v1.5.0

type GameVariableInfo struct {
	// InitValue is nil if the initial value is system dependent.
	InitValue *int16
	// Name is the short identifier for the variable.
	Name string
	// Description is an optional text with further information on the variable.
	Description string
	// Limits may be provided to describe the range of possible values.
	Limits *GameVariableLimits
	// ValueNames may be set for enumerated values.
	ValueNames map[int16]string
	// Hardcoded variables are fixed for a new game.
	Hardcoded bool
}

GameVariableInfo describes a variable in the game state of the archive.

func EngineBooleanVariable added in v1.5.0

func EngineBooleanVariable(index int) *GameVariableInfo

EngineBooleanVariable returns a variable info for boolean variables. If the given index is not used by the engine, nil is returned.

func EngineIntegerVariable added in v1.5.0

func EngineIntegerVariable(index int) *GameVariableInfo

EngineIntegerVariable returns a variable info for integer variables. If the given index is not used by the engine, nil is returned.

func GameVariableInfoFor added in v1.5.0

func GameVariableInfoFor(name string) GameVariableInfo

GameVariableInfoFor returns a new instance with given name.

func (GameVariableInfo) At added in v1.5.0

func (info GameVariableInfo) At(value int16) GameVariableInfo

At returns an information based on the current one, with the given initial value.

func (GameVariableInfo) Boolean added in v1.5.0

func (info GameVariableInfo) Boolean() GameVariableInfo

Boolean returns an enumerated information with No/Yes as possible values.

func (GameVariableInfo) DescribedAs added in v1.5.0

func (info GameVariableInfo) DescribedAs(text string) GameVariableInfo

DescribedAs returns an information with given text as description.

func (GameVariableInfo) Enumerated added in v1.5.0

func (info GameVariableInfo) Enumerated(names map[int16]string) GameVariableInfo

Enumerated returns an information with given value names.

func (GameVariableInfo) HardcodedAt added in v1.5.0

func (info GameVariableInfo) HardcodedAt(value int16) GameVariableInfo

HardcodedAt returns an information that is marked as being a hardcoded variable with given initial value.

func (GameVariableInfo) HardcodedConfig added in v1.5.0

func (info GameVariableInfo) HardcodedConfig() GameVariableInfo

HardcodedConfig returns an information that is marked as being a hardcoded initialized configuration value.

func (GameVariableInfo) LimitedBy added in v1.5.0

func (info GameVariableInfo) LimitedBy(min, max int16) GameVariableInfo

LimitedBy returns an information with given minimum and maximum values.

func (GameVariableInfo) ResetValueBool added in v1.7.0

func (info GameVariableInfo) ResetValueBool() bool

ResetValueBool returns the expected reset value for boolean variables.

func (GameVariableInfo) ResetValueInt added in v1.7.0

func (info GameVariableInfo) ResetValueInt() int16

ResetValueInt returns the expected reset value for integer variables.

type GameVariableInfoProvider added in v1.7.0

type GameVariableInfoProvider interface {
	IntegerVariable(index int) GameVariableInfo
	BooleanVariable(index int) GameVariableInfo
}

GameVariableInfoProvider provides lookup functionality for integer and boolean variables.

type GameVariableLimits added in v1.5.0

type GameVariableLimits struct {
	Minimum int16
	Maximum int16
}

GameVariableLimits describes limits of a game variable.

type GameVariables added in v1.5.0

type GameVariables map[int]GameVariableInfo

GameVariables is a lookup map for information on game variables.

func (GameVariables) Lookup added in v1.5.0

func (vars GameVariables) Lookup(index int) *GameVariableInfo

Lookup returns the information for given index. If the index is not known, nil is returned.

type GeneralInventorySlot added in v1.5.0

type GeneralInventorySlot struct {
	Index int
	State *GameState
}

GeneralInventorySlot describes properties of a general inventory slot.

func (GeneralInventorySlot) ObjectID added in v1.5.0

func (slot GeneralInventorySlot) ObjectID() level.ObjectID

ObjectID returns the ID of the object in this inventory slot.

func (GeneralInventorySlot) SetObjectID added in v1.8.0

func (slot GeneralInventorySlot) SetObjectID(id level.ObjectID)

SetObjectID updates the ID in this inventory slot.

type GrenadeTimerSetting added in v1.5.0

type GrenadeTimerSetting uint16

GrenadeTimerSetting is the value for explosive timers.

func (GrenadeTimerSetting) InSeconds added in v1.5.0

func (setting GrenadeTimerSetting) InSeconds() float32

InSeconds returns the amount in unit of seconds.

type HardwareState added in v1.5.0

type HardwareState struct {
	Index int
	State *GameState
}

HardwareState describes properties of hardware by type.

func (HardwareState) IsActive added in v1.5.0

func (hardware HardwareState) IsActive() bool

IsActive returns whether the hardware is currently active.

func (HardwareState) SetActive added in v1.5.0

func (hardware HardwareState) SetActive(on bool)

SetActive updates the active state of a hardware.

func (HardwareState) SetVersion added in v1.5.0

func (hardware HardwareState) SetVersion(value int)

SetVersion updates the version the character has installed.

func (HardwareState) Version added in v1.5.0

func (hardware HardwareState) Version() int

Version returns which version of the hardware is installed. Zero means not installed.

type InventoryAmmo added in v1.5.0

type InventoryAmmo struct {
	Index int
	State *GameState
}

InventoryAmmo describes properties of ammo by type.

func (InventoryAmmo) ExtraRoundsCount added in v1.5.0

func (ammo InventoryAmmo) ExtraRoundsCount() int

ExtraRoundsCount returns how many extra rounds the character is carrying.

func (InventoryAmmo) FullClipCount added in v1.5.0

func (ammo InventoryAmmo) FullClipCount() int

FullClipCount returns how many full clips the character is carrying.

func (InventoryAmmo) SetExtraRoundsCount added in v1.5.0

func (ammo InventoryAmmo) SetExtraRoundsCount(value int)

SetExtraRoundsCount updates the amount of extra rounds the character is carrying. Invalid values are clamped.

func (InventoryAmmo) SetFullClipCount added in v1.5.0

func (ammo InventoryAmmo) SetFullClipCount(value int)

SetFullClipCount updates the amount of full clips the character is carrying. Invalid values are clamped.

type InventoryGrenade added in v1.5.0

type InventoryGrenade struct {
	Index int
	State *GameState
}

InventoryGrenade describes properties of grenades by type.

func (InventoryGrenade) Count added in v1.5.0

func (grenade InventoryGrenade) Count() int

Count returns how many explosives the character is carrying.

func (InventoryGrenade) SetCount added in v1.5.0

func (grenade InventoryGrenade) SetCount(value int)

SetCount updates the amount of explosives the character is carrying. Invalid values are clamped.

func (InventoryGrenade) SetTimerSetting added in v1.5.0

func (grenade InventoryGrenade) SetTimerSetting(value GrenadeTimerSetting)

SetTimerSetting updates the generic timer used for this type of grenade.

func (InventoryGrenade) TimerSetting added in v1.5.0

func (grenade InventoryGrenade) TimerSetting() GrenadeTimerSetting

TimerSetting returns the generic timer used for this type of grenade.

type InventoryWeaponSlot added in v1.5.0

type InventoryWeaponSlot struct {
	Index int
	State *GameState
}

InventoryWeaponSlot describes one entry for weapons in the inventory.

func (InventoryWeaponSlot) IsInUse added in v1.5.0

func (slot InventoryWeaponSlot) IsInUse() bool

IsInUse returns true if the slot is currently holding a weapon.

func (InventoryWeaponSlot) SetFree added in v1.5.0

func (slot InventoryWeaponSlot) SetFree()

SetFree clears the weapon slot.

func (InventoryWeaponSlot) SetInUse added in v1.5.0

func (slot InventoryWeaponSlot) SetInUse(subclass object.Subclass, objType object.Type)

SetInUse inserts the given weapon in this slot. Other fields are reset to zero.

func (InventoryWeaponSlot) SetWeaponState added in v1.5.0

func (slot InventoryWeaponSlot) SetWeaponState(a, b byte)

SetWeaponState updates the two state values.

func (InventoryWeaponSlot) Triple added in v1.5.0

func (slot InventoryWeaponSlot) Triple() object.Triple

Triple returns the type information of the weapon in this slot.

func (InventoryWeaponSlot) WeaponState added in v1.5.0

func (slot InventoryWeaponSlot) WeaponState() (byte, byte)

WeaponState returns the two state values. Their interpretation is subclass specific.

type MessageState added in v1.5.0

type MessageState struct {
	Index int
	State *GameState
	// contains filtered or unexported fields
}

MessageState describes properties of message by index.

func (MessageState) Read added in v1.5.0

func (message MessageState) Read() bool

Read returns whether the given message was read.

func (MessageState) Received added in v1.5.0

func (message MessageState) Received() bool

Received returns whether the given message was received.

func (MessageState) SetRead added in v1.5.0

func (message MessageState) SetRead(value bool)

SetRead marks the read status of the message.

func (MessageState) SetReceived added in v1.5.0

func (message MessageState) SetReceived(value bool)

SetReceived marks the receive status of the message.

type PatchState added in v1.5.0

type PatchState struct {
	Index int
	State *GameState
}

PatchState describes properties of patches by type.

func (PatchState) Count added in v1.5.0

func (patch PatchState) Count() int

Count returns how many patches the character is carrying.

func (PatchState) SetCount added in v1.5.0

func (patch PatchState) SetCount(value int)

SetCount updates the amount of patches the character is carrying. Invalid values are clamped.

type VersionedSoftwareState added in v1.5.0

type VersionedSoftwareState struct {
	Index int
	State *GameState
	// contains filtered or unexported fields
}

VersionedSoftwareState describes software that is upgradeable (exists only once).

func (VersionedSoftwareState) SetVersion added in v1.5.0

func (sw VersionedSoftwareState) SetVersion(value int)

SetVersion sets the installed version number of the software.

func (VersionedSoftwareState) Version added in v1.5.0

func (sw VersionedSoftwareState) Version() int

Version returns the installed version number of the software. Zero means not installed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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