Should we prepare to do battle against the wind and snow?

I was looking at a battle issue reported recently that battle reports were not always being displayed. I’ve had reports before that the AI Lords don’t appear to engage in battle the same as the original, but I have tested this many times and not been able to find an issue other than the AI being unpredictable and a little shaky.

I had recently done some testing while adding the new game rules in place and had my lords attacked, and indeed failed an approach of lord and been attacked, and attacked a lord and battle had commenced, so on the whole it seemed to be working.

I poured over the code again to check the AI conditions of battle and noticed something interesting. The rule is that if the lord can’t walk forward and it is dawn and they are not blocked, then there is a 50% chance of them staying in the current location and ending their turn.

Analysing that a little; blocked means exactly that, they cannot move in the direction they want to under any circumstances. This is usually because of Icy Wastes or there are too many people in the location. Can’t walk forward is usually a transitory check, something in the location they are in or entering could potentially stop them entering, but nothing that would break the game. The Dawn check is just helping to differentiate moving into a location during the turn from moving out of a location at the start of the turn.

The code that makes those decisions is separate from the code that is handling the AI Turns logic. So I went to look at that to check under what condition the lord could not walk forward, and the thing that caught my eyes was – if there is an enemy in the current location. Combine that with the checks in the AI Turns logic and what you have is, there is a 50% chance that a lord will leave a battle at the start of his turn, but if they enter a location with an enemy they will always stop to fight.

The problem was that this flag was being reset by another piece of logic which was actually more to do with the player and not the AI, and also some shared LoM logic. The net effect was, if you attack an enemy lord, or have a failed approach, then the enemy will pretty much always move on and not engage. Now, this seems counter to what my testing has shown, so I can only posit that there was something else happening in these situations that was keeping the enemy at the same location.

Once I realised this it was a quick fix to isolate the piece of code that was overwriting the can’t walk forward flag. However, this then highlighted another bigger issue, and that was that the lord was not considering the enemy as their enemy, and thus the trigger was not occuring.

Again, I checked out the area of the code that handles this, and clearly it was based on LoM, in that Luxor is the friend, and Doomdark/Shareth is the foe. But this does not take in to account the multi-race nature of DDR. So what in effect was happening is that the AI was not really considering the players lords as enemy, or indeed not always correctly considering the enemy AI lords as enemy, which means they would often over look them. Obviously there were fighting, but again I think other issues were causing them to stay in the location of another lord. And as long as multiple lords are in the same location, the battle algorithm would get the friend/enemy check correct and they would fight.

Now, this looks like it has always been wrong, ie: nearly 10 years since I released the games. But I suspect the problem is actually due to the merging of the code bases and likely crept in in the later stages of v1 and then rolled over in to v2.

Stray boulders made a mountain range of the forest floor

I shall be releasing an update to both The Lords of Midnight and Doomdark’s Revenge toward the end of June. This is the “Summer Solstice” update.

There are currently three fixes.

  • Problem with Android rotation.
  • Cowardly lords can still enter a battle.
  • Characters are no longer correctly tinted by the time of day on the landscape.

Along with these fixes there will be a couple of new features. These features will be driven by the new gameplay rule system. The idea being that you can additionally enable certain features that will have an affect on how the game plays.

Menu showing gameplay options

I have been planning this for a while and intended to introduce it with the c# rebuild that I am working on (slowly), but after requesting features for possible inclusion in regular updates I have decided to bring it forward. It gives an easy way to extend gameplay options.

Neil Swanson contacted me with a few ideas for new features and they have been rolled in to the gameplay rules.

I’ve also always intended to have a game difficulty mode: easy, medium, hard. So the intention is to use this in conjunction with the gameplay rules to leverage different types of play.

The following rules have been slated for development and have issues created for them on my GitHub repos. There are likely a few things to consider for them, so details may change.

  • DDR – Original terrain travel times
  • DDR – Armies attack when near an enemy
  • DDR – Armies will continue a battle without just randomly leaving
  • LOM – Cup of Dreams can replenish overnight
  • LOM – Varied initial start positions
  • LOM – Utarg of Utarg can become disloyal
  • LOM – Doomdark will go after Morkin heavily if the Ice Crown is picked up
  • LOM – Doomdark will guard the Ice Crown more heavily
  • LOM – Change quest completion rules to align with Mike’s original intention
  • LOM – Fey are not recruitable
  • DDR – Fast Tunnels
  • LOM/DDR – Impassable mountains
  • LOM/DDR – AI Impassable mountains

