Skill refactor!

Thu, 16 Feb 2012 17:31:51 GMT
Skill refactor!
Tags:dweller makingOf skills
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";
this[myFunction]();

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.
blog comments powered by Disqus