Zork/MUD-like basic item structure
So at work the other day I was explaining Lantern to a buddy (@shamuspeveril) and we somehow got onto the topic of how well nodejs would work for a zork like game or a mud. Well, sure enough, with the idea stuck in my head I sat down today and tried to think through. Luckily I think this concept will apply well to what I hope to do with the Lantern server, so I don't feel like I deviated too much from my path.
In case you are not sure what a MUD is, this is a brief description grabbed from wiki :
MUDs combine elements of role-playing games, hack and slash, interactive fiction, and online chat. Players can read or view depictions of rooms, objects, other players, non-player characters, and actions performed in the virtual world. Players typically interact with each other and the world by typing commands that resemble a natural language.
And if you don't know what Zork is... Leave. Just go.
Anyways, making the basic nodejs server to handle limited verbs was pretty simple. Ex:
Server:
[code]
var http = require("http");
var url = require("url");
var fs = require("fs");
var sys = require("sys");
var qs = require("querystring");
var send404 = function(res){
res.writeHead(404);
res.write('404');
res.end();
}
var server = http.createServer(function(req,res)
{
var path = url.parse(req.url).pathname;
sys.puts(path);
switch (path)
{
case "/":
fs.readFile('mud/index.html', 'utf8', function(err, data)
{
if(err) {
res.writeHead(500, {});
res.end();
throw err;
}
res.writeHead(200, {
'Content-Length': data.length
, 'Content-Type': 'text/html'
});
res.write(data);
res.end();
});
break;
case "/command":
var commands = qs.parse(url.parse(req.url).query).commands;
handleCommands(commands);
break;
default:
if (/\.(js|html|swf)$/.test(path)){
try {
var swf = path.substr(-4) == '.swf';
res.writeHead(200, {'Content-Type': swf ? 'application/x-shockwave-flash' : ('text/' + (path.substr(-3) == '.js' ? 'javascript' : 'html'))});
res.write(fs.readFileSync(__dirname + path, swf ? 'binary' : 'utf8'), swf ? 'binary' : 'utf8');
res.end();
} catch(e){
send404(res);
}
break;
}
send404(res);
break;
}
});
server.listen(8000);
function handleCommands(commands)
{
var commandArr = commands.split(" ");
verbs(commandArr[0]);
}
function verbs(v)
{
switch(v)
{
case "n":
case "north":
sys.puts("Moving north");
break;
case "s":
case "south":
sys.puts("Moving south");
break;
}
}
[/code]
Client :
[code]
$(function(){
var commandObj = {
commands: document.getElementById('commands').value
}
$.get("http://localhost:8000/command", commandObj,
function(data)
{
}
, "json");
});
[/code]
So that just handles north/n and south/s but you can see how it would progress. Which should lead you to the problem I hit when I added the "south" command block - That is going to be one massive switch statement. So instead of continuing forward with my massive switch I decided to think about it yesterday and I think I came up with a solution that I will use also in Lantern for my crafting system.
The system relies on the item know what is can do and containing all the information that would make it able to control itself instead of a large switch/case on my part. And this whole set up is made 100 times easier because I'm going to be using mongodb. Here's some pseudo code to give you an idea of what I'm talking about:
[code]
{
type:"Room",
exits:
{
north:{desc:"You see an exit to the north",room:3242},
south:{desc:"There's a small door that seems to be locked",room:123}
},
description: "You're in a big room with two doors.",
items:"123,63,7456,34,99,4563,215789,45"
commands:
{
look:{desc:"The room you are in is stupidly large with only two tiny doors, one to the north and a seemingly locked one to the south."};
yell:{desc:"You shout at the top of your lungs and you just hear your voice echoing mockingly off the walls."}
}
}
{
type:"Item",
id:123,
description: "The rock is small and perfectly circular.",
commands:
{
take:{desc:"You take the rock and put it in your backpack.",callback:"addToInventory"};
}
}
{
type:"Item",
id:99,
description: "A small glass bottle filled with an unknown liquid."
commands:
{
combine:{desc:"Blah blah", callback:combineWith, ingredients:4345, creates:8456}
}
}
[/code]
As you can see with a system like this, each item is responsible for knowing everything about it and the other items it interacts with. While this make be more difficult to create up front, I feel that once the system is in place I could easily use this in Lantern, a MUD or really any game going forward.
Or maybe I'm brutally over thinking the problem. Is there a better way to handle item relations and verbs? Would a massive switch/case with all the different verbs I want be the way to go? Even if I got that path, I need a similar structure to above just for the content. And then added a simple onetime use command like "lick" or something would require new code instead of just text.
Let me know what you think. I will be starting on code like this soonish for Lantern and would like to have a method pinned out. Right after I figure out the mapping issues I'm having ^^
Lantern's Market
I would like to explore and get some thoughts out of my head on this topic. But before I get too far into this, I should first explain a little about Lantern's item system, crafting, questing, rare items and in general how they are collected.
A feature that hasn't been fully scoped out yet, but roughly exists in my head is the crafting system for lantern (another post later) which will rely heavily on a rather different stat system, but that's another post as well. The crafting system will be similar to that you find in many other games when it comes to the end result. Players will be able to create items from raw materials to sell. The big difference is if I make a sword and you make a sword, these swords could end up being very different. The quality of the sword, it's bonuses and other attributes will depend on the maker. For the market this means that items won't all be priced the same and players will need to figure out what is attributes are valued when making and buying certain items.
The next interesting note is there will only be a handful of NPC's that sell items. Most of the items in the game will end up being player made.
A third factor is that this game will maintain a living universe. This means that rare drops from a certain boss/challenge will likely only happen the once. This means there will actually be items in the game that only one person will ever have.
Fourthly with monsters having limited to no drops a player will almost be forced to play the market to make money. That's right. No grinding for loot. You can grind for everything else but that
And finally, markets will be localized. What I mean by this is that if you put an item for sale in a town 'a', those in town 'b' can't see it. The issue with this, if I want the system to remain logical, is how the player can have an item on sale in town if they aren't there? A few story idea's have crossed my mind, but the one I think I'm going to go with is a group who offers you handle sales of items for a small percentage.
With all these different factors, my intention to allow the market to have the freedom to grow as it will (no imits on prices), all players being able to craft to some extent and the ability to have players run a monopoly, I believe this could be a very interesting system.
Lantern Map
Look at this awesome map! Look at it!
This is a rough map I made in a few minutes for my friend William aka jetfx (http://jetfx.livejournal.com/). William is a cartographer, a world builder freak and an aspiring author. He will hopefully be helping me with my maps and story for Lantern as we move forward. Whenever he has a better map that the pretty epic one I drew, I'll post it for you all to see.
*UPDATE*
William, being pretty damn quick, thought my map looked too crappy to share so he cleaned it up for me as you can see. I decided to leave mine so you can see how much better he is and why I'm pretty stoked he's agreed to help.
Random Encounters
Progress on Random Encounters, a mini-game of sorts that I am using as a test bed for some of my Lantern concepts, is slowly trucking along. The game engine along with it's content creation tools are almost complete. Skinning hasn't been thought about yet, but the game itself is close. Something that I need to do and haven't yet is find a *cheap* host that will allow me to install mongo and nodejs. Emphasis on cheap as I am broke.
Random Encounters for me is a test for mongo, some simple js. though the initial build won't have it and some gameplay concepts that aren't nessicairly related to lantern but ones I am playing with.
The game will constantly be in beta and will be my playground for new idea's and tests. After the current road map I have in mind is complete, which I will write down and post later, I will likely publish all the code for people to use if they have the urge to host a crappy game.
Anyways, here's a little snippet of code for mongo to get a random record that took me a while to get working.
[code]
$numOfCreatures = $collection->count();
$ranCreatureId = floor(rand(0,$numOfCreatures-1));
$ranCreateObj = $collection->find()->limit(-1)->skip($ranCreatureId)->getNext();
[/code]
Windows + VirtualBox + Ubuntu + nodejs = hooray!
As I'm sure some of my readers (all four of you) may know because of the IRC room, I've lately been trying to get nodejs running on a virtual machine (ubuntu since nodejs doesn't like windows and I don't want to virtualize osx) that is accessible from my host (windows) so I can use it for Lantern. Well I had a few minutes tonight to sit down and do some reading and I figured it out, hence the post so I don't forget.
I'll go right from step one in case anyone else is trying to do this with no prior knowledge
I should also mention if you're on *nix you don't need to do this.
- Get virtualbox
- Get Ubuntu (or whatever distro tickles your fancy)
- Install a vm of ubuntu
- Download nodejs on vm
- Config/Make/Install - I had to install g++ and cmake to get it to build properly
- (The tricky part) On your host (windows) navigate to your virtualbox installation via command - something like this : C:\Program Files\Sun\VirtualBox\
- Run these commands :
VBoxManage.exe setextradata "ubuntu2" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage.exe setextradata "ubuntu2" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 8000
VBoxManage.exe setextradata "ubuntu2" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 8000
- Launch your vm, start node js and on your host in a browser go to localhost:8000- HOORAY!
So here's what I know about the commands what you need to edit to make it work
- Instead of "ubuntu2" use the name of your vm.
- the guestssh isn't important. Just a name use to group the settings. Call it whatever you want.
- Guest and Host ports are the port you want to access on your vm.
- If you change you're installation at all from the default you'll have to figure out the other changers yourself here : http://www.virtualbox.org/manual/ch06.html#natforward
Good luck ^^
Lantern Update
In my last post I was discussing Lantern's combat and party system. These two features are very closely related to the map, which is going to be the main area of action in Lantern, so I have been thinking a lot about how to approach this map. I think from some discussions I have had with people in the #bbg irc room and with a few coworkers, I'm going to try to use nodejs for handling the communication and npc logic. From my understanding of nodejs (which is very limited so please correct me if I'm wrong) I can use it to push data to players that need it and create objects at run time on the server and run based on a timer. What I'm looking to do with this functionality is to run the npc's logic independant of players input. I'm pretty sure nodejs will allow me to do this. All I need to do is set up linux on a virtual machine and get everything all playing nicely together so I can continue to develop on my local machine.
But as I work on Lantern and think about, the need to a test bed is becoming more apparent to me. So to fix this need I'm going to take a quick break from Lantern to make myself a small game that I can use to test different parts of Lantern. This will range from Mongo scripts to game tools (for creating quests/items/etc). The scope of the test bed currently is very limited to the mongo scripts and the game tools. If I can think of a way to test nodejs in this that would be great, but for now, just testing some idea's around those other elements would be enough. This small game test bed will be call Random Encounters. The game is exactly what it sounds like. You click a button and you encounter things. The game will suck, but it's purpose is testing. This small game will hopefully be online in the next few weeks. Work has be pretty busy of late, so I haven't been able to look at anything lately.
So that's where I am. If anyone can confirm or deny my thoughts on nodejs that would be great.
Lantern Combat and Party System
The time has come, the walrus said, to speak of many things: of swords and clubs and player groups, of adventures and rings... Ah to hell with it. Let's talk about how to create a party system for pbbg's that doesn't require players to be online, but is still interactive and fun, and killing things!
The thought of a party system is by no means a new idea. The challenge arises when you try to apply the principle to an environment where players won't be online when actions concerning them will be occurring. What I mean is that if a party of six players are on a quest, there's a good chance a when one player logs on, everyone else is offline. What will this player be able to do if they are a member of a party? Can they move the party? Will they be able to move around themselves but remain a member of the party? If so, will their gains be party gains? And then we have party combat; Will the leader direct each member or will combat pause until each member can log in and take a turn. Or maybe it would be better to allow players to create a rule set that will manage their character in battle for them.
Party Formation
With the party we have a few options to look at as mentioned above. First up is each player in the party has the ability to move the party. With a party of six where each player has the power to more the party this, I think, would quickly dissolve into players arguing and fighting amongst each other about how movement and combat should be handled. In a game where movement and actions will likely be limited to a tick, this outcome could actually ruin the game for some players. You also don't have the same clear definition of roles that can bring a lot of fun to party play.
How about party members being able to control themselves and their actions instead of being dictated by the party? This approach solves the what do players do when they are online and the combat because they are in full control. The issue is though is this is no longer party play. You are now playing the game on your own but yet remain in a 'party' of other individual players. A thought that would give this style more of party play and still resolve several issues with combat is to not allow the members of the party to move more than 10 or so tiles away from each other. Then if you make combat turn based, a player could engage an enemy and instead of fleeing stop playing until another member of the party or two and come and attack the enemy as well. I like this idea. It give players the option to still explore the world, combat and train while party members are not online but still gives the sense and benefits of a party.
The final concept I have for this is to have a leader that is the only one that can move the party. This means that when a player that isn't leader logs in there would need to be something they could logical do while in a party adventuring. And I can't think of anything. A player could log in and train or study, but that isn't really that fun in contrast to the leader where when they log in they have the power to move the party, enter battle and make all the quest decisions. While this limits player interactivity, combat and general fun... Actually, that's pretty much all it does.
Combat
This issue is tightly related to the type of party system that is in play, and I can think of three possible (read as not necessarily good) ideas for this. Let's start with the idea for combat and party system that I am leaning too; Turn based combat with players able to control themselves and move about the area the party is in. This approach would allow for players to decide how to enter combat. If an enemy is spotted five tiles over, the group may decide it's best for the tank to engage first and then have the other members join the fray. The enemies combat would also be turn based. The only point that is nagging me here is how would the enemy operate. Would they only respond when they have been 'activated' - attacked, tile entered? If so what happens when the tank attacks, the enemy strikes back, and then the archer 3 tiles away attacks? Does the enemy attack the tank or would it start to move towards the archer? Or maybe even move towards someone else that is in the area. Or flee. And what if the enemy is attacked simultaneously? Or if the archer attacks and then runs? Should the aggro stay active for a few turns and every time the archer moves, he calls the enemy to runs it's AI script and decide an action?
Keep in mind I only came up with this idea as I am writing this post, so this is what I think I would do with only a few moment of thought. I would have each player that engages an enemy active it for a number of rounds, even after combat. This means if the player tries to flee, it may be chased. But what this system also implies is that the enemy when it is engaged/activated/whatever it will run it's AI script and determine course of action around it. This means and could be really interesting, is that if a player that has attacked an enemy and decided to wait for help could still be killed when help arrives and triggers the enemy to make a move. My only concern is that this would lead to a player dying without knowing what happened. If all six members of a party attack an enemy at once and the enemies AI tells it to kick the crap out of the guy beside me six times before that player has a chance to refresh the page, they will refresh dead. This though would lead to party tactics and communication which I strongly support.
Another option for the party being control as a whole either by a leader or each member in the party is the concept of a combat rule set. What I mean is that a player will have a screen where they will see a list of options and how they would want their player to react to each own when they entered combat. For a system like this to work in my mind the players would need to receive rather detailed reports about the battle so they can tweak their rule set. And while this would be interesting, the party formation still limits much of the players actions and in the end rather boring (I think) way to do it. Not only can you not move yourself, your combat consists of conditional statements.
In the end for me, I think allowing the players to explore a limited area around their fellow members and creating some form of activated AI system seems like the best solution for me. What do you think?
PS
For those who are unfamiliar with how I write posts like this, I literally come into it with the topic and almost no other thoughts on the topic.
Monetizing Lantern
As I work on the gameplay and story for Lantern with my friend Lucas (who still doesn't have any form of site), he mentioned an idea that I going to attempt to avoid for a little bit but now that it's in my head I want to get my thoughts out about it.
As I've stated in the past, I refuse to allow players to buy themselves a better player, or give them an edge over others. This makes it very difficult to come up with ideas on how to get players to pay me other than out of the goodness of their hearts. Not that my goal is to make money, but it would sure be nice not to have to worry about server fee's.
So here's a quick break down of lantern in case you haven't read other posts related to it: It's a pbbg rpg with party based combat/quests in a living universe with a hex map for movement.
Commonly, or at least by what I have seen on these types of games, monetization has meant selling action points, in game items to make you more powerful, faster regen, more xp gains etc etc. But since I refuse to do that, I need to look at other features players may be willing to pay/donate/give me beer/vodka/rum/whiskey for. The first thing that pops into my mind is a friends list, but at the same time that to me seems to be a pretty basic feature. The thought of allowing the player to seem more of the hex map is still hanging in there for me though. While this may give players a slight edge I don't think it's an unbalancing one which is my problem with with buying bonuses. Another thought is to provide donators/buyers more data that is available to all players but on the map page where almost all game play will occur. For instance show them all their stats, the current quest and an overview of their party members. Another popular one is to remove ads if the a player dishes out a few bucks. This is another one I am strongly considering.
I think features that enhance the the game, but not having them doesn't leave you crippled, is the way I'm going to go. This way the players don't get a in-game bonus for spending their money and still feel like they are being rewarded for donating/subscribing. Of course, it would be great to be able to make these features available to all and just survive of the donations, but we'll see what comes of it all. How do you make money with your game? Do you offer in game bonuses? How do they effect play? I would love to hear from some people that offer xp/money/items and how they feel it effects their game.
Recap : Alliance/Clan systems in PBBGs
This is the second half of my polls idea is to do recaps after a few days of voting and comments, where I discuss what I've been thinking after reading the comments and poll results and try to explain how my thoughts on the subject relate with the polls/comments or how I differ from them.
Most of the poll results and the two comments lean towards allowing players being able to create their own groups, and if they are forced into factions be allowed to smaller groups. And I would have to say I agree. I like the idea of players being put into factions and then allowing them to form smaller groups where they can play with their friends.
Something I'm still up in the air about is allowing players to pick their 'faction' though. This can quickly lead to unbalanced teams and screw up the game. One of my favorite solutions that I've seen is how StarKingdoms handles joining the game. When you join you can automatically assigned your position but you can reserve three positions in your area so when your friends sign up you give them your code and they are now in your area. But for a system like this to properly work both sides have to be identical in what they offer to a player. If one side has mechs and one side has dinosaurs, you should let your user pick what they want, but if it's just two sides of the same coin, then forcing them into teams with options to ensure their friends can join is a good path.
This is of course you want users to be forced into teams which I think works best for position based strategy games. What I mean by position based strategy games is that your available actions depend on your location on the game board/world. To get from point a to c you need to go through b. These games use area and benefit from players close to each other teaming up.
In a game where position in the world has no limitations on the players movements or actions (like Earth 2025) allowing players to form their now teams and factions makes the most sense to me.
As I'm sure you've noticed, I've referenced strategy games each time I tried to described the differences. That's because for RPG's I don't really see the same problems. Players should be able to form their own groups. Sure you may have race's or different sides (like WoW) but the focus of the game isn't really on the warring between both sides which means worrying about balanced numbers of players on each side isn't as big an issue as for strategy games.
Question : Turn based or Unlimited play?
What do you prefer in a PBBG? Do you prefer the competitive edge that usually comes with turn based games (ex: You have 20 action points a day and every action your perform uses one limiting how much to can play a day?) or are you more a fan of games that allows you to play at your own pace and explore their world and store (ex: You literally can play all day. These games are generally quest based and are RPGs).
[poll id="4"]
I'll be writing a follow up post to my last poll soon and will do the same with this one after a few days. If anyone has some polls they'd like to see, feel free to email me or leave the idea in the comments

