Everything in the event-impact block will be handeled on event_impact no matter what entity triggered it. You have to take care for it by yourself.
Maybe something like this (
sry if i missunderstood your question):
void testevent(){
// --- do every frame
if (event_type == EVENT_FRAME){
//nothing here right now, just wanted to show how to react on different types in one event
//c_move/ent_animate what ever
}
// --- handle scan events (use SCAN_ENTS[!] to trigger via c_scan)
//if (event_type == EVENT_SCAN){
//if (you) if (you.ent_id == id_explosion) do_booooom_me_in_the_air_now();
//}
// --- finally handle the impact event
if (event_type == EVENT_IMPACT){ // handle impacts with ALL ents
if (you) {
//if (you == ent2){
//pXent_setcollisionflag (me, ent2, NX_NOTIFY_ON_START_TOUCH); // if me == ent1 dont know right now...
//}
//if (you == ent3){
//pXent_setcollisionflag (me, ent3, NX_NOTIFY_ON_START_TOUCH);
//}
pXent_setcollisionflag (me, you, NX_NOTIFY_ON_START_TOUCH); // or maybe only this if ent1=me and you(impacting ent) unknown...
}
}
}
action Test_WED(){
//ent1 = me; // ???
my.emask |= ENABLE_FRAME|ENABLE_IMPACT; // |ENABLE_SCAN;
my.event = testevent;
}
Hope this shows the logic behind. Normally you use one event only / ent.
Something like an "id"-skill can helpsto identify different ent-types in events, scans, traces or whatever. Example:
#define ent_id skill90 // i would not use skill1-10 because you often use them in WED to input unique values for some ents placed in the map.
#define id_dog 1000
action Dog_WED(){
my.ent_id = id_dog;
...
}
...
if (you) if (you.ent_id == id_dog) do_bark();
...
Greetsedit:
tip besides...
try to use as few as possible global entity pointers (+always check them before using, make sure not using them while a level loads and so on)!When your project grows, something like this may be hard to track down later (interaction between different entitys causing handle errors etc).
For myself i use a global var called level_loading. Events and other stuff do something like this:
if (event_type == EVENT_FRAME && !level_loading && !freeze_mode){
...
}
This way iam sure no empty pointers causing problems when switching the level for example. A good example is a global player entity pointer. Maybe he dies and you simply want to respawn him. While respawning you must take care that no other entity is using the player-pointer cause it might be empty for a frame or more. Such errors might feel like a "random" first.
Another info: If you remove me entity (safe_remove, ptr_remove) in any of the event-type-blocks, make sure to jump out fex via
return; cause next thing in the event block will try to use the removed me pointer which may lead to a crash pretty sure cause its empty now.
Btw...
Just wondering is event impact triggered from physic collisions? My guess right now is not, only from ent to ent. Not sure yet...have enough own problems to solve