SlideShare una empresa de Scribd logo
1 de 162
State-Based Scripting in




                               Jason Gregory
                            Generalist Programmer
                             Naughty Dog, Inc.


Monday, April 6, 2009
Agenda
       • Introduction to game scripting
       • Extending the game object model
       • State script syntax
       • Case studies from
         Uncharted 2: Among Thieves
       • Implementation discussion
       • Summary and some tips



       Game
Developers
Conference
2009     2
Monday, April 6, 2009
Introduction to State Scripts




                                                        3
Monday, April 6, 2009
Brief History of State Scripts
       • Script system on Uncharted: Drake’s Fortune originally developed
         for in-game cinematics (IGCs)
       • Evolved into general gameplay scripting system




       Game
Developers
Conference
2009                                      4
Monday, April 6, 2009
Brief History of State Scripts
       • UDF IGC system revamped for heavy
         use on Uncharted 2: Among Thieves
       • Inspirations:
           GOAL language used on Crash and Jak series
           State objects from God of War engine

                                         TM




       Game
Developers
Conference
2009                   5
Monday, April 6, 2009
Why Script?
       • Scripting languages used in games since Quake C
       • Primary benefits of script:
           Takes pressure off engineering team
           Code becomes data—rapid iteration
           Empowers content creators
           Key enabler of mod community




       Game
Developers
Conference
2009                     6
Monday, April 6, 2009
Why Script?
       • Scripting languages used in games since Quake C
       • Primary benefits of script:
                                                 I
feel
empowered!
           Takes pressure off engineering team
           Code becomes data—rapid iteration
           Empowers content creators
           Key enabler of mod community




       Game
Developers
Conference
2009                               6
Monday, April 6, 2009
Scripting Language Characteristics

       • Two kinds of game scripting languages:
           data definition languages
           runtime languages
       • Runtime scripting languages typically:
           interpreted by virtual machine (VM)
           simple and small—low overhead
           accessible to designers and other “non-programmers”
           powerful—one line of code = big impact

       Game
Developers
Conference
2009                            7
Monday, April 6, 2009
Choice of Language
       • At Naughty Dog, we make heavy use of both data definition
         and runtime script
           Both based on PLT Scheme (a Lisp variant)
       • Key benefits of Lisp-like languages:
           Easy to parse
           Data def and runtime code can be freely intermixed
           Powerful macro system—easy to define custom syntax
           Naughty Dog has a rich Lisp heritage—comfortable


       Game
Developers
Conference
2009                              8
Monday, April 6, 2009
Choice of Language
       • Of course you don’t have to use Lisp!
       • Data definition languages:
           custom text format,
           Excel comma-separated values (.csv),
           XML, ...
       • Runtime languages:
           Python, Lua, Pawn (Small C), OCaml, F#, ...
       • Many popular engines already provide a scripting language:
           Quake C, UnrealScript, C# (XNA), ...
       Game
Developers
Conference
2009                                9
Monday, April 6, 2009
Extending the Game Object Model
       • Every game engine has some kind of game object model
           Defines all object types in game world
           Often (but not always) written in an object-oriented language
       • Scripting language often used to extend the native object model
       • Many ways to accomplish this...




       Game
