Making Powers Configurable
v0.10 added hero powers in a pretty crude way. I added power variables as needed until the entire first set was complete. With that finished, now I need to move all the powers out to config files.
Power config files will contain variables like name, description, requires_mana, animation type, graphics and sounds, etc. Then I’ll have to modify the PowerManager class to handle any variation on powers, instead of branching on specific powers. PowerManager will also handle an arbitrary collection of images and sounds.
The Powers menu will be changed under the hood. A config file will allow slotting any power into the given slots. Powers could be swapped out. New powers could be added for even-numbered stat combinations. In the future, the entire layout of this menu will be configurable (but probably constrained to the given window size).
Each power will still rely on a base type. Current base power types:
- consume (for single-use items like potions)
- nonDamage (various special effects)
- missile (Shoot, Piercing Shot, Shock)
- missileX3 (currently only used by Multishot)
- groundRay (currently only used by Freeze)
- single (nonmoving area attacks that are dangerous on a single frame, like Burn and Quake. Includes melee attacks.)
New power types will simply be added as needed. I don’t mind having base types that are very niche (only used by one power) but it would be nice if I can generalize them (e.g. turn Missile x3 into MultiMissle that can handle X missiles separated by Y degrees. Should be possible to make a multimissle spell that, for instance, shoots missiles out in a complete circle around the player). Ground Ray will still be pretty niche, but at least similar powers can be done with a different visual style (e.g. a flame wave or shockwave).
Hooks will need to be added for powers that work in special ways. E.g. Block is an entire state, not just a power that occurs briefly. Vengeance is a power that is activated and expended in areas of the code unrelated to Powers in general. In the case of Block, it might simply need to be its own power type. Vengeance could belong to a new class of powers that trigger upon attack (Life Stealing could be added to this type).
All this effort so that we can easily slot powers for monsters…
Enemies don’t have PMOD stats in a meaningful way. Instead, enemies will have four fixed slots for powers.
- Physical Melee (usually a melee swing attack)
- Physical Ranged (shooting a bow/crossbow or throwing a projectile)
- Magical Melee (a close-ranged spell)
- Magical Ranged (often a missile spell)
Furthermore, enemies will have % chance per frame of activating these powers. This % can be zero (e.g. some creatures can simply have no magic, or no ranged). First, the enemy will determine whether he’s in melee range or physical range. Then, a random chance to active the appropriate powers.
Each power (in the config file) will have a unique numeric ID. Then, each enemy file will allow assigning these power IDs into the four creature power slots.
Further behavior will be determined by simple % chances to act. E.g. some creatures will favor staying at ranged, so they will not approach the hero (instead, staying back and using ranged powers).