Sly 1:LOCKG: Difference between revisions
TheOnlyZac (talk | contribs) (→Implementation: Added image) Tags: Mobile edit Mobile web edit |
TheOnlyZac (talk | contribs) m (Fix typo) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Infobox data structure |
{{Infobox data structure |
||
| image= File:Sly 1 SDC 3key unlocking.png |
|||
| sly1= y |
|||
| official= y |
| official= y |
||
}} |
}} |
||
⚫ | |||
{{todo|Cleanup, add memory addresses, fix formatting}} |
|||
⚫ | |||
{{Todo|Replace all the XXX placeholders throughout the article with the actual values}} |
|||
== Structure == |
|||
The structure of a LOCKG is as follows: |
|||
== Fields == |
|||
{{todo|Add struct fields table}} |
|||
The LOCKG struct has the following fields: |
|||
{{Struct top}} |
|||
{{Struct field||4|int|grfws|Bitfield OR'd with the grfws on the global {{Sly 1|GS}} struct when triggered}} |
|||
{{Struct field|offset=|size=4|type=struct SMA*|name=psma|description=The SMA activated when triggered}} |
|||
{{Struct field|offset=|size=4|type=struct SM*|name=psm|description='''Unknown''' SM pointer}} |
|||
{{Struct field||4|int|coidLock|Count of lock OIDs}} |
|||
{{Struct field||32|enum OID[8]|aoidLock|Array of lock OIDs}} |
|||
{{Struct field|offset=|size=4|type=int|name=cplock|description=Count of locks in the group}} |
|||
{{Struct field|offset=|size=32|type=LOCK*[8]|name=aplock|description=Array of lock pointers}} |
|||
{{Struct bottom}} |
|||
{{Investigate}} |
|||
== Implementation == |
== Implementation == |
||
[[File:Sly 1 SDC 3key unlocking.png|thumb|The cutscene after triggering a LOCKG in [[The Swamp’s Dark Center]]]] |
|||
⚫ | |||
⚫ | |||
⚫ | At some point a message with ID 0xXXX{{check}} is sent to the |
||
⚫ | At some point a message with ID 0xXXX{{check}} is sent to the {{Sly 1|JT}} struct. This message is processed by <code>HandleJtMessage</code>, which checks if the <code>ckey</code> on the current {{Sly 1|WS|world state}} is greater than the <code>cppock</code>{{check}} on the LOCKG (i.e. it checks if you have enough keys to open the lock). |
||
⚫ | If the check passes, it uses the |
||
⚫ | If the check passes, it uses the <code>LOCKG->FWS</code> as a bitmask to set the corresponding flag on the FWS of the current WS. It then unlocks the locks and sets the {{Sly 1|SMA}} based on the <code>LOCKG-> sma</code> pointer. The SMA is processed by {{Sly 1|Splice}} to trigger whatever scripted event happens as a result of the locks being unlocked. |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
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. |
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 == |
== Notes == |
||
* The <code> |
* The <code>aplock</code> 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. |
||
{{Navbox Sly 1}} |
{{Navbox Sly 1}} |
Latest revision as of 20:34, 26 September 2023
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.