The plan is to have the last 4 in the Solstice update, and the work on Impassable Mountains already almost complete.

It’s interesting that when you think of a simple one line description of a feature, how complex it can become when you start to develop it. For example, impassable mountains are just that. LoM and DDR already have a concept of impassable terrain with the Frozen and Icy Wastes, so dropping in Mountains seems simple enough until….

What happens if the friend/enemy is in a mountain? You need to disable approach and battle. Out of that comes the concept of AI Impassable mountains to stop the AI characters from freely moving around the map. But that has its own issues.

What happens when a lord loses a fight and runs away. Well in LoM they only leave on location and there is already a check that it’s not Frozen Wastes, so that becomes straight forward. But in DDR they move up to 3 locations away. It checks that the target location is not Icy Wastes but not if the locations to get there are. Which is why you can currently be bounced in to the Plains of Anvoril if you enter battle up against the Icy Wastes surrounding it.

In DDR special objects are randomly placed on the map. So they can’t be placed on a mountain, but technically they can’t be placed anywhere that can’t be accessed. There are a handful of locations that would be problematic. So either the map needs to be edited to make those locations accessible, or they need to be marked as un-accessible, or we need to allow particular lords or races to not be affected by Impassable Mountains – like say Giants and Dwarves. The later make sense as there are a few Dwarven fortresses that are locked away in the mountains.

Only Luxor remained with a thousand riders of his Houseguard, waiting for news.

Just an update of how things are progressing at the moment.

The move to Cocos2d-x is now almost complete. I have the full Lords of Midnight running with every screen implemented. Which means it is fully playable, however in order to hurtle through to completion I chose to priorities and simplify certain things.

For example. The select screen allows you to do just that. What is missing is the grouping functionality. Which means you can play the game and select all the recruited characters, you just can’t utilise grouping.

Here is my current TODO: list…

  • Landscaping – armies
  • panel_look – direction arrows
  • panel_map_detailed
  • Mouse Images
  • panel_look – shortcut keys
  • panel_look – show following character
  • panel_look – compass
  • panel_think – select character
  • panel_think – Post/Recruit
  • panel_look – help pending
  • panel_look – Landscape – keyboard control
  • Load XML Project Config
  • landscaping – mist
  • landscaping – grafitti
  • panel_select – Grouping
  • panel_select – shortcut keys
  • panel_select – drag and drop
  • DDR panel_gameover
  • DDR uicommandwindow – give text
  • DDR uicommandwindow – select face with name
  • DDR panel_look – Tunnel View
  • panel_advert – multiple adverts

I’ve been doing all this work with the MAC build because it’s easier. The next step was to make sure I could get the project working on iPhone, again because that’s the next easiest most logical step for me. I fixed up some cosmetic issues caused by multi-resolution support and added in support for the Safe Area of the iPhoneX range of phones – basically the notch, the curved corners, and the home indicator. This will also help with any potential AppleTV version that might come later. With the safe area I chose to allow the background to fill the full screen, but make sure any UI components are within the safe area.

The next thing is to get Windows32/Windows10 variants building, which for me unfortunately means spending time in a Windows VM. I also enjoy using Visual Studio less and less… but hey, needs must.

Once the windows version is building, at least the win32 version, I will swap back to Doomdark’s Revenge. I will make the changes required to get DDR running in the same way LoM is. The main thing will be tunnels, mist, landscaping and ui differences. The reason for this is so that I can have a version to give to Drew that will help him with the novel research.

After that, I will start pulling on the straggly strands together. I haven’t decided for definite yet, but I am thinking of releasing this version under the monicker “The Midnight Chronicles” and having both LoM and DDR as selectable campaigns, rather than releasing them as two separate apps. This wasn’t really possible when I first released LoM 6 years ago!

I am also considering In App Purchases. The idea is that the main game will be free, but you can pay for additional scenarios and graphic sets. It is likely that The Citadel will be released as a scenario rather than a new game. Some other scenarios might just be playing with the map or the game conditions. I like the idea of a scenario that more closely resembles the way the Novel plays out. I don’t intend to add IAP for functionality or gameplay, so there will be no in game currency for example!