Sly 1:WS: Difference between revisions

From SlyMods
Jump to navigation Jump to search
Content added Content deleted
m (Added link)
Tags: Mobile edit Mobile web edit Visual edit
(Fix field type)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Infobox data structure
{{hatnote|This article is about the state of worlds in Sly 1. For the data structure that controls the game state in Sly 2 and 3, see [[DAG]].}}
| name= WS
| size= 0x44c
| official= y
| sly1= y
}}


'''WS''' ('''W'''orld '''S'''tate) is a data structure in Sly 1. It stores an array of [[LS|Level States]], one for each level in the world.
'''WS''' (world state) is a data structure in {{Sly 1}}. It is responsible for tracking the state of a particular [[gameworld]].


== Structure ==
== Fields ==
The WS struct is declared as follows:


The WS struct has the following fields:
{{todo|Add C++ struct declaration}}
{{Struct top}}
{{Struct field|offset=0x0|size=0x438|type=LS[9]|name=als|description=Level states array}}
{{Struct field|offset=0x438|size=4|type=int|name=ckey|description=Count of keys collected on world}}
{{Struct field|offset=0x43c|size=4|type=int|name=cvault|description=Count of vaults opened on world}}
{{Struct field|offset=0x440|size=4|type=int|name=ctimed|description=Count of MTSs completed on world}}
{{Struct field|offset=0x444|size=4|type=float|name=dt|description=Time spent in world}}
{{Struct field|offset=0x448|size=4|type=int|name=fws|description=World state flags}}
{{Struct bottom}}
<!--
<syntaxhighlight lang="c++">
struct WS {
struct LS als[9]; /* Level states array */
dword ckey; /* Count of keys collected on world */
dword cvault; /* Count of vaults opened on world */
dword ctimed; /* Count of MTS completed on world */
float dt; /* Time spent in world */
enum FWS fws; /* World state flags */
};
</syntaxhighlight>
-->


== World state flags ==
== Level states array ==
The current state of the world is defined by the FWS enum, which has the following possible values:


{{See also|Sly 1:LS}}
{{todo|Add the enum values}}
Each <code>WS</code> has an array of 9 <code>LS</code> structs, even if the world has fewer than 9 levels. The LS structs are always aligned in the <code>als</code> array so the indices are as follows:
* <code>als[0]</code>: Intro
* <code>als[1]</code>: Hub
* <code>als[2]</code> - <code>als[7]</code>: Platforming/minigames
* <code>als[8]</code>: Boss

World 1 and World 5 have fewer than 9 levels, so some some of the entries levels in their <code>als</code> arrays are blank/unused.

== World state flags (FWS) ==

The current state of the world is defined by the FWS enum, which has the following possible values:
{{Enum top}}
{{Enum value|FWS_Visited|0x1|World is unlocked and can be selected in {{Sly 1|The Hideout}}}}
{{Enum value|FWS_Lock_0|0x2|Corresponds to a particular {{Sly 1|LOCKG}} in the world being unlocked}}
{{Enum value|FWS_Lock_1|0x4|"}}
{{Enum value|FWS_Lock_2|0x8|"}}
{{Enum value|FWS_Lock_3|0x10|"}}
{{Enum value|GRFWS_Lock_All|0x1e|All of the locks in the world have been unlocked}}
{{Enum bottom}}


The <tt>fws</tt> acts as a bitfield and the game ORs the its value with the FWS enum values to check if a particular condition is met.
== Level states ==
Each WS stores an array of 9 LS structs, called <code>als</code>, even if the world has fewer than 9 levels (such as Worlds 0 and 5). In the case of an unused level, the corresponding level states are blank and ignored.


Note that the the order of locks is not the same for every world because each LOCKG independently decides which bit on the <code>fws</code> gets set when it gets unlocked.
The level states are always arranged in the <code>als</code> array so the indices are as follows:
* 0: Intro level
* 1: Hub level
* 2-8: Generic levels
* 9: Boss fight


== See also ==
Because World 5 has no hub level and fewer than 6 generic levels, it is the only World with gaps between levels in the <code>als</code> array.
* {{Sly 2|DAG}}


{{Navbox Sly 1}}
[[Category:Game mechanics]]
[[Category:Game mechanics in Sly 1]]

Latest revision as of 02:57, 26 September 2023

WS
Data Structure
GameSly Cooper and the Thievius Raccoonus
Size0x44c
Official NameYes

WS (world state) is a data structure in Sly Cooper and the Thievius Raccoonus. It is responsible for tracking the state of a particular gameworld.

Fields

The WS struct has the following fields:

Offset Size Type Name Notes
0x0 0x438
LS[9]
als Level states array
0x438 4
int
ckey Count of keys collected on world
0x43c 4
int
cvault Count of vaults opened on world
0x440 4
int
ctimed Count of MTSs completed on world
0x444 4
float
dt Time spent in world
0x448 4
int
fws World state flags

Level states array

Each WS has an array of 9 LS structs, even if the world has fewer than 9 levels. The LS structs are always aligned in the als array so the indices are as follows:

  • als[0]: Intro
  • als[1]: Hub
  • als[2] - als[7]: Platforming/minigames
  • als[8]: Boss

World 1 and World 5 have fewer than 9 levels, so some some of the entries levels in their als arrays are blank/unused.

World state flags (FWS)

The current state of the world is defined by the FWS enum, which has the following possible values:

Name Value Description
FWS_Visited 0x1 World is unlocked and can be selected in The Hideout
FWS_Lock_0 0x2 Corresponds to a particular LOCKG in the world being unlocked
FWS_Lock_1 0x4 "
FWS_Lock_2 0x8 "
FWS_Lock_3 0x10 "
GRFWS_Lock_All 0x1e All of the locks in the world have been unlocked

The fws acts as a bitfield and the game ORs the its value with the FWS enum values to check if a particular condition is met.

Note that the the order of locks is not the same for every world because each LOCKG independently decides which bit on the fws gets set when it gets unlocked.

See also