The MMO Project Part 11: The technical debtor

The MMO Project Part 11: The technical debtor

Today I will first and foremost be finishing hooking up the DB wrapper to the Game Server, then moving on to fixing some bugs I left in because I didn't want to half-fix them and have to revisit them once I had the DB in. First I will be preventing double logins. I will probably rewrite two of these functions in the future to use Redis, though not until I can easily incorporate 3rd party libs into GDNative code. I really need to figure that one out... maybe some time in milestone 2?

There will be a lot of code changes to the Peer Disconnect on the Game Server since I want to make sure the character get saved on disconnect and also update the online accounts list with the Auth server. I could do this on the gateway but since the gateway is the one directly exposed to the client I just want it to mainly be a pass-through. This of course means the Auth server will have to work harder but it also means the gateway can be lightweight and run on some rinky-dink potato to save money. Servers ain't cheap.

Also in the Peer Disconnect I want to handle the removal of the other character dummies. I haven't really bothered up to now since I am usually restarting everything every 5 minutes and it really didn't matter. Though it will in the future and it's not like it's a hard thing to get working (cut to one week later, me still in the same clothes hunched over the keyboard hissing "I thought it would be so simple, didn't I?"). It should just be Client disconnects -> Broadcast to all relevant clients "Character X logged out" then on the clients call the destruction function for X dummy. Maybe play a little POP noise or something to indicate someone just vamoosed.

Once I get these three things done I will go back to the Codeck and decide the next task. It would be pretty cool if I could get this milestone done ahead of time but there is some pretty complex stuff coming up so who can say. Alright, 9:30, off I go.

Alright, managed to get the logout to play a POP noise and then remove the character from other clients. Also got the character save system working properly. What did not work was preventing double login. I think I may have missed a step in the auth server.

Alright, the problem was where I put my check I was negating it right after (Nice one) Fixed that. Also while testing it I found a character creation bug that would crash the server by trying to return an empty array of characters. I did a recursive return in the fetch characters function so when a character was auto-created it would return a recursive call to itself after the character was generated.

Looking through my Codeck to see what I should do next. Maybe enemies dropping gold and character exp gain/level up. This would primarily be firing on the enemy container's death function. Spawn gold on ground, broadcast gold to player. On clicking gold, pick it up, add it to character gold in the character container. Also on enemy death add exp to the container of the character who killed the enemy, if it goes over the threshold for level up, fire level up. Send exp back to peer who gained it, then on the client listen for that and update the exp display. In the level up function send back the new level and updated skill points and stat points.

I guess I will start with the gold dropping. First I need something on the client side to represent the gold. I should also protect the loot for the player who got last hit and set a timer on it to make it lootable by anyone after a while. I could go by total damage dealt or first player to hit but for now I am going to mimic the old school ways and then decide how I want modernize it after I have some player input.

Before I get started I should maybe make some lunch.

That Da Bomb Beyond Insanity sauce can make rice pretty spicy.  Cleared out my sinuses at least. Alright, so now to find me a gold pile sprite. Could make one but this section of development is about implementation of features, not so much making it pretty. To open game art!

That'll work.

Thanks to Bonsaiheldin for the sprite.

So basically what I want to happen is for this to spawn on the client and if the player stands near it and hits a button it calls Loot_Item on the server and passes the item id, The peer ID is automatically passed I just need to fetch it. Then the server checks if that player owns the item or if the owner is None and either adds the gold to the player's total gold and destroys it on the server and broadcasts to all clients telling them to destroy reference to it.

So I need an Area 2D on the character and on the Gold. Then I need to check if the gold shape overlaps with the player loot area shape and also do the same check server-side. To make sure I don't call Loot on a wall or something I will add the gold to a group called Lootable.

I notice that I pull a lot of these functions out of my ass, so far that's not going terribly for me but it could... perhaps I should write these things down before I start declaring them. Anyway the client now has the ability to ask the server if it can loot an item, if it can then the server sends out and Item_Removed_From_Map RPC to all clients that should be aware of it. I was going to call the function Item_Looted but I realized I would have to also call it from a timer to clean up items on the map after X seconds and it would have been less... readable.

The client also has an RPC for updating it's gold amount so if the player loots some gold the server will send back the new amount or if they drop or spend some it will do it then too. As you would expect. Also have a function that will spawn the item in the client based on it's existence on the server. Now... I also have to make sure to call this for all existing items in range of the player on login. Imagine if you got a big pile of gold in a drop then got disconnected. If you logged back in and it was invisible you would not be too happy.

I think I may only get the gold drop stuff in today, this is lining up to be quite complex.

Also have to make sure I don't add the gold to the character container until after I remove it from the world. Don't want someone using lag to loot the same shit more than once.

Cheeky lads.

I know someone will find ways around a lot of what I am doing to prevent the hax, but that's what testing is for, eh? Even then there will be more. It is the nature of networking software and game development. There will always be exploits I wouldn't expect. But I should try to account for as many as I can early to avoid adding later stress.


And now we can pick it up and it's saved to the database.


Alright, now the loot items have a 30 second timeout before they become lootable by anyone. The items currently on the floor are broadcast to new clients as they connect too.

Log out, log in. Gold still here.

This isn't going too terribly considering I am just making it up as I go along. I will live to eat those words though, mark my... words.

Next up, add exp on enemy death.

There we go, with a level cap of 5. Yep, 5 whole levels! LOOK AT ALL THAT CONTENT!

There's no visual representation on the client for this right now.

So the next steps for this will be adding the interface for displaying level and exp, then the interface for distributing stat points.

You'll have to excuse my spelling sometimes... my spellcheck doesn't work past a certain point for unknown raisins.

It's 4:15pm and I wont be able to finish anything else on this list but I will do some stuff in the Django app to make it a little easier for me going forward, then clock out for the day I did start an hour early after all.

Stuff like making a string representation for the character objects.

and making sure the exp and level ups are working as intended

Seems to be good.

Alright, it's time for clocking out, I will make my commits and be off.