Illusions (Part 1)

I have now implemented the ability to cast Illusions and the usage of a permanant disbelieve spell for human players. I still need to add AI support for casting disbelieve and illusions.

After some thought I have decided on the current method for selecting illusions. If in the future I have enough time I will include other user interface options..

When Illusions are on as a game option, you will find that moving over a creature spell will now show the words in the panel at the bottom: “cast as illusion” if over the top-half of the spell icon, or “cast as real” if over the bottom-half. Although a bit unintuitive to people new to Chaos this does help eliminate cheating as if other people are not looking at the screen then they have no clues as to what spell is cast.

I’ve played many games of Chaos Funk with friends and I know that if I put in the same pop-up box (yes, cancel, no) option then the friends who are looking away from the screen would be given a clue by the 2 mouse clicks as to the fact a player is casting a creature spell. Unlike in Funk there is virtually no need to press a mouse button prior to clicking on a spell icon. So 2 mouse clicks would be a give away compared to the normal 1 click.. Using the left and right mouse buttons seems an obvious answer, but on some mice these make a different clicking sound, again making the fact the player wants to cast an illusion painfully obvious. Anything that the player has to do extra for a creature spell (pressing a key, extra mouse clicks, etc..) is too much of a clue to sneaky friends!

At the weekend I will try to find time to add AI use of illusions and disbelieve. But, no promises! 🙂

Back with some more bug fixes

I’ve got a temp job lined up for Monday, so I can relax a little bit..

I’ve been fixing a few bugs:

  • Dismounting bug now fixed.
  • Mouse button is now checked to see if it’s being held down instead of just clicked.
  • Added check to skip over Independent movement turn if there are no generators or Independent creatures on the board.
  • Made it so pressing Escape exits through a menu gracefully, and also exits the game from the title screen.
  • Added “Magic Resistance Attack On Wizard” options – No Effect, Destroy Strongest Creature, Destroy all wizard creatures. This now works ok for human wizards, but needs more AI testing to make sure AI takes proper advantage..

Wizard Selection Screen

I now have a basic, but effective, Wizard Selection Screen in place..

Chaos Groove Screenshot

This uses the new config files to read in the wizard_options.ini file and use the text information held in there for the menus and to directly set up the wizards. Unlike previous menu systems I’ve written, the information is not transfered into seperate menu variables, but parsed directly from the text each frame. This might be too slow in a fast paced arcade game when used ingame, but for Chaos it’s not going to be a problem. It will also make it easier to code in new menu options and process them as well. In addition, the variables in the text can be used to deal with how the menu options are shown on the screen to some extent.

Unfortunately, my strengths do not lie in clean, modular, reusable abstract code like menu programming. So, the code is a bit hackerish I’m afraid, but is mostly data-driven and is effective. 😉

The next demo release will let you pick a combination of wizards (human, computer or off), as in Chaos Funk.


Today I have added Magic Fire and Gooey Blob:


Like the original, Gooey Blob will spread and cover pieces that don’t belong to it’s owner. They can also be rescued by killing the covering blob. Unlike Gooey Blob, Magic Fire will try to attack a piece, but will kill the piece completely if it wins. The growth routine is pretty simple and is a direct translation from the original code after being disassembled by a few people. I think the ‘grow and make the original piece die’ chance is not quite the same, but the rest of it is identical.

As you can see in the screenshot, I’ve added a quick blur glow to the fire gfx, which is a bit of a placeholder for the moment.

The growth options are all held in the piece data text files, so pieces can have a different chance of growing, dying, attacking, etc.. They can also grow a piece that is not the same as the current one, so for example you could have a bees nest which has a chance of creating a bee creature. 🙂

Most of the time today was spent on getting the AI to use the spells properly and to react to them on the board. Because they can grow the AI needs to be coded to realise that standing next to a growing piece is not a good idea! At the same time a wizard shouldn’t be so scared of blobs more than a square away that they would run away in a panic. They need to know that they cannot move and attack them. That is what I tried to today, even though it’s a bit tricky. I had to do a few changes (without hardcoding for specific spells), to make the AI treat them properly. It still needs some work, but that’s for another day.

