Jump to content
Sign in to follow this  
Freghar

Execute code on any Eden object placement?

Recommended Posts

Hello,

I know there are Eden EventHandlers, https://community.bistudio.com/wiki/Arma_3:_Event_Handlers:_Eden_Editor , but they oddly seem to be missing the most basic EH I would think of - placing an object (unit). The page mentions "Object Event Handlers" and even the text for RegisteredToWorld3DEN seems promising, but I don't know how to add it to a non-existent object (which hasn't yet been placed) and passing RegisteredToWorld3DEN to add3DENEventHandler doesn't seem to do anything.

 

Does anybody know how to execute a piece of code when (any) object/unit is placed in Eden, without having the object beforehand?

 

Thanks.

Share this post


Link to post
Share on other sites

You can use the regular init eventhandler and then check for is3DEN in the init script.

 

Example of the Nimitz:

config.cpp

                class EventHandlers {
                        init = "_this call TTT_nimitz_fnc_init";
                };

init.sqf

params[["_nimitz", ObjNull]];

...

if(is3DEN) then
{
        _nimitz call TTT_nimitz_fnc_edenInit;
}
else
{
        _nimitz call TTT_nimitz_fnc_defaultInit;
};

 

Share this post


Link to post
Share on other sites

I know, that's how ie. Module_F does it (the second parameter the engine passes to init EH can apparently be ie. "init" or "attributesChanged3DEN" or "registeredToWorld3DEN", etc.), however that would still mean I need to modify each and every unit in each and every mod I use, adding my init EH everywhere.

 

Is there really no way to do this without adding tens of thousands of EHs?

Share this post


Link to post
Share on other sites

My current workaround is hooking onSelectionChange and setting a custom variable on each "processed" unit, ignoring them on next selection change. A global variable (list) would be more efficient, but it doesn't get reset on ie. loading a scenario, starting a new scenario, etc., so per-object variables are safer. The only downside is that on a scenario load, any first selection processes all units all over again - this is fine for my use case, but might be unwanted for others.

 

Still, it would be great if there was an easier way (without using CBA XEHs, etc.).

Share this post


Link to post
Share on other sites
class CfgVehicles {
    class All {
        class EventHandlers {
            class someClass {
                init = "diag_log format ['thing created: %1',_this]";
            };
        };
    };
};

 

Spoiler

 0:52:26 "thing created: [52cbe400# 164040: camonet_big_f.p3d]"
 0:52:29 "thing created: [52cbdd00# 164041: camonet_big_f.p3d]"
 0:52:29 "thing created: [52d74100# 164045: mobilephone_old_f.p3d]"
 0:52:29 "thing created: [52d1e400# 164046: laptop_unfolded_f.p3d]"
 0:52:29 "thing created: [52d1c800# 164047: bagfence_long_f.p3d]"
 0:52:29 "thing created: [52d1c100# 164048: bagfence_long_f.p3d]"
 0:52:29 "thing created: [52d7b900# 164049: bagfence_long_f.p3d]"
 0:52:29 "thing created: [52d7ab00# 164050: floodlight_f.p3d]"
 0:52:29 "thing created: [52cff200# 164051: gastank_01_blue_f.p3d]"
 0:52:29 "thing created: [52cfb900# 164053: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [52cf8f00# 164054: camonet_open_f.p3d]"
 0:52:29 "thing created: [52cf8800# 164055: metalbarrel_f.p3d]"
 0:52:29 "thing created: [52cf8100# 164056: metalbarrel_f.p3d]"
 0:52:29 "thing created: [52d43900# 164057: metalbarrel_f.p3d]"
 0:52:29 "thing created: [52d41600# 164058: watertank_f.p3d]"
 0:52:29 "thing created: [8538c800# 164090: waterpump_01_f.p3d]"
 0:52:29 "thing created: [8537f900# 164091: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [8537f200# 164092: campingtable_f.p3d]"
 0:52:29 "thing created: [8537eb00# 164093: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [8536dd00# 164094: mapboard_f.p3d]"
 0:52:29 "thing created: [85366b00# 164095: metalcase_01_large_f.p3d]"
 0:52:29 "thing created: [85366400# 164096: cncbarrier_f.p3d]"
 0:52:29 "thing created: [85365d00# 164097: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [85365600# 164098: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [85364f00# 164099: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [85364800# 164100: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [85364100# 164101: cncbarrier_f.p3d]"
 0:52:29 "thing created: [8536b900# 164102: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [8536b200# 164103: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [8536ab00# 164104: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [8536a400# 164105: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [85369d00# 164106: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [85369600# 164107: hbarrier_5_f.p3d]"
 0:52:29 "thing created: [85343900# 164108: bagbunker_tower_f.p3d]"
 0:52:29 "thing created: [85343200# 164109: hbarrier_5_f.p3d]"

 

 

You probably need to do it with some base classes as well (like camanbase and air for ex)  idk, you'll have to experiment, but it's quicker to use inheritance and your own EH classes than making an EH for each class in the game...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×