Hit detection in realm of the mad god

For discussions about game development that does not fit in any of the other topics.
Post Reply
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Hit detection in realm of the mad god

Post by Callan S. »

If you're familiar with realm of the mad god, how do they do hit detection in that? Do they leave part of it to the client to determine, do you think? It seems alot of bullets to work out!
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Hit detection in realm of the mad god

Post by Jackolantern »

I have wondered that myself. It doesn't seem possible to leave something like that on the client and think it won't be abused in a matter of hours (particularly when the client is HTML5 or Flash). But wow that must be some processing on the server-side, even using every trick in the book!
The indelible lord of tl;dr
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Hit detection in realm of the mad god

Post by Callan S. »

Geez, if it baffles Jack I wonder if I should bother trying to figure it...!?

I tell you though, it is engaging gameplay in terms of dodging around bullets, etc. I'd be temped to just record the last, say, 3 seconds of player movement and then send that through (three seconds seems a good contact time for sending stuff to a server). Probably using unity if I can figure it out some more. Sure, people might hack and write a neo-like dodge code for dodging bullets, but I kind of think big deal. Perhaps just have an occasional attack you just can't dodge (ie, it rolls to attack, ala RPG's). Even then hey, if some people just want to remove the difficulty - well, that's like playing original doom with the cheat codes on. Just as a programmer make sure that if players can get advantage on other players, they can't get alot of it by hacking the code.

Okay, those are my random philosophical thoughts on it! :lol:
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Hit detection in realm of the mad god

Post by Jackolantern »

Why not try asking them how they did it? If I recall correctly, they are basically indie developers as well. While of course code is obviously out of the question, many indie developers have little issue with discussing the techniques to accomplish things, particularly if it won't sacrifice security in their systems :)
The indelible lord of tl;dr
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Hit detection in realm of the mad god

Post by Jackolantern »

One thing that I can definitely know they did was proximity-limiting the data transfers. If you aren't familiar, that is where you do extra calculations on the server to ensure that only the players who are directly influenced by an event are alerted to it. And for something as active as Mad God, the proximities were likely very small. Perhaps they were running server-side rays when bullets are launched, and then iterate through a list of all players inside a square made by that complete bullet trajectory, plus some padding around that potentially adds some more players (to account for small rectangles made by completely horizontal or vertical bullets). That way you can only send the bullet data to only players who are onscreen or could be affected by the bullet. Because really, most servers can crunch numbers like champs, with pretty much any kind of calculation you need essentially be done instantly. What bogs your server down is I/O, so limiting the number of players you are transmitting the data to will help keep everything running smoothly, which is basically a requirement for a game like this :)
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Hit detection in realm of the mad god

Post by hallsofvallhalla »

they are using Node which helps a ton. My assumption is they are doing hit detection on server side to weed out hacking. The client server system I built for Impact is quite close to what they are using except I did all my collisions client side then had a much lighter detection verification server side.
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Hit detection in realm of the mad god

Post by Callan S. »

Would it maybe just take a recording of the players moves every X seconds, then run the same events on the server rapidly to check that the client and server matched in outcomes? I think I recall an article saying guild wars 1 did that (saves on bandwidth too). So alot is done on the client, but even if you have a 'destroy all monsters' button hack, on the server the monsters are still there and merrily clawing you to death, even if on the client they are all gone?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Hit detection in realm of the mad god

Post by Jackolantern »

You have to do that of course, but that is not all. Most of the techniques for managing bandwidth fall into the category of "player predictions". What really kills bandwidth is sending data of what each player is doing to every other player in a crowded area. The bandwidth required grows nearly exponentially with each additional character in an area. One common trick figured out in the UO/Everquest days was that you don't constantly transmit data of what the player is doing. For example, if a player starts moving east, every other player only needs to know they started walking east, and will continue to animate them following a steady pace east. Then when the player stops or changes directions, that data is transmitted, along with a test of where they are now to resync location. Even if the player seems to be changing directions erratically, in computer time, they are skipping likely hundreds of potential data transfers between direction changes by allowing the clients to assume they are moving steadily instead of constantly sending them the same data over and over.

There are hundreds more tricks like that, where the client tries to handle as much rendering as possible with as little data as possible while staying accurate and fair.
The indelible lord of tl;dr
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Hit detection in realm of the mad god

Post by Callan S. »

Yep, those are good tricks! I mean, in realm of the mad god - you can't hit other players (or bump into them). You might think 'hey, that's for gameplays sake'. But really it's for servers sake! Even if it helps out gameplay in the end!
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Hit detection in realm of the mad god

Post by Jackolantern »

Very true, but most MMOs do not have any collision between players because that allows very potent griefing. If a player needs to see an NPC or pick something up, your group of friends form a chain and just go AFK like that, blocking them from getting to go where they need to go basically until the griefers log out. FFXI made the mistake of having collisions between players, and gold farmers used it to their advantage, bringing in armies of bot character to create walls to impede other players from claiming rare and valuable spawns. Eventually they updated it to allow players to eventually "slip through" once they try for a couple of seconds, but it was still wildly irresponsible in the first place (much like many other parts of FFXI's design lol).

But yes, a nice side-effect is that it does cut some server-side collision detection. It doesn't really help too much with data transfer, since every player in the area still needs to know what those other players are doing around them, but it does cut down on potential "collide and stop" data transfers on player collision, allowing them to better stay their straight course.
The indelible lord of tl;dr
Post Reply

Return to “General Development”