Technology Temerity

Tutorial – Random Names

Random names may seem like a superfluous addition at first, but they can go a long way toward giving characters in any game a bit more variance and personality. This is particularly true for low level enemies that are reused repeatedly throughout an OpenBOR module. This tutorial will demonstrate how to apply random names to entities as they are spawned into play. It is meant primarily for level spawns, but can easily be applied to any other type of entity, including player characters.

Objectives:

  1. Apply a random name when entity is spawned from set of predefined choices.
  2. Easily edit name list without disturbing other models or modifying scripts.
  3. Support of both random and non-random names without need for time consuming edits or storing additional data.
  4. Fail over support if random name is called for but not available.

To accomplish this, I have put together a system that takes advantage of kbandresson’s text file stream reader. A single text file contains all the random names each model will use, allowing for quick edits. The entity’s starting alias determines if randomizing is applied or not, so that specific naming is not interfered with. Finally, should randomizing be called for but no names provided, the script will use that model’s default name.

This system has been in place since around November 2008, and has served well in all of my WIPs so far.

Getting Started:

You will need the following files before beginning. Download and unzip each of the following to the specified locations in your module’s data folder.

Note: These scripts are formatted in Allman Style and written with MS Visual Studio 2010. You can use other applications if you wish, but if you do, the formatting will not render correctly and you may find the code difficult to read.

index – data/scripts/vars
z_spawn – data/scripts
name0001 – data/scripts/com
rnd0001 – data/scripts/com
name – data/bin

Step by Step:

Once you have the files above unzipped to their respective locations, open the text file of any model. For testing, I would recommend a commonly occurring enemy. Add the following to its header:

onspawnscript data/scripts/z_spawn.c


Next, open a level text file that contains spawns of the model you just modified. For every spawn instance you would like a random name, add or change the alias to “Random”.

All that is left now is to set the list of names up for your model to use. Open the name example file you unzipped earlier. It should look something like this:

To add your model, just insert another row between Model and End, and add your model’s default name to the first column. Note the last column must always be “1“. Insert as many alternate names as you want in between, separated by at least one space (tip: I recommend tabbing so that names from each row line up, it makes the text easier to work with). For obvious reasons you cannot uses spaces in names, but remember that OpenBOR does not display underscores “_”, so you may use those instead, as with Andy B. above. When your model is spawned into play, it will be given one of the names from its row. You’ll notice for example, I am using a theme naming scheme similar to Streets of Rage.

Andy_B: Doesn’t have any alternates, so will always uses default name.
Ray: Hair Care
Mika: Famous female wrestlers from the WWE.
Brian: Famous real life boxers.
Rick: Common boxing lingo.

You are of course free to use whatever naming style you like. You can add as many or as few as you want, so have fun!

Congratulations, you have added random naming!

Extra Credit:

  • Like any other function, name0001() can be called at any time. You can use it to rename characters at any point in the game. Try some things like changing names when life is low or when the entity is about to perform a certain attack.
  • The overall concept isn’t limited to names. Try applying it to story narrative, character dialog (“Ouch, that hurt!”, “stop hitting me!”) or anything else you can think of.
  • When I created this system, writing to the text file was not possible, but as of OpenBOR version 2.7111 that limitation no longer exists. With a little fine tuning, you could actually edit the name list in real time to create player name entry systems and other nifty game features.
  • Why stop with text? Try things like random AI modes, or even different models entirely. Use your imagination!

DC

Author: Damon Caskey

Hello all, Damon Caskey here - the esteemed owner of this little slice of cyberspace. Welcome!

Leave a Reply