Programming overview

Skills and Combat

Skills and Combat

Skill Types

There are several basic skill types.  Simple abilities like Autoattack will usually only contain one of these (AoE attack), but more complex abilities can contain several. It's also possible to combine several "layers" - for example a Ground Targeted skill might have a timer, and every second that target location spawns several projectiles flying outward in a circle.

These Skill Types then call an Interface for triggering a combat event on anything they hit.

Interfaces

A theoretical setup of how things could interact.

Interfaces

Combat Events: Incoming

To try and keep it "modular" and work with composition, we'll define several interfaces that can have effects on the targeted entity.

Damage:

We'll define incoming damage as:

This allows us some flexibility in applying direct damage. The function that's called by this signal then calculates if there's any resistances, and logs the event in combat log.

Healing:

Healing is a seperate interface because this makes it clearer that we can implement different functionality, like a "healing received" modifier for example when players have to protect an NPC, to not make it too easy. We want to keep this logic seperate from the damage logic.

 

Buff:

Buffs can be positive OR negative, since I did like the way it's done in 7 days to die - a buff adds some status effect, and debuff means the effect is removed.

 

Debuff:

Removes buffs/status effects/whatever.

 

Movement:

Moves the entity. Can be friendly or hostile. "grappling" means a constant "force" is applied, pulling entity towards target location.

Game Design Note: Heavily prefer both firendly and hostile movement to be skills cast by the player. Avoid situations where players get moved against their will, except maybe bossfights.

 

Special:

For things that do not fit in the other categories - For example, Resurrect skills, maybe Instant Kill events that can't be resisted, ...

Component system

We use components to avoid having to copypaste code, while also not running into inheritance issues that class systems have.
(classes are still used, but mainly to have pre-configured classes already containing components that are correctly linked to each other)

Component system

skills_component

Skills component adds the ability to cast skills to it's parent entity.

Interfaces:

cast_skill(id, target)

casts the specified skill, optionally on a given target. target can be a reference or location (? figure out if thats good, maybe look up in the skill db whether the skill is entity-target or ground target?)

get_stats()

if the skill can be affected by stats, the skill component checks if the parent has a stats component, if so it reads the relevant stats and applies them to the skill.

spawn_skill_scene(data, target)

once ready, the skills component instantiates the necessary scenes for the skill, and places them at the given target.

Neccessary initialisation:

skills_db:

the component needs a skill db to know what skills there are and which scenes to spawn for each.

skills_scenes:

we need to have pre-made scenes available for each skill. These can either be just a script, for example some buff that just modifies stats, or whole 3d scenes with animations, particles, collision boxes etc.

connecting signals:

to keep flexibility, we should implement the interfaces with signals - so skills_component needs to listen to it's parent's cast_skill signal. This also allows things like a mana component to listen to them, and we don't need to call 5 different components each skill cast. (cooldown should probably be handled by UI?)

player_skills_unlocked:

we need to get a list of skills that are available to the player, otherwise we'd be able to cast whatever.

Specifically excluded:

skills_UI:

we exclude the UI parts - mobs can cast skills but don't need this. The UI can also read data from the skills_db.

The UI will additionally only display skills the player has unlocked, so we do NOT need to check this within this component.

Classes

Classes

Mobs

Mobs are defined in one main class: mob

this mob class implements the combat component, health bars, targeting?, loot/exp drop

purposefully excluded is pathfinding