Opportunistic XEH guide - CBATeam/CBA_A3 GitHub Wiki

This guide is outdated. Please refer to this guide instead!

Sometimes, it might be desirable to offer compatibility with the extended event handler system without having to depend on CBA, nor having to create an adapter addon.

The third way is to review all the custom event handler in an addon and add calls to the CBA XEH functions that implement the extended event handlers into the custom event handler itself.

Let's take the original addon example again. As you may recall, this is how it looked:

/*
 * TAG_MyAddon - the original addon with a simple init event handler.
 *
 */
class CfgPatches
{
    class TAG_MyAddon
    {
        units[] = {"TAG_B_Soldier_F"};
        weapons[]={};
        requiredAddons[] = {"A3_Characters_F"};
        requiredVersion = 1.0;
    };
};

class CfgVehicles
{
    class B_Soldier_base_F;
    class B_Soldier_F: B_Soldier_base_F
    {
        class Eventhandlers;
    };

    class TAG_B_Soldier_F: B_Soldier_F
    {
        displayName = "TAG soldier (happy)";

        class Eventhandlers: Eventhandlers
        {
            init = "(_this select 0) setVariable ['TAG_isHappy', true]";
        };
    };
};

Now, this addon overrides the init event handler. In order to make it compatible with the extended event handler system, add a call to the XEH init event handler (_this call SLX_XEH_EH_Init):

...
...
    class TAG_B_Soldier_F: B_Soldier_F
    {
        displayName = "TAG soldier (happy)";

        class Eventhandlers: Eventhandlers
        {
            init = "_this call SLX_XEH_EH_Init; (_this select 0) setVariable ['TAG_isHappy', true]";
        };
    };
...

That's it. If the unit uses a killed event handler, you would add _this call SLX_XEH_EH_Killed and so on.