How to scan for only specific entities?

Posted By: June

How to scan for only specific entities? - 03/11/18 06:37

How do you scan for only specific entities?

This is for an exploding barrel code. Any barrel near an exploding one explodes too.

I added a c_scan instruction to the explosion sprite:
Code:
c_scan(my.x,my.pan,vector(150,150,150),SCAN_ENTS | SCAN_LIMIT );



And a scan event for the barrel:

Code:
if (event_type == EVENT_SCAN)
{
wait(-0.15);
set(my,INVISIBLE);
ent_create (expl1_tga, my.x, fire_blast); 
effect(particle_explo, 9, my.x, vector(0, 0, -100));
effect(particle_explosm, 40, my.x, vector(0, 0,0));
ent_create (smoke_tga, my.x, smokeballs);
ent_create (floor_scorch, my.x, floor_burn);
...........



And it works perfectly. The only problem is that when the player walks near the barrels they explode because the player has ENABLE_SCAN applied.

How do you make it so that the barrel only reacts to other explosions and not the player too?

Code:
action oil_barrel()
{
set (my, METAL | POLYGON);
my.emask |= (ENABLE_SHOOT | ENABLE_SCAN );
my.event = oilexplosion_event;
}

Posted By: Superku

Re: How to scan for only specific entities? - 03/11/18 08:01

Code:
var scan_indicator = 0;
#define SCAN_PLAYER 1
#define SCAN_EXPLOSION 2
...
scan_indicator = SCAN_EXPLOSION;
c_scan(my.x,my.pan,vector(150,150,150),SCAN_ENTS | SCAN_LIMIT );
...
if (event_type == EVENT_SCAN && scan_indicator == SCAN_EXPLOSION)

Posted By: 3run

Re: How to scan for only specific entities? - 03/11/18 09:27

Hi!

I would do different kind of types for entities, like this:
Code:
#define obj_type skill40
#define obj_none 0
#define obj_player 1
#define obj_barrel 2


And then in the event (of the barrel, that got scaned), I would check for it via 'you' pointer, like this:
Code:
if(you.obj_type == obj_player){ return; } // terminate the event
if(you.obj_type == obj_barrel){

       EXPLOSION HERE!

}



Best regards!
Posted By: Dooley

Re: How to scan for only specific entities? - 03/11/18 20:38

Assign each type of object to a different group.

Quote:
my.group = 2;



Then when you scan you can use c_ignore to designate the groups you do not want to scan.

Quote:
c_ignore(1,3,4,5,6,0);


This will ignore all groups except group 2 for instance.
Posted By: June

Re: How to scan for only specific entities? - 03/12/18 05:10

Its good to know there are many ways of going about the same thing. I will figure out which is the best option in good time.

Thank you guys for the advice, it is always helpful.
Posted By: Superku

Re: How to scan for only specific entities? - 03/12/18 09:15

Never thought about using c_ignore with c_scan as well, interesting.
Posted By: Dooley

Re: How to scan for only specific entities? - 03/12/18 20:55

Originally Posted By: Superku
Never thought about using c_ignore with c_scan as well, interesting.


You know, I have been using this, but it's actually not perfect. Sometimes it's hard to scan the things I want when other things are in the way ... maybe I'm doing it wrong.
© 2024 lite-C Forums