Developers
Conference
2009                                      10
Monday, April 6, 2009
Game Object Model References
       • Rob Fermier, “Creating a Data Driven Engine,” GDC, 2002
       • Scott Bilas, “A Data-Driven Game Object System,” GDC, 2002
         (http://www.drizzle.com/~scottb/gdc/game-objects.ppt)
       • Alex Duran, “Building Object Systems: Features, Tradeoffs and
         Pitfalls,” GDC, 2003
       • Doug Church, “Object Systems,” presented at a game development
         conference in Seoul, Korea, 2003
         (http://chrishecker.com/images/6/6f/ObjSys.ppt)
       • Jason Gregory, “Game Engine Architecture,” AK Peters, 2009
         (http://gameenginebook.com)
       Game
Developers
Conference
2009                                    11
Monday, April 6, 2009
Unreal’s Approach
       • UnrealScript tightly integrated with C++ object model
          Single-root class hierarchy with some add-on components
          Classes defined in UnrealScript (.uc)
          C++ header file (.h) automatically generated
          Implementation in C++ or entirely in UnrealScript
                                                     Pawn.h                    Actor
                                         generate
                        Pawn.uc
                                                     Pawn.cpp
                                                                Info           Pawn          Pickup     ...
                                         implement
                  implement
                                                                       Scout           Vehicle    ...
       Game
Developers
Conference
2009                                                                        12
Monday, April 6, 2009
Property-Centric / Componentized Designs
       • Property-centric design used on Thief, Dungeon Siege, Age of
         Mythology, Deus Ex 2 and others
           Game object just a unique id (UID)
           “Decorated” with various properties
            (health, armor, weaponry, etc.)
           Property encapsulates data + behavior
                                                                              Armor:
Light
                                                   Health:
200
                                                                    Object     Weapon:
BFG
                                                                    (UID)
                                                   AI:
PlayerAlly
                                                                             Weapon:
Pistol



       Game
Developers
Conference
2009                                                        13
Monday, April 6, 2009
Uncharted Engine’s Object Model
       • Uncharted class hierarchy:
          relatively shallow, single-root
          host of add-on components
                                                                   Process



                         SsTrackGroupProcess   SsProcess     ProcessGameObject         DynLight   CameraControl   ...
                                                           Character     SimpleEnOty     ...
                                                                       ...

       Game
Developers
Conference
2009                                                                                  14
Monday, April 6, 2009
Uncharted Engine’s Object Model
       • Uncharted class hierarchy:
          relatively shallow, single-root
                                                                                                    Objects

          host of add-on components                                                              that
update

                                                                                                   over
Dme
                                                                   Process



                         SsTrackGroupProcess   SsProcess     ProcessGameObject         DynLight      CameraControl   ...
                                                           Character     SimpleEnOty     ...
                                                                       ...

       Game
Developers
Conference
2009                                                                                     14
Monday, April 6, 2009
Uncharted Engine’s Object Model
       • Uncharted class hierarchy:
          relatively shallow, single-root
          host of add-on components                                                                 Objects

                                                                                                  with
transform

                                                                                                    and
mesh
                                                                   Process



                         SsTrackGroupProcess   SsProcess     ProcessGameObject         DynLight       CameraControl   ...
                                                           Character     SimpleEnOty     ...
                                                                       ...

       Game
Developers
Conference
2009                                                                                      14
Monday, April 6, 2009
Uncharted Engine’s Object Model
       • Uncharted class hierarchy:
          relatively shallow, single-root
          host of add-on components                                                              Base
class
for

                                                                                                  all
characters
                                                                   Process



                         SsTrackGroupProcess   SsProcess     ProcessGameObject         DynLight     CameraControl   ...
                                                           Character     SimpleEnOty     ...
                                                                       ...

       Game
Developers
Conference
2009                                                                                    14
Monday, April 6, 2009
Uncharted Engine’s Object Model
       • Uncharted class hierarchy:
          relatively shallow, single-root
          host of add-on components                                                                Simple

                                                                                                   animaDng

                                                                   Process
                                                                                                    object


                         SsTrackGroupProcess   SsProcess     ProcessGameObject         DynLight   CameraControl   ...
                                                           Character     SimpleEnOty     ...
                                                                       ...

       Game
Developers
Conference
2009                                                                                  14
Monday, April 6, 2009
Uncharted Engine’s Object Model
       • Uncharted class hierarchy:
          relatively shallow, single-root
          host of add-on components
                                                                     Process



                         SsTrackGroupProcess     SsProcess     ProcessGameObject         DynLight   CameraControl   ...
                                                             Character     SimpleEnOty     ...
                              Manages
a
State

                              Script
instance                            ...

       Game
Developers
Conference
2009                                                                                    14
Monday, April 6, 2009
Uncharted Engine’s Object Model
       • Uncharted class hierarchy:
          relatively shallow, single-root
          host of add-on components
                                                                   Process



                         SsTrackGroupProcess   SsProcess     ProcessGameObject         DynLight   CameraControl   ...

                Manages
a
                                 Character     SimpleEnOty     ...
                 chunk
of

              running
script

                                                                       ...
                   code

       Game
Developers
Conference
2009                                                                                  14
Monday, April 6, 2009
Uncharted Engine’s Object Model
       • Uncharted class hierarchy:
          relatively shallow, single-root
          host of add-on components
                                                     Process



                                         SsProcess




       Game
Developers
Conference
2009                         14
Monday, April 6, 2009
Uncharted Engine’s Object Model
       • Uncharted class hierarchy:
          relatively shallow, single-root
          host of add-on components
                                                           Process



                                         SsProcess




                                              SsInstance




       Game
Developers
Conference
2009                               14
Monday, April 6, 2009
Uncharted Engine’s Object Model
       • Uncharted class hierarchy:
          relatively shallow, single-root
          host of add-on components
                                                       Process



                                                  ProcessGameObject




                                         SsInstance     DrawControl   AnimControl   ...

       Game
Developers
Conference
2009                                                    14
Monday, April 6, 2009
Charter
       • World editor for
         Uncharted is called
         Charter
          Place game objects
          Edit object
           properties
          Control level
           streaming



       Game
Developers
Conference
2009   15
Monday, April 6, 2009
Uncharted State Scripts
       • State scripts similar in many respects to property-centric model...
           adds finite state machine (FSM) support
           not specifically tied to “properties”
           coarser-grained (one script per object)
       • More like scripted extension to existing entity type...
           ... or a “director” that orchestrates actions of other entities




       Game
Developers
Conference
2009                                         16
Monday, April 6, 2009
Anatomy of a State Script
       • A state script is comprised of:
           attributes
           states
       • States define object’s behavior via runtime script code:
           response to events
           natural behavior over time (update event)
           transitional actions between states (begin/end events)



       Game
Developers
Conference
2009                               17
Monday, April 6, 2009
Anatomy of a State Script

                             State
Script
1
                                         Variables

                                          State
A    State
Script
2
                                     On Update               Variables
                                     On Event1
                                                              State
C

                                          State
B           On Begin

                                         On Begin          On Event4




       Game
Developers
Conference
2009                                   18
Monday, April 6, 2009
Anatomy of a State Script

                             State
Script
1
                                         Variables   Event1

                                          State
A             State
Script
2
                                     On Update                        Variables
                                     On Event1
                                                                       State
C

                                          State
B                    On Begin

                                         On Begin                   On Event4




       Game
Developers
Conference
2009                                            18
Monday, April 6, 2009
Anatomy of a State Script

                             State
Script
1
                                         Variables   Event1

                                          State
A             State
Script
2
                                     On Update                        Variables
                                     On Event1
                                                                       State
C
               go
to

                                                                     On Begin
              State
B                     State
B
                                         On Begin                   On Event4




       Game
Developers
Conference
2009                                            18
Monday, April 6, 2009
Anatomy of a State Script

                             State
Script
1
                                         Variables   Event1

                                          State
A             State
Script
2
                                     On Update                        Variables
                                     On Event1
                                                                       State
C
               go
to

                                                                     On Begin
              State
B                     State
B
                                         On Begin    Event4         On Event4




       Game
Developers
Conference
2009                                            18
Monday, April 6, 2009
Instantiating a State Script
       • Attached to a native (C++) game object:   Game

                                                   Object
           designers extend or modify native
            C++ object type                            State
Script
1

           define entirely new object types




       Game
Developers
Conference
2009                                  19
Monday, April 6, 2009
Instantiating a State Script
       • Attached to a native (C++) game object:   Game

                                                   Object
           designers extend or modify native
            C++ object type                            State
Script
1

           define entirely new object types

       • Attached to a trigger region:
          convex volume                           Trigger
Region

          detects enter, exit and occupancy
                                                            State
Script
2




       Game
Developers
Conference
2009                                       19
Monday, April 6, 2009
Instantiating State Scripts
                                  SsProcess               • Placed as stand-alone object:
                                         State
Script
3
                                                              “director” orchestrates actions of
                                         (stand‐alone)         other objects (e.g. IGC)




       Game
Developers
Conference
2009                                                              20
Monday, April 6, 2009
Instantiating State Scripts
                                     SsProcess              • Placed as stand-alone object:
                                           State
Script
3
                                                                “director” orchestrates actions of
                                           (stand‐alone)         other objects (e.g. IGC)
                                                            • Associated with a task:
                        Task
A
                                                                task = check point
             Task
B1             Task
B2                        script manages associated task
                                                                orchestrates AI encounters
                        Task
C
                                     State
Script
4             controls player objectives
                        Task
D


       Game
Developers
Conference
2009                                                                20
Monday, April 6, 2009
Instantiating State Scripts
                                     SsProcess              • Placed as stand-alone object:
                                           State
Script
3
                                                                “director” orchestrates actions of
                                           (stand‐alone)         other objects (e.g. IGC)
                                                            • Associated with a task:
                        Task
A
                                                                task = check point
             Task
B1             Task
B2                        script manages associated task
                                                                orchestrates AI encounters
                        Task
C
                                     State
Script
4             controls player objectives
                        Task
D                              • Spawned by another state script
       Game
Developers
Conference
2009                                                                20
Monday, April 6, 2009
State Script Syntax




                                              21
Monday, April 6, 2009
Game
Developers
Conference
2009   22
Monday, April 6, 2009
State Script Syntax
       • State script defined as follows:
           Don’t let Lisp syntax throw you!
           Lisp syntax is all (parentheses)
                                               (define-state-script ("kickable-gate")
           Think C/C++ { } blocks               (state ("locked")
       • Parenthesized blocks highly             )
                                                   ...

         context-sensitive in Lisp/Scheme        (state ("opening")
                                                   ...
                                                 )
                                                 (state ("open")
                                                   ...
                                                 )
                                               )


       Game
Developers
Conference
2009                                                 23
Monday, April 6, 2009
State Script Syntax
       • State script defined as follows:
           Don’t let Lisp syntax throw you!
           Lisp syntax is all (parentheses)
                                               (define-state-script ("kickable-gate")
           Think C/C++ { } blocks               (state ("locked")
       • Parenthesized blocks highly             )
                                                   ...

         context-sensitive in Lisp/Scheme        (state ("opening")
                                                   ...
                                                 )
                                                 (state ("open")
                                                   ...
                                                 )
                                               )


       Game
Developers
Conference
2009                                                 23
Monday, April 6, 2009
State Script Syntax
       • State script defined as follows:
           Don’t let Lisp syntax throw you!
           Lisp syntax is all (parentheses)
                                               (define-state-script ("kickable-gate")
           Think C/C++ { } blocks               (state ("locked")
       • Parenthesized blocks highly             )
                                                   ...

         context-sensitive in Lisp/Scheme        (state ("opening")
                                                   ...
                                                 )
                                                 (state ("open")
                                                   ...
                                                 )
                                               )


       Game
Developers
Conference
2009                                                 23
Monday, April 6, 2009
State Script Syntax
       • State script defined as follows:
           Don’t let Lisp syntax throw you!
           Lisp syntax is all (parentheses)
                                               (define-state-script ("kickable-gate")
           Think C/C++ { } blocks               (state ("locked")
       • Parenthesized blocks highly             )
                                                   ...

         context-sensitive in Lisp/Scheme        (state ("opening")
                                                   ...
                                                 )
                                                 (state ("open")
                                                   ...
                                                 )
                                               )


       Game
Developers
Conference
2009                                                 23
Monday, April 6, 2009
Event Handler Blocks

                                            (define-state-script ("kickable-gate")
                                              (state ("locked")
                                                 (on (event "kick")
                                                   ... ;; handle "kick" event
       • Each state contains zero or more        )
                                                 (on (begin)
         event handler blocks                      ... ;; do when state entered
                                                 )
                                                 (on (update)
                                                   ... ;; do every frame
                                                 )
                                                (on (end)
                                                   ... ;; do when state exited
                                                 )
                                            )


       Game
Developers
Conference
2009                                              24
Monday, April 6, 2009
Event Handler Blocks

                                            (define-state-script ("kickable-gate")
                                              (state ("locked")
                                                 (on (event "kick")
                                                   ... ;; handle "kick" event
       • Each state contains zero or more        )
                                                 (on (begin)
         event handler blocks                      ... ;; do when state entered
                                                 )
                                                 (on (update)
                                                   ... ;; do every frame
                                                 )
                                                (on (end)
                                                   ... ;; do when state exited
                                                 )
                                            )


       Game
Developers
Conference
2009                                              24
Monday, April 6, 2009
Event Handler Blocks

                                            (define-state-script ("kickable-gate")
                                              (state ("locked")
                                                 (on (event "kick")
                                                   ... ;; handle "kick" event
       • Each state contains zero or more        )
                                                 (on (begin)
         event handler blocks                      ... ;; do when state entered
                                                 )
                                                 (on (update)
                                                   ... ;; do every frame
                                                 )
                                                (on (end)
                                                   ... ;; do when state exited
                                                 )
                                            )


       Game
Developers
Conference
2009                                              24
Monday, April 6, 2009
Event Handler Blocks

                                            (define-state-script ("kickable-gate")
                                              (state ("locked")
                                                 (on (event "kick")
                                                   ... ;; handle "kick" event
       • Each state contains zero or more        )
                                                 (on (begin)
         event handler blocks                      ... ;; do when state entered
                                                 )
                                                 (on (update)
                                                   ... ;; do every frame
                                                 )
                                                (on (end)
                                                   ... ;; do when state exited
                                                 )
                                            )


       Game
Developers
Conference
2009                                              24
Monday, April 6, 2009
Event Handler Blocks

                                            (define-state-script ("kickable-gate")
                                              (state ("locked")
                                                 (on (event "kick")
                                                   ... ;; handle "kick" event
       • Each state contains zero or more        )
                                                 (on (begin)
         event handler blocks                      ... ;; do when state entered
                                                 )
                                                 (on (update)
                                                   ... ;; do every frame
                                                 )
                                                (on (end)
                                                   ... ;; do when state exited
                                                 )
                                            )


       Game
Developers
Conference
2009                                              24
Monday, April 6, 2009
Runtime Script Code
       • Runtime script code inside (on ...)   (state ("locked")
                                                 (on (begin)
         blocks                                    [print-string "Starting idle!"]
                                                   [animate "self" "locked-idle"]
       • Simplified Scheme/Lisp                   )
                                                 (on (event "kicked")
           Most “commands” are native calls       [when [lock-broken?]
            into C++ code                             [print-string "BAM!"]
                                                   ]
           Conditional expressions                [if [task-complete? "wave2"]
                                                      [print-string "Complete!"]
           Simple looping via label/goto             [print-string "NOT!!!"]
                                                   ]
                                                 )
                                               )



       Game
Developers
Conference
2009                                               25
Monday, April 6, 2009
Runtime Script Code
       • Runtime script code inside (on ...)   (state ("locked")
                                                 (on (begin)
         blocks                                    [print-string "Starting idle!"]
                                                   [animate "self" "locked-idle"]
       • Simplified Scheme/Lisp                   )
                                                 (on (event "kicked")
           Most “commands” are native calls       [when [lock-broken?]
            into C++ code                             [print-string "BAM!"]
                                                   ]
           Conditional expressions                [if [task-complete? "wave2"]
                                                      [print-string "Complete!"]
           Simple looping via label/goto             [print-string "NOT!!!"]
                                                   ]
                                                 )
                                               )



       Game
Developers
Conference
2009                                               25
Monday, April 6, 2009
Runtime Script Code
       • Runtime script code inside (on ...)   (state ("locked")
                                                 (on (begin)
         blocks                                    [print-string "Starting idle!"]
                                                   [animate "self" "locked-idle"]
       • Simplified Scheme/Lisp                   )
                                                 (on (event "kicked")
           Most “commands” are native calls       [when [lock-broken?]
            into C++ code                             [print-string "BAM!"]
                                                   ]
           Conditional expressions                [if [task-complete? "wave2"]
                                                      [print-string "Complete!"]
           Simple looping via label/goto             [print-string "NOT!!!"]
                                                   ]
                                                 )
                                               )



       Game
Developers
Conference
2009                                               25
Monday, April 6, 2009
Runtime Script Code
       • Runtime script code inside (on ...)   (state ("locked")
                                                 (on (begin)
         blocks                                    [print-string "Starting idle!"]
                                                   [animate "self" "locked-idle"]
       • Simplified Scheme/Lisp                   )
                                                 (on (event "kicked")
           Most “commands” are native calls       [when [lock-broken?]
            into C++ code                             [print-string "BAM!"]
                                                   ]
           Conditional expressions                [if [task-complete? "wave2"]
                                                      [print-string "Complete!"]
           Simple looping via label/goto             [print-string "NOT!!!"]
                                                   ]
                                                 )
                                               )



       Game
Developers
Conference
2009                                               25
Monday, April 6, 2009
User-Defined Functions
                                           (defun verbose-anim ((anim string))
                                             [print-string "Starting " anim]
                                             [animate "self" anim]
                                           )
       • Script functions can be defined
         and called by script programmer   (define-state-script ("kickable-gate")
                                             (state ("locked")
                                                 (on (begin)
                                                   [verbose-anim "locked-idle"]
                                                 )
                                             )
                                             ...
                                           )




       Game
Developers
Conference
2009                                             26
Monday, April 6, 2009
User-Defined Functions
                                           (defun verbose-anim ((anim string))
                                             [print-string "Starting " anim]
                                             [animate "self" anim]
                                           )
       • Script functions can be defined
         and called by script programmer   (define-state-script ("kickable-gate")
                                             (state ("locked")
                                                 (on (begin)
                                                   [verbose-anim "locked-idle"]
                                                 )
                                             )
                                             ...
                                           )




       Game
Developers
Conference
2009                                             26
Monday, April 6, 2009
User-Defined Functions
                                           (defun verbose-anim ((anim string))
                                             [print-string "Starting " anim]
                                             [animate "self" anim]
                                           )
       • Script functions can be defined
         and called by script programmer   (define-state-script ("kickable-gate")
                                             (state ("locked")
                                                 (on (begin)
                                                   [verbose-anim "locked-idle"]
                                                 )
                                             )
                                             ...
                                           )




       Game
Developers
Conference
2009                                             26
Monday, April 6, 2009
User-Defined Functions
                                           (defun verbose-anim ((anim string))
                                             [print-string "Starting " anim]
                                             [animate "self" anim]
                                           )
       • Script functions can be defined
         and called by script programmer   (define-state-script ("kickable-gate")
                                             (state ("locked")
                                                 (on (begin)
                                                   [verbose-anim "locked-idle"]
                                                 )
                                             )
                                             ...
                                           )




       Game
Developers
Conference
2009                                             26
Monday, April 6, 2009
User-Defined Functions
                                           (defun verbose-anim ((anim string))
                                             [print-string "Starting " anim]
                                             [animate "self" anim]
                                           )
       • Script functions can be defined
         and called by script programmer   (define-state-script ("kickable-gate")
                                             (state ("locked")
                                                 (on (begin)
                                                   [verbose-anim "locked-idle"]
                                                 )
                                             )
                                             ...
                                           )




       Game
Developers
Conference
2009                                             26
Monday, April 6, 2009
The “Self” Argument
       • Any command operating on a game object takes its unique id
         (UID) as its first argument
       • Magic UID "self" refers to the object to which script is attached

                                         gate‐17
                                         Game

                                         Object


                                            State
Script
1




       Game
Developers
Conference
2009                                       27
Monday, April 6, 2009
The “Self” Argument
       • Any command operating on a game object takes its unique id
         (UID) as its first argument
       • Magic UID "self" refers to the object to which script is attached
                                                                 (on (begin)
                                         gate‐17
                                                                   [animate "self" "locked-idle"]
                                         Game
                   )
                                         Object


                                                State
Script
1


                                         self

       Game
Developers
Conference
2009                                                              27
Monday, April 6, 2009
The “Self” Argument
       • Any command operating on a game object takes its unique id
         (UID) as its first argument
       • Magic UID "self" refers to the object to which script is attached

                                         gate‐17             (on (begin)
                                         Game
                 [animate "gate-17" "locked-idle"]
                                         Object              )



                                            State
Script
1




       Game
Developers
Conference
2009                                                             27
Monday, April 6, 2009
The “Self” Argument
       • Any command operating on a game object takes its unique id
         (UID) as its first argument
       • Magic UID "self" refers to the object to which script is attached

                                         gate‐17
                                                             (on (begin)
                                         Game
                 [animate "lock-6" "fall-off"]
                                         Object              )


                                            State
Script
1                    lock‐6
                                                                             Game

                                                                             Object


       Game
Developers
Conference
2009                                                         27
Monday, April 6, 2009
Changing States
                                             (define-state-script ("kickable-gate")
                                               (state ("locked")
         • Transitions to other states via       ...
           (go "state-name") command             (on (event "kicked")
                                                     [when [lock-broken?]
         • State transitions cause current           ]
                                                         [go "opening"]

           state’s (on ...) blocks to be         )
                                               )
           aborted                             (state ("opening")
                                                 (on (begin)
         • Use (on (exit) ...) block for             ...
           clean-up                              )
                                                 ...
                                               )
                                             )


       Game
Developers
Conference
2009                                               28
Monday, April 6, 2009
Changing States
                                             (define-state-script ("kickable-gate")
                                               (state ("locked")
         • Transitions to other states via       ...
           (go "state-name") command             (on (event "kicked")
                                                     [when [lock-broken?]
         • State transitions cause current           ]
                                                         [go "opening"]

           state’s (on ...) blocks to be         )
                                               )
           aborted                             (state ("opening")
                                                 (on (begin)
         • Use (on (exit) ...) block for             ...
           clean-up                              )
                                                 ...
                                               )
                                             )


       Game
Developers
Conference
2009                                               28
Monday, April 6, 2009
Changing States
                                             (define-state-script ("kickable-gate")
                                               (state ("locked")
         • Transitions to other states via       ...
           (go "state-name") command             (on (event "kicked")
                                                     [when [lock-broken?]
         • State transitions cause current           ]
                                                         [go "opening"]

           state’s (on ...) blocks to be         )
                                               )
           aborted                             (state ("opening")
                                                 (on (begin)
         • Use (on (exit) ...) block for             ...
           clean-up                              )
                                                 ...
                                               )
                                             )


       Game
Developers
Conference
2009                                               28
Monday, April 6, 2009
Tracks
       • (on ...) blocks contain one or more tracks
       • A track is a bit like a thread or fiber
       • Tracks can be put to sleep
           Wait for duration
             • e.g., wait 5 seconds,
             • wait until frame 23, ...
           Wait for an action to be done
             • duration-agnostic
       • Tracks can be synchronized via signals
       Game
Developers
Conference
2009                29
Monday, April 6, 2009
Tracks
                   (state ("shake-hands")                                  State
"shake‐hands"
                     (on (begin)                                          On
Begin
                        (track ("player"))
                          [wait-move-to "player" "waypoint7"]                Track           Track
                                                                               P               S
                          [signal "player-at-waypoint"]
                          [wait-for-signal "sully-at-waypoint"]
                          [wait-animate "player" "shake-sullys-hand"]                s‐a‐w
                        )
                       (track ("sullivan"))
                          [wait-move-to "sullivan" "waypoint7"]
                          [signal "sully-at-waypoint"]                               p‐a‐w
                          [wait-for-signal "player-at-waypoint"]
                          [wait-animate "sullivan" "shake-drakes-hand"]
                        )
                     )
                   )


       Game
Developers
Conference
2009                                                               30
Monday, April 6, 2009
Tracks
                   (state ("shake-hands")                                  State
"shake‐hands"
                     (on (begin)                                          On
Begin
                        (track ("player"))
                          [wait-move-to "player" "waypoint7"]                Track           Track
                                                                               P               S
                          [signal "player-at-waypoint"]
                          [wait-for-signal "sully-at-waypoint"]
                          [wait-animate "player" "shake-sullys-hand"]                s‐a‐w
                        )
                       (track ("sullivan"))
                          [wait-move-to "sullivan" "waypoint7"]
                          [signal "sully-at-waypoint"]                               p‐a‐w
                          [wait-for-signal "player-at-waypoint"]
                          [wait-animate "sullivan" "shake-drakes-hand"]
                        )
                     )
                   )


       Game
Developers
Conference
2009                                                               30
Monday, April 6, 2009
Tracks
                   (state ("shake-hands")                                  State
"shake‐hands"
                     (on (begin)                                          On
Begin
                        (track ("player"))
                          [wait-move-to "player" "waypoint7"]                Track           Track
                                                                               P               S
                          [signal "player-at-waypoint"]
                          [wait-for-signal "sully-at-waypoint"]
                          [wait-animate "player" "shake-sullys-hand"]                s‐a‐w
                        )
                       (track ("sullivan"))
                          [wait-move-to "sullivan" "waypoint7"]
                          [signal "sully-at-waypoint"]                               p‐a‐w
                          [wait-for-signal "player-at-waypoint"]
                          [wait-animate "sullivan" "shake-drakes-hand"]
                        )
                     )
                   )


       Game
Developers
Conference
2009                                                               30
Monday, April 6, 2009
Tracks
                   (state ("shake-hands")                                  State
"shake‐hands"
                     (on (begin)                                          On
Begin
                        (track ("player"))
                          [wait-move-to "player" "waypoint7"]                Track           Track
                                                                               P               S
                          [signal "player-at-waypoint"]
                          [wait-for-signal "sully-at-waypoint"]
                          [wait-animate "player" "shake-sullys-hand"]                s‐a‐w
                        )
                       (track ("sullivan"))
                          [wait-move-to "sullivan" "waypoint7"]
                          [signal "sully-at-waypoint"]                               p‐a‐w
                          [wait-for-signal "player-at-waypoint"]
                          [wait-animate "sullivan" "shake-drakes-hand"]
                        )
                     )
                   )


       Game
