Tag Archives: programming

Adventures in AI scripting

I added two AI bots to my game prototype, and the process took a long time and a lot of work.  I ended up learning how to use echo statements to track the loading of the many files that I had changed and to determine where a particular file was erroring out.  This was useful debugging experience.

The way that I incorporated the AI bots initially resulted in my player character being chased by mirror versions of herself, which was eerie and reminiscent of similar Alucard versus Alucard doppleganger battles in Castlevania: Symphony of the Night.  But I soon switched the AIGuard model out so that I was fighting two demonic space orcs.

I also changed the projectile scripts on my first-person spells so that the projectiles would do damage, as well as creating various other effects such as invisibility and healing.

Then, while working on loading the animations for the ai bots, my mission stopped loading and started crashing in the middle of phase 2 loading.  I can’t figure out why, so I’m building a debug version of the app with the hope that I can find the specific line where the mission load is crashing.

Object selection problems and selecting objects in FPS mode

Here is today’s update on Arcana Manor, in the form of a post I made to the ArcaneFX section of the Garagegames forum.  The only addendum I have is that after this post I managed to fix most of the object selection problems, thanks to the help of the user named Gibby.  They were in the playgui.gui file.  Next up is the more challenging problem of selecting objects in first-person shooter mode.

In the process of making many script and code changes to implement several different features, I seem to have interfered with the game’s ability to select objects with the mouse rollover raycast.  I can select the orc AI player, but only from certain angles (specifically from a slight angle while he is running toward the player, and sometimes from behind if the player is standing close to him).  I can’t select the orc corpse at all, even though “corpsehiddenfromraycast” is set to “0″ and “$TypeMasks::CorpseObjectType”  is enabled in “AFX::targetSelectionMask.”  If I run the AFXDemo from a fresh install of AFX 1.7.1, it is much easier to select the orc and the orc corpse from almost any angle and distance, which suggests to me that I’ve done something to mess up the rolloverraycast function or another piece of code or script related to object selection.

I’ve used WinDiff to check afxtsctrl.cp against the same file in the fresh install of AFXDemo, but restoring this file to its original state doesn’t solve the problem.  Could anybody suggest where else I might look for changes to try to fix this problem?  I also checked in GameConnection.cpp because I think some of the object selection code is in that file, but I’m wondering where else the problem might be coming from.

To provide a little context, I am working on a game in which the player can cast spells from first-person mode, like in Oblivion.  So, one of the ultimate goals here is to be able to select objects in first-person shooter mode by toggling the cursor or using the crosshairs.   Gibby’s AFXFps mod and tutorial has been extremely helpful with this, though his solution is to cast spells from a 3rd person “psionics” mode.  For some reason, I can select objects in Gibby’s 3rd-person mode but not in his first-person mode, even when I toggle the cursor on.  I’ve studied the commands.cs script that Gibby uses to switch modes (which involve showing the reticle and the shapenamehud in first-person mode), but I’m not sure which part of this script would be causing the conflict between first-person mode and object selection.

So, a second question once I fix the raycast problem would be: how can I select objects while staying in first-person mode?

Moving Platforms

It’s been a few days since I’ve updated progress on Arcana Manor because I’ve been intently involved in implementing an important feature: moving platforms.  These are moving planes or scaled cubes that players can stand on top of, moving along with the platforms as on an elevator.  These moving platforms are important, by definition, to a game in which platforming a key part of gameplay.

Torque Game Engine Advanced doesn’t have out-of-the box support for moving platforms, which means that they have to be added as C++ code, preferably by the addition of one of the downloadable resources on Garagegames.com.  To integrate such a resource with a codebase that I’ve already heavily modified, I had to use WinDiff, a program for comparing files and isolating their differences.  Once I isolated these conflicting code fragments, I had to choose how to merge them by incorporating relevant new lines of code from the resource and discarding irrelevant lines of code.  This process was complicated by the porting of the resource from TGE 1.5.2 to TGEA 1.7.1, especially since the resource itself was actually for TGEA 1.8.1 but had been compiled from multiple TGE versions.  In practical terms, these multiple versions and resources meant that I had to spend several days reading through C++ source code, puzzling out its logic and structure until I could figure out which lines of code were needed and which were not.  I re-compiled the engine dozens of time, de-bugging code changes to preserve the resource’s functionality while updating it and slotting it in with ArcaneFX, melee, and other code changes I’ve already implemented.

I now have moving platforms.  The key is making the player object a child of the platform, which is a pathshape moving along the nodes of a path.

Unfortunately, I have to use a rectangular dts shape that came packaged with an early version of the resource, because the player falls through any dts that I make myself in Softimage.  I think this has to do with the way that collision meshes are set up in the process of exporting the model from Softimage to dts format, but after spending a day on collision meshes I haven’t been able to isolate the problem.

