Download Media Create Donate Forums


Action Bar and Powers

Time to nail down the logistics of the Action Bar and Powers.

Action Bar already has a place in the dependency hierarchy: GameEngine -> MenuManager -> MenuActionBar. Note that Avatar.logic() will need to read from MenuActionBar to determine actions.

It's possible that Powers need to be accessible in several places: MenuActionBar, MenuPowers, ItemDatabase, Avatar, Enemies, etc. It probably does not have dependencies of its own. So might create it in GameEngine and pass its pointer to the children who need it.

Action Bars slots (1-0 numbers and M1/M2) are loaded with Powers. Those 12 slots will be integers of the appropriate Power ID.

Powers have ID and Type. Each type (or collection of types) will be handled by its own function. An activate() function in turn calls the appropriate handler function for the type.

Example 1: Drink a Potion. Currently the activate() for this item is in ItemDatabase but it will move. Drinking a potion can be triggered in these ways: (1) right-click on the inventory, (2) hotkey or click the potion on the action bar. Play the potion sound effect. Alter Avatar.StatBlock.hp. Remove the potion from the inventory.

Example 2: Shoot a Bow. Triggered by hotkey or click the potion on the action bar. Create a new missile hazard. Change the Avatar state to Shooting.

Example 3: Cast Shock. Triggered by hotkey or click the potion on the action bar. Create a new missile hazard. Change the Avatar state to Shooting. Alter

To have access to activate(), MenuActionBar needs a pointer to Powers. Same with MenuInventory and MenuPowers, to allow right-click use. Powers will have its own set of sound effects. Powers will have a public Hazard (or queue of Hazards) so that the HazardManager can pick those up. Powers needs access to Avatar.StatBlock to change various stats. I think that's it.

What about Powers generated by enemies? I think this is basically handled similarly. Powers needs a link to the Enemy.StatBlock (in fact, activate() should probably take StatBlock as a parameter). Hazards have damage sources so that's taken care of.

Where are buff durations, etc. stored? In the StatBlock.

Where are animations and graphics for Powers stored? Probably in the Powers class. When getting renderables for Hazards we'll need to read some info from Hazard and some from Powers. When getting renderables for Buffs/Debuffs we'll need some info from StatBlock and some from Powers.

Powers could be stored in a powers.txt file.

type=basic_ranged #defines tells activate() which 
requirement=po,1 #places this power in the skill tree
description=Basic Range Attack

requirement=pd,1 #places this power in the skill tree
description=Basic Melee Attack
value=p # damage is based on the equipped Physical weapon

requirement=md,3 #places this power in the skill tree
description=Restore health
value=m # healed amount is based on the equipped Magical weapon

name=Health Potion
description=Restore 100% Health
value=max_hp # healed amount is the drinker's max hp

When a power is used that requires the user to change state (e.g. melee swing), the power (often, hazard) activates on a specific frame of that animation. The action frame should be a parameter in the animation part of StatBlock.

Where are the power animations defined? perhaps a power_animations.txt in the powers folder.