August 17, 2010

EGV Scripting

Filed under: Technical — wickedworx dev clone 1 @ 3:50 pm

Quite a lot of the work we’re doing currently is writing scripts for Excruciating Guitar Voyage.

EGV uses its own custom scripting system. I was trying to explain to someone how this worked the other day, so here’s a blog about it.

EGV script comes from simple XML. You have a command and a set of parameters.

Commands can be synchronous or asynchronous with the game (e.g. “wait” is asynchronous, as the game will continue.. but many other commands – e.g. spawn object, delete object, set value) will be run synchronously with no game update between them (this means if you want to do a bunch of commands in one frame.. e.g. spawn 4-5 objects in one go, you don’t have to worry).

More than one script can be running at any one time – but, the same applies – depending on the commands they are running, they will either block other scripts or run asynchronously alongside them.

This is set per command type – so you don’t have to worry about this while writing scripts (just when adding new command types).

We’ve also got very simple branching/if statements/and “goto” style things… as well as asynchronous wait command for animations to finish, player to make decisions, characters to walk / talk / – or even for just a fixed time etc..

So far we haven’t had much difficulty writing scripts for the game… and we’ve documented our many commands on our private dev wiki.

Currently we’ve got around 40 different commands… A large number of these are to do with camera movement/zoom/focus, and also object spawning/behaviour…
One of the coolest features we have is the ability to spawn a custom component-based object  in script… So I can just say “spawn this object, with these components (using this data)”… e.g. in one of our cutscenes, I want to create a “Molly” at the helicopter’s current location:

  <spawn_object_data node="helicopterf" x="-2" y="0">
    <object name="molly">
      <component type="color" r="200" g="200" b="200" />
      <component type="position" x="0" y="0" z="0" rx="0" ry="0" rz="0" />
      <component type="humanoid_physics" w="1.5" h="3" bottom="1.5"/>
      <component type="animate" filename="molly.anim" layer="3"/>
      <component type="talkable" name="Molly" x="0.5" y="-2" />
      <component type="ai_walk" />

Here is an example showing how the mixed asynchronous/synchronous scripting works:

  <cutscene_start />
  <start_music cue="intro_amb" /> <!-- first two commands are run in one go --!>
  <wait time="2" /> <!-- game continues running for 2 seconds, script waits here --!>
  <speak target="narrator" key="narrator_intro_1" />
  <speak target="narrator" key="narrator_intro_2" />
  <speak target="narrator" key="narrator_intro_3" />
  <speak target="narrator" key="narrator_intro_4" />
  <speak target="narrator" key="narrator_intro_5" />
  <speak target="narrator" key="narrator_intro_6" />
  <speak target="narrator" key="narrator_intro_7" />
  <speak target="narrator" key="narrator_intro_8" />
  <speak target="narrator" key="narrator_intro_9" /> <!-- all speak commands run in one go, narrator character queues up his dialogue --!>
  <wait_for_main_slot /> <!-- game continues running while dialogue is spoken, script waits here until it finishes --!>
  <fade target="1" />
  <set_music_effect target="100" />

  <camera_speed speed="5" linear="true"/>
  <camera_zoom zoom="40" set="true"/>
  <add_focal target="pan_1" jump="true" />
  <add_focal target="pan_2" />
  <remove_focal target="pan_1" /> <!-- script sets all these camera options ready to go, in one update. all of these commands are just changing the state of the camera. game does not update --!>

  <wait time="2" /> <!-- game continues updating for 2 seconds, script waits here --!>

anyway – hope someone finds this interesting. we’ve got loads of work to do, so i’m gonna get back to it!


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: