Sly 1:LOCKG: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(Created article for data structure)
 
(Fixed formatting, added links)
Line 1: Line 1:
{{todo|Cleanup, add memory addresses, fix formatting}}
{{todo|Cleanup, add memory addresses, fix formatting}}
'''LOCKG''' (likely short for Lock Goal) is a data structure in {{Sly 1}} that handles interaction between Sly and obstacles locked with treasure keys.
'''LOCKG''' (likely short for '''Lock G'''oal) is a data structure in {{Sly 1}} that handles interaction between Sly and treasure key locks.


== Structure ==
== Structure ==
Line 7: Line 7:


== Implementation ==
== 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 LOCK in the apLock array. These keys fly to their assigned locks and then despawn.
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 [[LOCK]] in the <code>apLock</code> 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 WS (World State) is greater than the cpLock{{check}} on the LOCKG (ie. it checks if you have enough keys to open the lock).
At some point a message with ID 0xXXX{{check}} is sent to the [[JT (Sly 1)|JT]] struct. This message is processed by <code>HandleJtMessage</code>, which checks if the <code>ckey</code> on the current [[WS]] (World State) is greater than the <code>cpLock</code>{{check}} on the LOCKG (ie. it checks if you have enough keys to open the lock).


If the check passes, it uses the LOCKG’s FWS as a bit mask to set the corresponding flag on the current WS’ FWS. It then unlocks the locks and sets the SMA goal based on the LOCKG’s smaGoal pointer. The SMA goal, which seems to be processed by Splice, determines the outcome (ie. what happens as a result of the locks being opened).
If the check passes, it uses the LOCKG’s FWS as a bit mask to set the corresponding flag on the FWS of the current WS. It then unlocks the locks and sets the [[SMA]] goal based on the LOCKG’s <code>smaGoal</code> pointer. The SMA goal, which seems to be processed by [[Splice]], determines the outcome (ie. what happens as a result of the locks being opened).


Once all locks have are unlocked, they are removed from from the game world along with the LOCKG itself.{{check}}
Once all locks complete their unlock [[ASEG|animation]], they are removed from from the game world along with the LOCKG itself.{{check}}


== Example ==
=== Example ===
In Prowling the Grounds, the LOCKG which handles for unlocking the cannon is based at address 0xXXXXXX{{check}}. It’s cpLock{{check}} value is 7, meaning there are 7 locks, so when you approach the cannon, it checks if you have 7 keys.
In Prowling the Grounds, the LOCKG which handles unlocking the cannon is based at address 0xXXXXXX{{check}}. It’s <code>cpLock</code>{{check}} value is 7, meaning there are 7 locks in the <code>apLock</code> 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 apparently to handles 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 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 soft locks.
* 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.


[[Category:Data structures]]
[[Category:Data structures]]