The Kingdom of Galanor, Playtest Available

Phew! Finally finished the two big updates to these core systems.

Strangely enough the 2nd phase, which I thought was going to be the bigger job of the two, actually turned out to be far less work than upgrading the skills system.

One of the biggest headaches I faced was noticing a null ref bug after making some changes to the game item serialisation code and then spending the best part of three hours going back over what I’d changed and double checking everything, only to eventually find that the bug was caused by something entirely unrelated that I’d changed a few weeks ago and hadn’t spotted the bug at the time.

I really hate it when that happens!

I managed to do this and still be able to have existing characters retain their progress, with hardly anything in the way of extra code to manage this, specifically one single line conditional check when deserialising game item information.

Once I’ve tested things a bit more to ensure I haven’t missed any other major bugs, I can get back to adding more game content :slight_smile:

Something I’ve been working on for some time now, which I’ve never been happy with is the way the combat system handles the order that attacks are played out each round.

The goal was to have them ordered primarily by dexterity, so that faster combatants get to perform their attacks before slower ones.

But then I wanted all similar entity types (i.e. player, pet, mob), to attack at the same time, so the fastest players will always attack first, followed by the fastest pets, then the fastest mobs. But, I also wanted to further break this down, so that the attack order amongst entities in the same ‘phase’ would be all melee attacks, followed by all matching ranged attacks. I also wanted to have the option to override these base rules on a skill by skill basis.

Basically, the way the combat system works, is that all the attacks each round are collected into a list, which is then sorted into attack order (fastest attackers going first) and then each attack is performed and the outcome is stored in another list. At this point there is no visual representation of the attacks.

Once I have the list of stored attack results, this is sent to remote clients if in a party and then the list is parsed by all party members and the visual representation of the fight is played out.

The problem I was struggling with, was how to properly sort the attacks, and from the list of results, how to generate each ‘attack phase’ of the round. But I’m pleased to say that I’ve finally come up with a solution that works how I wanted, by using a two step system, that starts with a custom sorter for the attacks, and then a parser for the sorted list that generates each of the attack phases. Previously, all ranged attacks were being cast one after each other and only certain melee attacks would be grouped, which made the combat sequence for a large party of players and mobs a little tedious.

This final solution was made far easier to implement by the previous recent updates to the skill system.

Here’s some of the code if it’s of interest to anyone.
Attack Custom Sorter

class AttackSorter : IComparer<CombatAttackInfo>
{
    Combat combat;
    Skill xSkill;
    Skill ySkill;

    public AttackSorter(Combat combat)
    {
        this.combat = combat;
    }

    public int Compare(CombatAttackInfo x, CombatAttackInfo y)
    {
        xSkill = QuerySkill(x.skillID);
        ySkill = QuerySkill(y.skillID);

        var dexCheck = combat.entityInfos[y.attackerInfoIndex].stats.DEX.CompareTo(combat.entityInfos[x.attackerInfoIndex].stats.DEX);
        if (dexCheck != 0) return dexCheck;

        var entityTypeCheck = combat.entityInfos[x.attackerInfoIndex].stats.type.CompareTo(combat.entityInfos[y.attackerInfoIndex].stats.type);
        if (entityTypeCheck != 0) return entityTypeCheck;

        var skillGroupCheck = xSkill.skillGroup.CompareTo(ySkill.skillGroup);
        if (skillGroupCheck != 0) return skillGroupCheck;

        return x.skillID.CompareTo(y.skillID);
    }

}

