Sly 1:LOCKG
Data Structure | |
---|---|
Game | Sly Cooper and the Thievius Raccoonus |
Official Name | Yes |
LOCKG (internal name LOCK_GROUP) is a data structure in Sly Cooper and the Thievius Raccoonus that handles interaction between Sly and treasure key locks.
To Do: Replace all the XXX placeholders throughout the article with the actual values |
Fields
The LOCKG struct has the following fields:
Offset | Size | Type | Name | Notes |
---|---|---|---|---|
4 | int
|
grfws
|
Bitfield OR'd with the grfws on the global GS struct when triggered | |
4 | struct SMA*
|
psma
|
The SMA activated when triggered | |
4 | struct SM*
|
psm
|
Unknown SM pointer | |
4 | int
|
coidLock
|
Count of lock OIDs | |
32 | enum OID[8]
|
aoidLock
|
Array of lock OIDs | |
4 | int
|
cplock
|
Count of locks in the group | |
32 | LOCK*[8]
|
aplock
|
Array of lock pointers |
This topic needs further investigation. |
Implementation
When the trigger volume associated with a LOCKG is triggered it sets off a sequence of events. It starts with the animation that spawns a KEY for each Sly 1:LOCK in the aplock
array. Each key flies to its assigned lock and then despawns.
At some point a message with ID 0xXXX[check] is sent to the JT struct. This message is processed by HandleJtMessage
, which checks if the ckey
on the current world state is greater than the cppock
[check] on the LOCKG (i.e. it checks if you have enough keys to open the lock).
If the check passes, it uses the LOCKG->FWS
as a bitmask to set the corresponding flag on the FWS of the current WS. It then unlocks the locks and sets the SMA based on the LOCKG-> sma
pointer. The SMA is processed by Splice to trigger whatever scripted event happens as a result of the locks being unlocked.
Once all locks complete their unlock animation, the associated locks disappear from the world.
Example
In Prowling the Grounds, the LOCKG which handles unlocking the cannon is based at address 0xXXXXXX[check]. It’s cplock
[check] value is 7, meaning there are 7 locks in the aplock
array, so when you approach the cannon it checks if you have 7 keys.
If the check fails, nothing happens. If the check passes, it sets the SMA goal to 0xXXXXXX[check], which seems to handle removing the lid from the cannon.
Notes
- The
aplock
field is an array of 8 LOCK pointers. You can change these to point to any other entity in the level and they key will fly to and delete that entity instead. If you use this method to delete JT, the cutscene can’t complete and the game softlocks.