Link to home
Start Free TrialLog in
Avatar of Mutsop
MutsopFlag for Belgium

asked on

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?

Avatar of darren-w-
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Avatar of Mutsop


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.
Avatar of Bardobrave
Flag of Spain image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mutsop


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?
Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of Mutsop


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 :)

Avatar of Mutsop



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... :(
Avatar of Mutsop


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.
Avatar of Mutsop



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.
Avatar of Mutsop


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.
Avatar of Mutsop


Well thanks for your help :)

It helped me alot... Now I would need to find some time coding this project
Avatar of Mutsop


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 ;-)
Avatar of Mutsop


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.