MUD using PHP and AJAX?

For discussions about game development that does not fit in any of the other topics.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

MUD using PHP and AJAX?

Post by Jackolantern »

This is kind of an extension of the "TCG using PHP and AJAX thread". What about making a browser-based MUD with PHP and AJAX? I am pretty familiar with MUD programming, and the 3 most difficult things to deal with in MUD programming using a traditional MUD language such as C or C++ are:

1. Threading
2. Sockets and network code
3. Clumsy and inelegant Telnet interfaces

If you used PHP and AJAX, you would basically deal with all three of these in one shot. I am still pretty new to PHP, but it appears that all threading for multiple users is done by the web server itself. That is a huge part of creating a MUD, since neither C nor C++ are built to natively thread. And while I know PHP does have some socket coding, the networking element would be incredibly streamlined when compared to C or C++ since you are working with browsers and standard internet transfer protocols. And finally, naturally, there is no Telnet, so no having to deal with Telnet.

There are many AJAX live web chat systems out there, and any of these could be used as a starting point for the client-end page, since that is really all that the Telnet terminal is as far as MUDs are concerned. Then you only need to write the game logic (which is still not small task) and connect it to built database and the AJAX chat front-end.

I have still had a lot of interest in MUDs for developing small to medium indie MMORPGs. I still think that MUDs have a place in the game world, just as books still have a place in the world of movies. MUDs actually started experiencing a decline before UO was ever released. Most people assume it was the creation of graphical MMORPGs that lead to their decline, and while I am sure it had something to do with it, a big issue was the massive re-use of existing codebases. The market became flooded with people who just got a copy of DikuMUd, SMAUG, or some other codebase, threw in some pre-built, generic areas and mobs and turned on their server. MUDs competed by room count instead of room quality, and the result was that about 99%+ of these MUD's rooms were generic rooms found is many, many other games (I can't count how many times I have gone through "MUD School" in different games). The MUD playing community was divided between a gigantic amount of generic game servers, so each game seemed quite sparsely populated.

The few MUDs who actually have created proprietary engines with all unique rooms, items, NPCs and quests have done quite well. Achaea is one notable game, which started the same year that UO was released. It regularly has over 1,000 players registered with it, and is one of the oldest microtransaction games available (this is the first big game by Matt Mihaley, who is now creating Earth Eternal). Probably one of the largest successes is Gemstone IV, which is a monthly-fee supported MUD that has over 50,000 active subscribers. The game has a $14.95 a month subscription fee. That's right. 50k players playing a text-based MUD for $14.95 a month.

Bandwidth costs are also very low for MUDs, giving either more room for profit for a commercial game, or less fees to cover for free-to-play games. And of course, there is no cost of creating art assets. This gives the design team a huge amount of freedom for creating special events and new content. Content can be created very quickly, and in some cases, can even be created without bringing down the servers by allowing "builders" to create new items, rooms and NPCs through special commands. Events can be epic and far reaching due to the ease of development. For example, in one event in Achaea, giant dragons came out of a cave (this was to mark the opening of a new cavernous area) and started attacking the cities. One of the cities was damaged badly, with building being burnt down, castles towers being knocked down and other mayhem. All this could not have been done in a graphical game for a 5-day event. Every building would have to have been re-modeled in various states of destruction, and then everything would have to have been changed again for the rebuilding. This would just not be economical in a graphical game, but in a MUD, that is just a day or two of event coding.

I think a good, creative MUD could garner at least a medium-sized community today. Having it browser-based would make it that much more accessible, too. All it takes is a creative design team to break the now stale mold of MUDs, and create something truly different than the scores of bland MUD codebases that exist today. With all unique rooms, quests and NPCs, it could definitely work. In many ways, the surging popularity of graphic MMOs has only increased the amount of people interested in MUDs. However, in today's MUD world, they simply get turned off by over-simplistic game mechanics that seem archaic compared to modern MMORPGs. But that has nothing to do with them being text-based, and has everything to do with the fact that some of these codebases have had limited updates in the last 20 years. This is particularly sad considering that MUDs can be (and at several points in time, very much have been) on the bleeding edge of MMORPG gameplay due to not having the baggage that comes with graphical games.
The indelible lord of tl;dr
User avatar
Noctrine
Posts: 928
Joined: Thu Apr 23, 2009 9:57 pm

Re: MUD using PHP and AJAX?

Post by Noctrine »

I've always been a fan of graphics, I love graphical muds (RPGworld anybody?) traditional MUDs scare me. Maybe it was just because telnet was a bitch. But yeah, I can't argue with your logic, but as far as MUDs still having a place in gaming.

I think it would be more of a niche audience, just like people who still frequent usergroups.
Jesse Dorsey
ProjectANI - Lead Developer Person
http://about.me/jessedorsey
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: MUD using PHP and AJAX?

Post by hallsofvallhalla »

i agree to many and all points here. there is still a huge fanbase to conventional muds and anyone who says otherwise just doesn't want to accept the truth. As is the same with 2d fans.

PHP, js, and ajax would save a hella lot of time and could be done easily.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: MUD using PHP and AJAX?

Post by Jackolantern »

I don't think it is just the existing MUD fanbase either. As recent as just last year, Achaea and other MUDs were still getting several new players who who had never even tried a MUD before signing up every day (sometimes as many as 30 or 40 in a day). Unfortunately, many of these curious players quickly get turned off by a lack of good direction in the newbie experience. Most MUDs have very sparse beginning tutorials, or they just throw a wall of text at you without actually showing you anything. Then, after whatever introduction they want to show you, they just toss you out into the world for you to figure out what your goals are.

