The MMO Project Part 12: Hell is other NPCs

The MMO Project Part 12: Hell is other NPCs

I figure since I will be doing some simple UI for exp, levels and gold today I will probably design the NPCs and how they work as the majority of an NPC is the dialogue and maybe flags? I will have to model character flags in the DB as a many-many relationship. I wont do that yet as I wont be needing them until the Quest system and that's quite a ways off. Maybe even Milestone 3.

The next thing I will probably do is Inventory and then add shop NPCs. After that I have to add chat, map changes(If I have extra time in this milestone I want to experiment with 3D maps), adding in a few more enemies, making the combat a little better, securing the connection between the servers a little better, client version checking codes, enemy control optimizations (The server shouldn't be updating the enemy position every tick, it should pick a spot to go to, then send that to the clients and use range based checks, this will allow the server to control at least thousands of enemies rather than a couple hundred) and a few bug fixes, then I will have completed the first milestone which is a very basic game that can be played. The goal is to finish it by the end of November and be on to milestone 2 in December.

Milestone 2 I hope to have things like Equipment, Quests, Server Side Collision handling, Enemy attacks and following, Actual combat, More SFX, more GFX, more maps, some kind of idea what the game should look and feel like(right now I just want to get the bare bones in, if I bog myself down with that kind of stuff at this point I am going to have a bad time and start overthinking)... generally by X-mas this year I want to have some kind of basic game that I could have a few friends play-test. The focus of next year will probably be more around creating a world and skills... hopefully having something I can do some kind of closed alpha in by summer and go around indie dev communities inviting testers. I doubt there will be any interest in my little project here by then.

Anyway, once I figure out how to show my road-map from Codecks to the public, I will have a link up at the top of the site so you can track my progress.

One day this week I will probably be rebuilding my X-mas tree, though I might do that over the weekend. We'll see. But that might take a day from my development schedule. I also have to start working on Tamakai proper as well as get going on Mantilogs M2 sometime in the next few weeks as well. I will probably be working on them Tuesdays and Thursdays or at least one day a week so that will probably slow me down a little but I do need a bit of a break from working on this all the time so I don't burn out. I don't really feel like I will but it's better to at least have one day on other projects. Besides, they need to be completed too.

After M2 is done I am not sure exactly how that schedule will change. If I somehow got funded to work on this full time I would certainly do that but I will need to think about how I am going to make money and get out of this hole I am in. I got goals, while this is one of them I also want to travel the world once it is safe to do so again. Living like I am now I will never get to do that. Continually working on my projects will keep me learning new things though, I purposfully chose these projects for this period of my life knowing that they would challenge me to think in new ways and also give me something to look forward to every morning. This way I can pick up new skills while I work toward a goal and not feel like I am wasting my time.

Anyway, enough yapping. I got an NPC system to design.

So the first thing I will need to do is create an NPC dummy, much like the enemy dummies or player dummies. This one will not walk around, though. I will have some that do but for simplicities sake I wont do so with this one as it will give me a good template for future NPCs. This will just be a dude or lady what stands about, maybe having an idle animation, it depends on what I find on OGA. Like I said before, not gonna start spriting my own stuff til I got most if not all of the scaffolding in place and all the systems working and solidified. If I start spriting now I will have to change the sprites often and it will just slow me down way more than I am willing to deal with right now.

Now the NPC will have have a radius around it that can be interacted within. This will be maintained by the server, something like 150px circle around it. When the player is within this range and clicks on the NPC it should fire a request to the server that will then fire back dialogue and whatever other information is required in JSON format. (This way I can have all the NPCs be in the Database later, then I can change them while the game server is running and do troublesooting, etc.) The client will then parse this information and display a dialogue box with buttons. The buttons will send further requests to the server which will send back more data to parse, etc.

Step one; Client Side Dummy and Dialogue Box. Need some assets. To OGA! I guess I should also decide if I want portraits, this will be more work later... but I guess it would be nice? I'll skip it for now and leave it so I can add them later if I want.

Using one of the sprites I am considering for the character.

I had a witch I wanted to use but that required some cleanup work and I wanted to get to work quickly here.

I'll be using Godot's built in UI for the dialogue box for now. I can change it to something fancy later.

It'll do.

I may end up making the buttons long and wide, stacking vertically to allow the player to have more verbose dialogue but for now I just want it so I can test it.

Real quick fixed a bug in the auth server where if the game server disconnects it never logs out the accounts.

As I write the code to handle the NPCs on the server side it is starting to occur to me that I have had a trend of slowing down lately. I think working on the weekends is having a negative effect. I might need to take the week off or something if I can't seem to get a second wind. Or maybe just do half days for the rest of the week or something. I find the past few days I spend more time just staring at the code than I do writing it. I also could do with a white board or something to that effect in here I am burning through my notepads. I can't have krita running while I got all this stuff running, my laptop is already screaming.

I am also wondering if I shouldn't just hard code all the NPCs. This will certainly give them more personality but it will also be more work... I wish I could have a scripting language instead that I could load in on boot and handle all the NPCs as scripts. I think for now I will just hardcode them and get them working. I'll make a test one as a sort of template and just have a folder called "NPC Scripts" that I can load NPCs from. This will allow me to have more granular control over individual NPCs but will make it a bit of extra work for each npc I need to write. Though I suppose Ctrl+D is a thing if I need it. This will allow me to set up patrol paths and maybe make the buggers have daily schedules and whatnot if I want to add that to specific ones. Also would keep the code leaner on random folks that just wander around town to give life to the place. I think I overthought the NPCs earlier as I tend to do with everything in all projects.

I don't plan to have thousands of NPCs after all. Though I might at some point, I really have not stopped to think about the design outside of the systems yet. If it does become a pain I could probably have NPCs load in as part of a PCK file, assuming I do ever have other people working on this project it would probably be best to keep all the tools either tools I write or use constantly... so yeah. GDScript for NPCs sounds like a good idea. Idiot me overthinking as usual.

Alright, gonna have some halloween candy and take my dog out and start implementing afterward.

So the npc will handle state changes on the dialog box. Also on spawn the NPC can check the character flag data and do any number of things to itself based on them. If it had the flag for a particular quest then maybe the NPC would be hidden in this place but show elsewhere. There will be code to switch on these things and send different states on spawn determined by the flags on the character for that particular client.

Here's the initial state for my test NPC.

npc_data = {
		'npc_name': npc_name,
		'npc_map': npc_map,
		'x': x,
		'y': y,
		'message': "Hello. I am Kromdibular. Would you like a tangelo? Clowns hate tangelos.",
		'button_one': {
			'text': 'Yes',
			'response': 'yes'
		},
		'button_two': {
			'text': 'No',
			'response': 'no'
		},
		'button_three': {
			'text': 'Clowns?',
			'response': 'clowns'
		}

Which will set up the dialog on the client with three buttons that when clicked will send a response to the NPC which will handle the response and setup a state depending on the response, then return it which will change the buttons and text in the UI. Fairly simple here but the state can be anything, including a sprite to load or a location to move to or any other property of the NPCDummy node I have on the client. I could also change it's location on the server so other players see the change which I guess I will call a Global State change.

Totally have a plan. Yep. 

Now NPCs Load in and Spawn on the server on startup with all their data ready. Just need to hook em up to the client.

It may not look like much, but that's an NPC spawned on the Server.

And now I got them showing client-side, not setting up their names and stuff yet but you know... they are there.

Hello, NPC Name! I'm the cakeman,

There we go.

What the fuck is a Kromdibular?

Wired up the Dialog box to the NPC.

I still need to wire up the buttons and stuff but I am out of time for today. It's 5pm and I gotta cook some dinner. I also have to do something to trigger the close dialog function.

Might work on Chat tomorrow afterward instead of Inventory since I might be needing them chat debug commands sooner than expected.

Cheers.