Introduction to Scripting

One of the unique features of WorldForge is the ability of players to use the power of programming to enhance their gaming experience.

More than just a tacked on feature, scripting is a fundamental and critical piece of the WorldForge system. Scripting allows individual players to participate in the creation and maintenance of the world, including economics, politics, warfare, and community building. It helps provide a richer game world to adventure in, and taps the vast resource of the player community to provide the labor of world building, AI generation, and administration.

Scripts are associated with Events. When a particular event occurs, a particular script will kick in to provide guidance and control. Each event is assigned a priority level, so that one can assure that one's RunAwayFromDragon script doesn't get interrupted by one's ImHungryAndWillEatALoaf script, but that the reverse does occur.

A player's first encounter with the scripting system will likely be the "wimpy" scripts. These are scripts that kick into play when bad things happen to the character. For example, if the character's hit points drop below 10, the character could be scripted to flee. When the player's connection is lost, the character could be scripted to avoid combat and return home ASAP.

Scripting for Non-coders

Players who are not coders should not fear being unable to participate in the game. A repository of "stock" scripts will be made available, and these should provide enough event handlers that the player should be able to make their character able to respond to threats and take advantage of automation for training, moneymaking, and community building. Those players interested in coding will have the advantage of having better "tuned" scripts, and having custom manufactured scripts to do unusual things.

Can non-coders do this customization and tuning of scripts, too? There has been talk of developing a GUI script builder, using drag-and-drop, toggle buttons, or "fill in the blank" to create the scripts. See the Lego Mindstorms website for examples. It remains to be seen if anyone will be interested in building these sophisticated script writing utilities.

It should probably be pretty easy to set up a point-n-click "record" capability in the client program to keep track of commands set to the server, for later replay. This should simplify the amount of coding that the player will need to do, though like any recorded macro, some amout of clean up and generalization may be needed. This is probably an excellent way to learn the scripting language.

Default Scripts to be Available

One may wonder what sorts of scripts will be available to players from the start. Here are a few ideas:

Event Handling

Scripts are in actuality "prioritized event handlers". They're event handlers in the sense that when an "event" occurs, they kick in and do stuff. They're "prioritized" in the sense that some events are more important than others, and need to be handled first.

Part of a character's definition is a set of events and event handlers. The character also has a queue of scripts to be performed. Each turn, the script with the highest priority will be run to determine the action that the character should perform. The script is allowed to change its priority, the priority of other scripts, or add/remove itself or other scripts from the queue.

A character will probably have a whole host of contingency scripts defined, that would rarely ever be used, but would be of extremely high priority if the situation arose! For example, RunAwayFromDragon. Also, the character could have a whole host of "chore" oriented scripts, such as ImHungryAndWillEatALoaf with a very low priority, that'd be added to the queue at a low priority, so that they'd certainly occur, but only when things are "quiet". Obviously, if the character is very busy and cannot tend to the minor chores, they may become more important (the character gets hungrier and hungrier, for instance). This is why it is possible to increase the priority of a script already in the queue. Eventually, eating will become so important that it's priority will rise above all the other tasks and eventually come to the front of the queue.

Events can be created dynamically. That is, a character can define new sorts of events, such as, "When-someone-says-Ni", or "when-golden-lion-is-spotted". The character's player can then assign scripts and prioritization schemes to these events as they wish.

Instincts and Morales

In order to prevent abusive "suicide" and "criminal" scripts from subverting and casting a dark shadow upon the WorldForge system, it may be necessary to impose rules on things that characters will or will not do. Natural instincts, for instance.

Logs

Every character will keep a log of events that occur to it, the times that they occur, and a few situational notes. For instance: "I was attacked by an ogre and felt in danger, so I fled back to the palace gates."

The Grand Scheme

Scripting has some advantages for making one's adventuring character more powerful, and is obviously necessary for making the administrator's non-player characters and monsters function. But where this feature really becomes interesting is with "offline characters" - fully scripted characters "owned" by players but not run by players.

The reader should recognize several abusive ways scripts could be used: 1) A player could create a character, script it to do something profitable, and reap the monetary rewards to make his adventuring character better; 2) mean players could create combat scripts and assemble an army of scripted characters to conduct raids on otherwise peaceful settlements; 3) characters could script a character to endlessly practice a skill, log off, and come back in a few weeks to take advantage of the "pumped up" character; 4) the player could use scripts to make their character able to deal with any contingency, and thus become in effect a super-warrior.

In WorldForge, we actually hope players will take advantage of these situations! Why? Because in addition to benefitting the player, they benefit the WorldForge world. Here is how:

1) Players who script up NPCs to gather, craft, and trade for money will be building the foundations of an economy using a very free-market-like approach. If the player scripts their adventuring character to "have a day job", it is even better, as provides the player with an incentive to not be a player killer. If the player runs multiple characters, it similarly discourages them from doing any player killing, as it could risk retribution to any of their characters, not just the one doing the evil deed.

