browser mmo pvp...

Post all your tuts or request for tuts here.
Post Reply
alexander19
Posts: 180
Joined: Fri Apr 02, 2010 1:05 pm

browser mmo pvp...

Post by alexander19 »

Hello everyone!

I'm currently working on a browser mmo and I got a problem with the pvp system.
I'm trying to make the pvp system same as halls battle script for fighting mosters(the fight happening in rounds) but the problem is that it would require some kind of online check(to check if the player is online,cause without this check the fight would be plain and the enemy wont be able to use his spells/potions and so on...)
And it would probably require a timer too...for instance,each round will have 10 seconds,and if a player wont choose any action in those 10 sec his round will over ...

So is it possible to do a pvp system like this using php?

From what I've seen some browser mmos use a plain fighting script...like choosing the opponent you want to fight and then the script would loop through all the rounds and show the results but this wont work in my case,cause I'll have to change a lot of stuff

Any hints would be greatly appreciated.

*Sorry for my english :oops:

Alexander,
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: browser mmo pvp...

Post by Jackolantern »

Javascript and AJAX are really the only ways to do it in real-time like that. PHP has to hit the server every time for an update, so you would have players constantly refreshing to see if the opponent has gone and if it is their turn.
The indelible lord of tl;dr
Gheeda
Posts: 43
Joined: Fri Sep 03, 2010 12:12 am

Re: browser mmo pvp...

Post by Gheeda »

Jackolantern wrote:Javascript and AJAX are really the only ways to do it in real-time like that. PHP has to hit the server every time for an update, so you would have players constantly refreshing to see if the opponent has gone and if it is their turn.
An example of what type of pvp php is capable of...create a neopet account and look at the battledome system. They go as far as to create a stable of single player battle dome opponents too.

What neopets does for pvp is this though...
-You do your attack
-Redirect to 'waiting for opponent page' & simultaneously pops up a mini window
-Mini window Auto refreshes looking for the exchange/change of data (probably consisting of nothing more than a few IF commands a THEN to redirect and continue battle and an ELSE to refresh loop til IF catches the change in data.)
-Then closes as it redirects your main page to your attack option page w/ the events of the last moves below.
-repeats

...sounds simple enough I almost think I could code it :P

So I can say it is possible to automate the pvp via php....just couldn't hand you the code.
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: browser mmo pvp...

Post by Callan S. »

I disagree with Jack in this doesn't have to be genuine real time, if I understand it right.
but the problem is that it would require some kind of online check(to check if the player is online,cause without this check the fight would be plain and the enemy wont be able to use his spells/potions and so on...)
And it would probably require a timer too...for instance,each round will have 10 seconds,and if a player wont choose any action in those 10 sec his round will over ...
I don't understand your need to check if someones online or not?

If they are offline, they just miss their turn?

What you have is code at two layers. One is the refresh command, that refreshes a page after X seconds

Code: Select all

header("Refresh: 10; url='brawler.php'");
The other is the time() command which you can grab the current time in seconds. You record in the database when the players turn started, in seconds. Then you have both the referesh code AND code that checks if ten seconds has passed/whether the player misses out on their turn.

It's not genuinely real time as the code only updates when that refresh happens - but it'd take both guys suppressing their browsers refresh to stop it, and then they'd just be shooting themselves in the foot. If even one of them leaves the refresh, then they win. So it all works out.
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: browser mmo pvp...

Post by Jackolantern »

That is what I mean: it isn't real time. PHP has no real-time ability, only work-arounds and illusions. If someone was going to go to all this trouble to try to simulate real-time PvP, it seems like it would be just a bit more work to implement real real-time PvP with jQuery.
The indelible lord of tl;dr
alexander19
Posts: 180
Joined: Fri Apr 02, 2010 1:05 pm

Re: browser mmo pvp...

Post by alexander19 »

I've left the pvp to the end..as I considered it the hardest part,but I will look into these and see if I can come up with something interesting.
Thx for your help guys.
Post Reply

Return to “Tutorials”