Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 855 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Shootable lamp entity with flare #471452
03/05/18 03:34
03/05/18 03:34
Joined: Feb 2005
Posts: 67
USA
June Offline OP
Junior Member
June  Offline OP
Junior Member

Joined: Feb 2005
Posts: 67
USA
This is an in-progress code for a light emitting lamp entity that turns off when shot (from a weapon that uses c_trace).

It works as intended except that the flare isn't removed when the lamp is shot.

This might be a simple mistake I'm making (noob coding). Can anyone see the problem?



var lamplife = 1; // Lamp is lit when at 1

function lampshot_event()// If shot, things happen
{

if (event_type == EVENT_SHOOT)
{
lamplife = 0; // lamp is dead, trigger to remove flare
my.ambient = 50;
my.lightrange = 0;
//add sound, sparks, glass particles
}
}


function lamp_light1_flr()//Lamp flare model

{
set (my, TRANSLUCENT);
set (my, PASSABLE);
set (my, BRIGHT);
my.alpha = 15;
my.ambient = 100;
vec_set(my.pan, your.pan);
vec_set(my.x, vector(0, 0, 0)); //Position at lamp
vec_for_ent(my.x, you); // World coordinates

if (lamplife == 0)//Remove the flare when lamp is shot
{
wait(1);
ent_remove (my);
}
}

action lamp_light1() // Round, shootable lamp
{
my.emask = ENABLE_SHOOT;
my.event = lampshot_event;

set (my, TRANSLUCENT);
my.ambient = 100;
my.alpha = 95;

set(my,LIGHT);
my.lightrange = 155;
my.red = 100;
my.blue = 100;
my.green = 100;

//Create flare mdl
ent_create ("lmp_round01_flr.mdl", my.x, lamp_light1_flr);

}

Last edited by June; 03/05/18 04:31.

June
smooth-3d.com
Re: Shootable lamp entity with flare [Re: June] #471453
03/05/18 08:20
03/05/18 08:20
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 681
Germany
I think, you don t Need an Event in this case.
Just ask, if the you Pointer is "lamp" and remove.


Btw.

Code:
set (my, TRANSLUCENT);
set (my, PASSABLE); 
set (my, BRIGHT); 

set (my, TRANSLUCENT|PASSABLE|BRIGHT);


Last edited by Ayumi; 03/05/18 08:20.
Re: Shootable lamp entity with flare [Re: Ayumi] #471485
03/06/18 06:25
03/06/18 06:25
Joined: Feb 2005
Posts: 67
USA
June Offline OP
Junior Member
June  Offline OP
Junior Member

Joined: Feb 2005
Posts: 67
USA
I tried the code without the event as a separate function and included in the action instead but it does not work.

I don't want to remove the lamp itself, just the flare. I know there is a way to do it but my understanding of pointers is limited.

Thanks for the tip, I didn't know you could combine settings into one line. That should clean up future code quite nicely.


June
smooth-3d.com
Re: Shootable lamp entity with flare [Re: June] #471499
03/06/18 18:09
03/06/18 18:09
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 681
Germany
I am not 100% about the Skill Casting, but i am sure , it s possible.
Code not tested, just try...

Code:
#define EntGroup skill1

#define TypeLampFlare 1
#define TypeLamp 2


action Lamp()
{
	// ... set Lamp settings
	my.EntGroup= TypeLamp;
	my.skill3 = ent_create("LampFlare.mdl", vector, DoSomthing);
	
}

void Shoot()
{
	VECTOR vecShot;
	
   			   			   
   vec_set(vecShot, vector(1, 1, 1));	
   vec_rotate(vecShot, camera.pan);
	vec_add(vecShot, camera.x);
//   c_ignore(2,3,0);	      	      
   c_trace(camera.x, vecShot, IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES|SCAN_TEXTURE);			   	   
	
   if(TARGTE_HIT)
   {
      if(you.EntGroup == TypeLamp)
      { 
         if(you.skill3 != NULL)
       	 {
            ENTITY* ent = (ENTITY*)you.skill3;
            ptr_remove(ent);
         }
      }
   }		
}


Last edited by Ayumi; 03/07/18 08:20.
Re: Shootable lamp entity with flare [Re: Ayumi] #471510
03/07/18 02:55
03/07/18 02:55
Joined: Feb 2005
Posts: 67
USA
June Offline OP
Junior Member
June  Offline OP
Junior Member

Joined: Feb 2005
Posts: 67
USA
Thank you for taking the time to write this out, Ayumi. I will do some testing and see what happens.


June
smooth-3d.com

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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