Design - In Practice

This covers some things you may want to do in practice.

Beyond the example demo

Once you add the Attributes and Vitals components to some Avatar/Agent you have in your game then you can start interacting with the data that they hold. You will need to put formulas somewhere, perhaps inline in your classes that interface with attributes, which will calculate results based on the attributes of some character(s).

Here are some common use cases and how they might work.

Level Up

Add one level to the character.

myAttributesClass.AddLevel(1);

Scale Damage Output By Strength

Multiply some 'base damage' by the current strength. (This is a huge, unrealistic increase)

int myDmgOutput = (int)(myBaseDamage * myAttributesClass.GetBase(AttType.Strength));

Scale Damage Input By Endurance

Reduce incoming damage by the Endurance (This is a huge, unrealistic decrease)

int reducedDamage = (int)(incomingDamage / myAttributesClass.Get(AttType.Endurance));

Add a Modifier (such as "Weaken: -3 STR for 5 sec")

Requires an AttributeModifierPreset. Design an appropriate modifier preset in Vault, then reference it from a class. Feel free to design your own modifiers.

public AttributeModifierPreset EffectModifier; // select your "weaken" effect here, for example.

public virtual void Cast(IAttributesUser source, IAttributesUser target)
{
    // simply tell the attributes system to attach it, and it'll do the rest.
    target.Attributes.AttachModifier(EffectModifier, source);
}

Last updated