The Combat Phase Parser

    public IEnumerator DoCombatPhaseAnimations(List<CombatAttackInfo> networkAttacks)
    {
        var phase = GetCombatPhase(networkAttacks);
        yield return StartCoroutine(ShowCombatPhaseAnimations(phase));
        phase.ForEach(c => networkAttacks.Remove(c));
    }

    List<CombatAttackInfo> GetCombatPhase(List<CombatAttackInfo> networkAttacks)
    {
        var phase = new List<CombatAttackInfo>();
        phase.Add(networkAttacks[0]);
        if (networkAttacks.Count > 0)
        {
            // Find all attacks that share the same AttackGroupID (Additional multi-target attacks) and add them to this phase
            for(int n = 1; n < networkAttacks.Count; n++)
            {
                var attack = networkAttacks[n];
                var entityInfo1 = entityInfos[attack.attackerInfoIndex];
                var entityInfo2 = entityInfos[phase[0].attackerInfoIndex];
                if (attack.attackGroupID == phase[0].attackGroupID) phase.Add(attack);
            }

            for (int n = 1; n < networkAttacks.Count; n++)
            {
                var attack = networkAttacks[n];
                var entityInfo1 = entityInfos[attack.attackerInfoIndex];
                var entityInfo2 = entityInfos[phase[0].attackerInfoIndex];

                if (!entityInfo1.InSameGroup(entityInfo2)) break; // End the combat phase if this attack is by an entity not in same group as first attack
            
                // Now check for differing skill groups to see if the combat phase should be ended
                var firstSkill = Doofah.Skills.SkillManager.QuerySkill(phase[0].skillID);
                var attackSkill = Doofah.Skills.SkillManager.QuerySkill(attack.skillID);

                // skillGroup -1 always plays separately
                if (firstSkill.skillGroup == -1 || attackSkill.skillGroup == -1) break;

                // skillGroup 0 == melee attacks, play these together
                if(firstSkill.skillGroup == 0 && attackSkill.skillGroup == 0)
                {
                    if (!phase.Contains(attack)) phase.Add(attack);
                    continue;
                }

                // skillGroup 1 == ranged attacks, play together all that share the same game item ID
                if (firstSkill.skillGroup == 1 && attackSkill.skillGroup == 1)
                {
                    if(phase[0].skillID == attack.skillID)
                    {
                        if (!phase.Contains(attack)) phase.Add(attack);
                        continue;
                    }
                }
                else if (firstSkill.skillGroup == attackSkill.skillGroup) // custom skillGroup values will be grouped together
                {
                    if (!phase.Contains(attack)) phase.Add(attack);
                    continue;
                }

                // If we got here, end this combat phase
                break; ;
            }
        }

        return phase;
    }

Short video showing the new combat sequencer in action.

1 Like

Been doing some more work on Emerald Hills, the level 20-25 area. Here are some screen shots of Newbarrow and nearby points of interest. Newbarrow is one of the villages in Emerald Hills, which is the home of the Saursela, a race of imps and is the hub of a quest line concerning them.

Facebook Page

Facebook Page

One of things I struggled the most with when first planning this game, was how to handle increases in stat values as the players and mobs gain higher levels and at the same time balance the amount of damage done by attacks.

One of the fundamental problems is that the rate of increase in either can’t be linear and still produce pleasing results. Once you add to this the variables of defence and other buff/debuffs it becomes a nightmare to find a calculation that will produce sensible numbers over a large range of levels. For example what works in a fight between level 10 players/mobs will produce wildly differing results at level 80.

So in the end I decided to first of all just work out a system that produced a rate of HP increase that I liked and then decide what to do about damage after that. After some experimentation I came up with a system for generating HP as an entity levels up that gave a nice growth curve.

So then, in terms of how I wanted this to work with the damage, what I was looking to achieve was a system whereby, when a player of a particular level is fighting a mob of a particular level, the amount of damage done as a percentage of the target’s health pool should remain roughly the same regardless of how high or low that level may be, let’s say say around 5% for arguments sake.

So if a level 5 player with 100 health gets hit by a level 5 mob, he would take 5 damage. Whereas at level 20 with 3000 HP the player would take 150 damage from a level 20 mob. Obviously this is a much simplified example, and the actual calculation will take other factors into account and add a small amount of randomness, but the nett result would be a damage system that produces sensible numbers no matter what level the combatants are.

So having sorted the HP growth calculation I played around with various damage calculation algorithms, taking into account the stats of each entity, their relative levels and the type of combat skill used. I worked out a few that that produced good results between levels 1 to around 20, but as the levels increased, the damage quickly moved away from the percentage amount I was looking to achieve.

After struggling with this for a while I hit upon the idea of using a final modifier to the damage calculation based on a value obtained from an animation curve with the entity level as the timeline. By adding keys and tweaking the curve accordingly, I can multiply the final damage value by a value obtained from the curve based on the target’s level. The result being that the damage can be kept to roughly the percentage of HP that I want.

Having that final piece of the puzzle in place I just needed a way to quickly test the result of fights between combatants at all levels (current max for the game is set at 200), creating and levelling characters in the game and then testing fights to check the results of the various settings is far too time consuming (even with cheats to quickly add levels), so I knocked up an editor tool that allows me to quickly set up and test fights between combatants at any level and stats with just a few clicks, speeding up the iteration time for working out the damage curves immensely.

This is the editor I made (still needs more work to allow testing of elite mobs and equipment with bonus stats).