I am a firm believer that to keep as many new players as possible, you need to set up beginner goals for players. They are not familiar with your world, and thus, they have no preconceived goals to work towards, and will get bored or frustrated with a game quickly. Most highly successful MMORPGs follow this model, and give players tasks to accomplish that are larger than a single quest, yet small enough to only take up about 10% of their level progression. By the time players are 10 to 15 levels into the game (in your average 60 or 70 level cap game), players have enough of a foothold to know what will make their character stronger, what crafting professions they may want to try, if they are interested in building a PvP character, if they want to try to become rich, perhaps what guild they want to join, etc. Almost all MUDs overlook this critical new player disorientation problem, and the text-based environment makes it that much more difficult for new players to overcome bad beginner game design.

However, the nice thing about a PHP/AJAX system is that you could add buttons, menus and interactive manuals right on the user client page. This way players can quickly and easily get hints of what they can do next, reminders of commands, get connected with recruiting guilds and much more. Everything in a Telnet-powered game has to be hidden behind unfamiliar text commands, which a new player will not know, and which then disappear as the player continues playing. This would be a huge advantage to this type of system as far as helping and retaining new players.
The indelible lord of tl;dr
Cayle
Posts: 272
Joined: Fri Jul 03, 2009 4:45 am

Re: MUD using PHP and AJAX?

Post by Cayle »

What about a web services interface on the MUD? To issue a command, you invoke a URL with the command as a parameter and the . This incidentally would not make any assumptions about the user interface; whether it is a graphical client or a text client.

Alternative logons via web and smartphone anyone?
Alexx
Posts: 23
Joined: Sun Jul 26, 2009 3:39 am

Re: MUD using PHP and AJAX?

Post by Alexx »

Noctrine wrote:telnet was a bitch.
haha, couldn't have said it better myself
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: MUD using PHP and AJAX?

Post by Jackolantern »

Cayle wrote:What about a web services interface on the MUD? To issue a command, you invoke a URL with the command as a parameter and the . This incidentally would not make any assumptions about the user interface; whether it is a graphical client or a text client.

Alternative logons via web and smartphone anyone?
Creating a full MUD with PHP and AJAX is still currently well out of my ability, as I am still learning about web programming. Therefore, I am really not completely sure about what this entails. However, alternative logins through smartphones does sound cool 8-)

EDIT: As far as the original idea of a PHP/AJAX MUD, this is not far off from Hall's own PHP MMO tutorial. The main difference is integrating an AJAX chat-like system to give the game feedback and gather input instead of the various pages used in standard PHP MMORPGs. There are several PHP MUD projects up on Sourceforge, but they all seem to be standard PHP MMOs, with different pages for different functions, etc.
The indelible lord of tl;dr
User avatar
Noctrine
Posts: 928
Joined: Thu Apr 23, 2009 9:57 pm

Re: MUD using PHP and AJAX?

Post by Noctrine »

Cayle using RESTful web services would be an epic approach to this. Jack you have to learn faster! Then you can bring us more great games :p
Jesse Dorsey
ProjectANI - Lead Developer Person
http://about.me/jessedorsey
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: MUD using PHP and AJAX?

Post by hallsofvallhalla »

the ajax and javascript side will be VERY easy. Especially for someone like you who is skilled with OOP. JS is very OOP. Not POOP.

example of a simple movement where you have buttons on a compass, you could do it with typing, not much harder to script.

Code: Select all

<div id="buttonnorth"> <img id ="buttonimagenorth" src="images/northbutton.png" onClick="travelnorth()"></div>
<div id="buttonsouth"> <img id ="buttonimagesouth" src="images/southbutton.png" onClick="travelsouth()"></div>

<script="javascript">
function travelnorth()
{
direction = "north";
travel(direction);
}

function travelsouth()
{
direction = "south";
travel(direction);
}


///////////////this function updates the player has moved in the database so when 
////////////////they log out they return right back here...you also use this 
///////////////command to return the stats on the new room but I did not add that 
///////////////here but its all one simple ajax query. 


function travel(direction)
		{
			
		var ajaxRequest;  
	
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			}}
		var queryString = "?id=" + id + "&direction=" + direction;
	ajaxRequest.open("GET", "travel.php" + queryString, true);
		ajaxRequest.send(null); 
		}
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: MUD using PHP and AJAX?

Post by Jackolantern »

hallsofvallhalla wrote:the ajax and javascript side will be VERY easy. Especially for someone like you who is skilled with OOP. JS is very OOP. Not POOP.

example of a simple movement where you have buttons on a compass, you could do it with typing, not much harder to script.

Code: Select all

<div id="buttonnorth"> <img id ="buttonimagenorth" src="images/northbutton.png" onClick="travelnorth()"></div>
<div id="buttonsouth"> <img id ="buttonimagesouth" src="images/southbutton.png" onClick="travelsouth()"></div>

<script="javascript">
function travelnorth()
{
direction = "north";
travel(direction);
}

function travelsouth()
{
direction = "south";
travel(direction);
}


///////////////this function updates the player has moved in the database so when 
////////////////they log out they return right back here...you also use this 
///////////////command to return the stats on the new room but I did not add that 
///////////////here but its all one simple ajax query. 


function travel(direction)
		{
			
		var ajaxRequest;  
	
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			}}
		var queryString = "?id=" + id + "&direction=" + direction;
	ajaxRequest.open("GET", "travel.php" + queryString, true);
		ajaxRequest.send(null); 
		}
Thanks for the script idea! I have not really started working with Javascript much yet, but it is probably the part I am least worried about. If nothing else, there are plenty of existing AJAX live chat systems (like the one on the MMORPGMaker.com forum) that could make good starting points. Instead of outputting the text that other users are typing, just send it the game info. And that does make me feel a bit better that Javascript is heavily OOP-based. :D
The indelible lord of tl;dr
Post Reply

Return to “General Development”