Had a brainstorm on the bike ride home yesterday about the actual implementation of skills. When the pool of skills is small I was thinking small, and each skill was a one-off, called during update as needed.
Thing is, that's not very manageable, not very intuitive. I'd end up with a bunch of these individual calls (one per skill) scattered all over the place, with implementations who knows where. There are already quite a few things going on in a creature's (or player's) turn, and every new added skill would just compound the problem.
So instead I made everything a skill (well, except movement although now that I think about it ... why not?); they're more like "actions" at this point, except some are passive, some active, and some reactive - this part will still take some thought. A creature (and the player) will get those skills loaded up through their XML (now in easy-to-parse, easy-to-tweak comma separated format) on creature generation, and then simply iterate through all of their skills, whatever they may be.
Currently, everyone has the ability 'regen' which is a passive and always happens (unless suppressed somehow), a few creatures have the ability 'throwWeapon', and some have 'summonSelf' which summons another creature of the same type to help. Some of these actions take a turn, some don't, so some will be "blockers" for other actions. What I'm still working on is a sort of weight as to which action a creature should take, for which I think the creature STATUS and STATS will be responsible for.
For example, let's say a creature has 'teleportSelf' and 'castFireball'. If I just give it a percentage chance to occur, the creature will always end up doing one more often than other. However, whether I want the critter to do one or the other depends on what state it's in! If it's wounded, it should probably teleport away; if it's close by it might want to attack in melee instead; and when it's far away, it should throw that fireball. I already have some rudimentary statuses in like ENGAGED, SEEKING_TARGET, SEEKING_ITEM but I suspect these will have to become more verbose. Still, by solidifying the skills into an actual system all of this will be much easier to do.
Oh yes, if anyone else searches for "using a string as function call in as3", this is the way to do it:
var myFunction:String = "castFireball";
I had no idea that was possible. It's tremendously useful for things like this, when you need to call functions that you don't necessarily know the names of.
There are a couple of things that I wanted to address for some time, but I've been so head down in the mechanics (still am, armor and ranged combat remaining) that it got put off over and over.
First, I still don't have a concept of endgame, or deeper design than just keep-going-down-and-kill-things. While this is fine for plenty a roguelike, I always wanted to do a little bit more. The game was always intended as a hybrid roguelike and dungeon simulator (lite), it's just that the roguelike had to happen first so there was a foundation to build off of. A lot of things are created with that in mind - the randomized weaponry, randomized levels, randomized critters, flexible tiling system, the planned Events as an action trigger ... I'm sure I'm not looking far ahead enough and will have to do rewrites anywhere, but I'm trying to plan for many eventualities.
With that in mind, the game will eventually let you control and alter dungeon rooms to your liking. I have yet to decide what those will be, other than some basics such as Armory, Training Room, Baths (a clean monster is a happy monster!), Recruitment Center all of which will impact the number and equipment of friendlies on a level, and then luxury things like Alchemist, Weaponmaster, and of course a Dungeon Enhancements 'R Us so you can obtain traps and such. As I think of these things, some sort of design plan is crystallizing in my head for "endgame". See, the initial concept of you being a disgruntled dungeon inhabitant and turning on your creator/paymaster works only up until you get to him/her and take them out. But then what?
Well, I still have the core of heroes invading the dungeon and trying to do the task for you, so you have to deal with them as well. But once you get there, what would be the reason for the monsters to line up behind you, and for the dungeon to be secure? There wouldn't be - so you turn right around and go back with the wizard's (or warlord's, or mad scientist's) artifact (haven't decided what yet, how does this sound:), the Sceptre of Sealing, and make your dungeon the most secure, well-defended and most importantly - unionized and well-paying! - dungeon ever. Hmm, maybe the Sceptre of Fair Pay. At this point the monsters will be mostly neutral with only a few holdouts, you'll have more money so you can build more structures, and the influx of heroes (who have heard of the wizard's downfall and are running for the loot) will become a serious problem and teaming up with other monsters will become vital.
I AM MAKING ALL OF THIS UP AND IT IS FUN.
I think with this somewhat tongue in cheek design concept I have no choice but to outsource some snark for the game. I therefore welcome all comments in that vein - I could use monster, weapon and armor names and attributes, as well as catchphrases to display on the (nonexistent title screen). So far I got:
"Dungeon dwellers of the underworld, unite; you have nothing to lose but well, everything."
"Dungeon Contractors LLC; no dungeon too small, some wizards too tough."
"One day only - patented hero detectors. Only at Dungeon Enhancements 'R us!"
"A monster has appeared! Run/Fight/Talk/Swap stories?"
"A hero party has appeared; the paladin looks buff. Run/Run/Run/Run?"
I JUST MADE THESE UP ALSO (you might be able to tell). This is GAME DEV.
You can see the making of here: [do-internets.posterous.com]
really pleased and amazed at how fast this is coming along. I think the "if it doesn't work, abandon technology and try something else" approach has a lot to recommend for it! Also, quite glad I didn't stick with that Ruby thing; I was trying to do too much right away, there.
Next up, some Dweller stuff since this is pretty usable already. I can add an about page at some point, a footer, some actual colors - or not. Well, that's all if I can tear myself away from Dredmor anyway ...