The MMO Project Part 6: Enemy Incursion

The MMO Project Part 6: Enemy Incursion

My poor little laptop is screaming from running all 3 servers and 2 clients, but I have made the melee synchronized across clients. Movement uses UDP so it's less accurate considering my PC is chugging to run all this. I might have to work from my gaming rig or offload the servers to my R710. That'd be a day's work to get everything spun up and configured though so I am trying to hold out on that one.

Sausage stares in 2 directions, since UDP for movement.

Now that that works I have to make enemies that the server can control. Easier said than done but I made it this far, eh? No turning back now. Looks like I'm making this thing.

Alright so the enemies now spawn on the clients. Basically on the server I create an enemy container that when the server calls Spawn() sets up a basic enemy with some simple data, picks a spawn point within 1000 pixels of 0,0 and creates itself as a child of /Server/Enemies with name created from the enemy_data.name and the get_instance_id()

Beset by Orcish assholes!

Then the server sends the Enemy to the clients via RPC and the client sets them up with the data passed by the server and uses the same name as on the server. This will come in later when I need to apply damage and get drops and exp and all that.

Also right after the new client connects and gets all the current players spawned into it, a function runs to populate the client with the monsters. One problem I have been having is I use monster and enemy interchangeably in my thoughts and in the code. Luckily I spot it before I test and fix it but man that's something I gotta kick.

Next step is to get the server to make these orcs walk around but not past a certain range. The server has no way of determining collision for the orcs currently and as such will allow them to wander off into the aether indefinitely making them veritable needles in haystacks.

So what I plan to do is just extract the code that moves them around on the client and plop it down on the containers in the server, then hit it with a hammer until it fits.

Ohhh boy that fan is spinnin' I will definately have to sort this out. It is getting colder now so I could feasibly justify running the server... maybe tomorrow I will give that a good hard think.

Well, hello lads.
More clients don't break it, so that's nice.

Next is the ability for the server to determine if the player hits an enemy,  I guess what I could do is create damage cones for directions and check if the enemy is inside them, given that the player is just a straight up normal Node and doesn't have any positional data on the server. I can't do the check client-side because then you could feasibly make your damage box the size of the map and just kill everything with a little hex editing. So this must be done client-side.

I guess what I could do is figure out the width of my damage arc, then the distance from the player's center mass it sits, then check if anything exists within that triangle when the player attacks. I could, theoretically fully simulate the maps and positions within the server but it would be more intensive and... yeah my laptop can't take much more cap'n.

I do need to optimize the enemy movement and player movement as well as add range checking to the server to make sure it's not broadcasting data to clients that don't need it but optimizing will come once I have a game that can be played.

I have two ideas for how to proceed with collision checks and handling combat server side. One is the idea with damage cones and writing something to output the collision data from the map as a series of 1,0 in a matrix so the server knows 1 means collision and 0 means no collision. However if I were to have players colliding with enemies this would require updating that binary matrix every tick which would run faster but take more work than the other idea which is much heavier on the server but also much less work. Considering my aim for CCU is at least 100 players per map region (Server) and my funding wont allow for any extravegant servers I will probably be doing this the hard way.

Unfortunately the only way I can think to check if enemies are in the collision cone involves looping through enemies every time a player attacks... which even if I were to cut down the number of objects in the loop with a range check ahead of time I would still have a good chunk of overhead compared to how it worked when the enemies were only client side. I could broadcast the damage from a client and check that it is not hitting anything too far away in order to have less work done on the server... still exploitable though.

Google was no help. I got one answer and it was "You can't" Well, I ain't about to take that.

Alright... I think for now we will just implement some basic way to deal with this. I will work out the collision later but for the player damaging enemies I will do the collision check client-side and verify range on the server. It's not the best way to handle it, but I am perhaps over-thinking it given the current state of development and today's goals in particular. Maybe wednesday I will work out how to deal with collision and then work it into that. I'll have to do some reading and see how other people may have handled this sort of thing in their projects.

Alright, I have implemented damage, death and respawn on enemies. Soon I will have to optimize this stuff, it's getting rough.

Die, die, die, die!

Time to make some dinner now, though. Off I go.

Cheers.