Sly 2:Game state: Difference between revisions

From SlyMods
Jump to navigation Jump to search
Content added Content deleted
(Added navboxes)
(Add gallery of Sly 2 DAGs)
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Infobox game mechanic
The '''DAG''' ('''D'''irected '''A'''cyclic '''G'''raph) is a data structure used in Sly 2 and Sly 3 to control the current state of the game world. It was the subject of a 2005 GDC presentation by Bruce Oberg, the Principal Engineer at Sucker Punch.<ref>[https://www.gdcvault.com/play/1020295/The-Picture-Worth-a-Thousand The Picture Worth a Thousand Bugs] - YouTube, 3 April 2021 (archived from a 2005 GDC conference)</ref>
|image=Sly 2 Palace DAG official.png
|caption=The official DAG for Sly 2 Episode 2
}}

The '''game state''' is the current state of everything in the game world. It was the subject of a 2005 GDC presentation by Bruce Oberg, the Principal Engineer at Sucker Punch.<ref>[https://www.gdcvault.com/play/1020295/The-Picture-Worth-a-Thousand The Picture Worth a Thousand Bugs] - YouTube, 3 April 2021 (archived from a 2005 GDC conference)</ref>


== Tasks ==
== Tasks ==
The DAG is a directed graph of nodes, where each node is called a "task". For instance, <code>t1_follow_dmitri_on_streets</code> is the task of tailing Dimitri in the "Follow Dimitri" job (the prefix <code>t1</code> indicates that it is a task in Episode 1, and <code>follow</code> is the codename for the "Follow Dimitri" job).
The current game state is represented by a '''directed acyclic graph''' ('''DAG'''), which is a directed graph with no cycles. Each node on the DAG is called a {{Sly 2|Task|task}}. For example, <tt>t1_follow_dmitri_on_streets</tt> is the task of tailing Dimitri in the "Follow Dimitri" job (the prefix <tt>t1</tt> indicates that it is a task in Episode 1, and <tt>follow</tt> is the codename for the "Follow Dimitri" job).


=== Task States ===
=== Task States ===
Each task has a ''state'', which is one of the following:
Each task has a state value which can be one of the following:


* {{color|red|Unavailable}}
*{{color|red|0 – Unavailable}}
* {{color|dodgerblue|Available}}
*{{color|limegreen|1 – Available}}
* {{color|limegreen|Complete}}
*{{color|dodgerblue|2 – Complete}}
* {{color|gray|Final}}
*{{color|gray|3 – Final}}


All tasks in the DAG start off as {{color|red|Unavailable}}. A task becomes {{color|dodgerblue|Available}} once all of its predecessors are {{color|limegreen|Complete}}. Tasks become {{color|limegreen|Complete}} through conditions being met in the level scripts, and tasks become {{color|gray|Final}} through missions.
All tasks begin as {{color|red|Unavailable}}. A task becomes {{color|limegreen|Available}} once all of its predecessors are {{color|dodgerblue|Complete}}. Tasks become {{color|dodgerblue|Complete}} through conditions being met in the level scripts, and tasks become {{color|gray|Final}} through completing missions.


=== State Forcing ===
===State Forcing===
At all times, every task ''before'' an Available task must be Complete or Final. Additionally, every task ''after'' an Available task must be unavailable. It is possible to "force" a task to a particular state, which propagates throughout the DAG to ensure those conditions are always met.
At all times, every task ''before'' an Available task must be Complete or Final. Additionally, every task ''after'' an Available task must be unavailable. It is possible to "force" a task to a particular state, which propagates throughout the DAG to ensure those conditions are always met.


== Missions ==
== Missions ==
Tasks in the DAG can be grouped into ''missions''. A mission usually refers to a particular job in the game's story. For instance, <code>m1_follow</code> is the job "Follow Dmitri" (the prefix <code>m1</code> indicates that it is a mission in Episode 1).
Tasks are grouped into {{Sly 2|Mission|missions}}, where each mission is typically a particular job in the story. For instance, <tt>m1_follow</tt>{{check}} is the job "Follow Dmitri". The prefix <tt>m1</tt> indicates that it is a mission in Episode 1, and <tt>follow</tt> is the codename for the mission.


If a task belongs to a mission and the "exit" task in that mission is Completed, then all the tasks in that job become Final.
When the task marked as the "exit task" for a mission is Completed, then all the tasks in that mission become Final.


== Checkpoints ==
== Checkpoints ==
A task is considered a ''checkpoint task'' if it has some checkpoint data associated with it, including a particular character and location in the game world. When a checkpoint task becomes Available, that checkpoint is set as the ''latest'' checkpoint.
Some tasks are "checkpoint tasks". A task is a checkpoint if it has some associated {{Sly 2|Checkpoint|checkpoint data}}, which includes
* the character to respawn as
* a location to spawn at


When a rollback occurs, the game uses the latest checkpoint to set the current character and their location.
When a checkpoint task becomes Available, that checkpoint is set as the latest checkpoint.


== Rollbacks ==
== Rollbacks ==
A rollback is when the game rewinds the DAG to an earlier state (such as when the player dies). This is accomplished by:
A rollback is when the game state rewinds to an earlier state (such as when the player dies). This is accomplished by:

* Resetting the world
* Resetting the world
* Placing the player at the latest checkpoint
* Placing the player at the latest checkpoint
* Forcing the checkpoint task to Available (which may result in the states of other tasks being updated)
* Forcing the checkpoint task to Available (which may result in the states of other tasks being updated)


== References ==
== Gallery ==
The following are all DAGs for Sly 2. The DAG for Episode 2 is the official DAG as the developers would have seen it. The rest are reconstructed from data structures in the game's memory.

<gallery mode="nolines" widths=200px heights=200px>
File:Sly2 Intro DAG.png|Sly 2 Intro (Cairo)
File:Sly2 Ep1 Nightclub DAG.png|Sly 2 Ep 1 (Nightclub)
File:Sly 2 Palace DAG official.png|Sly 2 Ep 2 (Palace)
File:Sly2 Ep3 Temple DAG.png|Sly 2 Ep 3 (Temple)
File:Sly2 Ep4 Prison DAG.png|Sly 2 Ep 4 (Prison)
File:Sly2 Ep5 Castle DAG.png|Sly 2 Ep 5 (Castle)
File:Sly2 Ep6 Train DAG.png|Sly 2 Ep 6 (Train)
File:Sly2 Ep7 Sawmill DAG.png|Sly 2 Ep 7 (Sawmill)
File:Sly2 Ep8 Blimp DAG.png|Sly 2 Ep 8 (Blimp)
</gallery>

== See also ==

*[[DAGviz]] - A tool for viewing and editing the DAG in real time
*[[Sly 1:GS]] - The game state struct in {{Sly 1}}.

==References==
<references />
<references />
[[Category:Game mechanics]][[Category:Game mechanics in Sly 2]][[Category:Game mechanics in Sly 3]]


{{Navbox Sly 2}}
{{Navbox Sly 2}}

{{Navbox Sly 3}}
[[Category:Game mechanics]]
[[Category:Game mechanics in Sly 2]]
[[Category:Game mechanics in Sly 3]]

Latest revision as of 19:25, 19 March 2024

Game state
Game Mechanic
The official DAG for Sly 2 Episode 2
GameSly 2: Band of Thieves

The game state is the current state of everything in the game world. It was the subject of a 2005 GDC presentation by Bruce Oberg, the Principal Engineer at Sucker Punch.[1]

Tasks

The current game state is represented by a directed acyclic graph (DAG), which is a directed graph with no cycles. Each node on the DAG is called a task. For example, t1_follow_dmitri_on_streets is the task of tailing Dimitri in the "Follow Dimitri" job (the prefix t1 indicates that it is a task in Episode 1, and follow is the codename for the "Follow Dimitri" job).

Task States

Each task has a state value which can be one of the following:

  • 0 – Unavailable
  • 1 – Available
  • 2 – Complete
  • 3 – Final

All tasks begin as Unavailable. A task becomes Available once all of its predecessors are Complete. Tasks become Complete through conditions being met in the level scripts, and tasks become Final through completing missions.

State Forcing

At all times, every task before an Available task must be Complete or Final. Additionally, every task after an Available task must be unavailable. It is possible to "force" a task to a particular state, which propagates throughout the DAG to ensure those conditions are always met.

Missions

Tasks are grouped into missions, where each mission is typically a particular job in the story. For instance, m1_follow[check] is the job "Follow Dmitri". The prefix m1 indicates that it is a mission in Episode 1, and follow is the codename for the mission.

When the task marked as the "exit task" for a mission is Completed, then all the tasks in that mission become Final.

Checkpoints

Some tasks are "checkpoint tasks". A task is a checkpoint if it has some associated checkpoint data, which includes

  • the character to respawn as
  • a location to spawn at

When a checkpoint task becomes Available, that checkpoint is set as the latest checkpoint.

Rollbacks

A rollback is when the game state rewinds to an earlier state (such as when the player dies). This is accomplished by:

  • Resetting the world
  • Placing the player at the latest checkpoint
  • Forcing the checkpoint task to Available (which may result in the states of other tasks being updated)

Gallery

The following are all DAGs for Sly 2. The DAG for Episode 2 is the official DAG as the developers would have seen it. The rest are reconstructed from data structures in the game's memory.

See also

  • DAGviz - A tool for viewing and editing the DAG in real time
  • Sly 1:GS - The game state struct in Sly Cooper and the Thievius Raccoonus.

References

  1. The Picture Worth a Thousand Bugs - YouTube, 3 April 2021 (archived from a 2005 GDC conference)