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
(Added struct declaration)
Line 4: Line 4:


== Structure ==
== Structure ==
The WS struct is declared as follows:
The WS struct is declared as follows:<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>


== Level states array ==
{{todo|Add C++ struct declaration}}
Each <code>WS</code> stores an array of 9 <code>LS</code> 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 state is blank and ignored.

The level states are always aligned in the <code>als</code> array so the indices are as follows:
* <code>als[0]</code>: Intro level
* <code>als[1]</code>: Hub level
* <code>als[2]</code> - <code>als[7]</code>: Generic levels
* <code>als[8]</code>: Boss fight

Because World 5 has no hub level and fewer than 6 generic levels, it is the only gameworld with gaps between levels in the <code>als</code> array.


== World state flags ==
== World state flags ==
The current state of the world is defined by the FWS enum, which has the following possible values:
The current state of the world is defined by the FWS enum, which has the following possible values:
{| class="wikitable"

|FWS_Visited
{{todo|Add the enum values}}
|0x1

|-
== Level states ==
|FWS_Lock_0
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.
|0x2

|-
The level states are always arranged in the <code>als</code> array so the indices are as follows:
|FWS_Lock_1
* 0: Intro level
|0x4
* 1: Hub level
|-
* 2-8: Generic levels
|FWS_Lock_2
* 9: Boss fight
|0x8

|-
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.
|FWS_Lock_3

|0x10
|-
|GRFWS_Lock_All
|0x1e
|}
[[Category:Game mechanics]]
[[Category:Game mechanics]]
[[Category:Game mechanics in Sly 1]]
[[Category:Game mechanics in Sly 1]]

Revision as of 04:43, 12 July 2022

WS (World State) is a data structure in Sly 1. It stores an array of Level States, one for each level in the world.

Structure

The WS struct is declared as follows:

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 */
};

Level states array

Each WS stores an array of 9 LS structs, called als, 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 state is blank and ignored.

The level states are always aligned in the als array so the indices are as follows:

  • als[0]: Intro level
  • als[1]: Hub level
  • als[2] - als[7]: Generic levels
  • als[8]: Boss fight

Because World 5 has no hub level and fewer than 6 generic levels, it is the only gameworld with gaps between levels in the als array.

World state flags

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

FWS_Visited 0x1
FWS_Lock_0 0x2
FWS_Lock_1 0x4
FWS_Lock_2 0x8
FWS_Lock_3 0x10
GRFWS_Lock_All 0x1e