It Seemed Like a Quiet Week


I thought it'd had been a fairly quiet week, my day job got busier and my kids have been loud and fun. That was until I looked back at my commit log and tried to rationalise what's changed this week. Here we go, there's quite a few - so if theres anything you'd like more detail about please let me know.

New Hair and Faces

Krishna was good enough to produce one of his Patreon updates, pop-culture renditions of his mini-fantasy character. These came along with some new random hair styles which I immediately put in as options to the character creator. Prizes for those that can guess where they each of the new three came from:


Of course, because there were new hair styles at this level I had to add new hairstyles in the portrait images. For one of the few bits of art I've done myself in this project I'm pretty pleased with how they came out.


Admin Tool Updates

One of the less interesting but essential parts I'm finding about writing a multiplayer online game is the need to be able to monitor and update the server and the players connected. My admin console is a fairly simple affair, plain old Javascript and HTML, but it does a fine job. 


This week I added a bunch of things I found I needed while play testing with some very helpful folks:

  • System Annouce - I can now put out messages for all players when the server is being restarted or some system event is happening.
  • Actor HP and Gold - all actors (players and monsters) now show what HP and gold they have. This helps me seeing how people play in certain areas.
  • Lag - the game works by having a controlled lag from the server and the admin console can now see the computed ideal lag for any given connected client.
  • System Stats - Up time, memory, cpu, and build date are all very useful to see to monitor and protect the server.

Chat

This one was particularly interesting, I'd run a poll on Twitter to find out what people thought about chat in online games. A very resounding vocal response of "no, don't do it, it's bad". I took the advice and left it out altogether. However, as soon as a few people started playing it became obvious that they needed some level of chat to allow them to explore together and most of all to have fun.

I didn't want to turn the game server into a glorified chat server so I've limited chat a little:

  1. The chat log isn't visible by default. You have to opt in by going to chat yourself to see the log.
  2. However, you can discover chat because single lines of chat appear above player's (and eventually NPCs) heads.
  3. You can only chat within a zone - e.g. if you go into a house you can only chat with players in the house

It's worked out quite well so far. As you can imagine given it was a multiplayer game already adding chat wasn't too much trouble, just passing text through the existing transport layer. The other thing to consider was the swear filter on the chat text which went in before I released it to the main server. 

Loot, Inventory Paging and Stackable Items

The inventory dialog that was put in last week has been working ok but as more content was added it was clear it wouldn't scale. When loot was first added the inventory rapidly got filled with blue shirts (the first loot item I tested). Monster configuration - the subject of another devlog maybe - defines what any given monster type should drop. However, the inventory dialog could show a maximum of 16 slots which quickly got filled.

I had a lot of blue shirts! Loot was great but it was causing me a few problems, so the first thing I did was to add paging into my inventory - the little green arrows let you go back and forward through the pages of items in your inventory. I'm not sure whether to limit the inventory at all or not - but right now I don't have to worry. 

Finally having lots of particular items is a bit of pain to organise. With items like shirts it doesn't matter too much, since you're unlikely to want to keep more than one or two (unless you really love your fashion). On the other hand, in the case of health potions the player will often want to keep a lot so they need to be stackable - that is one item might represent a lot of them like so:

Whether an item can be equipped, whether it's stackable and all the other associated information is driven through data files so it's reasonably easy to add new items.

Scriptable NPCs

Next up this week I wanted to get to the point where my NPCs could have dialogue trees and perform actions. In the past I've implemented this a few ways but the best I've found is:

  • Implement the dialogue trees in XML or JSON (json for me)
  • Allow javascript to placed in the dialogue trees where action are required
  • Ensure that javascript is run inside a defined context that doesn't have access to the whole game - otherwise you get tempted to write dark spaghetti magic code.

Here's a quick example of how that looks in the case of my single NPC, Alia the healer:


Dissecting the above you can see the dialogue has two pages, a welcome page with options "Thanks" and "Heal" - and a second page after healing has been completed. In the options the "exec" field contains javascript that is run inside the game with a controlled scope that exposes only the operations scripts are allowed to call - closing the dialog, changing the page and because of this NPC a heal function.  

Right now this is just proof of concept stuff but the framework feels like its the right level to be expanded on while maintaining a very rapid rate of world development. 

Path Smoothing

The final big thing this week was something that I've been wanting to do for a while. When the player (or any actor, monster, npc) moves in the world the path they follow is generated from an A* path search across a tile based map from the obstacles and objects placed in the world. This has been working well but does leave the player wondering why their character moves so stiffly between locations. 

To remedy this I've added path smooth, this is where the tile based path is simplified to straight lines where possible, as shown below.


On the left we have the path that was generated by the tile map based A* algorithm. It's a perfectly acceptable path but does feel a bit awkward to the player. After path smooth the path has been simplified down to a single long move that's still completely valid.

The algorithm I used to do this was roughly:

  1. Set start point to start of the path
  2. Set end point to end of the path
  3. Add start to the path
  4. Check if the path between start and end is clear
    1. If so - add end to the path, set start point to the current end point and reset end point to the end of the path
    2. If not - move the end point closer on the existing path
  5. Repeat 4 until you reach the end of the path

It's not super efficient but it does work out! So far no huge performance impact but the actor path following code did need a fair bit of rework to follow paths that weren't a unit long.

Wow, did you really read all of that? Thank you :) 

If there's something here you feel it's worth me writing more about or something else in the game, let me know in the comments.

Files

tales-of-yore-html.zip Play in browser
Version 8 Jun 15, 2021

Comments

Log in with itch.io to leave a comment.

Very interesting entry! Waiting for your next update :