This is the damage modifier curve for mobs.

I’ve also being doing some more work on the Emerald Hills map. This is Fairreach Hamlet.

Over the past few months as more and more detail and complexity has been added to the maps (especially the larger ones), I began to notice a gradual increase in the time it took to switch maps, to the point where it was now taking as much as 30 seconds to load one of the main maps. Something needed to be done!

The first thing I did was perform some tests to see where the time was being taken, so I could work out the best strategy to tackle the problem. What I noticed was that after a scene change was triggered Unity effectively locked up for the duration of the loading of the next map, so I thought maybe using LoadSceneAsync might somehow come to my rescue.

It soon became apparent however, that it wasn’t Unity’s scene loader that was the problem, because Load Scene and LoadSceneAsync were both completing in 1-2 seconds when I timed them, and then Unity was sitting there doing nothing (from the player’s viewpoint) for the rest of the 30 seconds.

In fact it wasn’t doing nothing, it was busy setting up all the stuff that forms the scene as designed in the editor. This ‘glitching’ during scene loading seems quite a common problem judging by the Google search results, and the usual advice is use LoadSceneAsync and just switch the new scene in one it’s loaded. The problem with this approach is, that when LoadSceneAsync has finished, the baulk of the work is yet to be be done, i.e. loading and instantiation all the prefabs, meshes and other resources that go to make up the scene, and it does all this work on the main thread, and stalls everything else until it’s finished. Which can take a loooong time for a complex scene.

Following this discovery, I worked out, by selectively removing stuff from the scenes, that the long setup time was split roughly 50/50 between all the scene geometry and all the mobs, so I decided to tackle each of them separately.

I was already aware of an asset called MegaScatter, which promised to deal with exactly this type of problem for objects placed in scenes, so I purchased a copy of it and got to work adapting one of the maps to make use of it.

It has two methods of dealing with scene objects, it can either collect up a group of objects and combine them into a single mesh, or it can generate a list of the objects and spawn them at runtime. (Either way the originals should be removed from the scene before saving.)

Thinking that combined meshes were going to be best for performance, I went with that as the first option. Two problems here though…First of all, the mesh data was stored in the scene file, which meant that the scene file quickly exceeded the 100MB max file size for Github, so to get around this I saved the meshes made by MegaScatter to assets instead. But the second and killer problem, was that loading the combined meshes actually increased the time it took for the scene to finish initialising!

Okay, I thought, I’ll use the second option and have MegaScatter instantiate all the bits and pieces after the scene has loaded, it has an option to restrict the amount of items instantiated each frame, so this should prevent frame rates tanking while it’s doing so.

However, no matter what I tried, Unity just sat there while all the objects were being instantiated (with nothing appearing each frame), until everything all appeared at once after a number of seconds, during which time framerate was zero. Not what I was expecting from the way it was described in the manual! Also, there doesn’t appear to be any way to instantly instantiate selected bits based on the location of the player, so there is the risk that after the map loads the player could see some of the later instantiated items pop into view.

The practical upshot being that MegaScatter didn’t help. But, I knew that spreading the creation of the scene objects over a short period of time had to be the way to go, so I set about creating my own scattering system. With a bit of experimentation I finally worked out a method that quickly and easily allows me to create and maintain scene objects in the editor, which aren’t saved with the scene, but are instantiated at runtime, without any of the problems outlined above.

In my next post I’ll describe how this works. But for now here’s some screenshots of some work I’ve been doing on one of the maps. (Because of variations in monitors some forum images as posted may be too dark/bright, but the game has settings to compensate for this).

1 Like

So following on from my last post, here’s a bit more detail about how I fixed the slow scene loading problem.

The first thing I had to do was change the approach I was using to design the map layouts, which up until then had consisted of a single scene for each map that contained everything that went to make up the contents of that area.

Instead of that I split the map design into two scenes, the first scene containing the terrain and anything that needs to be instantiated at the same time as the map loads, and then a second scene that contains all the actual geometry, buildings, vegetation, rocks, props etc. etc.

I then made a couple of utility scripts that enable me to, at the click of a button, generate assets that contain instantiation data for all the objects in the geometry scene, that the main scene can use at runtime to instantiate everything not included in the main scene.

Consequently, at runtime, I now only load the first of the two scenes for the map, which has very little in it, which loads quickly, and then another utility script instantiates all of the missing geometry over the course of a number of frames.

