Sly 1:LS: Difference between revisions

From SlyMods
Jump to navigation Jump to search
Content added Content deleted
(Updated hatnote)
Tags: Mobile edit Mobile web edit Visual edit
(Expanded article)
Line 3: Line 3:


== Structure ==
== Structure ==
The structure of LS is as follows:
The LS struct is defined as follows:<syntaxhighlight lang="c++">
struct LS {
enum FLS fls; /* Level state flags */
float dt; /* Time spent in level (secs) */
float dtTimedBest; /* Best MTS time for level */
float uSuck; /* Current player suck value for level */
float suck_field_0x10; /* Unknown value, related to uSuck */
int afDialogPlayed[12]; /* Dialog played flags */
struct SceneVar a_scene_vars[4]; /* Scene variables */
int cclue; /* Count of bottles collected */
uint fclue; /* Flags marking which bottles have been collected */
undefined4 field_0x6c; /* Unknown */
int field_0x70; /* Unknown */
byte * unk_ptr_0x74; /* Unknown ptr to 1-byte value */
};
</syntaxhighlight>


== Level state flags ==
{{todo|Add the C++ struct declaration}}

== Level State Flags ==
The current state of the level is represented using the FLS enum, which has the following possible values:
The current state of the level is represented using the FLS enum, which has the following possible values:
{| class="wikitable"
|Name
|Value
|Description
|-
|FLS_Visited
|0x1
|Level has been visited and is selectable from ''View Map''.
|-
|FLS_KeyCollected
|0x2
|The key has been collected on the level.
|-
|FLS_Secondary
|0x4
|The vault has been opened on the level.
|-
|FLS_Tertiary
|0x8
|The MTS has been completed on the level.
|-
|FLS_BossDefeated
|0x10
|Unknown
|}


== uSuck values ==
{{todo|Add the FLS enum values}}

