wlmanip

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: MIT Imports: 9 Imported by: 3

README

wlmanip

High level library for modifying Wasteland MSQ blocks

Documentation

Index

Constants

View Source
const (
	SubLocationMin = 256

	SubLocationHighpoolCave            = 256
	SubLocationHighpoolCommunityCenter = 257
	SubLocationHighpoolWorkshop        = 258

	SubLocationAgCenterRootCellar = 259

	SubLocationDesertNomadsTent = 260

	SubLocationUglysHideoutAlley = 261

	SubLocationNeedlesBishopsOffice = 262
	SubLocationNeedlesGarage        = 263
	SubLocationNeedlesPoliceStation = 264
	SubLocationNeedlesAmmoBunker    = 265

	SubLocationDarwinBlackMarket     = 266
	SubLocationDarwinLab             = 267
	SubLocationDarwinBlackGilaTavern = 268

	SubLocationLasVegasJail         = 269
	SubLocationLasVegasProtonAxRoom = 270

	SubLocationSpadesCasinoWineCellar = 271
	SubLocationSpadesCasinoLevel2     = 272
	SubLocationSpadesCasinoBasement   = 273
)

Sub locations are areas within another map that should be considered separate.

Variables

IntraTransitions indicates which transitions should be considered as "intra". That is, transitions which take the player from one section to another of a single area.

View Source
var LocationDepthMap = map[int]int{
	defs.LocationWorldMap:                  0,
	defs.LocationQuartz:                    1,
	defs.LocationScottsBar:                 2,
	defs.LocationStageCoachInn:             2,
	defs.LocationUglysHideout:              2,
	defs.LocationQuartzDerelictBuildings:   2,
	defs.LocationCourthouse:                2,
	defs.LocationSleeperBaseLevel1:         1,
	defs.LocationDesertNomads:              1,
	defs.LocationAgCenter:                  1,
	defs.LocationHighpool:                  1,
	defs.LocationLasVegasDerelictBuildings: 2,
	defs.LocationLasVegas:                  1,
	defs.LocationSleeperBaseLevel2:         2,
	defs.LocationSleeperBaseLevel3:         2,
	defs.LocationBaseCochiseOutside:        2,
	defs.LocationBaseCochiseLevel1:         3,
	defs.LocationBaseCochiseLevel3:         3,
	defs.LocationBaseCochiseLevel2:         3,
	defs.LocationBaseCochiseLevel4:         3,
	defs.LocationDarwin:                    1,
	defs.LocationDarwinBase:                2,
	defs.LocationFinstersBrain:             2,
	defs.LocationLasVegasSewersWest:        3,
	defs.LocationLasVegasSewersEast:        3,
	defs.LocationNeedles:                   1,
	defs.LocationBloodTempleTop:            2,
	defs.LocationBloodTempleBottom:         2,
	defs.LocationVerminCave:                2,
	defs.LocationWastePit:                  2,
	defs.LocationNeedlesDowntownEast:       3,
	defs.LocationNeedlesDowntownWest:       3,
	defs.LocationPoliceStation:             2,
	defs.LocationGuardianCitadelEntrance:   2,
	defs.LocationGuardianCitadelOuter:      3,
	defs.LocationTempleMushroom:            2,
	defs.LocationFaranBrygos:               2,
	defs.LocationFatFreddys:                2,
	defs.LocationSpadesCasino:              2,
	defs.LocationGuardianCitadelInner:      3,
	defs.LocationMineShaft:                 1,
	defs.LocationSavageVillage:             1,

	SubLocationHighpoolCave:            2,
	SubLocationHighpoolCommunityCenter: 2,
	SubLocationHighpoolWorkshop:        2,
	SubLocationAgCenterRootCellar:      2,
	SubLocationDesertNomadsTent:        2,
	SubLocationUglysHideoutAlley:       2,
	SubLocationNeedlesBishopsOffice:    2,
	SubLocationNeedlesGarage:           2,
	SubLocationNeedlesPoliceStation:    2,
	SubLocationNeedlesAmmoBunker:       2,
	SubLocationDarwinBlackMarket:       2,
	SubLocationDarwinLab:               2,
	SubLocationDarwinBlackGilaTavern:   2,
	SubLocationLasVegasJail:            2,
	SubLocationLasVegasProtonAxRoom:    2,
	SubLocationSpadesCasinoWineCellar:  3,
	SubLocationSpadesCasinoLevel2:      3,
	SubLocationSpadesCasinoBasement:    3,
}

