• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 841
  • Last Modified:

php mmorpg group interaction


After having made some websites for clients, I dont have any job ftm... So I'm getting bored :)
In the mean time, I would like to create my own php mmorpg... I know alot of people ask this, but my question will be different.

First of I know how to write php.. i think that is quite important for this matter :)

So, I'm willing to write some sort of dungeon and dragons website. so this means:
several groups playing different games
each group consist of a number of players
one person in each group is a dungeonmaster

Now i've been thinking while writing down some analyses on how to write this website... How would you interact the group with each other? How would you write this part? (not what but how?)

Would you store it all in a database? I mean a group is something that comes and goes... player can leave whenever they like...

But how would you write the code while they are playing?

2 Solutions
Perhaps you should look to setting up a bulletin board phpbb could be a good option, this uses php and mysql and then modify it to your needs, instructions on site, but suffice to say your server will need to support php and mysql.  www.phpbb.com/
MutsopAuthor Commented:
euhm.... are you sure this answer belongs to my question? or did you perhaps made a mistake.

I don't really get why a forum has aything to do with what I need.
I've thinked a lot of times myself in this type of projects.

A game of this type requires some type of dynamic interaction, so a forum is not the best option. It should be something like a chatroom, but, at same time, you would like to have info about users and some ability to change profiles or show certain info.

So my idea coming to scratches is something like this:

1) A web where players, profiles, groups, etc are managed, you even can get a forum inside to publish and arrange gameplay sessions between groups, news, looking for groups, etc...

2) Inside the web, you must allow your users to launch a session of chatroom (or "gameroom" if you prefer). The user who creates the gameroom is the "dungeon master" for this session, and can send invites to other users to join to the chatroom. This "gameroom" should allow users to check their stats and should allow "dungeon master" to check the stats of all the players.

3) A virtual checkboard where players can position their characters and where the "dungeon master" could draw would be very useful.

Once a Session ends, the dungeon master makes some anotations into it's "campaign" data and the "gameroom" instance is deleted (while data referring the session, as duration, players deaths, date, etc, etc... are stored into database)

Hope this helps.
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

MutsopAuthor Commented:
There are some nice ideas :)

But how would you do this codewise? For example, the position/coordinates of a player.
This has to be updated everytime he moves his token (using draggable jquery), how would you process this in php?

How about updating this on teh browser of the other players?
If you will be using coordinates to keep track of your players, then:

-yes, you have to put it in a database
-make sure you don't allow users to teleport. That means, a user from 1,1 cannot just teleport all the way to 50,50. So, you have to check that the user should be moving only to an acceptable coordinate (around current position).
-whenever he moves his token, jquery will also update the server and say the new coordinate
-the clients who are all connected to the website who are in the vicinity of that player (say 1,1 -- the players within the vicinity of 1,1), should all get the updates that the player has moved from one coordinate to another
-you can identify the players using player IDs. since you know that player IDs are unique, you can use it to identify their characters in your user interface. for example:
 mmorpg-the line of sight dictates to whom they can interact with :)
-your UI should constantly connect to the server for updates, you need to call a single page every how many seconds so when something happens in the server, clients will know about it once they fetch for an update.

As for the deletion of users when they leave, you can set accounts to expire after a month of inactivity.
I don't think a restriction of interaction is really needed on the board, as in this type of game there can be so many different situations in each moment (teleport is actually one of those, but also invisibility, going prone, fly, terrain effects, etc, etc....) So I would let that rest on the back of the "dungeon master", who will determine if a movement is valid or not.

This way, the master will be able to move any token on the map, while players will only be able to move it's own tokens. If I make a bad move, the master will correct it and warn me, or explain me why this type of movement is not valid.

Of course, in every moment you must track the coordinates of every token in the board (probably storing them in a database after each movement) and the main difficulty, as you point, is to update those movements in every player browser.

Usually, this type of gameplay, get a rotational turn-based style. So maybe you can allow the master to create the default positions in the map and assign initiative rotation order. After that, all the players get the initial map and the one with the highest initiative order is able to move it's token, after he makes it's move, he push a button that let it's turn pass. You can create a javascript function that works as a "listener", asking the server every 5 seconds or so if it is your player's turn. When the server returns a change in the turn status you force a reload of the board, and if it is also your player's turn, you get access to movement.

I don't really know... this is a difficult task and it must be cool planned before starting. I'm afraid here the most we can do is brainstorm a bit in order to orientate you in a direction that allows you to reach success.
MutsopAuthor Commented:
Waw, thanks alot for the explanation... I just came from work and need to go again. But i certainly think about all these points tomorrow and start planning. I'll let you guys know :)

MutsopAuthor Commented:

Well I've been thinking about this movement phase. I could use some sort of array as a map and calculate their movement/view range or even line of sight :)


