Friday, June 11, 2010

Keep it clean or you're doomed...

Just spent the last 2 nights restructuring the code to keep it clean and simple. I had objects like herbs and crystals that were being created by one manager, spells by another, and enemies by a third. So I bit the bullet and made them all derive from a common system. All my xml files are now read by a single system that can create all manner of objects... Of course that means not much glitter for this weeks blog video :( but its just too dangerous to let your code get too messy. The way I program, I tend to rush in and prototype stuff and get it working quickly, then spend a day or two redesigning the code framework. I try not to spend too much time designing up front until I know what the final design needs to be, and there's no way to know that until you've given it some prototyping and play testing.

Also I've switched all my enchants to script driven now, which lets me add an enchant to the game in, literally, a few seconds - though balancing it and choosing how the player will get the recipe takes a lot of thought and time. A script for my lowest level regeneration enchant looks like:

event name="OnTick" script="onPercent 10 (addHealth recipient (power * 1))"

This effectively reads that on every game cycle, we have a 10 percent chance to add power * 1 health to whoever is the recipient of this enchant.  The power is calculated based on the mages skill as well as the socket that the enchanted crystal is placed in.  There are 7 to choose from and they change in power depending on whats happening in the game.  The Life socket has more power if you have more life.  The War socket has more power you are attacking or being attacked.  The Dark socket has more power at night,  etc... The Balance socket is always active but is only half the power of the other sockets. In the video you will see me attack a giant. The first attack goes bad and I'm quite hurt. I back off and socket the regeneration enchant in the Life socket, but since I have few hitpoints, it has little effect.  Moving it to the balance or Spirit socket gives it a huge boost.  In the final game, you'll only be able to juggle sockets at midnight at a special location. This will mean you must live with your choices for a full game-day before you can experiment again.

Also in the video, you can see more of the dynamic lighting system. The distance you can see is reduced in caverns and you see the shadows nicely wrapping to the cave walls.



Watch on you tube

No comments:

Post a Comment