Dev Diary - MMORTS Abilities

Posted by : at

Category : MMORTS   Dev-Diary


Since finishing resources I went back to update how attacks, heals, buffs, and debuffs were working. Originally I had put in some basic code to be able to test commands, and I felt that this was a good time to revisit and fix up.

For me, Unit AI is separated into two categories: Commands and Abilities. Commands are the instructions a player (or computer opponent) gives to a unit to perform a task. My commands come in 5 flavors: Move, Attack, Assist, Seek, and DeStack. Commands can have a couple of modifying attributes to help maintain or modify their state, which gives me a plethora of ways to interact with the world. For example, an attack command targeted on a resource gathers the resource (if the unit can gather), a forced modifier on an attack command tells the unit to attack the target regardless of who owns the unit (friendly-fire), and the patrol modifier on an assist command keeps a healing unit checking each patient in its queue.

What commands lack are specific damage amounts and types of attacks. A warrior must be within a melee range to use her attack, an archer can be further out. Magic users may have multiple attack, how should the system determine which one to use? For this system I brought in 'Abilities' from my previous project. An Ability is composed of three components:

The Ability main class holds information about the use and firing. Recast delay, range, target type (single target, area effect, area effect centered on the target, self, etc.), cost to cast the ability, and other variables that deal with how and when the ability can be used. It is from this class that attack commands can check if the ability is available or if the unit needs to move into a closer range.

An ability's Effect is what the ability should do to the target. Often this is a change to statistics, the taking of health, or adding of health (in the case of healing), but not always. Multiple effects may be on an ability; like a vampire attack may have an effect to hurt the target and another effect to heal the caster. Effects can be seen as instructions for the next component.

Affects are effects added to the target of the ability. An effect may state that upon being hit by an ability the unit is blinded (zero sight range) for 30 seconds. The affect is applied to the target and decreases the current sight variable. After the allotted time the affect goes away. Some affects are instant and do their action then go away, never being stored on the target unit.

The Effect-Affect concept is a little weird, but give me a huge advantage. If affects on a unit properly manage the current statistics then I can use Affects for more than just abilities. For example, if the player achieves a goal I can apply a buff (a positive affect that lasts for a certain time) to their units in the form of an Affect.

So far I've been very happy with this system and as I flesh out the higher levels of AI I am planning on implementing more of these modular systems.


Categories
Useful Links