Game Scripting – Part 3 – The Guide!
Here we go! Two weeks ago, we introduced you to the concept of scripting. And last week we gave you the guide. This week we’re going to start to break things down nice and slow and make sure that everything is clear. To start, we’re going to look at the absolute basics of scripting.
Scripting in Arena functions a lot like writing HTML code if you are familiar with that. You need to use “tags” to tell the game engine (the game’s brain) when to do things, and when to stop doing things. The first and most obvious tag to learn then is the “script” tag. All maps will start with:
<script>
Anything inside of “< >” is a command to the game engine. It’s a single order. “Do this thing”. The <script> command is literally saying “Start working with this scripting”.
So that’s how you start a command. How do you end one?
</script>
Notice that “/”? That’s how you end any command in the scripting system. You use the same tag that opened your scripting command, but you add “/” after the “<”. This is universal for any and all commands. When the game engine has seen </script>, it knows that the scripting on your map is done. All scripted actions need to take place in this one <script></script> set, though. You can’t use the scripting tags more than once in a map.
Always always always remember to use an end tag for each command. If you start something with <do_something>, you need to make sure you end it with </do_something> or the game will be confused. How can it move onto the next thing until the first thing is finished?
Dialog
Let’s get started on some practical stuff now. Being the writer for Urbansquall, I’m most interested in the Chat command in the scripting engine, so that’s the one we’re going to break down today.
A Chat command will open up a dialog box along the bottom of the screen. It will have the name of the speaker, their text, their picture and a color for the box to indicate what team they are on.
Let’s start the chat command.
<response type="chat">
Note that most of the commands in the scripting system are going to be formatted in the <response type=”"> method. Inside the quotes you’ll list the word that specifies the type and tells the system exactly what you want to be doing.
Now how do you set the different items for a chat (speaker, message, image, box color)? Use the following, where the text in all caps gets changed out for something real in the actual map editor:
Speaker - <sender value="NAME">
Text - <message value="TEXT">
Image - <avatar value="IMAGE_NAME">
Box color - <color value="COLOR">
Pretty simple. And of course, once you’ve finished this up, how do you end things? Well, you started with a <response> tag, so…
</response>
Let’s look at something like it might actually look in the game.
<response type="chat">
<sender value="Captain Tucker">
<message value="You'll never get away with this, Durand.">
<avatar value="tucker">
<color value="red">
</response>
This will, of course, pop up a dialog from Tucker. If you want to have another line of dialog, you just need to add another one of these code blocks. Like so:
<response type="chat">
<sender value="General Durand">
<message value="Oh, but I already have, Tucker. You're too late.">
<avatar value="durand">
<color value="blue">
</response>
As long as you’re placing these between <script> and </script>, you’ve just made some level dialog for yourself.
Sample Level Script
Let’s get you a whole level you can work with. If you create a map and paste this all into the scripting field in the Map Editor, you should get a playable level with some dialog. Don’t worry about the bits you don’t understand yet, I’ll cover those later.
<script>
<event>
<condition type="startGame"/>
<response type="disableControllers">
<disable value="true"></disable>
</response>
<response type="chat">
<sender value="Captain Tucker"/>
<message value="You'll never get away with this, Durand."/>
<avatar value="tucker"/>
<color value="red"/>
</response>
<response type="chat">
<sender value="General Durand"/>
<message value="Oh, but I already have, Tucker. You're too late."/>
<avatar value="durand"/>
<color value="blue"/>
</response>
<response type="chat">
<sender value="Captain Tucker"/>
<message value="We settle this now."/>
<avatar value="tucker"/>
<color value="red"/>
</response>
<response type="disableControllers">
<disable value="false"></disable>
</response>
</event>
</script>
There’s a lot more to come, though! Keep your eyes on urbansquall.com!


Sup Dog!!!!!
scarmichael do u think some of this stuff is necesary by: Sup Dog!!!!!
August 10th, 2009 at 12:49 pmscarmichael
None of the scripting is necessary to create a level map in Arena. However, if you want to include dialog and other actions in the level to make it more of an experience for people to play, then yes, all of these elements are necessary to make the scripting function.
August 12th, 2009 at 10:14 amConqueror95
Very cool, urban, this is like the same way you make a game! Keep up the good work.
August 17th, 2009 at 6:46 amMaZa
Nice. I was thinking that is there a way to set values for units like health, damage, attackrange, moverange etc… It would be very useful.
October 22nd, 2009 at 4:26 am