2) It is expected that wars will be fun. Half the fun of building a city and establishing a defensive system is seeing that system in action. Having a few army scripters in our midst to challenge the defenses will increase rather than decrease the enjoyment of the game. It turns an otherwise abusive player into an interesting problem to be solved; tactician-oriented players will jump at the opportunity to prevent the abusive player from taking advantage of the same chink in the town's defenses twice!

Having a lot of characters is also a strong incentive to be good, because doing one wrong deed with one of one's character is going to incite retribution on any (or all!) of one's other characters. Obviously, such out-of-character revenge may be unrealistic, but because of the strong consequence it brings to any player engaging in undesireable activities, we may want to overlook this OOC'ishness.

It has also been discussed that a player will need to earn the ability to run additional NPCs, perhaps by paying N AP per character generated (the first one is always free, of course.) This way, one could build an army, but only after a lot of time spent adventuring, and only at the cost of giving up lots of potential character advancements. This danger is less important with military armies, and more of a concern of general labor. Having 200 miners under one's thumb can help generate a great deal more income than one player character should have. But as outlined earlier, this "capitalist" problem has some benefits as well, and may not need restrictions other than those placed by the game players themselves.

Finally, keep in mind that it will always better to have an army of individually managed and guided PCs than it is to have an army of NPCs that one must micro-manage. Yes, the NPCs' actions will be more predictable, but that can be as much of a hinderance as benefit. The NPC army is also going to be less flexible and adaptable than the PC army.

3) "Macroing" is a topic that has been discussed in great detail on the mailing lists. Because of the potential abuse of this system, practice alone cannot be relied on to advance a character's skills. Even so, the presence of scripted skill-practicers can be turned to the advantage of the WorldForge world. Scripted characters will need food, protection from danger, and a place to sleep if they are to train new skills safely. This means that they'll need to find a safe city, which probably means that they'll have to pay taxes or other fees to support a garison, frequent the various food sellers, and so forth. Thus a seemingly anti-social character becomes a fundamental upholder of the community.

4) Players who spend a lot of time tuning up their character's scripting codes will help out the system by identifying good algorithms and exploits for other players to use. The best of these tactical algorithms will eventually be given to NPCs, thus helping in creating more sophisticated and intelligent artificial beings.

Teaching and Learning

Rather than relying on "cut and paste" to share scripts between characters in an OOC manner, "teaching" methods will be added to the game. These will permit one character to pass on the formula for a particular deed on to other characters. A teaching roll will be required; failure may indicate that only a part of the algorithm was taught. The character could swap code in from a similar program to "fill in the holes". Also, there will be potential for some random variation in a few of the scripts commands.

In addition to PCs teaching PCs, or PCs teaching NPCs, there will be means of NPCs teaching one another, and also for characters to learn scripts simply by observation.

Those familiar with genetic algorithms will recognize the above process as sharing similarity with recombination and mutation. This is intended. By using this pseudo-genetic approach, NPCs may be able to "learn" on their own, develop new techniques, and gradually evolve to be more sophisticated.

Removal From Game When Offline

Some players will balk at the notion of risking their character's life when the player needs to attend to real life duties. The player may only have time to play on the weekends, for instance. For these players the notion of "inns" and "guildhouses" are established.

Inns are places a character can go to "rent out". For a certain fee per day the character will be removed from the server's memory and essentially placed in stasis. Theoretically, the character is relaxing, healing old wounds, dining in-house, and caring for his equipment, but programmatically, the character is somewhere outside of the game server and completely ignorable.

This concept is extremely similar to how "rent" works in MUDs, but with one difference: Each character in the inn is assigned a room. When the character enters the room, it is removed from the game, but if anyone subsequently enters the room, the character is brought back into memory, and can be killed, robbed, etc. by the invader. Thus, it is critical one picks their inn with care. Find one that is well guarded and that cannot easily be broken into.

One side benefit of this system is that it will be easier to punish criminals. Player killers who are wanted for murder cannot simply drop connection or "rent out" to avoid revenge; the authorities will be notified, an investigation begun, and eventually the murderer will be dragged from his innroom to stand trial for his crimes.

Guildhouses are much like inns, except that they cater to a smaller clientelle and rely on their members to assist with defense. For instance, the thieves guild might provide protection to its members from the legal authorities, but require its thieves to perform deeds to benefit the guild, such as spying on the chief of police, or swiping money to help pay for extra guards.

Conclusion

As can be seen in the above introduction to the concept of scripting, this has a great deal of potential, and helps blur the line between player characters and non-player characters. Hopefully, it'll spur creation of algorithms to make the artificial beings more fun to play with, and will serve to making the gaming experience in general more enjoyable.