I’m now trying to trigger the moving platforms with a spell so that I can incorporate telekinesis into my magic system.  Since the magic system is the focus of the game and the surreal mansion is the secondary focus, it would be best if these two aspects of gameplay could be tied together.  I have a telekinesis spell that can move an interior instance with the settransform() function, but the interior leaps all at once rather than animating smoothly and carrying the player with it.  If I can trigger a pathshape with a spell, the player could raise and lower bridges with the alterative school of magic, corresponding to the wands.

A few theoretical thoughts about magic systems, allegory, programming

I don’t think about theory much these days, focusing more on creative projects. For the last couple of days I’ve been doing some preparation for my classical myth and media class, which sparked a few theoretical thoughts.  Also, I’m continuing to think about magic systems, inspired in part by a podcast ( on which Roger Travis graciously invited me to be a guest) about this subject and its relation to Arcana Manor. Magic systems have become the focus of my creative design work and my research, and I tend to think about them through the lens of interactive or procedural allegory, a system of expressive rules.

This will make more sense to readers (hopefully) when the podcast is posted.

A magic system is a set of core mechanics (spell-casting is one of them, maybe the primary one) for  simulating supernatural powers and abilities rigorously and symbolically.

Quests, because of their relationship to narrative, tend to be scripted within an engine through quest flags and state changes.

Magic systems can be partially scripted within an engine (depending on the engine’s flexibility), but truly innovative mechanics have to be programmed.  New mechanics tend to require, at the very least, modifications to an engine’s source code and may require the development of new engines (or at least sub-systems within an engine).

What matters to me is allegory as system, as organized matrix of rules for generating symbolic meanings. This is distinct from a linear procession of symbols (i.e. narrative) or from free-floating pool of symbols merging into each other (collective unconscious, dream). In linear mediums, allegory manifests itself as narrative (although I wonder if poetry, in its capturing of de-contextualized images, may be allegorical without being solely or even primarily narrative). Rimbaud’s Vowels or Baudelaire’s Correspondences are dense symbols without narratives. Dante’s Divine Comedy does chronicle the adventures of one pilgrim (Dante) through Hell, Purgatory, and Heaven, but the descriptive focus of the poem is the spatial organization of these realms and their inhabitants. The afterlife is a cosmological system for representing the punishment of sin and the rewarding of virtue.

A mythology (whether real as with the Ancient Greeks or invented as in the Cthulhu Mythos) is a system (a pantheon, a set of places, artifacts, recurrent events, themes). Many narratives can occur within a mythos, but many systems can also be generated by a mythology. When I was thinking about quests, I was trying to connect narrative and system, to explore their generative interplay. As I think about magic systems, I am more and more concerned with dynamic, procedural systems, which can be expressive in interactive, procedural, re-configurable ways.

Ritual is a key middle term.  Ritual is enacted myth, enacted symbolism.

Eric Zimmerman says that there is magic in games but argues that this magic is the thrill of creativity and problem-solving, which are distinct in his mind from a mage’s 8th-level fireball spell or the mystical experiences of organized religion.

I don’t see these three aspects of magic as inevitably distinct.  There are all sorts of connections to be woven between them.

That’s why I have a Clive Barker quotation above my desk, which in condensed form says “magic is the first and last of the world’s religions: a religion whose profoundest ritual is play.”  The quotation is longer but would require a detailed gloss to do it justice, because the idea is too important for me to treat lightly.  But the main point is that in Barker’s mind the three aspects of magic in games are intertwined expressions of one another.  (And he puts his money where his mouth is, since this quotation is from the introduction to his Imajica collectible card game, and he has also discussed the metaphysical implications of the magic system in Undying.  Incidentally, the magic system in Undying may be my second favorite magic system, just beneath Eternal Darkness.)

(A sidenote on Jung: Jung coopts the concept of the symbol for psychoanalytic purposes, but the term comes to prominence in Western thought in Romanticism (English, German, French), which precedes Jung chronologically. (e.g. Coleridge, Baudelaire, Rimbaud, Nerval).  In the game Eternal Darkness, the narrator invokes Jung, Freud, and Skinner as possible correspondences to the three Ancients, but then dismisses these psychoanalysts as inadequate to the horror and majesty of the beings represented by the runes. This is a nice way of suggesting that, while Jung is a key figure in understanding symbols, their content and operation eludes his unitarian and trans-historical attempts to explain all symbols as products of a psychoanalytic entity (the collective unconscious) which he invented. A theoretical entity which originates in his own German Romanticist/early modernist context and his Freudian training.)

And allegory precedes Jung also (Plato, Spenser, Dante).

I need to read Angus Fletcher’s Allegory: Theory of a Symbolic Mode.

Question for further research: what are some of the most innovative magic systems, both in terms of mode of spell-casting, effects, and symbolism?

Mage: The Ascension and Mage: The Awakening (tabletop)

Magic: The Gathering (cardgame)

Betrayal at Krondor (crpg)

Arx Fatalis (crpg)

