CellEffects are event/action pairs whose events are always “OnEnter.”  It’s not a huge jump from that to Skills, whose event/action pairs will be similar except they’ll fire “OnUse.”  In fact, it’s done!  I’ve created a few sample skills to test things out; eventually players will learn skills as they play the game and activate/deactivate them as they play.

Here’s the SkillDefn sheet in the xls:


Looks similar to the CellEffectDefns sheet from my earlier post, except it adds a few Skill-specific columns such as which class the Skill belongs to and whether it’s Active (triggered OnUse) or passive (always active – triggered OnGainSkill and removed in OnRemoveSkill).

The code to serialize the SkillDefns into object format is dead-simple thanks to the action parser that I wrote for CellEffectDefn (and the fact that the same Event/Action infrastructure supports both):

static public class SkillPersister
    static public void CreateGameModelFromExcelModel(string gameVersion, ExcelQueryFactory sourceData)
        GameDefinition.SkillDefns = new Dictionary<string, SkillDefn>();

        var skills = from i in sourceData.Worksheet<ExcelSkillData>("SkillDefns")
                        where i.GameVer == gameVersion
                        select i;

        foreach (ExcelSkillData skillData in skills)
            // Create a new game-model from each of the Excel-Defns
            string skillId = skillData.Id.ToLower();
            GameDefinition.SkillDefns[skillId] = new SkillDefn()
                Id = skillId,
                Cooldown = skillData.Cooldown,
                CharClass = (CharClass)Enum.Parse(typeof(CharClass), skillData.Class, true),
                SkillTrigger = (SkillTrigger)Enum.Parse(typeof(SkillTrigger), skillData.ActiveOrPassive, true),
                SkillAction = ActionInfoParser.Parse(skillData.OnUseAction)

Given that, giving skills to the player is simple; the following code is all that’s needed to give two of the skills listed in the xls above:

newDungeon.Skills.ActiveSkills.Add(new SkillModel(GameDefinition.SkillDefns["renew"]));
newDungeon.Skills.ActiveSkills.Add(new SkillModel(GameDefinition.SkillDefns["minorhealth"]));

When the player clicks on a skill button, the following causes the skill to get used:

Action_UseSkill.Perform(Model.Skills.ActiveSkills[0], Model.PlayerChar, Model.Skills.ActiveSkills[0].SkillDefn.SkillAction);

And then the final bit of code to enable skills to work is Action_UseSkill.Perform:

public static EventResult Perform(EventableModel eventSource, EventableModel actionSource, ActionInfo actionInfo)
    EntityModel performingActor = actionSource as EntityModel;
    SkillModel skillModel = eventSource as SkillModel;

    // Notify listeners that the actor is about to use the skill
    if (EventMgr.FireTwoWayEvent(EventType.BeginUsingSkill, EventType.BeginBeingUsed, performingActor, skillModel) == EventResult.Cancelled)
        return EventResult.Cancelled;

    // Fire past-tense 'Performed' event.  This allows chaining of Events
    EventMgr.FireTwoWayEvent(EventType.HasUsedSkill, EventType.HasBeenUsed, performingActor, skillModel);

    return EventResult.Normal;

And that’s all the code that was required to add Skills.