LocationDepthMap indicates the "depth" of each location in the game. The world map has a depth of 0; everything deeper has a greater depth. This is used when setting transition data. It doesn't make sense to replace a shallow-to-deep transition with a deep-to-shallow one. For example, Highpool-to-cave is a shallow-to-deep transition. It would be confusing if this were replaced by courthouse-to-quartz.

LocationPostSewersMap indicates which locations the player is expected to explore only after completing the sewers.

LocationReadXListMap contains blacklisted and whitelisted transitions.

View Source
var SubLocMap = map[SubLocDesc]defs.LocPair{

	SubLocDesc{0, defs.Block0Highpool, 1}: defs.LocPair{-1, SubLocationHighpoolCave},
	SubLocDesc{0, defs.Block0Highpool, 2}: defs.LocPair{SubLocationHighpoolCave, -1},
	SubLocDesc{0, defs.Block0Highpool, 3}: defs.LocPair{-1, SubLocationHighpoolCommunityCenter},
	SubLocDesc{0, defs.Block0Highpool, 4}: defs.LocPair{SubLocationHighpoolCommunityCenter, -1},
	SubLocDesc{0, defs.Block0Highpool, 5}: defs.LocPair{-1, SubLocationHighpoolWorkshop},
	SubLocDesc{0, defs.Block0Highpool, 6}: defs.LocPair{SubLocationHighpoolWorkshop, -1},

	SubLocDesc{0, defs.Block0AgCenter, 3}:   defs.LocPair{-1, SubLocationAgCenterRootCellar},
	SubLocDesc{0, defs.Block0VerminCave, 0}: defs.LocPair{SubLocationAgCenterRootCellar, -1},

	SubLocDesc{0, defs.Block0DesertNomads, 1}:  defs.LocPair{-1, SubLocationDesertNomadsTent},
	SubLocDesc{0, defs.Block0DesertNomads, 12}: defs.LocPair{-1, SubLocationDesertNomadsTent},
	SubLocDesc{0, defs.Block0DesertNomads, 13}: defs.LocPair{SubLocationDesertNomadsTent, -1},

	SubLocDesc{0, defs.Block0Quartz, 92}:      defs.LocPair{-1, SubLocationUglysHideoutAlley},
	SubLocDesc{0, defs.Block0UglysHideout, 1}: defs.LocPair{SubLocationUglysHideoutAlley, -1},

	SubLocDesc{0, defs.Block0Needles, 8}:       defs.LocPair{-1, SubLocationNeedlesBishopsOffice},
	SubLocDesc{0, defs.Block0PoliceStation, 6}: defs.LocPair{SubLocationNeedlesBishopsOffice, -1},
	SubLocDesc{0, defs.Block0Needles, 9}:       defs.LocPair{-1, SubLocationNeedlesPoliceStation},
	SubLocDesc{0, defs.Block0PoliceStation, 3}: defs.LocPair{SubLocationNeedlesPoliceStation, -1},
	SubLocDesc{0, defs.Block0Needles, 10}:      defs.LocPair{-1, SubLocationNeedlesGarage},
	SubLocDesc{0, defs.Block0PoliceStation, 2}: defs.LocPair{SubLocationNeedlesGarage, -1},
	SubLocDesc{0, defs.Block0Needles, 19}:      defs.LocPair{-1, SubLocationNeedlesAmmoBunker},
	SubLocDesc{0, defs.Block0WastePit, 5}:      defs.LocPair{SubLocationNeedlesAmmoBunker, -1},

	SubLocDesc{1, defs.Block1Darwin, 3}:  defs.LocPair{-1, SubLocationDarwinBlackMarket},
	SubLocDesc{1, defs.Block1Darwin, 1}:  defs.LocPair{SubLocationDarwinBlackMarket, -1},
	SubLocDesc{1, defs.Block1Darwin, 10}: defs.LocPair{SubLocationDarwinBlackMarket, -1},
	SubLocDesc{1, defs.Block1Darwin, 11}: defs.LocPair{SubLocationDarwinBlackMarket, -1},
	SubLocDesc{1, defs.Block1Darwin, 4}:  defs.LocPair{-1, SubLocationDarwinLab},
	SubLocDesc{1, defs.Block1Darwin, 2}:  defs.LocPair{SubLocationDarwinLab, -1},
	SubLocDesc{1, defs.Block1Darwin, 5}:  defs.LocPair{-1, SubLocationDarwinBlackGilaTavern},
	SubLocDesc{1, defs.Block1Darwin, 6}:  defs.LocPair{-1, SubLocationDarwinBlackGilaTavern},
	SubLocDesc{1, defs.Block1Darwin, 0}:  defs.LocPair{SubLocationDarwinBlackGilaTavern, -1},
	SubLocDesc{1, defs.Block1Darwin, 9}:  defs.LocPair{SubLocationDarwinBlackGilaTavern, -1},

	SubLocDesc{1, defs.Block1LasVegas, 1}:   defs.LocPair{-1, SubLocationLasVegasJail},
	SubLocDesc{1, defs.Block1FatFreddys, 6}: defs.LocPair{SubLocationLasVegasJail, defs.LocationLasVegas},
	SubLocDesc{1, defs.Block1LasVegas, 3}:   defs.LocPair{-1, SubLocationLasVegasProtonAxRoom},
	SubLocDesc{1, defs.Block1FatFreddys, 5}: defs.LocPair{SubLocationLasVegasProtonAxRoom,
		defs.LocationLasVegas},

	SubLocDesc{1, defs.Block1SpadesCasino, 1}: defs.LocPair{-1, SubLocationSpadesCasinoWineCellar},
	SubLocDesc{1, defs.Block1SpadesCasino, 2}: defs.LocPair{SubLocationSpadesCasinoWineCellar, -1},
	SubLocDesc{1, defs.Block1SpadesCasino, 3}: defs.LocPair{-1, SubLocationSpadesCasinoLevel2},
	SubLocDesc{1, defs.Block1SpadesCasino, 4}: defs.LocPair{SubLocationSpadesCasinoLevel2, -1},
	SubLocDesc{1, defs.Block1SpadesCasino, 7}: defs.LocPair{-1, SubLocationSpadesCasinoBasement},

	SubLocDesc{1, defs.Block1SpadesCasino, 5}: defs.LocPair{SubLocationSpadesCasinoBasement,
		defs.LocationSpadesCasino},
}