Loom (Adventure Game)

Eternal Darkness: Sanity’s Requiem

New team member Shaun Walsh

Shaun Walsh, an experienced programmer in the process of learning Torque, has graciously agreed to be on the Arcana Manor.  Shaun is interested in conceptual code design, i.e. planning out how to implement various features, such how to program a magic system in which the player will trace runes and sigils on the screen to produce various magical effects.  This is a tremendous addition to the team given the difficulty of programming and how slow I am at learning it. :)

Shaun has experience in Php, C/C++/C#, VisualBasic, and a host of other languages.  As an example of his coding facility, here is what he was able to come up with very quickly regarding the implementation of the mechanic for tracing runes:

So, this wouldn’t be an overnight project by any means. Your drawing of the spells to the screen is interesting. Castlevania for the DS had the same concept, but they had built in functionality for that. How it would work is you would have to have a file that stored 2d coordinates of the first mouse click on the screen (where he starts drawing) and then does a match function to determine the roundabout next point he would have to draw to, something like a direction map. Heres an examples

User starts drawing at 25,25

So, the computer would figures the next point is 25 points lower, and 30 points to the right so the next cord would be 50,55. Then it would go onto the next point. The file would look like this

0: +25,+30 (this is actually the second point)

1: +25, -30

2: -25, -30

3: -25, +30

4: END_SPELL

This would make a pyramid drawing. You would obviously have to make a buffing system that would make use of extreme math cause the user wouldn’t be able to click EXACT coordinates. I would think the closer he is to exact, the more critical the spell is. Obviously, some of the marks he would be drawing would be more complicated, but that’s just a basic concept.”

Something like that would have taken me hours to figure out, which shows why recruiting team members if important.  Welcome aboard, Shaun.

Programming: first steps

I’ve been working in Torquescript, using The Game Programmer’s Guide to Torque by Edward Maurina (which is published by A.K. Peters, the same company that publishes Quests).

Specifically, I’ve been working on setting up a GUI or Graphical User Interface for an inventory system, using some resources and tutorials on the GarageGames site.  The process of scripting such a system is extremely complex, because a game in the Torque Game Engine Advanced is a maze of directories and sub-directories containing thousands of scripts.  Even when working with a pre-existing resource, a programmer has to figure out exactly where to put specific snippets of code in many different files on both the server and client side.  My license of TGEA actually allows me full access to the engine’s source code, which can be modified in C++ and then re-compiled to add functionality to the engine, but this is both a blessing and a curse because their are now hundreds of thousands of lines of C++ code than can be potentially altered and recompiled.

And, despite the complexity of all this (or maybe because of it) I absolutely love the process of programming, which is like solving a vast and intricate jigsaw puzzle.  When I have a working interface, I’ll post screenshots.

Magic Systems and Meaningful Scripting

Runes in Eternal Darkness

Runes in the Magic System of Eternal Darkness

One of my next projects will be an article comparing the magic systems of various games, both conceptually and in terms of their underlying quantitative mechanics, as one example of how interactive symbolism can be programmed. As readers of Quests know, I regard programming as a form of procedural, interactive writing, which unfolds according to a set of rules that both constrain and facilitate player actions and interpretations. For example, the magic systems of role-playing games (tabletop, single-player, and MMO) comprise rigorous, quantitative rules for altering the physical and sometimes mental reality of a particular game world. Because these systems often involve glyphs, runes, and incantations, there are opportunities to encode meaning into a core game mechanic, as in the tabletop game Mage: The Awakening or the elaborate cosmology of Eternal Darkness.

Questions for research include:

  • How have different table-top RPG’s, CRPG’S, action-adventure games, and MMO’s implemented magic systems?
  • What are the origins of magic systems in fantasy novels? For example, the convention of having magic users memorize spells that are then erased from their memory after being cast derives from Fritz Leiber, but not from Tolkien (who eschewed direct references to the concept of magic in his work).
  • What is the relationship between game systems of magic and real occultist systems? (This treads on difficult ground, because of many gamers’ understandable discomfort with the association by fundamentalists of Dungeons and Dragons with black magic. However, Gary Gygax himself encouraged dungeon masters to consult encyclopedias of the occult as reference works, and Silicon Knights did thorough research into actual historical arcane systems in order to build the elaborate spell-casting system of Eternal Darkness. The table-top role-playing systems Nephilim and Mage: The Awakening both embrace mystical lore as metaphors explored through their game mechanics.)
  • Most importantly, as relates to programming practice:
  1. How did the World of Darkness mod (WoDMod) script the magic system of the Mage tabletop game into Vampire: The Masquerade Redemption?
  2. How do custom NWN scripters make their own spells?
  3. How could we as designers learn from past design of magic systems in order to make our own games’ magic systems both more fun and metaphorically resonant, so that we invest this aspect of fantasy with all its potential for symbolism rather than reducing it to the glitz and glamor of flashy visual effects without substance?