Well it's true that the dungeon master should always have its last word on it. But what if a movement has been comfirmed? So I should aslo keep track of previous movements of teh players, so some sort of undo can be done.

About the listeners, thanks for the idea :)

What I'm still not on is, how to process a game if a player is missing or disconnects. Should they pauze the game? Should they be able to continue? What if the players reconnects? Should he start at his leaving point? or should I just let the dungeon master decide?
I think it really depends on the type of game you want to describe. The most restrictive is your UI, the most difficult to fit the adventures into it, but probably your interface apps will be more useful and more powerful.

From my point of view, movement inside the board should be totally free, as the board is only a mere representation of player positions. If you are playing a game with a DM, he's who has to take the decissions about the things that happen on the board. If you restrict your player movements on the board... why do you need a DM?

What I would do in this event is to create a totally free board, where players can positionate their tokens in every place. Normal players only can move their token, and only in certain moments, where it's their turn. On the other side, DM users will be able always to alter the order of players moving and move every token on the map.

This way, if a player makes a mistake moving it's token, the DM can detect it, send to the server an alteration in the initiative order and get a turn after this player's one, correct the movement, explain what happened and let the whole proccess to continue.

As an advantage for this drawback, your games will not be restricted by a static ruleset, if the DM decides that a monster drops an object that doubles a character's movement, or that allows him to fly, or whatever action that your ruleset has not defined, the game will not be altered.

From my point of view, a static ruleset and the control of movement and interactions is absolutely needed in a game without DM, but more a problem that a solution in a game with one.
About reconnections... well... first idea that jumps to my mind. Once a player connects to a instance of gameroom, its ID is stored in player's profile. When he connects to the page it's checked if the last instance he was connected to is "alive", and in this case the user receive the offer to reconnect, otherwise the ID is erased.

When a player disconnects, and sticking to the DM theory, should be decission of the DM if the player disappears or continues being handled by himself (until a reconnection maybe?)

The problem here, of course, is what happen if the DM disconnects... :(
MutsopAuthor Commented:
Well for the dm, I could make sure that the session would be saved.... afterwards a voting wold occur under the players of whoever may be the dm. Yet offcourse when the main dm comes back they have the possibility to reload there last session.
MutsopAuthor Commented:

So I've been setting up the core of the website and also started with the database.
Now I have one more problem.

I've set a table for the game room which hold:
title, description, created_date (which makes sure that after 30 days of inactivity the room will be deleted)
DM_ID (the user id of who is the dungeon master of that room)
map_id (text file of map)
isPublic (wether the room is public or not)
min_rating (so each public player gets rated by other players to prevent trolls from joining)

Now I also added a table which holds the connection between the users and gamerooms:

Now what I'm stuck at is, how would a dm add monsters/traps/.... to a map and be able to save it? Should I do the same as the connection between users and rooms? Or do you guys have another idea?

Also opinions/suggestions are welcome on the previous tables
I think that a board whould has it's own table, related to the gameroom. So a gameroom holds the chat and users interactions, and the board holds positions of tokens related to players.

You can treat the board as a matrix, so you load an image file as background for the map, and add a reticule over the image to allow players to precisely measure the movement of their players. DM should be able to stablish the size relationship of the reticule: i.e.: I want for my map a 30x60 reticule, and I stablish that every cell of the recitule will size ingame 3 foot by side.

This way, you can add tokens (monsters, players, structures) to the map by using image objects in a more external layer, and place them always related to the reticule coordinates.

So each time you have to load (or reload) the board, you read for the board instance:
The background map to render.
The characteristics of the reticule to draw.
For every Token (elements in a related table to the board) in this board instance
   read it's image file and it's coordinates inside the map
   load the token inside the point expected.

This is, at least, the way I see this structure. I hope it helps you.
MutsopAuthor Commented:
k, but a chat would need it's own table no? also each user/room related stuff would also needs its own table I think (Let's say his character with level and attributes that improve).

Also for the board I might have found an nice addon which I might use and modify

Yes, of course, every individual entity will need it's own table, even you should think in using a table for players and other one for characters, so this way one player could be able to play different campaigns with different DMs and characters.
MutsopAuthor Commented:
Well thanks for your help :)

It helped me alot... Now I would need to find some time coding this project
MutsopAuthor Commented:
Thanks alot for your help
Good luck with your project. It's something I always wanted to do but never found time :)

Tell me when you need testers ;-)
MutsopAuthor Commented:
I certainly will :)
any way to contact you? As I can't seem to find contact information on your profile

But same as you, I don't have that much time, so it might take a while before I'm at even alpha testing :D
You can contact me through bardobrave at gmail dot com

If I have any time when you start testing I'll lend you a hand.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now