Sly 1:LOCKG

From SlyMods
Revision as of 18:22, 23 September 2023 by TheOnlyZac (talk | contribs) (Started struct fields table)
Jump to navigation Jump to search
LOCKG
Data Structure
GameSly Cooper and the Thievius Raccoonus
Official NameYes

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.

Fields

The LOCKG struct has the following fields:

Offset Size Type Name Notes
4
int
cpLock Number of locks in the group
32
LOCK*[8]
apLock Array of lock pointers
4
struct SMA*
smaGoal The SMA goal to set upon opening the locks.

Implementation

The cutscene after triggering a LOCKG in The Swamp's Dark Center

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 Sly 1: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 cpLock[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 SmaGoal based on the LOCKG-> smaGoal pointer. The SMA goal, 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.