A couple of advantages that my home grown solution gives me is that it allows instant instantiation of geometry that is within a certain distance of the player when the map is loaded, so that the map being ‘built’ isn’t visible to the player. But, possibly more importantly, it enabled me to easily implement a system that allows for a reduction in map detail to help the frame rate on lower specification machines, by selectively only instantiating a certain percentage of the scene geometry. Important things like buildings and such can be flagged to always instantiate.

I adapted the same process to handle spawning the mobs in a similar way, which was the final piece of the puzzle that was the scene loading problem.

So I’ve now got a nice workflow that allows for easy design and alteration of the maps and results in much faster load times, a large map now takes about 5 seconds to load, and that’s including the fade-out and fade-in, which feels much more acceptable.

As well as sorting out the scene loading issue, I’ve been working on a new area and quest line which takes place in Emerald Hills.

Nestled deep in the heart of Emerald Hills is the Temple Of Althraxia.
Recently discovered after lying hidden and abandoned for thousands of years, it is protected by the re-animated remains of the warriors that used to guard it.
Legends tell of fabulous treasures being hidden in the depths of the temple catacombs, but knowing what also awaits unwary explorers within, will anyone dare to enter?

Here’s a few screenshots, hope you like them.

More screenshots of the Temple Of Althraxia

Another progress update…

I’ve teamed up with Reed Means Music to start adding a soundtrack to the game, with different themes for all the maps and buildings. Really happy with the results, the music definitely adds to the atmosphere of the game.

I’ve also started adding ambient sounds and other sound effects. Still a lot of work to do on that front, but it’s coming along nicely.

I’m currently putting together a video showcasing this, which I hope to have ready sometime in the next few days.

On a slightly different note, I’ve continued working on optimizing the network side of things and that also seems to be looking pretty good. Here’s the Photon Dashboard analysis of a few hours of testing from yesterday.


Not a big test by any means with a max of 7 CCU. But with a maximum of 3 msg/s per room and 0.1kb total bandwith over the course of a few hours it’s looking like it should be okay for the new target of being able to support 50 users per room that I’ve set myself.

I still haven’t tested it with more than 20 CCU, so I’m still not entirely certain how exponential the rise in msg/s will be once I get more players connected to the same room instance. But unless absolutely everyone congregates in a very small area and is constantly moving around, then I’m pretty sure the interest management system will keep the networking load manageable.

Also, following on from my previous posts regarding map loading times, I’ve got the loading time (including fading in/out) down to 3 seconds irrespective of the size of the map, which I reckon is probably about as good as it’ll go. The incremental building of the map geometry caused me a few headaches with remote character avatars and mobs spawning before they had anything to stand on sometimes, but I managed to sort that out in the end.

As usual, any comments and/or suggestions are most welcome! :slight_smile:

Hi all, here’s a link to a You Tube video showcasing the current progress of the combat, party and questing elements of Kingdom of Galanor, the game I’m currently developing using Unity.

I recently teamed up with Reed Means Music for the in game music which has now been added to some of the maps and I’ve also started adding sound effects and ambient sounds.

There will be different music tracks for each map and building type, but all following the same underlying theme/style.

As usual any and all comments, suggestions and general feedback are most welcome

I’ve engaged the services of a character modelling studio to have the main characters remodelled so that they start off wearing no equipment rather than having their armour/clothing as part of the character mesh as is currently the case. I’m also having made various armour/equipment sets for them to wear.

I’ve implemented a system that visually represents armour items on the character as they are equipped now, which will give better feedback as equipment items are equipped and upgraded and lead to a greater variation in the look of each character class (once I’ve got more equipment sets added to the game).

Also, hair and beards are separate models too now, which will allow for further customization of the character appearance, as will the addition of different skin tones and face designs which is planned for a later date. I’m also looking at implementing a way to allow basic customization of the body shape for each class to add further variety.

Here’s a short video showing it in action.

Just over a month since my last update, how time flies!

I’ve finally finished the Temple Of Althraxia map, quests and boss fights. It took me a while longer than I hoped, but the quest story involving it is fairly complex, consisting of somewhere in the region of 20 separate quests in total.

What also slowed down the progress was the fact that I needed to develop some completely new quest mechanics while I was working on this area to enable me to construct the quest line how I wanted.

Following on from my previous post, I’ve also continued working on the equipment system. I abandoned my original approach, which was to have a semi naked character body and then have armour pieces that fitted over it due to the amount of issues I encountered with parts of the body clipping through the armour when animated. Whether or not this is an inherent problem with this approach or was due to poor setup of the bone weights on the armour parts I’m not entirely sure about, but I was wasting too much time on it as it was.