Like much of Chaos, one little thing here can have unforeseen consequences later on due to the way things interact. It certainly takes longer than you think for getting the logic right!

I’ve also fixed a few display user interface bugs with text not being removed at the start of a new turn and with removing highlighting in a computers turn and messing up his movement. I’ve still got a few issues to fix with wizards mounting a piece with a magic bow and not shooting, and not doing anything in a magic tree. But for today the Magic Fire and Gooey Blob are pretty much done. Mutation and Teleport next I think..

Hard work!

I’m knackered.. I’ve been working on the 2nd demo this weekend and it’s took longer than I expected to try to get the AI to use the spells (and move) more intelligently. Also, I had a few bugs I had to track down and all together I’ve worked a bit too much.

It’s safe to say that if it hadn’t been raining nearly non-stop for the last 2 days I would have not got so much done..

There are still some bits I haven’t been able to get done, but for today I’m going to have a proper break. The demo is now done and it’s just stopped raining (finally!)

See my next post for the demo..

AI Work (and a few other bits)

I’ve been working hard on making the AI work properly with the new spells like subversion, magic bolt, etc..

This has involved me fixing a few AI bugs as well as rewriting a few parts to deal with the new non-creature spells. I’m also trying to work on the movement side for the wizards and tweak a few things to make the AI protect the wizard much more. I need to do all this because the spells weren’t being used properly by the AI previously.

Oh, I’ve fixed the highlighting error reported previously, now creature’s owners are highlighted correctly.

I hope to get a demo out tomorrow (fingers crossed!)

Pathfinding test

Chaos Groove Pathfinding test Screenshot

This is just a test of the pathfinding under extreme conditions to make sure it all works properly. 🙂

I will also use this pathfinding for game options which throw in a user definable amount of walls and destructable objects on the board to make sure no wizard is trapped in a corner. 😉

Yet more bits & pieces..

More little bits & pieces done today..

Firstly, I’ve implemented proper black borders around the screen if they are required. This is to erase the overdraw caused by the cloud drawing, which can move into the border area due to the way they are animated. So, in a widescreen display black borders are drawn to the left and right, and if in a portrait display (or a screen mode where the ratio is not 4:3) then borders are drawn top and bottom. I tested it in a variety of windowed sizes and it works fine for me, and it should hopefully make the game playable for more people with widescreen monitors. Smaller screensizes do make the small font look much worse though!

I’ve also implemented some code which at the start of a spell selection phase, goes through a human wizards spells and checks each one to see if it is castable or not (any space, or targets available). If not then it is shown with a red border and moving over it with the mouse shows a Can’t Cast message in red at the bottom. It is of course not selectable. This helps the player at a glance to not look at spells which can’t be cast. As you can tell I’m hugely in favour of these kind of UI designs which reduce time and save the player unnecessary work!

Following on from that, the game will now also show a green border (for one turn only) around new bonus spells found from magic woods. I did something similar in Chaos Funk and this does help show the new spell..

I’ve implemented a proper spell casting check for the AI wizards too, so now no spell that can’t be cast should be selected. This was much easier than would have been possible in Chaos Funk due to the design of Chaos Groove. Something I’m going to touch on in a later post.

Oh, I also added a AI check to make pieces that can be ‘ridden’ be cast closest to the wizard. This is to stop spells like Magic Castles being cast close to the enemy like shadow woods or walls would be. Using the ‘rideable’ stat lets me avoid hard-coding things like this for specific spells, something I’m trying to avoid at all costs.

Finally, I’ve fixed a few bugs with the AI, and made the vertical spacing between the text at the bottom shorter, so it now lines up with the brief spell description as drawn using PTK’s multiline text function.

There is still some errors when highlighting the current wizards creatures. This is made more difficult because I’m trying to set the highlights intelligently in case working out the path-finding each frame kills the framerate on slower PC’s. It shouldn’t do really, but I’m trying to make the game work well on many different kind of PC’s.

