Thursday, March 27, 2014

Crafting interface implemented

I added support for crafting. NPCs can now display a crafting window. They can freely define how many slots to display and where to display them. The item script can also define a handler-function which receives the items the player dragged into the window. Each slot can define a "tag" which says which items can go there. Items can now have one or more such tags which define the crafting use they have.

The Java part of the engine does the ground-work of validating that the users input is legal (tags match the slots, user actually has the items).

The scripted function is then responsible for checking if the combination is a valid recipe, remove the items and give the player a new item. This function could also be implemented as a Java class. When I develop a more complex crafting system, I might opt to do so.

Java 8

I updated to Java8 and experimented with some of its new features. I coverted the admin command handlers to use the new lambda feature, and it really improves the code. The new Nashorn Javascript engine gave me some problems because some scripts no longer worked the way they used to, but I think I solved all the issues (wrote a Q&A on stackoverflow about it).

Tuesday, March 18, 2014

Statistics

Last week I worked on ways to obtain some usage statistics.

The server now accumulates statistics about how much network traffic is sent and received for each message type. I added a command /traffic to access this information from within the game. This should tell me where I need to optimize my protocol. So far it seems like move-messages and map-layout messages are the traffic users number 1 and 2.

Both leave some room for optimization. The move-messages send the coordinates in ascii-encoded floating point numbers with a precision much higher than needed. Two decimal places should be more than enough. And the map information is basically the whole JSON data as it comes from Tiled. That's a lot information the user is not meant to see. It can and should be redacted.

But I need real usage data by real players to say for sure where optimization is needed most.

Another method to generate statistics are web-reports. I created a system to regularly export data as JSONP files and save them somewhere. A website can then use javascript to import this data and output it in a presentable way. Currently I have a list of current players and a list of active maps with player count. The JSONP technique makes the data available to anyone. This is intentional; I would like to see what the community can come up with to beautify my data.

I am thinking about archiving these reports in the database too. That would give me access to historical data.

Monday, March 3, 2014

Visible equipment

I made it possible for an object to consist of multiple sprites and to set these from the server. This in turn enabled me to implement visible equipment. When a player puts on and takes off equipment, this is now visible on their sprite.

Currently this only works with hats and staffs because I only have sprites for these yet. But that's just a matter of creating the content. The next step will be to allow differently colored equipment.