Also, the animation studio I was working with didn’t seem to be able to hit quite the right mark with the texturing style I was after, so with both those problems I started looking into other options.

After some research into how others approached this, I found that World Of Warcraft characters models are put together in a modular way and then the textures are applied to the character afterwards. So I decided to use the same approach. I already had an asset that took this approach, however I had previously decided not to use it because it worked by having all the parts contained on a single character and disabling certain bits to achieve the look required. This felt kind of inefficient to me, especially considering how much equipment will eventually be included in the game, but mainly because as it was I couldn’t adapt it to work in a similar fashion to the World Of Warcraft method.

So, it was time to download Blender and get on YouTube to watch some tutorials in the hope that I might be able to do something about it myself.

As it turned out, it didn’t take me too long to work out how to import the modular character .fbx file into Blender and export each armour piece separately (with its rig), which was the first step, which meant I now had all the separate parts required to build up a complete character at runtime.

Secondly, I adapted this to set up a system where the character can be assembled at runtime and all the bone weights for the separate parts are copied to the main part, so that they will all animate correctly using a single animator controller.

The final step was to work out how to do the texturing. As it stood, all the parts were textured from a single atlas, which was fine except that as the texture atlas was already full, there was no room to add the textures for new parts, meaning that I would end up with multiple textures being used to draw each character depending on what they had equipped.

What I came up with was a system whereby each armour part has its own 512x512 texture, and the character has a single material with a blank 2048x2048 texture. I worked out how to remap the UVs for the armour parts, so that each particular type (head, chest, gloves, shoes, etc) map to a corresponding 512x512 section of the 2048x2048 character texture and as each item is equipped it copies its texture to its section of the character atlas.

This gives me complete flexibility for adding new items to the game as well as always only using a single material for each character regardless of what they are wearing.

One caveat with the stitching method I’m using at the moment is that each equipment item is still a separate child gameobject once combined with the main character, which I believe results in a draw call for each piece as skinned mesh renderers aren’t currently batched. If this eventually turns out to be a performance issue I’ll look into actually combining the meshes, but at the moment it isn’t a concern.

Here’s a few pictures showing how some of the characters look wearing different equipment.

Here’s a couple of screenshots from part of Shadow Boulder Ridge, the area of Emerald hills where the next major quest line will take place. I’ve only been working on this part for 3-4 days so it’s still very early days.

I’m excited to announce that the the first phase of public play testing for Kingdom Of Galanor has commenced.

You can request access to the play test by visiting the Steam store page and clicking on the ‘Request Access’ button here https://store.steampowered.com/…/The_Kingdom_of_Galanor/

Please be aware that KoG is still very early on in development, consequently many of the intended features are incomplete or missing altogether and there isn’t very much in the way of in-game tutorial at the moment (Basic instructions will be uploaded to the community hub in soon).

However, there is still plenty to do, with 4 character classes to choose from and somewhere in the region of 200 quests and character content that will take you to around level 25. Also, most of the crafting and profession system is in place.

This testing phase is primarily to test the networking performance and multiplayer interaction.

At the moment the only input method is keyboard/mouse. Game controller support will be added at a later date.

Hope you enjoy the test and please let us have your comments and suggestions and bug reports.

Nestled in the foothills of the Greymist Mountains can be found Elendor, the capital city of Galanor.

A bustling hub of trade and commerce, the city of Elendor is one of the most important places in Galanor and would be heroes will find they spend a lot of time there working, training and replenishing supplies.

Still in development, here are some screenshots of its progress so far. All comments, criticisms and suggestions are welcome.

Want to join the public play test? You can do so here for free https://store.steampowered.com/…/The_Kingdom_of_Galanor/

1 Like

It’s been quite a while since I posted any progress updates for KoG, but I have been working on it a lot in the meantime.

The Steam play test highlighted a number of areas that needed work, and I decided to redesign some of the core components of the game from the ground up to address the issues.

That work is going well, and the end result will be worth the extra time and effort. I’ll periodically post updates here as progress continues.

As a side project, I’m considering releasing some of the editor tools I’ve made that have helped me with my workflow for KoG, you can check it out here . I’d be interested to find out if they sound like they might be useful.

This looks very neat and for Android, that’s amazing. :smile:

1 Like

Thanks very much. But it isn’t for Android it’s a PC game :slight_smile: