Author: Solus
Author Website:

Requirements: No addons required

Version: 1.26
Signed: Yes

Short description:
Date: 2007-12-28 20:58
Submitted by: Solus


Comments: (0)
Rating:



 

Extended Init Event Handler
by
Solus


Description:
    Init Eventhandler: This addon allows a virtually infinite amount of init event handlers to be used together from different addons. The event handlers are executed for the matching class and all inheriting classes. The event handler init line also contains the extended event handler class to look for, so you can have a custom inheritance for custom units. There are two example addons included to demonstrate how to assign new event handlers and the event handler inheritance. The example pbos should not be installed except for testing.

    Normally event handlers can only be added in configs, and trying to add a new event handler caused all previous event handlers to be overwritten, this addon allows that limitation to be overcome. This is mostly useful for having addons that can add different functionality, for example in OFP addons that had their own event handlers wouldn't inherit default event handlers, such as a custom unit with EHs being used with ECP or FFUR wouldn't have the ECP or FFUR effects.

    Fired Eventhandler:
    This addon allows a virtually infinite amount of fired event handlers to be used together from different addons. The Extended Init Event Handlers addon must be installed to use this addon.

    The extended fired event handler has several different parts:

    First the extended init EH is run for all units to add together and compile all of the inherited fired event handlers and use setVariable to attach those to the unit. Also the Extended_FiredEH_ShotInfo function is compiled at init, so that it can be quickly called during the fired event game state cycle to capture info about the shot, such as the position, direction, speed, etc.

    The extended fired event handler is added to Extended_EventHandlers so that all of the cfgVehicles class EventHandlers inherit it. When a unit fires and sets off the event handler the shot is immediately captured in the same game state cycle and the Extended_FiredEH_ShotInfo function is run to catch the shot's info. Then the compiled extended fired events are called by using getVariable to retrieve them from the unit, but this takes until another game state cycle before the extended scripts/functions are able to run so they can't catch the shot's info before it moves away, which is why the ShotInfo function is needed.

    The Extended_FiredEH_ShotInfo function can be modified to get more info about the shot but it shouldn't be changed in any way that can break addons made for previous versions by rearranging the info or something. The fired event handler init line contains the extended event handler class to look for, so you can have a custom inheritance for custom units. The event handlers are executed for the matching class and all inheriting classes.

    There is an example addon included to demonstrate how to assign new fired event handlers and the event handler inheritance. The example pbo should not be installed except for testing.

    Normally event handlers can only be added in configs, and trying to add a new event handler caused all previous event handlers to be overwritten, this addon allows that limitation to be overcome. This is mostly useful for having addons that can add different functionality, for example in OFP addons that had their own event handlers wouldn't inherit default event handlers, such as a custom unit with EHs being used with ECP or FFUR wouldn't have the ECP or FFUR effects.

    The extended fired event handler allows more fired events to be used together, for example a script that makes shots affected by wind and a tracer script could be used together.

    Note:
    The ShotInfo function has been removed, since it's possible to run precompiled functions from the extended fired EH. You can quickly get your own data about the shot's start state using your own function defined in the init then run from the extended fired EH. However having too many of these quick data collecting functions for each EH script might slow things down so it might be better to readd the default shotinfo function to get data for most scripts to use.

    It might be useful for someone to make another addon that makes the shotinfo function that's still included in the fired EH .pbo get compiled at init and run by the extended fired EH, so that other extended fired EH addons can use the data without needing their own info gathering script to run. The only problem might be the order that the extended fired EventHandlers are run in but that should be easy to figure out and fix. The included example addon has an example of a function that is compiled with the extended init event handler and called by the extended fired EH so that the shot's info can be collected and used before the shot moves away.
Included files:
extended_init_eventhandlers.pbo
extended_fired_eventhandlers.pbo


Key:
This is a signed addon. Server admins can download the key from here.


Version:
v1.25
Fixed signature files and added bikey.

v1.2
Changed the ExecVM to call compile, thanks to UNN.
Added LCD's fix, thanks for finding that!
Added signature files.

v1.1
Fixed people in vehicles having no inits.
Included SightAdjustment example "bridge" addon that allows the GMJ_SightAdjustment addon to be used with other extended init event handler addons.

v1.0
- Initial Release


Forum topic:
- BIS




Download from FTP #1:
Extended Init Event Handler
Download from FTP #2:
Extended Init Event Handler
Download from FTP #3:
Size : 1 MB   Downloaded : 8425 times     Report broken download link



Tags: No tags