330 likes | 549 Views
Scripting Languages. By Justin Karneeb. What is a scripting Language?. Many people have different views It is not a High-Level language It has low functionality (innate abilities) It has minimal debugging tools It simplifies a complex task for another program So what is the answer??.
E N D
Scripting Languages By Justin Karneeb
What is a scripting Language? • Many people have different views • It is not a High-Level language • It has low functionality (innate abilities) • It has minimal debugging tools • It simplifies a complex task for another program So what is the answer??
Wikipedia says…. • A scripting language, script language or extension language, is a programming language that controls a software application. • But that is a very vague response…… but because of the debate, I guess it has to be.
My definition • There is one thing that everyone agrees on • It is almost always used to solve a task for another program Scripting Languages are languages where there core use is to extend the use of another language or piece of software.
How do they work? • There are two parts to a scripting language • The Language itself • Defines syntax just like a High-Level language • The Engine/Interpreter • A scripting language normally runs in a virtual machine similar to Java.
Compiling • Most programming languages compile into machine code/assembly • Scripting languages mostly compile into what is know as a bytecode stream. • It contains simpler instructions than the language itself, but not as simple as assembly.
Engine/Interpreter • Also known as a Virtual Machine or VM. • The VM takes the bytecode stream and runs it. • This is generally slower than it running innately, however it also has many positives as well. • Since they are running independently from the main program, the entire program will not crash if there is a problem.
When should you use scripting languages? • You can use a scripting language to do almost any task, however it is suited to some more than others • Anything which needs to be multiplatform • Anytime in which non programmers need to have direct access to the behavior of a program • When gluing different pieces of software together or to have them communicate effectively.
Webpages • Webpages are perfect places to utilize scripting languages. • Since they need to be multiplatform, their VM based compiling/running is extremely handy. • HTML, PHP, XML, SWF, these are all scripting language extensions.
Parallel development • This allows developers to work on parts of the program that do not necessarily require the completed program. • This is also applicable in games, developers can begin work on mapping and scripting npcs while the game itself is still under development.
AI in Video Games • Many NPCs in video games are completely scripted • The path the walk, what they say and even what they do is coded in a scripting language which communicates with the engine. • The infamous Half-Life Marines were scripted to move in a specific way
“Modding” games Some games release scripting languages complete with API’s for the gamer community to use to “mod” their game. • Unreal tournament allows users to make custom bots • The original Half-Life had many scripting capabilities through programs like AMX
The Pros and Cons • As with everything, scripting languages have their upsides an downsides • Scripting languages seem to have more ups than downs, especially as technology gets better and faster
The Cake -- Pros • Allows developers to work independently of the programmers • Easy to understand and use compared to languages like c++ and java • Does not crash program, less error prone • Scripts can be put on hold • Is multiplatform • Has a data-driven design • Allows a modding community to extend a game
Parser?! I barely know her! --Cons • Most do not have debugging tools • Runs extremely slowly when compared to fully compiled code • Normally has less functionality, less innate abilities • Using scripts too much (in games) can lead to boring gameplay • Overdependence on scripting can lead to horrible problems late in development (using too much processing power)
Now for the fun stuff • We have dealt with what scripting languages are, when to use them and how they work, now its time to show some real examples of scripting languages in action. • Far Cry Instincts • Half-Life
Far Cry Instincts • A console based FPS which takes place on several islands. • The game is made to be played by sneaking around, which presented a serious problem • NPCs on the island needed to look as if they had a purpose. • How would you code hundreds of different NPCs to independently do normal activities? • Scripting Languages : )
The Anchor System • Originally, Ubisoft tried to code their behaviors directly into the NPCs behavior • They decided to take a new approach where developers could place “Anchors” on things in game. • The anchor would tell the NPC what to do next
How powerful were they? • At first they were simple, but they soon expanded their use. • An anchor can play animations, trigger events, issue commands and just about anything else an NPC would want to do
What did they use? • The developers were not versed in programming, so they decided to go with XML • It fit in well with their engine • Was overall easy to learn • XML is a text based scripting language that is powerful enough to get the job done
It took a while…. • The developers needed to get used to the XML code • Some picked it up fast, but not everyone • Because the coding is generally easy, the programmers were able to make a GUI interface which could be used to write the code for the developers.
Problems • Because the developers were unfamiliar with the subtitles of programming, they ran into some problems • Ignore All command lead to many problems • Vehicles could not use anchors • Physics issues
Half-Life • I have personal experience with scripting for Half-Life, specifically counterstrike and some other mods. • Half-Life itself has been modded more times than I prefer to count. • My experience is with AMX, it makes minor changes to the games.
AMX? • AMX is a scripting language made specifically for Half-Life modifications. • It starts as a text file which gets compiled into a .AMX file • AMX links with the Half-Life engine and while in game runs “plugins” that are written by the modders. • When you combine AMX’s plugins with the already modded HL engine, there are millions of different gameplay options available.
My Favorites • Ninja Rope • Allowed you to swing from any surface via a “rope” • Slap • Allowed admins/users to “slap” (do 1 damage and knock the slapie around a bit) players • Predator • Made one user invisible, gave them extra health and speed. • Defend Your Castle/Force Grab
How it worked • The plugin asked the engine who the user was currently looking at, and returned to it its x,y, and z positions in the plane • When activated, as the user moved his/her cursor, the x,y and z coordinates of the player being grab were updated to that new location (the distance between them remained constant)
Problems? • While we were able to achieve a very high toss into the air, which would kill players in impact, if you forcibly drove a player into the ground and he died while being grabbed, the plugin would crash. • Half-Life was unaffected however AMX would stop working until the server was restarted. • We were never able to solve this problem, there seemed to be no exception handling in AMX.
It seems they were right • I learned a lot about scripting languages back then even though I had no idea what I was doing. • It was extremely powerful • It was hard to debug • It was easy to learn • I had never programmed before • When it crashed, it did not ruin the game • It fit our definition perfectly.