Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 396 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
pXent_setcollisionflag #484565
11/12/21 04:23
11/12/21 04:23
Joined: Feb 2010
Posts: 8
P
Power_P Offline OP
Newbie
Power_P  Offline OP
Newbie
P

Joined: Feb 2010
Posts: 8
Hello...

... if I use the following code, the event works correctly.


pXent_setcollisionflag (ent1, ent2, NX_NOTIFY_ON_START_TOUCH)
ent.event = EventImpact1;


But if I add another collision event, the bottom event is triggered in both cases.


pXent_setcollisionflag (ent1, ent2, NX_NOTIFY_ON_START_TOUCH)
ent.event = EventImpact1;

pXent_setcollisionflag (ent1, ent3, NX_NOTIFY_ON_START_TOUCH)
ent.event = EventImpact2;


What can I do so that only the corresponding event is triggered?

Thanks...

Re: pXent_setcollisionflag [Re: Power_P] #484569
11/12/21 13:07
11/12/21 13:07
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
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):
Code
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:
Code
#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();
...


Greets



edit:
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:
Code
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 laugh


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: pXent_setcollisionflag [Re: Power_P] #484576
11/13/21 17:52
11/13/21 17:52
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Code
#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!
Something like this will do the trick. Activate coll between ents. In event type friction react on it and check what type of entity it was.
I never used this command before thats why i made an example about event impact. Anyway it does not change much how to handle this as u can see.

And like i already said please try to do this without global entity pointers like ent1, ent2 and ent3. My example event shows you wont need them most times.
Lets say you make a FPS. Ideally you have something like two global entity pointers. A player and a gun laugh. Of course you end up with more for sure, i just want to point out that you can do 90% without those unique ENTITY*'s



Good luck.
Greets


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: pXent_setcollisionflag [Re: rayp] #484612
11/19/21 08:49
11/19/21 08:49
Joined: Feb 2010
Posts: 8
P
Power_P Offline OP
Newbie
Power_P  Offline OP
Newbie
P

Joined: Feb 2010
Posts: 8
Da du deinem Profil nach aus Deutschland kommst, anworte ich auf deutsch. smile

Danke für die umfangreiche Antwort. Ich werde mich mit dem EVENT Thema nochmal intensiver beschäftigen.

Re: pXent_setcollisionflag [Re: Power_P] #484614
11/19/21 18:18
11/19/21 18:18
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Gerne und viel Erfolg.


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1