Developers
Conference
2009                                                               30
Monday, April 6, 2009
Tracks
                   (state ("shake-hands")                                  State
"shake‐hands"
                     (on (begin)                                          On
Begin
                        (track ("player"))
                          [wait-move-to "player" "waypoint7"]                Track           Track
                                                                               P               S
                          [signal "player-at-waypoint"]
                          [wait-for-signal "sully-at-waypoint"]
                          [wait-animate "player" "shake-sullys-hand"]                p‐a‐w
                        )
                       (track ("sullivan"))
                          [wait-move-to "sullivan" "waypoint7"]
                          [signal "sully-at-waypoint"]                               s‐a‐w
                          [wait-for-signal "player-at-waypoint"]
                          [wait-animate "sullivan" "shake-drakes-hand"]
                        )
                     )
                   )


       Game
Developers
Conference
2009                                                               30
Monday, April 6, 2009
Track Execution Over Time
       • Rules for execution of code within a track:
           Greedily consume instructions sequentially...
           ... until a [wait* ...] command encountered...
           ... then relinquish control until the action is complete
       • NOTE: A [wait* ...] command doesn’t have to wait; for example:
           [wait-seconds 0]
           [wait-npc-move-to "pos-4"] when she’s already there



       Game
Developers
Conference
2009                                    31
Monday, April 6, 2009
Options and Variable Declarations
                                                              • Options declared at top of
          (define-state-script ("kickable-gate")                 script:
            :initial-state "closed"
            :declarations (decl-list
                                                                  initial state
                (var "num-attempts" :type int32)
                (var "is-locked" :type boolean :default #t)
                                                                  variable declarations
            )                                                     debugging options
            (state ("kicked")
                ...
            )
            ...
          )




       Game
Developers
Conference
2009                                                       32
Monday, April 6, 2009
Options and Variable Declarations
                                                              • Options declared at top of
          (define-state-script ("kickable-gate")                 script:
            :initial-state "closed"
            :declarations (decl-list
                                                                  initial state
                (var "num-attempts" :type int32)
                (var "is-locked" :type boolean :default #t)
                                                                  variable declarations
            )                                                     debugging options
            (state ("kicked")
                ...
            )
            ...
          )




       Game
Developers
Conference
2009                                                       32
Monday, April 6, 2009
Options and Variable Declarations
                                                              • Options declared at top of
          (define-state-script ("kickable-gate")                 script:
            :initial-state "closed"
            :declarations (decl-list
                                                                  initial state
                (var "num-attempts" :type int32)
                (var "is-locked" :type boolean :default #t)
                                                                  variable declarations
            )                                                     debugging options
            (state ("kicked")
                ...
            )
            ...
          )




       Game
Developers
Conference
2009                                                       32
Monday, April 6, 2009
(define-state-script ("kickable-gate")
                                             :initial-state "closed"
            Manipulating Variables           :declarations (decl-list
                                                 (var "num-attempts" :type int32)
       • Simple commands for reading             (var "is-locked" :type boolean :default #t)
                                             )
         and writing variables               (state ("kicked")
                                                 (on (begin)
       • Lisp/Scheme uses prefix notation           [when [get-boolean "is-locked"]
                                                      [set-int32 "num-attempts"
         (a.k.a. Polish notation)                        [+ 1 [get-int32 "num-attempts"]]
                                                      ]
           [+ a b] calculates (a + b)                [wait-animate "self" "kick-failure"]
                                                      [go "closed"]
           [set "x" [+ 1 [get "x"]]]              ]
            increments variable “x”                ;; else...
                                                   [wait-animate "self" "kick-success"]
                                                   [go "open"]
                                                 )
                                             )
                                             ...

       Game
Developers
Conference
2009                                                     33
Monday, April 6, 2009
(define-state-script ("kickable-gate")
                                             :initial-state "closed"
            Manipulating Variables           :declarations (decl-list
                                                 (var "num-attempts" :type int32)
       • Simple commands for reading             (var "is-locked" :type boolean :default #t)
                                             )
         and writing variables               (state ("kicked")
                                                 (on (begin)
       • Lisp/Scheme uses prefix notation           [when [get-boolean "is-locked"]
                                                      [set-int32 "num-attempts"
         (a.k.a. Polish notation)                        [+ 1 [get-int32 "num-attempts"]]
                                                      ]
           [+ a b] calculates (a + b)                [wait-animate "self" "kick-failure"]
                                                      [go "closed"]
           [set "x" [+ 1 [get "x"]]]              ]
            increments variable “x”                ;; else...
                                                   [wait-animate "self" "kick-success"]
                                                   [go "open"]
                                                 )
                                             )
                                             ...

       Game
Developers
Conference
2009                                                     33
Monday, April 6, 2009
(define-state-script ("kickable-gate")
                                             :initial-state "closed"
            Manipulating Variables           :declarations (decl-list
                                                 (var "num-attempts" :type int32)
       • Simple commands for reading             (var "is-locked" :type boolean :default #t)
                                             )
         and writing variables               (state ("kicked")
                                                 (on (begin)
       • Lisp/Scheme uses prefix notation           [when [get-boolean "is-locked"]
                                                      [set-int32 "num-attempts"
         (a.k.a. Polish notation)                        [+ 1 [get-int32 "num-attempts"]]
                                                      ]
           [+ a b] calculates (a + b)                [wait-animate "self" "kick-failure"]
                                                      [go "closed"]
           [set "x" [+ 1 [get "x"]]]              ]
            increments variable “x”                ;; else...
                                                   [wait-animate "self" "kick-success"]
                                                   [go "open"]
                                                 )
                                             )
                                             ...

       Game
Developers
Conference
2009                                                     33
Monday, April 6, 2009
(define-state-script ("kickable-gate")
                                             :initial-state "closed"
            Manipulating Variables           :declarations (decl-list
                                                 (var "num-attempts" :type int32)
       • Simple commands for reading             (var "is-locked" :type boolean :default #t)
                                             )
         and writing variables               (state ("kicked")
                                                 (on (begin)
       • Lisp/Scheme uses prefix notation           [when [get-boolean "is-locked"]
                                                      [set-int32 "num-attempts"
         (a.k.a. Polish notation)                        [+ 1 [get-int32 "num-attempts"]]
                                                          ˘
                                                      ]
           [+ a b] calculates (a + b)                [wait-animate "self" "kick-failure"]
                                                      [go "closed"]
           [set "x" [+ 1 [get "x"]]]              ]
            increments variable “x”                ;; else...
                                                   [wait-animate "self" "kick-success"]
                                                   [go "open"]
                                                 )
                                             )
                                             ...

       Game
Developers
Conference
2009                                                     33
Monday, April 6, 2009
(define-state-script ("kickable-gate")
                                             :initial-state "closed"
            Manipulating Variables           :declarations (decl-list
                                                 (var "num-attempts" :type int32)
       • Simple commands for reading             (var "is-locked" :type boolean :default #t)
                                             )
         and writing variables               (state ("kicked")
                                                 (on (begin)
       • Lisp/Scheme uses prefix notation           [when [get-boolean "is-locked"]
                                                      [set-int32 "num-attempts"
         (a.k.a. Polish notation)                        [+ 1 [get-int32 "num-attempts"]]
                                                      ]
           [+ a b] calculates (a + b)                [wait-animate "self" "kick-failure"]
                                                      [go "closed"]
           [set "x" [+ 1 [get "x"]]]              ]
            increments variable “x”                ;; else...
                                                   [wait-animate "self" "kick-success"]
                                                   [go "open"]
                                                 )
                                             )
                                             ...

       Game
Developers
Conference
2009                                                     33
Monday, April 6, 2009
Configuration Parameters
       • All game objects have
         properties (key-value pairs)
           Property values edited in
            Charter




       Game
Developers
Conference
2009   34
Monday, April 6, 2009
Configuration Parameters
       • All game objects have
         properties (key-value pairs)
           Property values edited in
            Charter




       Game
Developers
Conference
2009   34
Monday, April 6, 2009
Configuration Parameters
       • Designers can create their
         own free-form properties,
         called tags                     meaning-of-life = 42



           Simply type “key = value”
            in Tags field




       Game
Developers
Conference
2009                          34
Monday, April 6, 2009
Configuration Parameters
       • State scripts have read-only access to game object properties...
           ... and free-form tags




       Game
Developers
Conference
2009                                      35
Monday, April 6, 2009
Configuration Parameters
       • State scripts have read-only access to game object properties...
           ... and free-form tags


                  (define-state-script ("kickable-gate")
                    (state ("kicked")
                        (on (begin)
                          [wait-animate "self"
                            [tag-string "kick-anim"]
                          ]
                    )
                    ...
                  )


       Game
Developers
Conference
2009                                      35
Monday, April 6, 2009
Configuration Parameters
       • State scripts have read-only access to game object properties...
           ... and free-form tags


                  (define-state-script ("kickable-gate")
                    (state ("kicked")
                        (on (begin)
                          [wait-animate "self"
                            [tag-string "kick-anim"]
                          ]
                    )
                    ...
                  )


       Game
Developers
Conference
2009                                      35
Monday, April 6, 2009
Configuration Parameters
       • State scripts have read-only access to game object properties...
           ... and free-form tags


                  (define-state-script ("kickable-gate")
                    (state ("kicked")
                        (on (begin)
                          [wait-animate "self"
                            [tag-string "kick-anim"]
                          ]
                    )
                    ...
                  )


       Game
Developers
Conference
2009                                      35
Monday, April 6, 2009
Data Definition and Runtime
                                          (define-state-script ("kickable-gate")
       • Offline data-definition language     (state ("locked")
                                                (on (begin)
         (Scheme) is intermingled with            [print-string "Starting idle!"]
                                                  [animate "self" "locked-idle"]
         runtime code                           )
                                                (on (event "kicked")
                                                  [when [lock-broken?]
                                                     [print-string "BAM!"]
                                                  ]
                                                  [if [task-complete? "wave2"]
                                                     [print-string "Complete!"]
                                                     [print-string "NOT!!!"]
                                                  ]
                                                )
                                            )
                                            ...
                                          )

       Game
Developers
Conference
2009                                              36
Monday, April 6, 2009
Data Definition and Runtime
                                          (define-state-script ("kickable-gate")
       • Offline data-definition language     (state ("locked")
                                                (on (begin)
         (Scheme) is intermingled with            [print-string "Starting idle!"]
                                                  [animate "self" "locked-idle"]
         runtime code                           )
                                                (on (event "kicked")
                                                  [when [lock-broken?]
                                                     [print-string "BAM!"]
                                                  ]
                                                  [if [task-complete? "wave2"]
                                                     [print-string "Complete!"]
                                                     [print-string "NOT!!!"]
                                                  ]
                                                )
                                            )
                                            ...
                                          )

       Game
Developers
Conference
2009                                              36
Monday, April 6, 2009
Data Definition and Runtime

                                            class Vector3
                                            {
                                            private:
                                               float x, y, z;
       • Really no different than the       public:
                                               float Dot(const Vector3& b)
         distinction between declarations      {
                                                   return (x * b.x
         and definitions in C++                           + y * b.y
                                                         + z * b.z);
                                               }
                                               ...
                                            };




       Game
Developers
Conference
2009                                      36
Monday, April 6, 2009
Data Definition and Runtime

                                            class Vector3
                                            {
                                            private:
                                               float x, y, z;
       • Really no different than the       public:
                                               float Dot(const Vector3& b)
         distinction between declarations      {
                                                   return (x * b.x
         and definitions in C++                           + y * b.y
                                                         + z * b.z);
                                               }
                                               ...
                                            };




       Game
Developers
Conference
2009                                      36
Monday, April 6, 2009
Case Studies




                                       37
Monday, April 6, 2009
Custom Object Type: Breakable Sign




       Game
Developers
Conference
2009           38
Monday, April 6, 2009
Custom Object Type: Breakable Sign




       Game
Developers
Conference
2009           38
Monday, April 6, 2009
Custom Object Type: Breakable Sign


           (define-state-script ("falling-sign")
             (state ("untouched")
                 (on (update)
                   [when [task-complete? "wz-post-combat"]
                     [go "fallen"]
                   ]
                 )
                (on (event "hanging-from")
                   [go "breaking"]
                 )
             )
             ...




       Game
Developers
Conference
2009                       39
Monday, April 6, 2009
Custom Object Type: Breakable Sign


           (define-state-script ("falling-sign")
             (state ("untouched")
                 (on (update)
                   [when [task-complete? "wz-post-combat"]
                     [go "fallen"]
                   ]
                 )
                (on (event "hanging-from")
                   [go "breaking"]
                 )
             )
             ...




       Game
Developers
Conference
2009                       39
Monday, April 6, 2009
Custom Object Type: Breakable Sign


           (define-state-script ("falling-sign")
             (state ("untouched")
                 (on (update)
                   [when [task-complete? "wz-post-combat"]
                     [go "fallen"]
                   ]
                 )
                (on (event "hanging-from")
                   [go "breaking"]
                 )
             )
             ...




       Game
Developers
Conference
2009                       39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                             (state ("breaking")
                                                (on (begin)
                                                  [spawn-particles-at-joint "self"
                                                    "hinge"
                                                    "sign-break-dust"]
                                                  [wait-animate "self" "sign-break"]
                                                  [go "fallen"]
                                               )
                                             )
                                             (state ("fallen")
                                                (on (begin)
                                                  [animate "self" "sign-broken"] ;; looping
                                                )
                                             )
                                         )


       Game
Developers
Conference
2009                                                        39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                             (state ("breaking")
                                                (on (begin)
                                                  [spawn-particles-at-joint "self"
                                                    "hinge"
                                                    "sign-break-dust"]
                                                  [wait-animate "self" "sign-break"]
                                                  [go "fallen"]
                                               )
                                             )
                                             (state ("fallen")
                                                (on (begin)
                                                  [animate "self" "sign-broken"] ;; looping
                                                )
                                             )
                                         )


       Game
Developers
Conference
2009                                                        39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                             (state ("breaking")
                                                (on (begin)
                                                  [spawn-particles-at-joint "self"
                                                    "hinge"
                                                    "sign-break-dust"]
                                                  [wait-animate "self" "sign-break"]
                                                  [go "fallen"]
                                               )
                                             )
                                             (state ("fallen")
                                                (on (begin)
                                                  [animate "self" "sign-broken"] ;; looping
                                                )
                                             )
                                         )


       Game
Developers
Conference
2009                                                        39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                             (state ("breaking")
                                                (on (begin)
                                                  [spawn-particles-at-joint "self"
                                                    "hinge"
                                                    "sign-break-dust"]
                                                  [wait-animate "self" "sign-break"]
                                                  [go "fallen"]
                                               )
                                             )
                                             (state ("fallen")
                                                (on (begin)
                                                  [animate "self" "sign-broken"] ;; looping
                                                )
                                             )
                                         )


       Game
Developers
Conference
2009                                                        39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                             (state ("breaking")
                                                (on (begin)
                                                  [spawn-particles-at-joint "self"
                                                    "hinge"
                                                    "sign-break-dust"]
                                                  [wait-animate "self" "sign-break"]
                                                  [go "fallen"]
                                               )
                                             )
                                             (state ("fallen")
                                                (on (begin)
                                                  [animate "self" "sign-broken"] ;; looping
                                                )
                                             )
                                         )


       Game
Developers
Conference
2009                                                        39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                             (state ("breaking")
                                                (on (begin)
                                                  [spawn-particles-at-joint "self"
                                                    "hinge"
                                                    "sign-break-dust"]
                                                  [wait-animate "self" "sign-break"]
                                                  [go "fallen"]
                                               )
                                             )
                                             (state ("fallen")
                                                (on (begin)
                                                  [animate "self" "sign-broken"] ;; looping
                                                )
                                             )
                                         )


       Game
Developers
Conference
2009                                                        39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                             (state ("breaking")
                                                (on (begin)
                                                  [spawn-particles-at-joint "self"
                                                    "hinge"
                                                    "sign-break-dust"]
                                                  [wait-animate "self" "sign-break"]
                                                  [go "fallen"]
                                               )
                                             )
                                             (state ("fallen")
                                                (on (begin)
                                                  [animate "self" "sign-broken"] ;; looping
                                                )
                                             )
                                         )


       Game
Developers
Conference
2009                                                        39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                             (state ("breaking")
                                                (on (begin)
                                                  [spawn-particles-at-joint "self"
                                                    "hinge"
                                                    "sign-break-dust"]
                                                  [wait-animate "self" "sign-break"]
                                                  [go "fallen"]
                                               )
                                             )
                                             (state ("fallen")
                                                (on (begin)
                                                  [animate "self" "sign-broken"] ;; looping
                                                )
                                             )
                                         )


       Game
Developers
Conference
2009                                                        39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                             (state ("breaking")
                                                (on (begin)
                                                  [spawn-particles-at-joint "self"
                                                    "hinge"
                                                    "sign-break-dust"]
                                                  [wait-animate "self" "sign-break"]
                                                  [go "fallen"]
                                               )
                                             )
                                             (state ("fallen")
                                                (on (begin)
                                                  [animate "self" "sign-broken"] ;; looping
                                                )
                                             )
                                         )


       Game
Developers
Conference
2009                                                        39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                                                 (state ("breaking")
                                                                    (on (begin)
           (define-state-script ("falling-sign")
                                                                      [spawn-particles-at-joint "self"
             (state ("untouched")
                                                                        "hinge"
                 (on (update)
                                                                        "sign-break-dust"]
                   [when [task-complete? "wz-post-combat"]
                                                                      [wait-animate "self" "sign-break"]
                     [go "fallen"]
                                                                      [go "fallen"]
                   ]
                                                                   )
                 )
                                                                 )
                (on (event "hanging-from")
                                                                 (state ("fallen")
                   [go "breaking"]
                                                                    (on (begin)
                 )
                                                                      [animate "self" "sign-broken"] ;; looping
             )
                                                                    )
             ...
                                                                 )
                                                             )


       Game
Developers
Conference
2009                                                                            39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                                                 (state ("breaking")
                                                                    (on (begin)
           (define-state-script ("falling-sign")
                                                                      [spawn-particles-at-joint "self"
             (state ("untouched")
                                                                        "hinge"
                 (on (update)
                                                                        "sign-break-dust"]
                   [when [task-complete? "wz-post-combat"]
                                                                      [wait-animate "self" "sign-break"]
                     [go "fallen"]
                                                                      [go "fallen"]
                   ]
                                                                   )
                 )
                                                                 )
                (on (event "hanging-from")
                                                                 (state ("fallen")
                   [go "breaking"]
                                                                    (on (begin)
                 )
                                                                      [animate "self" "sign-broken"] ;; looping
             )
                                                                    )
             ...
                                                                 )
                                                             )


       Game
Developers
Conference
2009                                                                            39
Monday, April 6, 2009
Custom Object Type: Breakable Sign

                                                                 (state ("breaking")
                                                                    (on (begin)
           (define-state-script ("falling-sign")
                                                                      [spawn-particles-at-joint "self"
             (state ("untouched")
                                                                        "hinge"
                 (on (update)
                                                                        "sign-break-dust"]
                   [when [task-complete? "wz-post-combat"]
                                                                      [wait-animate "self" "sign-break"]
                     [go "fallen"]
                                                                      [go "fallen"]
                   ]
                                                                   )
                 )
                                                                 )
                (on (event "hanging-from")
                                                                 (state ("fallen")
                   [go "breaking"]
                                                                    (on (begin)
                 )
                                                                      [animate "self" "sign-broken"] ;; looping
             )
                                                                    )
             ...
                                                                 )
                                                             )


       Game
Developers
Conference
2009                                                                            39
Monday, April 6, 2009
Making the Sign Script Generic
                                                                (state ("animating")
                                                                   (on (begin)
                                                                     [spawn-particles-at-joint "self"
          (define-state-script ("simple-animating-obj")
                                                                       [tag-string "particle-joint"]
            (state ("initial")
                                                                       [tag-string "particle-name"]]
                (on (update)
                                                                     [wait-animate "self"
                  [when [task-complete?
                                                                       [tag-string "anim-name"]]
                                [tag-string "done-task"]]
                                                                     [go "done"]
                    [go "done"]
                                                                  )
                  ]
                                                                )
                )
                                                                (state ("done")
               (on (event "hanging-from")
                                                                   (on (begin)
                  [go "animating"]
                                                                     [animate "self"
                )
                                                                       [tag-string "done-anim-name"]]
            )
                                                                   )
            ...
                                                                )
                                                            )

       Game
Developers
Conference
2009                                                                  40
Monday, April 6, 2009
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves

Más contenido relacionado

La actualidad más candente

ゲームAI製作のためのワークショップ(II)
ゲームAI製作のためのワークショップ(II)ゲームAI製作のためのワークショップ(II)
ゲームAI製作のためのワークショップ(II)Youichiro Miyake
 
【UE4.25 新機能】新しいシリアライゼーション機能「Unversioned Property Serialization」について
【UE4.25 新機能】新しいシリアライゼーション機能「Unversioned Property Serialization」について【UE4.25 新機能】新しいシリアライゼーション機能「Unversioned Property Serialization」について
【UE4.25 新機能】新しいシリアライゼーション機能「Unversioned Property Serialization」についてエピック・ゲームズ・ジャパン Epic Games Japan
 
FINAL FANTASY XVにおけるPhoton利用事例 - Photon運営事務局 GTMF 2018 OSAKA / TOKYO
FINAL FANTASY XVにおけるPhoton利用事例 - Photon運営事務局 GTMF 2018 OSAKA / TOKYOFINAL FANTASY XVにおけるPhoton利用事例 - Photon運営事務局 GTMF 2018 OSAKA / TOKYO
FINAL FANTASY XVにおけるPhoton利用事例 - Photon運営事務局 GTMF 2018 OSAKA / TOKYOGame Tools & Middleware Forum
 
【Unity道場】新しいPrefabワークフロー入門
【Unity道場】新しいPrefabワークフロー入門【Unity道場】新しいPrefabワークフロー入門
【Unity道場】新しいPrefabワークフロー入門Unity Technologies Japan K.K.
 
Uncharted Animation Workflow
Uncharted Animation WorkflowUncharted Animation Workflow
Uncharted Animation WorkflowNaughty Dog
 
Unreal Engine 4 Introduction
Unreal Engine 4 IntroductionUnreal Engine 4 Introduction
Unreal Engine 4 IntroductionSperasoft
 
Killzone Shadow Fall: Threading the Entity Update on PS4
Killzone Shadow Fall: Threading the Entity Update on PS4Killzone Shadow Fall: Threading the Entity Update on PS4
Killzone Shadow Fall: Threading the Entity Update on PS4jrouwe
 
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~Unity Technologies Japan K.K.
 
【Unite Tokyo 2018】『崩壊3rd』開発者が語るアニメ風レンダリングの極意
【Unite Tokyo 2018】『崩壊3rd』開発者が語るアニメ風レンダリングの極意【Unite Tokyo 2018】『崩壊3rd』開発者が語るアニメ風レンダリングの極意
【Unite Tokyo 2018】『崩壊3rd』開発者が語るアニメ風レンダリングの極意UnityTechnologiesJapan002
 
Unity Internals: Memory and Performance
Unity Internals: Memory and PerformanceUnity Internals: Memory and Performance
Unity Internals: Memory and PerformanceDevGAMM Conference
 
人工知能とゲーム(後篇)
人工知能とゲーム(後篇)人工知能とゲーム(後篇)
人工知能とゲーム(後篇)Youichiro Miyake
 
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesUnreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesEpic Games China
 
[IGC 2016] 골드로쉬 김현석 - 왜 항상 기획자는 욕을 들어야만 하는 걸까? –게임 기획의 포지션 변화-
[IGC 2016] 골드로쉬 김현석 - 왜 항상 기획자는 욕을 들어야만 하는 걸까? –게임 기획의 포지션 변화-[IGC 2016] 골드로쉬 김현석 - 왜 항상 기획자는 욕을 들어야만 하는 걸까? –게임 기획의 포지션 변화-
[IGC 2016] 골드로쉬 김현석 - 왜 항상 기획자는 욕을 들어야만 하는 걸까? –게임 기획의 포지션 변화-강 민우
 
NDC 2010 이은석 - 마비노기 영웅전 포스트모템 2부
NDC 2010 이은석 - 마비노기 영웅전 포스트모템 2부NDC 2010 이은석 - 마비노기 영웅전 포스트모템 2부
NDC 2010 이은석 - 마비노기 영웅전 포스트모템 2부Eunseok Yi
 
Level Design Challenges & Solutions - Mirror's Edge
Level Design Challenges & Solutions - Mirror's EdgeLevel Design Challenges & Solutions - Mirror's Edge
Level Design Challenges & Solutions - Mirror's EdgeElectronic Arts / DICE
 
背景を作って苦労してみた ~Amplify Impostors~
背景を作って苦労してみた ~Amplify Impostors~背景を作って苦労してみた ~Amplify Impostors~
背景を作って苦労してみた ~Amplify Impostors~poko ponmaru
 
Scene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game EnginesScene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game EnginesBryan Duggan
 
Ndc12 이창희 render_pipeline
Ndc12 이창희 render_pipelineNdc12 이창희 render_pipeline
Ndc12 이창희 render_pipelinechangehee lee
 

La actualidad más candente (20)

ゲームAI製作のためのワークショップ(II)
ゲームAI製作のためのワークショップ(II)ゲームAI製作のためのワークショップ(II)
ゲームAI製作のためのワークショップ(II)
 
【UE4.25 新機能】新しいシリアライゼーション機能「Unversioned Property Serialization」について
【UE4.25 新機能】新しいシリアライゼーション機能「Unversioned Property Serialization」について【UE4.25 新機能】新しいシリアライゼーション機能「Unversioned Property Serialization」について
【UE4.25 新機能】新しいシリアライゼーション機能「Unversioned Property Serialization」について
 
FINAL FANTASY XVにおけるPhoton利用事例 - Photon運営事務局 GTMF 2018 OSAKA / TOKYO
FINAL FANTASY XVにおけるPhoton利用事例 - Photon運営事務局 GTMF 2018 OSAKA / TOKYOFINAL FANTASY XVにおけるPhoton利用事例 - Photon運営事務局 GTMF 2018 OSAKA / TOKYO
FINAL FANTASY XVにおけるPhoton利用事例 - Photon運営事務局 GTMF 2018 OSAKA / TOKYO
 
【Unity道場】新しいPrefabワークフロー入門
【Unity道場】新しいPrefabワークフロー入門【Unity道場】新しいPrefabワークフロー入門
【Unity道場】新しいPrefabワークフロー入門
 
Uncharted Animation Workflow
Uncharted Animation WorkflowUncharted Animation Workflow
Uncharted Animation Workflow
 
Unreal Engine 4 Introduction
Unreal Engine 4 IntroductionUnreal Engine 4 Introduction
Unreal Engine 4 Introduction
 
Killzone Shadow Fall: Threading the Entity Update on PS4
Killzone Shadow Fall: Threading the Entity Update on PS4Killzone Shadow Fall: Threading the Entity Update on PS4
Killzone Shadow Fall: Threading the Entity Update on PS4
 
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~
【Unite Tokyo 2018】その最適化、本当に最適ですか!? ~正しい最適化を行うためのテクニック~
 
【Unite Tokyo 2018】『崩壊3rd』開発者が語るアニメ風レンダリングの極意
【Unite Tokyo 2018】『崩壊3rd』開発者が語るアニメ風レンダリングの極意【Unite Tokyo 2018】『崩壊3rd』開発者が語るアニメ風レンダリングの極意
【Unite Tokyo 2018】『崩壊3rd』開発者が語るアニメ風レンダリングの極意
 
Unity Internals: Memory and Performance
Unity Internals: Memory and PerformanceUnity Internals: Memory and Performance
Unity Internals: Memory and Performance
 
人工知能とゲーム(後篇)
人工知能とゲーム(後篇)人工知能とゲーム(後篇)
人工知能とゲーム(後篇)
 
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile GamesUnreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
Unreal Open Day 2017 UE4 for Mobile: The Future of High Quality Mobile Games
 
[IGC 2016] 골드로쉬 김현석 - 왜 항상 기획자는 욕을 들어야만 하는 걸까? –게임 기획의 포지션 변화-
[IGC 2016] 골드로쉬 김현석 - 왜 항상 기획자는 욕을 들어야만 하는 걸까? –게임 기획의 포지션 변화-[IGC 2016] 골드로쉬 김현석 - 왜 항상 기획자는 욕을 들어야만 하는 걸까? –게임 기획의 포지션 변화-
[IGC 2016] 골드로쉬 김현석 - 왜 항상 기획자는 욕을 들어야만 하는 걸까? –게임 기획의 포지션 변화-
 
NDC 2010 이은석 - 마비노기 영웅전 포스트모템 2부
NDC 2010 이은석 - 마비노기 영웅전 포스트모템 2부NDC 2010 이은석 - 마비노기 영웅전 포스트모템 2부
NDC 2010 이은석 - 마비노기 영웅전 포스트모템 2부
 
Level Design Challenges & Solutions - Mirror's Edge
Level Design Challenges & Solutions - Mirror's EdgeLevel Design Challenges & Solutions - Mirror's Edge
Level Design Challenges & Solutions - Mirror's Edge
 
背景を作って苦労してみた ~Amplify Impostors~
背景を作って苦労してみた ~Amplify Impostors~背景を作って苦労してみた ~Amplify Impostors~
背景を作って苦労してみた ~Amplify Impostors~
 
Scene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game EnginesScene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game Engines
 
Ndc12 이창희 render_pipeline
Ndc12 이창희 render_pipelineNdc12 이창희 render_pipeline
Ndc12 이창희 render_pipeline
 
UE4 Hair & Groomでのリアルタイムファーレンダリング (UE4 Character Art Dive Online)
UE4 Hair & Groomでのリアルタイムファーレンダリング (UE4 Character Art Dive Online)UE4 Hair & Groomでのリアルタイムファーレンダリング (UE4 Character Art Dive Online)
UE4 Hair & Groomでのリアルタイムファーレンダリング (UE4 Character Art Dive Online)
 
Unreal engine4を使ったVRコンテンツ製作で 120%役に立つtips集+GDC情報をご紹介
Unreal engine4を使ったVRコンテンツ製作で 120%役に立つtips集+GDC情報をご紹介Unreal engine4を使ったVRコンテンツ製作で 120%役に立つtips集+GDC情報をご紹介
Unreal engine4を使ったVRコンテンツ製作で 120%役に立つtips集+GDC情報をご紹介
 

Destacado

GDC 2011 Level Design in a Day. Summary & Introduction: Coray Seifert, Senior...
GDC 2011 Level Design in a Day. Summary & Introduction: Coray Seifert, Senior...GDC 2011 Level Design in a Day. Summary & Introduction: Coray Seifert, Senior...
GDC 2011 Level Design in a Day. Summary & Introduction: Coray Seifert, Senior...LevelDesign InADay
 
SPU Optimizations - Part 2
SPU Optimizations - Part 2SPU Optimizations - Part 2
SPU Optimizations - Part 2Naughty Dog
 
Adventures In Data Compilation
Adventures In Data CompilationAdventures In Data Compilation
Adventures In Data CompilationNaughty Dog
 
SPU Optimizations-part 1
SPU Optimizations-part 1SPU Optimizations-part 1
SPU Optimizations-part 1Naughty Dog
 
Creating A Character in Uncharted: Drake's Fortune
Creating A Character in Uncharted: Drake's FortuneCreating A Character in Uncharted: Drake's Fortune
Creating A Character in Uncharted: Drake's FortuneNaughty Dog
 
Amazing Feats of Daring - Uncharted Post Mortem
Amazing Feats of Daring - Uncharted Post MortemAmazing Feats of Daring - Uncharted Post Mortem
Amazing Feats of Daring - Uncharted Post MortemNaughty Dog
 
Uncharted 2: Character Pipeline
Uncharted 2: Character PipelineUncharted 2: Character Pipeline
Uncharted 2: Character PipelineNaughty Dog
 
Practical Spherical Harmonics Based PRT Methods
Practical Spherical Harmonics Based PRT MethodsPractical Spherical Harmonics Based PRT Methods
Practical Spherical Harmonics Based PRT MethodsNaughty Dog
 
Naughty Dog Vertex
Naughty Dog VertexNaughty Dog Vertex
Naughty Dog VertexNaughty Dog
 

Destacado (11)

Pacing in games
Pacing in gamesPacing in games
Pacing in games
 
GDC 2011 Level Design in a Day. Summary & Introduction: Coray Seifert, Senior...
GDC 2011 Level Design in a Day. Summary & Introduction: Coray Seifert, Senior...GDC 2011 Level Design in a Day. Summary & Introduction: Coray Seifert, Senior...
GDC 2011 Level Design in a Day. Summary & Introduction: Coray Seifert, Senior...
 
SPU Optimizations - Part 2
SPU Optimizations - Part 2SPU Optimizations - Part 2
SPU Optimizations - Part 2
 
Adventures In Data Compilation
Adventures In Data CompilationAdventures In Data Compilation
Adventures In Data Compilation
 
SPU Optimizations-part 1
SPU Optimizations-part 1SPU Optimizations-part 1
SPU Optimizations-part 1
 
Autodesk Mudbox
Autodesk MudboxAutodesk Mudbox
Autodesk Mudbox
 
Creating A Character in Uncharted: Drake's Fortune
Creating A Character in Uncharted: Drake's FortuneCreating A Character in Uncharted: Drake's Fortune
Creating A Character in Uncharted: Drake's Fortune
 
Amazing Feats of Daring - Uncharted Post Mortem
Amazing Feats of Daring - Uncharted Post MortemAmazing Feats of Daring - Uncharted Post Mortem
Amazing Feats of Daring - Uncharted Post Mortem
 
Uncharted 2: Character Pipeline
Uncharted 2: Character PipelineUncharted 2: Character Pipeline
Uncharted 2: Character Pipeline
 
Practical Spherical Harmonics Based PRT Methods
Practical Spherical Harmonics Based PRT MethodsPractical Spherical Harmonics Based PRT Methods
Practical Spherical Harmonics Based PRT Methods
 
Naughty Dog Vertex
Naughty Dog VertexNaughty Dog Vertex
Naughty Dog Vertex
 

Similar a State-Based Scripting in Uncharted 2: Among Thieves

StateScriptingInUncharted2
StateScriptingInUncharted2StateScriptingInUncharted2
StateScriptingInUncharted2gcarlton
 
Ghajini - The Game Development
Ghajini - The Game DevelopmentGhajini - The Game Development
Ghajini - The Game DevelopmentImran K
 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hdslantsixgames
 
Mp24: Python in gaming industry
Mp24: Python in gaming industryMp24: Python in gaming industry
Mp24: Python in gaming industryMontreal Python
 
Brewing Your Own Game Engie eng
Brewing Your Own Game Engie engBrewing Your Own Game Engie eng
Brewing Your Own Game Engie engCoconut Island
 
Mono for Game Developers - AltDevConf 2012
Mono for Game Developers - AltDevConf 2012Mono for Game Developers - AltDevConf 2012
Mono for Game Developers - AltDevConf 2012Xamarin
 
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...gamifi.cc
 
Confrontation Pipeline and SCons
Confrontation Pipeline and SConsConfrontation Pipeline and SCons
Confrontation Pipeline and SConsslantsixgames
 
PRESENTATION ON Game Engine
PRESENTATION ON Game EnginePRESENTATION ON Game Engine
PRESENTATION ON Game EngineDiksha Bhargava
 
Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011Karsten Wysk
 
ميهين
ميهينميهين
ميهينAhmed
 
De Re PlayStation Vita
De Re PlayStation VitaDe Re PlayStation Vita
De Re PlayStation VitaSlide_N
 
I phone udvikling best brains
I phone udvikling best brainsI phone udvikling best brains
I phone udvikling best brainsOve larsen
 
Supersize Your Production Pipe
Supersize Your Production PipeSupersize Your Production Pipe
Supersize Your Production Pipeslantsixgames
 
Maximize Your Production Effort (English)
Maximize Your Production Effort (English)Maximize Your Production Effort (English)
Maximize Your Production Effort (English)slantsixgames
 
Introduction to Game Engine: Concepts & Components
Introduction to Game Engine: Concepts & ComponentsIntroduction to Game Engine: Concepts & Components
Introduction to Game Engine: Concepts & ComponentsPouya Pournasir
 
Video game development for everybody
Video game development for everybodyVideo game development for everybody
Video game development for everybodySarah Sexton
 

Similar a State-Based Scripting in Uncharted 2: Among Thieves (20)

StateScriptingInUncharted2
StateScriptingInUncharted2StateScriptingInUncharted2
StateScriptingInUncharted2
 
Ghajini - The Game Development
Ghajini - The Game DevelopmentGhajini - The Game Development
Ghajini - The Game Development
 
God Of War : post mortem
God Of War : post mortemGod Of War : post mortem
God Of War : post mortem
 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hd
 
Mp24: Python in gaming industry
Mp24: Python in gaming industryMp24: Python in gaming industry
Mp24: Python in gaming industry
 
Brewing Your Own Game Engie eng
Brewing Your Own Game Engie engBrewing Your Own Game Engie eng
Brewing Your Own Game Engie eng
 
Mono for Game Developers - AltDevConf 2012
Mono for Game Developers - AltDevConf 2012Mono for Game Developers - AltDevConf 2012
Mono for Game Developers - AltDevConf 2012
 
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
 
Confrontation Pipeline and SCons
Confrontation Pipeline and SConsConfrontation Pipeline and SCons
Confrontation Pipeline and SCons
 
PRESENTATION ON Game Engine
PRESENTATION ON Game EnginePRESENTATION ON Game Engine
PRESENTATION ON Game Engine
 
Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011
 
From Web to Mobile with Stage 3D
From Web to Mobile with Stage 3DFrom Web to Mobile with Stage 3D
From Web to Mobile with Stage 3D
 
ميهين
ميهينميهين
ميهين
 
De Re PlayStation Vita
De Re PlayStation VitaDe Re PlayStation Vita
De Re PlayStation Vita
 
I phone udvikling best brains
I phone udvikling best brainsI phone udvikling best brains
I phone udvikling best brains
 
Supersize Your Production Pipe
Supersize Your Production PipeSupersize Your Production Pipe
Supersize Your Production Pipe
 
Maximize Your Production Effort (English)
Maximize Your Production Effort (English)Maximize Your Production Effort (English)
Maximize Your Production Effort (English)
 
Drama Dash
Drama DashDrama Dash
Drama Dash
 
Introduction to Game Engine: Concepts & Components
Introduction to Game Engine: Concepts & ComponentsIntroduction to Game Engine: Concepts & Components
Introduction to Game Engine: Concepts & Components
 
Video game development for everybody
Video game development for everybodyVideo game development for everybody
Video game development for everybody
 

Último

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 

Último (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

State-Based Scripting in Uncharted 2: Among Thieves

  • 1. State-Based Scripting in Jason Gregory Generalist Programmer Naughty Dog, Inc. Monday, April 6, 2009
  • 2. Agenda • Introduction to game scripting • Extending the game object model • State script syntax • Case studies from Uncharted 2: Among Thieves • Implementation discussion • Summary and some tips Game
Developers
Conference
2009 2 Monday, April 6, 2009
  • 3. Introduction to State Scripts 3 Monday, April 6, 2009
  • 4. Brief History of State Scripts • Script system on Uncharted: Drake’s Fortune originally developed for in-game cinematics (IGCs) • Evolved into general gameplay scripting system Game
Developers
Conference
2009 4 Monday, April 6, 2009
  • 5. Brief History of State Scripts • UDF IGC system revamped for heavy use on Uncharted 2: Among Thieves • Inspirations:  GOAL language used on Crash and Jak series  State objects from God of War engine TM Game
Developers
Conference
2009 5 Monday, April 6, 2009
  • 6. Why Script? • Scripting languages used in games since Quake C • Primary benefits of script:  Takes pressure off engineering team  Code becomes data—rapid iteration  Empowers content creators  Key enabler of mod community Game
Developers
Conference
2009 6 Monday, April 6, 2009
  • 7. Why Script? • Scripting languages used in games since Quake C • Primary benefits of script: I
feel
empowered!  Takes pressure off engineering team  Code becomes data—rapid iteration  Empowers content creators  Key enabler of mod community Game
Developers
Conference
2009 6 Monday, April 6, 2009
  • 8. Scripting Language Characteristics • Two kinds of game scripting languages:  data definition languages  runtime languages • Runtime scripting languages typically:  interpreted by virtual machine (VM)  simple and small—low overhead  accessible to designers and other “non-programmers”  powerful—one line of code = big impact Game
Developers
Conference
2009 7 Monday, April 6, 2009
  • 9. Choice of Language • At Naughty Dog, we make heavy use of both data definition and runtime script  Both based on PLT Scheme (a Lisp variant) • Key benefits of Lisp-like languages:  Easy to parse  Data def and runtime code can be freely intermixed  Powerful macro system—easy to define custom syntax  Naughty Dog has a rich Lisp heritage—comfortable Game
Developers
Conference
2009 8 Monday, April 6, 2009
  • 10. Choice of Language • Of course you don’t have to use Lisp! • Data definition languages:  custom text format,  Excel comma-separated values (.csv),  XML, ... • Runtime languages:  Python, Lua, Pawn (Small C), OCaml, F#, ... • Many popular engines already provide a scripting language:  Quake C, UnrealScript, C# (XNA), ... Game
Developers
Conference
2009 9 Monday, April 6, 2009
  • 11. Extending the Game Object Model • Every game engine has some kind of game object model  Defines all object types in game world  Often (but not always) written in an object-oriented language • Scripting language often used to extend the native object model • Many ways to accomplish this... Game
Developers
Conference
2009 10 Monday, April 6, 2009
  • 12. Game Object Model References • Rob Fermier, “Creating a Data Driven Engine,” GDC, 2002 • Scott Bilas, “A Data-Driven Game Object System,” GDC, 2002 (http://www.drizzle.com/~scottb/gdc/game-objects.ppt) • Alex Duran, “Building Object Systems: Features, Tradeoffs and Pitfalls,” GDC, 2003 • Doug Church, “Object Systems,” presented at a game development conference in Seoul, Korea, 2003 (http://chrishecker.com/images/6/6f/ObjSys.ppt) • Jason Gregory, “Game Engine Architecture,” AK Peters, 2009 (http://gameenginebook.com) Game
Developers
Conference
2009 11 Monday, April 6, 2009
  • 13. Unreal’s Approach • UnrealScript tightly integrated with C++ object model  Single-root class hierarchy with some add-on components  Classes defined in UnrealScript (.uc)  C++ header file (.h) automatically generated  Implementation in C++ or entirely in UnrealScript Pawn.h Actor generate Pawn.uc Pawn.cpp Info Pawn Pickup ... implement implement Scout Vehicle ... Game
Developers
Conference
2009 12 Monday, April 6, 2009
  • 14. Property-Centric / Componentized Designs • Property-centric design used on Thief, Dungeon Siege, Age of Mythology, Deus Ex 2 and others  Game object just a unique id (UID)  “Decorated” with various properties (health, armor, weaponry, etc.)  Property encapsulates data + behavior Armor:
Light Health:
200 Object Weapon:
BFG (UID) AI:
PlayerAlly Weapon:
Pistol Game
Developers
Conference
2009 13 Monday, April 6, 2009
  • 15. Uncharted Engine’s Object Model • Uncharted class hierarchy:  relatively shallow, single-root  host of add-on components Process SsTrackGroupProcess SsProcess ProcessGameObject DynLight CameraControl ... Character SimpleEnOty ... ... Game
Developers
Conference
2009 14 Monday, April 6, 2009
  • 16. Uncharted Engine’s Object Model • Uncharted class hierarchy:  relatively shallow, single-root Objects
  host of add-on components that
update
 over
Dme Process SsTrackGroupProcess SsProcess ProcessGameObject DynLight CameraControl ... Character SimpleEnOty ... ... Game
Developers
Conference
2009 14 Monday, April 6, 2009
  • 17. Uncharted Engine’s Object Model • Uncharted class hierarchy:  relatively shallow, single-root  host of add-on components Objects
 with
transform
 and
mesh Process SsTrackGroupProcess SsProcess ProcessGameObject DynLight CameraControl ... Character SimpleEnOty ... ... Game
Developers
Conference
2009 14 Monday, April 6, 2009
  • 18. Uncharted Engine’s Object Model • Uncharted class hierarchy:  relatively shallow, single-root  host of add-on components Base
class
for
 all
characters Process SsTrackGroupProcess SsProcess ProcessGameObject DynLight CameraControl ... Character SimpleEnOty ... ... Game
Developers
Conference
2009 14 Monday, April 6, 2009
  • 19. Uncharted Engine’s Object Model • Uncharted class hierarchy:  relatively shallow, single-root  host of add-on components Simple
 animaDng
 Process object SsTrackGroupProcess SsProcess ProcessGameObject DynLight CameraControl ... Character SimpleEnOty ... ... Game
Developers
Conference
2009 14 Monday, April 6, 2009
  • 20. Uncharted Engine’s Object Model • Uncharted class hierarchy:  relatively shallow, single-root  host of add-on components Process SsTrackGroupProcess SsProcess ProcessGameObject DynLight CameraControl ... Character SimpleEnOty ... Manages
a
State
 Script
instance ... Game
Developers
Conference
2009 14 Monday, April 6, 2009
  • 21. Uncharted Engine’s Object Model • Uncharted class hierarchy:  relatively shallow, single-root  host of add-on components Process SsTrackGroupProcess SsProcess ProcessGameObject DynLight CameraControl ... Manages
a
 Character SimpleEnOty ... chunk
of
 running
script
 ... code Game
Developers
Conference
2009 14 Monday, April 6, 2009
  • 22. Uncharted Engine’s Object Model • Uncharted class hierarchy:  relatively shallow, single-root  host of add-on components Process SsProcess Game
Developers
Conference
2009 14 Monday, April 6, 2009
  • 23. Uncharted Engine’s Object Model • Uncharted class hierarchy:  relatively shallow, single-root  host of add-on components Process SsProcess SsInstance Game
Developers
Conference
2009 14 Monday, April 6, 2009
  • 24. Uncharted Engine’s Object Model • Uncharted class hierarchy:  relatively shallow, single-root  host of add-on components Process ProcessGameObject SsInstance DrawControl AnimControl ... Game
Developers
Conference
2009 14 Monday, April 6, 2009
  • 25. Charter • World editor for Uncharted is called Charter  Place game objects  Edit object properties  Control level streaming Game
Developers
Conference
2009 15 Monday, April 6, 2009
  • 26. Uncharted State Scripts • State scripts similar in many respects to property-centric model...  adds finite state machine (FSM) support  not specifically tied to “properties”  coarser-grained (one script per object) • More like scripted extension to existing entity type...  ... or a “director” that orchestrates actions of other entities Game
Developers
Conference
2009 16 Monday, April 6, 2009
  • 27. Anatomy of a State Script • A state script is comprised of:  attributes  states • States define object’s behavior via runtime script code:  response to events  natural behavior over time (update event)  transitional actions between states (begin/end events) Game
Developers
Conference
2009 17 Monday, April 6, 2009
  • 28. Anatomy of a State Script State
Script
1 Variables State
A State
Script
2 On Update Variables On Event1 State
C State
B On Begin On Begin On Event4 Game
Developers
Conference
2009 18 Monday, April 6, 2009
  • 29. Anatomy of a State Script State
Script
1 Variables Event1 State
A State
Script
2 On Update Variables On Event1 State
C State
B On Begin On Begin On Event4 Game
Developers
Conference
2009 18 Monday, April 6, 2009
  • 30. Anatomy of a State Script State
Script
1 Variables Event1 State
A State
Script
2 On Update Variables On Event1 State
C go
to
 On Begin State
B State
B On Begin On Event4 Game
Developers
Conference
2009 18 Monday, April 6, 2009
  • 31. Anatomy of a State Script State
Script
1 Variables Event1 State
A State
Script
2 On Update Variables On Event1 State
C go
to
 On Begin State
B State
B On Begin Event4 On Event4 Game
Developers
Conference
2009 18 Monday, April 6, 2009
  • 32. Instantiating a State Script • Attached to a native (C++) game object: Game
 Object  designers extend or modify native C++ object type State
Script
1  define entirely new object types Game
Developers
Conference
2009 19 Monday, April 6, 2009
  • 33. Instantiating a State Script • Attached to a native (C++) game object: Game
 Object  designers extend or modify native C++ object type State
Script
1  define entirely new object types • Attached to a trigger region:  convex volume Trigger
Region  detects enter, exit and occupancy State
Script
2 Game
Developers
Conference
2009 19 Monday, April 6, 2009
  • 34. Instantiating State Scripts SsProcess • Placed as stand-alone object: State
Script
3  “director” orchestrates actions of (stand‐alone) other objects (e.g. IGC) Game
Developers
Conference
2009 20 Monday, April 6, 2009
  • 35. Instantiating State Scripts SsProcess • Placed as stand-alone object: State
Script
3  “director” orchestrates actions of (stand‐alone) other objects (e.g. IGC) • Associated with a task: Task
A  task = check point Task
B1 Task
B2  script manages associated task  orchestrates AI encounters Task
C State
Script
4  controls player objectives Task
D Game
Developers
Conference
2009 20 Monday, April 6, 2009
  • 36. Instantiating State Scripts SsProcess • Placed as stand-alone object: State
Script
3  “director” orchestrates actions of (stand‐alone) other objects (e.g. IGC) • Associated with a task: Task
A  task = check point Task
B1 Task
B2  script manages associated task  orchestrates AI encounters Task
C State
Script
4  controls player objectives Task
D • Spawned by another state script Game
Developers
Conference
2009 20 Monday, April 6, 2009
  • 37. State Script Syntax 21 Monday, April 6, 2009
  • 38. Game
Developers
Conference
2009 22 Monday, April 6, 2009
  • 39. State Script Syntax • State script defined as follows:  Don’t let Lisp syntax throw you!  Lisp syntax is all (parentheses) (define-state-script ("kickable-gate")  Think C/C++ { } blocks (state ("locked") • Parenthesized blocks highly ) ... context-sensitive in Lisp/Scheme (state ("opening") ... ) (state ("open") ... ) ) Game
Developers
Conference
2009 23 Monday, April 6, 2009
  • 40. State Script Syntax • State script defined as follows:  Don’t let Lisp syntax throw you!  Lisp syntax is all (parentheses) (define-state-script ("kickable-gate")  Think C/C++ { } blocks (state ("locked") • Parenthesized blocks highly ) ... context-sensitive in Lisp/Scheme (state ("opening") ... ) (state ("open") ... ) ) Game
Developers
Conference
2009 23 Monday, April 6, 2009
  • 41. State Script Syntax • State script defined as follows:  Don’t let Lisp syntax throw you!  Lisp syntax is all (parentheses) (define-state-script ("kickable-gate")  Think C/C++ { } blocks (state ("locked") • Parenthesized blocks highly ) ... context-sensitive in Lisp/Scheme (state ("opening") ... ) (state ("open") ... ) ) Game
Developers
Conference
2009 23 Monday, April 6, 2009
  • 42. State Script Syntax • State script defined as follows:  Don’t let Lisp syntax throw you!  Lisp syntax is all (parentheses) (define-state-script ("kickable-gate")  Think C/C++ { } blocks (state ("locked") • Parenthesized blocks highly ) ... context-sensitive in Lisp/Scheme (state ("opening") ... ) (state ("open") ... ) ) Game
Developers
Conference
2009 23 Monday, April 6, 2009
  • 43. Event Handler Blocks (define-state-script ("kickable-gate") (state ("locked") (on (event "kick") ... ;; handle "kick" event • Each state contains zero or more ) (on (begin) event handler blocks ... ;; do when state entered ) (on (update) ... ;; do every frame ) (on (end) ... ;; do when state exited ) ) Game
Developers
Conference
2009 24 Monday, April 6, 2009
  • 44. Event Handler Blocks (define-state-script ("kickable-gate") (state ("locked") (on (event "kick") ... ;; handle "kick" event • Each state contains zero or more ) (on (begin) event handler blocks ... ;; do when state entered ) (on (update) ... ;; do every frame ) (on (end) ... ;; do when state exited ) ) Game
Developers
Conference
2009 24 Monday, April 6, 2009
  • 45. Event Handler Blocks (define-state-script ("kickable-gate") (state ("locked") (on (event "kick") ... ;; handle "kick" event • Each state contains zero or more ) (on (begin) event handler blocks ... ;; do when state entered ) (on (update) ... ;; do every frame ) (on (end) ... ;; do when state exited ) ) Game
Developers
Conference
2009 24 Monday, April 6, 2009
  • 46. Event Handler Blocks (define-state-script ("kickable-gate") (state ("locked") (on (event "kick") ... ;; handle "kick" event • Each state contains zero or more ) (on (begin) event handler blocks ... ;; do when state entered ) (on (update) ... ;; do every frame ) (on (end) ... ;; do when state exited ) ) Game
Developers
Conference
2009 24 Monday, April 6, 2009
  • 47. Event Handler Blocks (define-state-script ("kickable-gate") (state ("locked") (on (event "kick") ... ;; handle "kick" event • Each state contains zero or more ) (on (begin) event handler blocks ... ;; do when state entered ) (on (update) ... ;; do every frame ) (on (end) ... ;; do when state exited ) ) Game
Developers
Conference
2009 24 Monday, April 6, 2009
  • 48. Runtime Script Code • Runtime script code inside (on ...) (state ("locked") (on (begin) blocks [print-string "Starting idle!"] [animate "self" "locked-idle"] • Simplified Scheme/Lisp ) (on (event "kicked")  Most “commands” are native calls [when [lock-broken?] into C++ code [print-string "BAM!"] ]  Conditional expressions [if [task-complete? "wave2"] [print-string "Complete!"]  Simple looping via label/goto [print-string "NOT!!!"] ] ) ) Game
Developers
Conference
2009 25 Monday, April 6, 2009
  • 49. Runtime Script Code • Runtime script code inside (on ...) (state ("locked") (on (begin) blocks [print-string "Starting idle!"] [animate "self" "locked-idle"] • Simplified Scheme/Lisp ) (on (event "kicked")  Most “commands” are native calls [when [lock-broken?] into C++ code [print-string "BAM!"] ]  Conditional expressions [if [task-complete? "wave2"] [print-string "Complete!"]  Simple looping via label/goto [print-string "NOT!!!"] ] ) ) Game
Developers
Conference
2009 25 Monday, April 6, 2009
  • 50. Runtime Script Code • Runtime script code inside (on ...) (state ("locked") (on (begin) blocks [print-string "Starting idle!"] [animate "self" "locked-idle"] • Simplified Scheme/Lisp ) (on (event "kicked")  Most “commands” are native calls [when [lock-broken?] into C++ code [print-string "BAM!"] ]  Conditional expressions [if [task-complete? "wave2"] [print-string "Complete!"]  Simple looping via label/goto [print-string "NOT!!!"] ] ) ) Game
Developers
Conference
2009 25 Monday, April 6, 2009
  • 51. Runtime Script Code • Runtime script code inside (on ...) (state ("locked") (on (begin) blocks [print-string "Starting idle!"] [animate "self" "locked-idle"] • Simplified Scheme/Lisp ) (on (event "kicked")  Most “commands” are native calls [when [lock-broken?] into C++ code [print-string "BAM!"] ]  Conditional expressions [if [task-complete? "wave2"] [print-string "Complete!"]  Simple looping via label/goto [print-string "NOT!!!"] ] ) ) Game
Developers
Conference
2009 25 Monday, April 6, 2009
  • 52. User-Defined Functions (defun verbose-anim ((anim string)) [print-string "Starting " anim] [animate "self" anim] ) • Script functions can be defined and called by script programmer (define-state-script ("kickable-gate") (state ("locked") (on (begin) [verbose-anim "locked-idle"] ) ) ... ) Game
Developers
Conference
2009 26 Monday, April 6, 2009
  • 53. User-Defined Functions (defun verbose-anim ((anim string)) [print-string "Starting " anim] [animate "self" anim] ) • Script functions can be defined and called by script programmer (define-state-script ("kickable-gate") (state ("locked") (on (begin) [verbose-anim "locked-idle"] ) ) ... ) Game
Developers
Conference
2009 26 Monday, April 6, 2009
  • 54. User-Defined Functions (defun verbose-anim ((anim string)) [print-string "Starting " anim] [animate "self" anim] ) • Script functions can be defined and called by script programmer (define-state-script ("kickable-gate") (state ("locked") (on (begin) [verbose-anim "locked-idle"] ) ) ... ) Game
Developers
Conference
2009 26 Monday, April 6, 2009
  • 55. User-Defined Functions (defun verbose-anim ((anim string)) [print-string "Starting " anim] [animate "self" anim] ) • Script functions can be defined and called by script programmer (define-state-script ("kickable-gate") (state ("locked") (on (begin) [verbose-anim "locked-idle"] ) ) ... ) Game
Developers
Conference
2009 26 Monday, April 6, 2009
  • 56. User-Defined Functions (defun verbose-anim ((anim string)) [print-string "Starting " anim] [animate "self" anim] ) • Script functions can be defined and called by script programmer (define-state-script ("kickable-gate") (state ("locked") (on (begin) [verbose-anim "locked-idle"] ) ) ... ) Game
Developers
Conference
2009 26 Monday, April 6, 2009
  • 57. The “Self” Argument • Any command operating on a game object takes its unique id (UID) as its first argument • Magic UID "self" refers to the object to which script is attached gate‐17 Game
 Object State
Script
1 Game
Developers
Conference
2009 27 Monday, April 6, 2009
  • 58. The “Self” Argument • Any command operating on a game object takes its unique id (UID) as its first argument • Magic UID "self" refers to the object to which script is attached (on (begin) gate‐17 [animate "self" "locked-idle"] Game
 ) Object State
Script
1 self Game
Developers
Conference
2009 27 Monday, April 6, 2009
  • 59. The “Self” Argument • Any command operating on a game object takes its unique id (UID) as its first argument • Magic UID "self" refers to the object to which script is attached gate‐17 (on (begin) Game
 [animate "gate-17" "locked-idle"] Object ) State
Script
1 Game
Developers
Conference
2009 27 Monday, April 6, 2009
  • 60. The “Self” Argument • Any command operating on a game object takes its unique id (UID) as its first argument • Magic UID "self" refers to the object to which script is attached gate‐17 (on (begin) Game
 [animate "lock-6" "fall-off"] Object ) State
Script
1 lock‐6 Game
 Object Game
Developers
Conference
2009 27 Monday, April 6, 2009
  • 61. Changing States (define-state-script ("kickable-gate") (state ("locked") • Transitions to other states via ... (go "state-name") command (on (event "kicked") [when [lock-broken?] • State transitions cause current ] [go "opening"] state’s (on ...) blocks to be ) ) aborted (state ("opening") (on (begin) • Use (on (exit) ...) block for ... clean-up ) ... ) ) Game
Developers
Conference
2009 28 Monday, April 6, 2009
  • 62. Changing States (define-state-script ("kickable-gate") (state ("locked") • Transitions to other states via ... (go "state-name") command (on (event "kicked") [when [lock-broken?] • State transitions cause current ] [go "opening"] state’s (on ...) blocks to be ) ) aborted (state ("opening") (on (begin) • Use (on (exit) ...) block for ... clean-up ) ... ) ) Game
Developers
Conference
2009 28 Monday, April 6, 2009
  • 63. Changing States (define-state-script ("kickable-gate") (state ("locked") • Transitions to other states via ... (go "state-name") command (on (event "kicked") [when [lock-broken?] • State transitions cause current ] [go "opening"] state’s (on ...) blocks to be ) ) aborted (state ("opening") (on (begin) • Use (on (exit) ...) block for ... clean-up ) ... ) ) Game
Developers
Conference
2009 28 Monday, April 6, 2009
  • 64. Tracks • (on ...) blocks contain one or more tracks • A track is a bit like a thread or fiber • Tracks can be put to sleep  Wait for duration • e.g., wait 5 seconds, • wait until frame 23, ...  Wait for an action to be done • duration-agnostic • Tracks can be synchronized via signals Game
Developers
Conference
2009 29 Monday, April 6, 2009
  • 65. Tracks (state ("shake-hands") State
"shake‐hands" (on (begin) On
Begin (track ("player")) [wait-move-to "player" "waypoint7"] Track Track P S [signal "player-at-waypoint"] [wait-for-signal "sully-at-waypoint"] [wait-animate "player" "shake-sullys-hand"] s‐a‐w ) (track ("sullivan")) [wait-move-to "sullivan" "waypoint7"] [signal "sully-at-waypoint"] p‐a‐w [wait-for-signal "player-at-waypoint"] [wait-animate "sullivan" "shake-drakes-hand"] ) ) ) Game
Developers
Conference
2009 30 Monday, April 6, 2009
  • 66. Tracks (state ("shake-hands") State
"shake‐hands" (on (begin) On
Begin (track ("player")) [wait-move-to "player" "waypoint7"] Track Track P S [signal "player-at-waypoint"] [wait-for-signal "sully-at-waypoint"] [wait-animate "player" "shake-sullys-hand"] s‐a‐w ) (track ("sullivan")) [wait-move-to "sullivan" "waypoint7"] [signal "sully-at-waypoint"] p‐a‐w [wait-for-signal "player-at-waypoint"] [wait-animate "sullivan" "shake-drakes-hand"] ) ) ) Game
Developers
Conference
2009 30 Monday, April 6, 2009
  • 67. Tracks (state ("shake-hands") State
"shake‐hands" (on (begin) On
Begin (track ("player")) [wait-move-to "player" "waypoint7"] Track Track P S [signal "player-at-waypoint"] [wait-for-signal "sully-at-waypoint"] [wait-animate "player" "shake-sullys-hand"] s‐a‐w ) (track ("sullivan")) [wait-move-to "sullivan" "waypoint7"] [signal "sully-at-waypoint"] p‐a‐w [wait-for-signal "player-at-waypoint"] [wait-animate "sullivan" "shake-drakes-hand"] ) ) ) Game
Developers
Conference
2009 30 Monday, April 6, 2009
  • 68. Tracks (state ("shake-hands") State
"shake‐hands" (on (begin) On
Begin (track ("player")) [wait-move-to "player" "waypoint7"] Track Track P S [signal "player-at-waypoint"] [wait-for-signal "sully-at-waypoint"] [wait-animate "player" "shake-sullys-hand"] s‐a‐w ) (track ("sullivan")) [wait-move-to "sullivan" "waypoint7"] [signal "sully-at-waypoint"] p‐a‐w [wait-for-signal "player-at-waypoint"] [wait-animate "sullivan" "shake-drakes-hand"] ) ) ) Game
Developers
Conference
2009 30 Monday, April 6, 2009
  • 69. Tracks (state ("shake-hands") State
"shake‐hands" (on (begin) On
Begin (track ("player")) [wait-move-to "player" "waypoint7"] Track Track P S [signal "player-at-waypoint"] [wait-for-signal "sully-at-waypoint"] [wait-animate "player" "shake-sullys-hand"] p‐a‐w ) (track ("sullivan")) [wait-move-to "sullivan" "waypoint7"] [signal "sully-at-waypoint"] s‐a‐w [wait-for-signal "player-at-waypoint"] [wait-animate "sullivan" "shake-drakes-hand"] ) ) ) Game
Developers
Conference
2009 30 Monday, April 6, 2009
  • 70. Track Execution Over Time • Rules for execution of code within a track:  Greedily consume instructions sequentially...  ... until a [wait* ...] command encountered...  ... then relinquish control until the action is complete • NOTE: A [wait* ...] command doesn’t have to wait; for example:  [wait-seconds 0]  [wait-npc-move-to "pos-4"] when she’s already there Game
Developers
Conference
2009 31 Monday, April 6, 2009
  • 71. Options and Variable Declarations • Options declared at top of (define-state-script ("kickable-gate") script: :initial-state "closed" :declarations (decl-list  initial state (var "num-attempts" :type int32) (var "is-locked" :type boolean :default #t)  variable declarations )  debugging options (state ("kicked") ... ) ... ) Game
Developers
Conference
2009 32 Monday, April 6, 2009
  • 72. Options and Variable Declarations • Options declared at top of (define-state-script ("kickable-gate") script: :initial-state "closed" :declarations (decl-list  initial state (var "num-attempts" :type int32) (var "is-locked" :type boolean :default #t)  variable declarations )  debugging options (state ("kicked") ... ) ... ) Game
Developers
Conference
2009 32 Monday, April 6, 2009
  • 73. Options and Variable Declarations • Options declared at top of (define-state-script ("kickable-gate") script: :initial-state "closed" :declarations (decl-list  initial state (var "num-attempts" :type int32) (var "is-locked" :type boolean :default #t)  variable declarations )  debugging options (state ("kicked") ... ) ... ) Game
Developers
Conference
2009 32 Monday, April 6, 2009
  • 74. (define-state-script ("kickable-gate") :initial-state "closed" Manipulating Variables :declarations (decl-list (var "num-attempts" :type int32) • Simple commands for reading (var "is-locked" :type boolean :default #t) ) and writing variables (state ("kicked") (on (begin) • Lisp/Scheme uses prefix notation [when [get-boolean "is-locked"] [set-int32 "num-attempts" (a.k.a. Polish notation) [+ 1 [get-int32 "num-attempts"]] ]  [+ a b] calculates (a + b) [wait-animate "self" "kick-failure"] [go "closed"]  [set "x" [+ 1 [get "x"]]] ] increments variable “x” ;; else... [wait-animate "self" "kick-success"] [go "open"] ) ) ... Game
Developers
Conference
2009 33 Monday, April 6, 2009
  • 75. (define-state-script ("kickable-gate") :initial-state "closed" Manipulating Variables :declarations (decl-list (var "num-attempts" :type int32) • Simple commands for reading (var "is-locked" :type boolean :default #t) ) and writing variables (state ("kicked") (on (begin) • Lisp/Scheme uses prefix notation [when [get-boolean "is-locked"] [set-int32 "num-attempts" (a.k.a. Polish notation) [+ 1 [get-int32 "num-attempts"]] ]  [+ a b] calculates (a + b) [wait-animate "self" "kick-failure"] [go "closed"]  [set "x" [+ 1 [get "x"]]] ] increments variable “x” ;; else... [wait-animate "self" "kick-success"] [go "open"] ) ) ... Game
Developers
Conference
2009 33 Monday, April 6, 2009
  • 76. (define-state-script ("kickable-gate") :initial-state "closed" Manipulating Variables :declarations (decl-list (var "num-attempts" :type int32) • Simple commands for reading (var "is-locked" :type boolean :default #t) ) and writing variables (state ("kicked") (on (begin) • Lisp/Scheme uses prefix notation [when [get-boolean "is-locked"] [set-int32 "num-attempts" (a.k.a. Polish notation) [+ 1 [get-int32 "num-attempts"]] ]  [+ a b] calculates (a + b) [wait-animate "self" "kick-failure"] [go "closed"]  [set "x" [+ 1 [get "x"]]] ] increments variable “x” ;; else... [wait-animate "self" "kick-success"] [go "open"] ) ) ... Game
Developers
Conference
2009 33 Monday, April 6, 2009
  • 77. (define-state-script ("kickable-gate") :initial-state "closed" Manipulating Variables :declarations (decl-list (var "num-attempts" :type int32) • Simple commands for reading (var "is-locked" :type boolean :default #t) ) and writing variables (state ("kicked") (on (begin) • Lisp/Scheme uses prefix notation [when [get-boolean "is-locked"] [set-int32 "num-attempts" (a.k.a. Polish notation) [+ 1 [get-int32 "num-attempts"]] ˘ ]  [+ a b] calculates (a + b) [wait-animate "self" "kick-failure"] [go "closed"]  [set "x" [+ 1 [get "x"]]] ] increments variable “x” ;; else... [wait-animate "self" "kick-success"] [go "open"] ) ) ... Game
Developers
Conference
2009 33 Monday, April 6, 2009
  • 78. (define-state-script ("kickable-gate") :initial-state "closed" Manipulating Variables :declarations (decl-list (var "num-attempts" :type int32) • Simple commands for reading (var "is-locked" :type boolean :default #t) ) and writing variables (state ("kicked") (on (begin) • Lisp/Scheme uses prefix notation [when [get-boolean "is-locked"] [set-int32 "num-attempts" (a.k.a. Polish notation) [+ 1 [get-int32 "num-attempts"]] ]  [+ a b] calculates (a + b) [wait-animate "self" "kick-failure"] [go "closed"]  [set "x" [+ 1 [get "x"]]] ] increments variable “x” ;; else... [wait-animate "self" "kick-success"] [go "open"] ) ) ... Game
Developers
Conference
2009 33 Monday, April 6, 2009
  • 79. Configuration Parameters • All game objects have properties (key-value pairs)  Property values edited in Charter Game
Developers
Conference
2009 34 Monday, April 6, 2009
  • 80. Configuration Parameters • All game objects have properties (key-value pairs)  Property values edited in Charter Game
Developers
Conference
2009 34 Monday, April 6, 2009
  • 81. Configuration Parameters • Designers can create their own free-form properties, called tags meaning-of-life = 42  Simply type “key = value” in Tags field Game
Developers
Conference
2009 34 Monday, April 6, 2009
  • 82. Configuration Parameters • State scripts have read-only access to game object properties...  ... and free-form tags Game
Developers
Conference
2009 35 Monday, April 6, 2009
  • 83. Configuration Parameters • State scripts have read-only access to game object properties...  ... and free-form tags (define-state-script ("kickable-gate") (state ("kicked") (on (begin) [wait-animate "self" [tag-string "kick-anim"] ] ) ... ) Game
Developers
Conference
2009 35 Monday, April 6, 2009
  • 84. Configuration Parameters • State scripts have read-only access to game object properties...  ... and free-form tags (define-state-script ("kickable-gate") (state ("kicked") (on (begin) [wait-animate "self" [tag-string "kick-anim"] ] ) ... ) Game
Developers
Conference
2009 35 Monday, April 6, 2009
  • 85. Configuration Parameters • State scripts have read-only access to game object properties...  ... and free-form tags (define-state-script ("kickable-gate") (state ("kicked") (on (begin) [wait-animate "self" [tag-string "kick-anim"] ] ) ... ) Game
Developers
Conference
2009 35 Monday, April 6, 2009
  • 86. Data Definition and Runtime (define-state-script ("kickable-gate") • Offline data-definition language (state ("locked") (on (begin) (Scheme) is intermingled with [print-string "Starting idle!"] [animate "self" "locked-idle"] runtime code ) (on (event "kicked") [when [lock-broken?] [print-string "BAM!"] ] [if [task-complete? "wave2"] [print-string "Complete!"] [print-string "NOT!!!"] ] ) ) ... ) Game
Developers
Conference
2009 36 Monday, April 6, 2009
  • 87. Data Definition and Runtime (define-state-script ("kickable-gate") • Offline data-definition language (state ("locked") (on (begin) (Scheme) is intermingled with [print-string "Starting idle!"] [animate "self" "locked-idle"] runtime code ) (on (event "kicked") [when [lock-broken?] [print-string "BAM!"] ] [if [task-complete? "wave2"] [print-string "Complete!"] [print-string "NOT!!!"] ] ) ) ... ) Game
Developers
Conference
2009 36 Monday, April 6, 2009
  • 88. Data Definition and Runtime class Vector3 { private: float x, y, z; • Really no different than the public: float Dot(const Vector3& b) distinction between declarations { return (x * b.x and definitions in C++ + y * b.y + z * b.z); } ... }; Game
Developers
Conference
2009 36 Monday, April 6, 2009
  • 89. Data Definition and Runtime class Vector3 { private: float x, y, z; • Really no different than the public: float Dot(const Vector3& b) distinction between declarations { return (x * b.x and definitions in C++ + y * b.y + z * b.z); } ... }; Game
Developers
Conference
2009 36 Monday, April 6, 2009
  • 90. Case Studies 37 Monday, April 6, 2009
  • 91. Custom Object Type: Breakable Sign Game
Developers
Conference
2009 38 Monday, April 6, 2009
  • 92. Custom Object Type: Breakable Sign Game
Developers
Conference
2009 38 Monday, April 6, 2009
  • 93. Custom Object Type: Breakable Sign (define-state-script ("falling-sign") (state ("untouched") (on (update) [when [task-complete? "wz-post-combat"] [go "fallen"] ] ) (on (event "hanging-from") [go "breaking"] ) ) ... Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 94. Custom Object Type: Breakable Sign (define-state-script ("falling-sign") (state ("untouched") (on (update) [when [task-complete? "wz-post-combat"] [go "fallen"] ] ) (on (event "hanging-from") [go "breaking"] ) ) ... Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 95. Custom Object Type: Breakable Sign (define-state-script ("falling-sign") (state ("untouched") (on (update) [when [task-complete? "wz-post-combat"] [go "fallen"] ] ) (on (event "hanging-from") [go "breaking"] ) ) ... Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 96. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) [spawn-particles-at-joint "self" "hinge" "sign-break-dust"] [wait-animate "self" "sign-break"] [go "fallen"] ) ) (state ("fallen") (on (begin) [animate "self" "sign-broken"] ;; looping ) ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 97. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) [spawn-particles-at-joint "self" "hinge" "sign-break-dust"] [wait-animate "self" "sign-break"] [go "fallen"] ) ) (state ("fallen") (on (begin) [animate "self" "sign-broken"] ;; looping ) ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 98. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) [spawn-particles-at-joint "self" "hinge" "sign-break-dust"] [wait-animate "self" "sign-break"] [go "fallen"] ) ) (state ("fallen") (on (begin) [animate "self" "sign-broken"] ;; looping ) ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 99. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) [spawn-particles-at-joint "self" "hinge" "sign-break-dust"] [wait-animate "self" "sign-break"] [go "fallen"] ) ) (state ("fallen") (on (begin) [animate "self" "sign-broken"] ;; looping ) ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 100. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) [spawn-particles-at-joint "self" "hinge" "sign-break-dust"] [wait-animate "self" "sign-break"] [go "fallen"] ) ) (state ("fallen") (on (begin) [animate "self" "sign-broken"] ;; looping ) ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 101. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) [spawn-particles-at-joint "self" "hinge" "sign-break-dust"] [wait-animate "self" "sign-break"] [go "fallen"] ) ) (state ("fallen") (on (begin) [animate "self" "sign-broken"] ;; looping ) ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 102. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) [spawn-particles-at-joint "self" "hinge" "sign-break-dust"] [wait-animate "self" "sign-break"] [go "fallen"] ) ) (state ("fallen") (on (begin) [animate "self" "sign-broken"] ;; looping ) ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 103. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) [spawn-particles-at-joint "self" "hinge" "sign-break-dust"] [wait-animate "self" "sign-break"] [go "fallen"] ) ) (state ("fallen") (on (begin) [animate "self" "sign-broken"] ;; looping ) ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 104. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) [spawn-particles-at-joint "self" "hinge" "sign-break-dust"] [wait-animate "self" "sign-break"] [go "fallen"] ) ) (state ("fallen") (on (begin) [animate "self" "sign-broken"] ;; looping ) ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 105. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) (define-state-script ("falling-sign") [spawn-particles-at-joint "self" (state ("untouched") "hinge" (on (update) "sign-break-dust"] [when [task-complete? "wz-post-combat"] [wait-animate "self" "sign-break"] [go "fallen"] [go "fallen"] ] ) ) ) (on (event "hanging-from") (state ("fallen") [go "breaking"] (on (begin) ) [animate "self" "sign-broken"] ;; looping ) ) ... ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 106. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) (define-state-script ("falling-sign") [spawn-particles-at-joint "self" (state ("untouched") "hinge" (on (update) "sign-break-dust"] [when [task-complete? "wz-post-combat"] [wait-animate "self" "sign-break"] [go "fallen"] [go "fallen"] ] ) ) ) (on (event "hanging-from") (state ("fallen") [go "breaking"] (on (begin) ) [animate "self" "sign-broken"] ;; looping ) ) ... ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 107. Custom Object Type: Breakable Sign (state ("breaking") (on (begin) (define-state-script ("falling-sign") [spawn-particles-at-joint "self" (state ("untouched") "hinge" (on (update) "sign-break-dust"] [when [task-complete? "wz-post-combat"] [wait-animate "self" "sign-break"] [go "fallen"] [go "fallen"] ] ) ) ) (on (event "hanging-from") (state ("fallen") [go "breaking"] (on (begin) ) [animate "self" "sign-broken"] ;; looping ) ) ... ) ) Game
Developers
Conference
2009 39 Monday, April 6, 2009
  • 108. Making the Sign Script Generic (state ("animating") (on (begin) [spawn-particles-at-joint "self" (define-state-script ("simple-animating-obj") [tag-string "particle-joint"] (state ("initial") [tag-string "particle-name"]] (on (update) [wait-animate "self" [when [task-complete? [tag-string "anim-name"]] [tag-string "done-task"]] [go "done"] [go "done"] ) ] ) ) (state ("done") (on (event "hanging-from") (on (begin) [go "animating"] [animate "self" ) [tag-string "done-anim-name"]] ) ) ... ) ) Game
Developers
Conference
2009 40 Monday, April 6, 2009