== uSuck ==
{{main|Difficulty#Sly 1}}
{{main|Difficulty#Sly 1}}


Each individual has a uSuck value used for scaling the difficulty level. There is also a second value related to suck stored at offset 0x10, but the purpose of that variable is currently unknown.
Each individual level state has a <code>uSuck</code> value which is used to scale the game's difficulty. There is also a second value related to suck stored at offset 0x10, but the purpose of that value is currently unknown. It is often incremented at the same time as the first suck value, but the second one is sometimes multiplied by some value to make it bigger or smaller.
{{todo|Investigate the mystery suck value.}}
{{todo|Investigate the mystery suck value.}}


== Dialogue Flags ==
== Clue values ==
The level state has two values associated with clue bottles. The first, <code>cclue</code>, is the quantity of clue bottles have been collected in the level. The second, <code>fclue</code>, is a bitfield that keeps track of which specific clue bottles have been collected.
Each level has an array for storing up to 12 [[DIALOG|dialogue]] flags. Each of these flags corresponds to a dialog/cutscene where Bentley talks to Sly.

Each bit in <code>fclue</code> corresponds to a specific clue in the map. During a level load, any particular clue bottle will only be spawned in if the corresponding bit is not set.

== Dialogue flags ==
Every <code>LS</code> has an array for storing up to 12 [[DIALOG|dialogue]] flags, <code>afDialogPlayed</code>, with each flag corresponding to a specific dialog. Most are Bentley cutscenes but it is also used for things like the PA announcements in the hub maps.


If a dialog flag is set to 0, that dialog will automatically play when Sly enters the relevant trigger volume. If the flag is set to 1, then the trigger volume instead causes the L1 popup [[BLOT|blot]] appears in the lower-left corner, giving the option to replay the dialog.
If a dialog flag is set to 0, that dialog will automatically play when Sly enters the associated trigger volume. If the flag is set to 1, then the trigger volume instead causes the L1 popup [[BLOT|blot]] to appear in the lower-left corner, giving the option to replay the dialog.


== Scene Variables ==
== Scene variables ==
{{todo|Investigate if there is an official name for these variables (the term “scene variables” was coined by me).}}
{{todo|* Investigate if there is an official name for these variables (the term “scene variables” was coined by me).
* Document the IDs and values of all scene vars in the game}}
Each LS has an array for storing up to 4 scene variables. A scene variable takes up 8 bytes, consisting of an ID and value pair. For instance, in [[The Swamp’s Dark Center]], ID 0x693 corresponds to the state of the left candle on the purple voodoo gate, and a value of 1 corresponds to that candle being broken.
Every <code>LS</code> has an array for storing up to 4 scene variables. A scene variable consists of two int values comprising an ID and value pair. For instance, in [[The Swamp’s Dark Center]], an ID of 0x693 corresponds to the state of the left candle on the purple voodoo gate, and a value of 1 corresponds to that candle being broken.


When the game sets a scene variable it uses the first available slot on the LS. When the game reads the scene variables, it calls a function that takes a map ID and an variable ID, which iterates over the array of scene flags for that map’s LS and stops when it finds a match.
When the game sets a scene variable it uses the first available slot on the <code>LS</code>. When the game needs to check the value of a scene variable, it calls a function that takes a map ID and a variable ID, iterating over the array of scene flags on that map’s <code>LS</code> and stops when it finds a match.


[[Category:Game mechanics]]
[[Category:Game mechanics]]

Revision as of 04:59, 12 July 2022

LS (Level State) is a data structure in Sly Cooper and the Thievius Raccoonus. It is used for storing the current state of each level in the Game State.

Structure

The LS struct is defined as follows:

struct LS {
    enum FLS fls; /* Level state flags */
    float dt; /* Time spent in level (secs) */
    float dtTimedBest; /* Best MTS time for level */
    float uSuck; /* Current player suck value for level */
    float suck_field_0x10; /* Unknown value, related to uSuck */
    int afDialogPlayed[12]; /*  Dialog played flags */
    struct SceneVar a_scene_vars[4]; /* Scene variables */
    int cclue; /* Count of bottles collected */
    uint fclue; /* Flags marking which bottles have been collected */
    undefined4 field_0x6c; /* Unknown */
    int field_0x70; /* Unknown */
    byte * unk_ptr_0x74; /* Unknown ptr to 1-byte value */
};

Level state flags

The current state of the level is represented using the FLS enum, which has the following possible values:

Name Value Description
FLS_Visited 0x1 Level has been visited and is selectable from View Map.
FLS_KeyCollected 0x2 The key has been collected on the level.
FLS_Secondary 0x4 The vault has been opened on the level.
FLS_Tertiary 0x8 The MTS has been completed on the level.
FLS_BossDefeated 0x10 Unknown

uSuck values

Each individual level state has a uSuck value which is used to scale the game's difficulty. There is also a second value related to suck stored at offset 0x10, but the purpose of that value is currently unknown. It is often incremented at the same time as the first suck value, but the second one is sometimes multiplied by some value to make it bigger or smaller.

Clue values

The level state has two values associated with clue bottles. The first, cclue, is the quantity of clue bottles have been collected in the level. The second, fclue, is a bitfield that keeps track of which specific clue bottles have been collected.

Each bit in fclue corresponds to a specific clue in the map. During a level load, any particular clue bottle will only be spawned in if the corresponding bit is not set.

Dialogue flags

Every LS has an array for storing up to 12 dialogue flags, afDialogPlayed, with each flag corresponding to a specific dialog. Most are Bentley cutscenes but it is also used for things like the PA announcements in the hub maps.

If a dialog flag is set to 0, that dialog will automatically play when Sly enters the associated trigger volume. If the flag is set to 1, then the trigger volume instead causes the L1 popup blot to appear in the lower-left corner, giving the option to replay the dialog.

Scene variables

Every LS has an array for storing up to 4 scene variables. A scene variable consists of two int values comprising an ID and value pair. For instance, in The Swamp’s Dark Center, an ID of 0x693 corresponds to the state of the left candle on the purple voodoo gate, and a value of 1 corresponds to that candle being broken.

When the game sets a scene variable it uses the first available slot on the LS. When the game needs to check the value of a scene variable, it calls a function that takes a map ID and a variable ID, iterating over the array of scene flags on that map’s LS and stops when it finds a match.