SubLocMap indicates which transitions actually lead to or from a sub location (as opposed to a regular location). A value of -1 represents the parent regular location.

View Source
var SubLocationNameMap = map[int]string{
	SubLocationHighpoolCave:            "HighpoolCave",
	SubLocationHighpoolCommunityCenter: "HighpoolCommunityCenter",
	SubLocationHighpoolWorkshop:        "HighpoolWorkshop",
	SubLocationAgCenterRootCellar:      "AgCenterRootCellar",
	SubLocationDesertNomadsTent:        "DesertNomadsTent",
	SubLocationUglysHideoutAlley:       "UglysHideoutAlley",
	SubLocationNeedlesBishopsOffice:    "NeedlesBishopsOffice",
	SubLocationNeedlesGarage:           "NeedlesGarage",
	SubLocationNeedlesPoliceStation:    "NeedlesPoliceStation",
	SubLocationNeedlesAmmoBunker:       "NeedlesAmmoBunker",
	SubLocationDarwinBlackMarket:       "DarwinBlackMarket",
	SubLocationDarwinLab:               "DarwinLab",
	SubLocationDarwinBlackGilaTavern:   "DarwinBlackGilaTavern",
	SubLocationLasVegasJail:            "LasVegasJail",
	SubLocationLasVegasProtonAxRoom:    "LasVegasProtonAxRoom",
	SubLocationSpadesCasinoWineCellar:  "SpadesCasinoWineCellar",
	SubLocationSpadesCasinoLevel2:      "SpadesCasinoLevel2",
	SubLocationSpadesCasinoBasement:    "SpadesCasinoBasement",
}

Functions

func CopyTrans