I’ve still get a few bits to do before being able to do a new demo. I’ll try to do one soon, but I’m not going to promise a date!

Testing & Fixing


Here is a screenshot showing some of the new additions. Notice the massive range of the Lightning spell for testing purposes, and the way that pieces on the board are obscuring the line of sight. The line of sight routine is rather generous, since from my own experience it’s more frustrating not being able to cast a spell that you think you should than the other way around..

I noticed earlier today that for some reason whenever I moved over some spells like Raise Dead and Lightning I got a massive frame drop from 60fps to around 20-38fps. At first I thought this was perhaps an error in the line of sight code or the highlighting code, but that checked out fine. After more testing I found that drawing the spell description was responsible for the slowdown..

Switching to a single line text system removed the frame drop, so I thought that it was my home made word wrap code that was to blame. Well, it wasn’t too efficient, so I rewrote it to work properly and more efficiently, but saw no difference! After more testing I found that the getstringwidth function in PTK was killing the framerate. Well, I remembered reading something about a speedup in the truetype functions in PTK and checked the website. It turned out I didn’t have the latest version of PTK downloaded as I had thought and instead had an older version where the truetype text was about 160 times slower (according to the history). So, one swift update later and now it ran great at 60fps again!

The new version also provided a new multiline function though. It doesn’t let me adjust the vertical spacing to get a nice lineup between the three lines of the description and the info on the lines on the right. That’s the downside, but the good part is that it does let me have extra spacing between words to get perfectly alligned text at each end. This does look better, so I’m using this function instead for now.

I also had another silly bug in there where the highlight square in position 0, 0 of the board was always being removed for some spells. I tracked that one down to a missing alive check when finding if a wizard was in a square. As a result wizards that were not alive had a position of 0, 0 and were triggering the ‘can’t cast on wizards’ code which removed highlights from them (including 0,0!).. Doh! Now, it’s fixed.

So, two little things which took a few hours to trace.. 🙂

Tightening the experience!

I’ve been working on a few different things today to improve the game:

  • Made the spellcast effect shorter in duration, because it seemed to be going on a bit too long, especially when casting trees.
  • Stopped the yellow highlight cursor effect being drawn when the AI has it’s turn. This makes things look better when land based creatures with a few movement points are moving. Previously the yellow highlight square would be placed at the empty destination square, which could look a little odd.
  • Added a dull grey highlight for spells which only affect other pieces (subversion, magic attacks, etc..) This is to help show the spell’s range, but is only applied to empty squares.
  • Made the range of a spell be displayed in the spell’s description.
  • When a wizard dies, his or her pieces now go through an exploding particle animation as well as disappearing.
  • Added a 3rd highlighted cursor style (4 corner brackets, slightly thicker than the dotted border line cursor). This is now used to show owners of a piece, and so if you move over an enemy wizards creatures his pieces will be highlighted in red. Moving over your pieces will highlight them in green (or blue if they have moved), as well as showing the squares that creature can move to, attack or mount. Unlike previously where I tried using the dotted line highlight, the different designs help distinguish things. So, dotted border squares are where you can move to or cast onto. Thick solid border squares are where you can attack or ride (mount). Finally the new corner square border is to show a piece’s owner. Slightly more complicated, but I think it works well when you play with it for a while and is less confusing and more intuitive than other approaches.
  • Pressing the right mouse button over a empty square will now highlight all pieces on the board by their respective owners colour. This is a very handy way to see who owns which pieces at a glance.
  • Added support for magic missile spells with the ability to change the missile gfx (the default one is the white spell beam gfx), the casting effect (the default is the spellcasting effect), the amount of the effect, and also I’ve added an attack value to use against the creature. With this in place, I’ve implemented Magic Bolt and Lightning and these new options let us also do other spell combinations if desired.

All these changes help to improve the game and make it more easy to play too.. 🙂