Forum

Flashlights in darkplaces

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Flashlights in darkplaces

Postby Nahuel » Thu Feb 17, 2011 2:36 am

Hi all, I tried to use the in flashlight Darkplaces (which uses the cubemaps)
with this code written by Nash

// flashlight code

// player flashlight state
.float flashlight_state;

.entity flashlight;

void() flashlight_think =
{
if (self.owner.health > 0)
{
//setorigin(self, self.owner.origin + (self.owner.view_ofs - '0 0 16'));
makevectors (self.owner.v_angle);
traceline (self.owner.origin, (self.owner.origin + (v_forward * 32)), FALSE, self);
setorigin(self, trace_endpos + (v_forward * -16) + (self.owner.view_ofs - '0 0 8'));
self.angles = self.owner.v_angle;
self.angles_x = self.angles_x * -1;
self.nextthink = time;
}
};

void() player_flashlight =
{
local entity newflashlight;
newflashlight = spawn();
newflashlight.pflags = PFLAGS_FULLDYNAMIC;
newflashlight.light_lev = 1024;
newflashlight.color = '2 2 2';
newflashlight.skin = 200;
newflashlight.owner = self;
self.flashlight = newflashlight;
newflashlight.think = flashlight_think;
newflashlight.nextthink = time;
};

void () player_flashlight_toggle =
{
if (self.flashlight_state == FALSE)
{
self.flashlight_state = TRUE;
player_flashlight();
}
else
{
self.flashlight_state = FALSE;
self.flashlight.think = SUB_Remove;
self.flashlight.nextthink = time;
}
};

The flashlight in question does not work properly and worst of all, it has some odd angles and seem reversed. also the flashlight blinks too and it seems off when I shoot a gun.; Is there another way to create a good flashlight that works with cubemaps and other light options of tenebrae and Darkplaces?
thank you very much
Last edited by Nahuel on Thu Feb 17, 2011 7:56 pm, edited 1 time in total.
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: Flashlights in darkplaces

Postby Sajt » Thu Feb 17, 2011 3:30 am

The "blinking" (including when shooting) is probably your own shadow is getting in the way. It sort of looks like your code is supposed to handle that, but what you posted obviously isn't the exact code you're using because it won't even compile.

Nahuel wrote:makevectors (self.owner.v_angle)
traceline (self.owner.origin (self.owner.origin + (v_forward * 32)), FALSE, self);
setorigin (self, trace_endpos + (v_forward * -16) + (self.owner.view_ofs - '0 0 8 '));


Also, a minor note: not sure if it affects anything, but correctly the last argument to traceline should be "self.owner", not "self".
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Re: Flashlights in darkplaces

Postby Nahuel » Thu Feb 17, 2011 7:54 pm

Sajt wrote:The "blinking" (including when shooting) is probably your own shadow is getting in the way. It sort of looks like your code is supposed to handle that, but what you posted obviously isn't the exact code you're using because it won't even compile.

Nahuel wrote:makevectors (self.owner.v_angle)
traceline (self.owner.origin (self.owner.origin + (v_forward * 32)), FALSE, self);
setorigin (self, trace_endpos + (v_forward * -16) + (self.owner.view_ofs - '0 0 8 '));


Also, a minor note: not sure if it affects anything, but correctly the last argument to traceline should be "self.owner", not "self".

I do not know how it happened that strange error in the copy of the code. The first line should be
.float flashlight_state;
no
. Flashlight_state float;
I will correct the code.
is really weird, but I think my mouse betrayed me.:oops: :oops: :oops:
Well I tried putting alpha to the player to not cast shadows and the DP_EF_NOSHADOW but the light still goes out when I shoot, I think that this is not the shadow of the player.
here is the original source if this light would work well (with the correct angles) would be really awesome.
the original code is in
http://forums.inside3d.com/viewtopic.php?t=820&highlight=flashlight
Greetings
PS: I tested with the "self.owner"and the quake guy looked like a possessed.Image
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest