Extended Eventhandlers by Solus

VTE - The most detailed and comprehensive Vietnam modification for ArmA

Moderators: Lone Wolf, Snake Man

Snake Man
Commander-In-Chief
Posts: 9355
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC

Extended Eventhandlers by Solus

Post by Snake Man » 2008-05-30 08:55:31

Extended Eventhandlers by Solus (and Killswitch?). XEH

So far I have no knowledge of what these do, I know they are used in for example in ArmA Effects and so on. I have tried VTE with the ArmA Effects and it works ok, so I assume VTE dont have to be XEH compatible(?).

Could someone who understands how XEH and addons using it works, share some knowledge here, should VTE add compatibility and how would that be configured etc?
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

Killswitch
Newbie
Posts: 10
Joined: 2003-07-03 04:09:28

Post by Killswitch » 2008-06-07 09:26:56

One can describe Solus' XEH as something that basically makes it possible to have several different event handlers of the same type (init, fired, engine etc) and allow for new ("XEH-enabled") addons to add yet more event handlers to vehicles. It's a sort of "event handler plugin system".

You can think of it as a way of allowing multiple inheritance for the class EventHandlers entry. Imagine if it was possible to write your configs like this:

Code: Select all

class KLS_MySoldier {
    ...
    ...
    class EventHandlers: ABC_EventHandlers, XYZ_EventHandlers
    {
        init = "basic stuff; goes here";
        ...
    };
}
Now, think of XEH as a system for allowing this, where in the end, class KLS_MySoldier will have init event handler code from "ABC_EventHandlers" and "XYZ_EventHandlers" added to the init EH code from MySoldier itself.

That's XEH in a nutshell - the ability to "plug in" or extend event handlers. The way you write the configs to accomplish this is a bit more complicated than in the example above, though.

Now, the reason why Matt's ArmAEffects addon (which uses XEH) works with VTE is that currently, most units and vehicles in VTE are not declaring their own class EventHandlers (the exception seems to be several vehicles in the VTE_config\veh\air.hpp file.)

HOWTO make VTE fully XEH-compatible

1. In VTE_config\veh\air.hpp, comment out all the class EventHandlers blocks that aren't already commented out.

2. Add this code snippet to VTE_config\defines.hpp :

Code: Select all

class Extended_Fired_EventHandlers
{
    class VTE_Plane
    {
        VTE_Plane_Fired="_this exec ""\VTE_config\scripts\events\firedEH.sqs""";
    };
};
What this will do is make sure that all planes that are descendants of VTE_Plane will get the VTE fired EH. (I know- currently, that event handler is used only on specific subclasses of VTE_Plane, but to make this HOWTO shorter and simpler, I'm showing you how to add the XEH:ified version to the parent class)

3. (Optional) Comment out the old "class VTE_Air_EventHandlers" class, since it won't be used.

4. Add a dependency on "Extended_EventHandlers" to the CfgPatches part of VTE_config\config.cpp:

Code: Select all

class CfgPatches
{
    class Vietnam_The_Experience
    {
        units[] = {};
        requiredVersion = 1.12;
        requiredAddons[] = {
            "CAAir", "CABuildings", "CACharacters", "CAData",
            "CAMisc", "CAPlants", "CARoads", "CARocks", "CAVoice",
            "CAWeapons", "Extended_EventHandlers"
        };
    };
};
5. Add the XEH addon and associated bisign and key files to the VTE fileset. When I type this, the latest version is 1.7: Extended_EventHandlers17.zip.

6. In the name of performance, please rewrite the firedEH.sqs and make it a pre-compiled .sqf function. :wink:

Lesson #2: adding a fired EH for another vehicle class
After a while, VTE decides it needs another fired event handler for all units of type "VTE_man". This fired EH uses a precompiled function that we'll use an init EH to prepare. To do this, you would add to the class Extended_Fired_EventHandlers class from the example above, making it look like this:

Code: Select all

class Extended_Fired_EventHandlers
{
    class VTE_Man
    {
        VTE_Man_Fired="_this call VTE_ManFired";
    };
    class VTE_Plane
    {
        VTE_Plane_Fired="_this exec ""\VTE_config\scripts\events\firedEH.sqs""";
    };
};
We'll use a new XEH init event handler to load the fired EH function. This is accomplished by adding an Extended_Init_EventHandlers class to the config:

Code: Select all

class Extended_Init_EventHandlers
{
    class VTE_Man
    {
        VTE_Man_Init="if(isNil""VTE_ManFired"")then{VTE_ManFired=compile preprocessFile""\VTE_config\scripts\events\man_fired.sqf""}";
    };
};

Return to “Vietnam: The Experience (ArmA)”

Who is online

Users browsing this forum: No registered users and 0 guests