Sly 1:LS: Difference between revisions

From SlyMods
Jump to navigation Jump to search
Content added Content deleted
m (TheOnlyZac moved page LS to Sly 1:LS: Moved to gamespace)
(→‎Fields: Update fields)
 
(12 intermediate revisions by the same user not shown)
Line 5: Line 5:
| sly1= y
| sly1= y
}}
}}
{{Google sheets|https://docs.google.com/spreadsheets/d/1cT5ZpMyTpoCMEb_xbVJ3QAjduLg2cCZIQFtFdG6Bk4I/}}
{{hatnote|This article is about the states of Sly 1 levels. For the state of levels in in Sly 2 and 3, see [[DAG]].}}
'''LS''' (level state) is a data structure in {{Sly 1}}. It is responsible for the state of each [[worldlevel]] in the game.


== Fields ==
'''LS''' ('''L'''evel '''S'''tate) is a data structure in {{Sly 1}}. It is used for storing the current state of each level in the [[GS|Game State]].


The LS struct has the following fields:
== Structure ==

The LS struct is defined as follows:<syntaxhighlight lang="c++">
{{Struct top}}
struct LS {
enum FLS fls; /* Level state flags */
{{Struct field|type=enum FLS|name=fls|offset=0x0|size=4|description=Level state flags}}
float dt; /* Time spent in level (secs) */
{{Struct field|type=float|name=dt|offset=0x4|size=4|description=Total spent in level (secs)}}
float dtTimedBest; /* Best MTS time for level */
{{Struct field|type=float|name=dtTimedBest|offset=0x8|size=4|description=Best MTS time for level}}
float uSuck; /* Current player suck value for level */
{{Struct field|type=float|name=uSuck|offset=0xc|size=4|description=Player's suck value for level (increases when you die)}}
float suck_field_0x10; /* Unknown value, related to uSuck */
{{Struct field|type=float|name=?|offset=0x10|size=4|description='''Unknown value''', realated to suck}}
{{Struct field|type=int[12]|name=afDialogPlayed|offset=0x14|size=48|description=Array of dialog played flags}}
int afDialogPlayed[12]; /* Dialog played flags */
struct SceneVar a_scene_vars[4]; /* Scene variables */
{{Struct field|type=struct SceneVar[4]|name=scene vars array|offset=0x44|size=32|description=Array of scene variables}}
int cclue; /* Count of bottles collected */
{{Struct field|type=int|name=cclue|offset=0x64|size=4|description=Count of clue bottles collected}}
uint fclue; /* Flags marking which bottles have been collected */
{{Struct field|type=CBitArray<64>|name=abitClue|offset=0x68|size=4|description=Bitfield marking which bottles have been collected}}

undefined4 field_0x6c; /* Unknown */
{{Struct field|type=CBitArray<8>|name=abitChkpnt|offset=0x70|size=8|description=}}
int field_0x70; /* Unknown */

byte * unk_ptr_0x74; /* Unknown ptr to 1-byte value */
{{Struct bottom}}
};
</syntaxhighlight>


== Level state flags ==
== 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:
{{Enum top}}
{| class="wikitable"
{{Enum value|FLS_Visited|0x1|The level has been visited and is selectable from the map}}
!Name
{{Enum value|FLS_KeyCollected|0x2|The key has been collected on the level}}
!Value
{{Enum value|FLS_Secondary|0x4|The vault has been opened on the level}}
!Description
{{Enum value|FLS_Tertiary|0x8|The MTS has been completed on the level}}
|-
{{Enum value|FLS_BossDefeated|0x10|Self-explanatory}}
|FLS_Visited
{{Enum bottom}}
|0x1
|The 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 ==
== uSuck values ==

{{main|Difficulty#Sly 1}}
{{main|Sly 1:Difficulty}}


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.
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.}}
{{Investigate|What is the mystery suck value used for?}}


== Clue values ==
== 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.
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 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.
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 ==
== Dialog 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.
Every <code>LS</code> has an array for storing up to 12 [[Sly 1:DIALOG|dialog]] 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 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.
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 [[Sly 1: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).
* Figure out what the unknown scene flags do}}
Every <code>LS</code> has slots for up to 4 scene variables. Each scene variable is a numerical ID and value pair. On a new game, the ID and values of all scene variables are 0, and the game sets them as it needs to.


{{Investigate|<br/>
When the game first sets a scene variable, it uses the first available slot on the <code>LS</code>. Then, when the game needs to check the value of a scene variable for a particular level, it iterates over the scene flags on that level’s <code>LS</code> and stops when it finds a match.
* See if there is an official name for these type of variables.
* Figure out what the unknown scene flags do, particularly the one in Prowling the Grounds}}

Each <tt>LS</tt> has slots for up to 4 scene variables. A new game has no scene vars set, and the game sets them as it needs to.

When the game wants to set a scene variable, it uses the following algorithm:
# Checks all the scene flags on the <tt>LS</tt> for that level to see if a variable with that ID is already set.
#* If so, update the value.
#* If not, write the ID/value pair to the first available slot on the level.


The following is a list of all known scene variables the game uses. There may still be more that are undiscovered.
The following is a list of all known scene variables the game uses. There may still be more that are undiscovered.
Line 85: Line 76:
! ID (dec)
! ID (dec)
!Known Values
!Known Values
!Notes
|-
|-
|Prowling the Grounds
|{{Sly 1|Prowling the Grounds}}
|0x748
|0x748
|1864
|1864
|'''1''' - Set when you attempt to unlock the generator without enough keys. Disables the "you need x more keys" dialog.
|1
| Unknown
|-
|-
|Into The Machine
|{{Sly 1|Into The Machine}}
|0x7e3
|0x7e3
|2019
|2019
|'''2019''' - Set if the [[Anticrack#Firewall|invisible wall of fire]] is activated.
|2019
|Set to 2019 if the [[Anticrack#Firewall|invisible wall of fire]] is activated
|-
|-
|Last Call
|{{Sly 1|Last Call}}
|0x5a8
|0x5a8
|1448
|1448
|'''1''' - Set every time you hit a mirror. Disables the "why don't you try hitting those mirrors" dialog.
|1
|Unknown
|-
|-
|The Swamp's Dark Center
|{{Sly 1|The Swamp's Dark Center}}
|0x692
|0x692
|1682
|1682
|'''1''' - Voodoo gate left candle broken in the {{Sly 1|v_hub|W3 hub}}
|1
|Set to 1 when the left{{Check}} candle is broken
|-
|-
|The Swamp's Dark Center
|The Swamp's Dark Center
|0x695
|0x695
|1685
|1685
|'''1''' - Voodoo gate right candle broken in the W3 hub
|1
|Set to 1 when the right{{Check}} candle is broken
|-
|-
|Duel by the Dragon
|{{Sly 1|Duel by the Dragon}}
|0x53b
|0x53b
|1339
|1339
|'''0''' - Set when you first load the level. Enables the Carmelita cutscene on the roof.
|1
'''1''' - Set when the first Carmelita cutscene plays. Disables the Carmelita cutscene until you leave and re-enter the level.
|Unknown, set to 0 when the level loads and 1 when you trigger the initial Carmelita cutscene
|-
|-
|A Strange Reunion
|{{Sly 1|A Strange Reunion}}
|0x701
|0x701
|1793
|1793
|'''1''' - '''Unknown''', set when the level starts. Probably related to cutscenes.
|1, 3
'''3''' - '''Unknown''', probably related to cutscenes.
|Unknown, set to 1 when the level starts
|-
|-
|A Strange Reunion
|A Strange Reunion
|0x704
|0x704
|1796
|1796
|'''10''' - Unknown
|10
|Unknown
|}
|}

== See also ==

* {{Sly 1|GS}}
* {{Sly 1|WS}}
* {{Sly 2|DAG}}

{{Navbox Sly 1}}
{{Navbox Sly 1}}

Latest revision as of 02:56, 26 September 2023

LS
Data Structure
GameSly Cooper and the Thievius Raccoonus
Size0x78
Official NameYes

LS (level state) is a data structure in Sly Cooper and the Thievius Raccoonus. It is responsible for the state of each worldlevel in the game.

Fields

The LS struct has the following fields:

Offset Size Type Name Notes
0x0 4
enum FLS
fls Level state flags
0x4 4
float
dt Total spent in level (secs)
0x8 4
float
dtTimedBest Best MTS time for level
0xc 4
float
uSuck Player's suck value for level (increases when you die)
0x10 4
float
? Unknown value, realated to suck
0x14 48
int[12]
afDialogPlayed Array of dialog played flags
0x44 32
struct SceneVar[4]
scene vars array Array of scene variables
0x64 4
int
cclue Count of clue bottles collected
0x68 4
CBitArray<64>
abitClue Bitfield marking which bottles have been collected
0x70 8
CBitArray<8>
abitChkpnt


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 The level has been visited and is selectable from the 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 Self-explanatory

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.

Dialog flags

Every LS has an array for storing up to 12 dialog 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

Each LS has slots for up to 4 scene variables. A new game has no scene vars set, and the game sets them as it needs to.

When the game wants to set a scene variable, it uses the following algorithm:

  1. Checks all the scene flags on the LS for that level to see if a variable with that ID is already set.
    • If so, update the value.
    • If not, write the ID/value pair to the first available slot on the level.

The following is a list of all known scene variables the game uses. There may still be more that are undiscovered.

Level ID (hex) ID (dec) Known Values
Prowling the Grounds 0x748 1864 1 - Set when you attempt to unlock the generator without enough keys. Disables the "you need x more keys" dialog.
Into The Machine 0x7e3 2019 2019 - Set if the invisible wall of fire is activated.
Last Call 0x5a8 1448 1 - Set every time you hit a mirror. Disables the "why don't you try hitting those mirrors" dialog.
The Swamp's Dark Center 0x692 1682 1 - Voodoo gate left candle broken in the W3 hub
The Swamp's Dark Center 0x695 1685 1 - Voodoo gate right candle broken in the W3 hub
Duel by the Dragon 0x53b 1339 0 - Set when you first load the level. Enables the Carmelita cutscene on the roof.

1 - Set when the first Carmelita cutscene plays. Disables the Carmelita cutscene until you leave and re-enter the level.

A Strange Reunion 0x701 1793 1 - Unknown, set when the level starts. Probably related to cutscenes.

3 - Unknown, probably related to cutscenes.

A Strange Reunion 0x704 1796 10 - Unknown

See also