#define ent_id skill90
#define id_dog 1000
#define id_cat 1001
//#define id_snake 1002 // and so on...
void do_bark() { ...snd_play (snd_bark, 50, 0);... }
void do_miau() { ...snd_play (snd_miau, 50, 0);... }
action Dog_WED(){
ent2 = me; // please try to avoid using such global entity pointers, if possible
my.ent_id = id_dog;
//my.emask |= ENABLE_FRICTION;
}
action Cat_WED(){
ent3 = me;
my.ent_id = id_cat;
//my.emask |= ENABLE_FRICTION;
}
/*
Or instead of using a action for every ent (animals in my example) you can combine it in one WED action.
Skill will be masked in WED as "AnimalNr". 0/1 = dog 2 = cat
Same you can do with do_bark and do_miau...fex: void do_animalsound (var sndnr){ if (sndnr==1){}}
*/
//skill1 AnimalNr 0
action Animal_WED(){
if (my.skill1 <= 1){
//ent2=me;
my.ent_id = id_dog;
}
if (my.skill1 >= 2){
//ent3=me;
my.ent_id = id_cat;
}
}
void testevent(){
if (event_type == EVENT_FRICTION){ // ent1(me) hit another activated entity(you)? which one?
if (you){ // if (you == ent2)
if (you.ent_id == id_dog){ // ent1 hit ent2? (when not using global pointers this will also work for more than one(ent2) dog-ents btw)
do_bark();
} // if (you == ent3)
if (you.ent_id == id_cat){ // ent1 hit ent3?
do_miau();
}
}
}
}
...
...
pXent_setcollisionflag (ent1, ent2, NX_NOTIFY_ON_START_TOUCH); // activate coll between ent1 and ent2 / dog (ent1 or better "my" instead?)
pXent_setcollisionflag (ent1, ent3, NX_NOTIFY_ON_START_TOUCH); // activate coll between ent1 and ent3 / cat
...
...
//ent1.emask |= ENABLE_FRICTION; // ent1 or better "my" instead?
ent1.event = testevent; // ent1 handles collision event: hit a dog(ent2)? then bark! hit a cat(ent3)? miau!