func CopyTrans(dst *action.Transition, src action.Transition)

CopyTrans replaces a destination transition with a source. A few fields in the destintion are preserved to maintain data integrity in the parent MSQ block.

func ExecTransOp

func ExecTransOp(coll *Collection, state *decode.DecodeState, op TransOp)

ExecTransOp modifies a pair of transitions according to the specified TransOp. It modifies a TransOp's first two transitions as follows:

1. A.From --> A.to BECOMES A.From --> B.to 2. A.From <-- A.to BECOMES A.From <-- B.to

func FixupTransitions

func FixupTransitions(state *decode.DecodeState) error

FixupTransitions converts some relative transitions to absolute. The transitions that it modifies are specified in a hardcoded list.

func LocationFullString

func LocationFullString(loc int) string

LocationFullString is an embellished form of LocationString.

func LocationString

func LocationString(loc int) string

LocationString produces a user-friendly string for the given location code. It accepts an exact location (i.e., either a regular location or a sub location).

func ParseLocation

func ParseLocation(s string) (int, error)

ParseLocation converts a string to an exact location code.

func ParseLocationNoCase

func ParseLocationNoCase(s string) (int, error)

ParseLocationNoCase converts a string to an exact location code, ignoring case.

func TransitionIsIntra

func TransitionIsIntra(lp defs.LocPair) bool

TransitionIsIntra indicates whether a transition is marked as "intra" (i.e., within the same general area).

Types

type CollectCfg

type CollectCfg struct {
	KeepWorld          bool
	KeepRelative       bool
	KeepShops          bool
	KeepDerelict       bool
	KeepPrevious       bool
	KeepAutoIntra      bool
	KeepHardcodedIntra bool
	KeepPostSewers     bool
}

CollectCfg specifies which transitions to keep and which to filter.

type Collection

type Collection struct {
	// contains filtered or unexported fields
}

Collection is the set of all usable transitions among all MSQ blocks. Elements in its slices can be modified, but none should be added or removed.

func Collect

func Collect(state decode.DecodeState, cfg CollectCfg) (*Collection, error)

Collect gathers the transitions from among all MSQ blocks and constructs a Collection.

func (*Collection) FilteredRoundTrips

func (c *Collection) FilteredRoundTrips() []defs.LocPair

FilteredRoundTrips retrieves the set of round trip transitions from the filtered list. Return trips are not included in the returned slice. In other words, x-->y is returned only if both x-->y and y-->x are present in the filtered list. In this case, ONLY x-->y is returned (not y-->x).

func (*Collection) Get1WayUp

func (c *Collection) Get1WayUp(from int) []*TransEntry

Get1WayUp retrieves the set of unfiltered transitions from the given location that have the following properties: 1. Lead to a lesser depth location, and 2. Are one way (no return trip).

func (*Collection) GetFiltered

func (c *Collection) GetFiltered(lp defs.LocPair) []*TransEntry

func (*Collection) GetUnfiltered

func (c *Collection) GetUnfiltered(lp defs.LocPair) []*TransEntry

type LocPairMap

type LocPairMap map[int]map[int][]*TransEntry

LocPairMap maintains the full set of transitions among all MSQ blocks. [exact-from-loc][exact-to-loc].

type SubLocDesc

type SubLocDesc struct {
	GameIdx  int
	BlockIdx int
	Selector int
}

type TransEntry

type TransEntry struct {
	FromBlock defs.BlockZIP
	FromLoc   int // Inexact (i.e., never a sub-location).
	Trans     action.Transition
	Selector  int

	FromExactLoc int
	ToExactLoc   int
}

TransEntry represents a single transition. It is annotated with some extra information that allows it to be used for replacing one transition with another.

type TransOp

type TransOp struct {
	A defs.LocPair
	B defs.LocPair
}

A TransOP is used to replace one transition with another. It consists of four transitions:

1. A.From --> A.To 2. A.From <-- A.To (A return trip) 3. B.From --> B.To 4. B.From <-- B.To (B return trip)

type TransXList

type TransXList struct {
	Black []int
	White []int
}

type TransXListPair

type TransXListPair struct {
	Read  TransXList
	Write TransXList
}

Jump to

Keyboard shortcuts

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