I made a flashlight!
Moderator: InsideQC Admins
22 posts
• Page 2 of 2 • 1, 2
Hi Sajt,
Thanks for your reply. I am VERY new to QuakeC and programming in general.
However, after taking your code and guessing how to do stuff, I managed to get the new flashlight to work.
However, I stumbled upon two problems:
1) The player's shadow is casting everywhere.
2) The world isn't casting shadows (walls, map geometry, monsters, etc).
Here's my flashlight.qc:
What am I doing wrong?
(201 is a cubemap which I "borrowed" from Frika's horror speedmod because I needed some graphics to work with real quick. Hope you don't mind, Frika :oops: )
Thanks for your reply. I am VERY new to QuakeC and programming in general.
However, after taking your code and guessing how to do stuff, I managed to get the new flashlight to work.
However, I stumbled upon two problems:
1) The player's shadow is casting everywhere.
2) The world isn't casting shadows (walls, map geometry, monsters, etc).
Here's my flashlight.qc:
- Code: Select all
// flashlight code
.entity flashlight;
void() flashlight_think =
{
setorigin(self, self.owner.origin + self.owner.view_ofs);
self.angles = self.owner.v_angle;
self.angles_x = self.angles_x * -1;
self.nextthink = time;
};
void() player_flashlight =
{
local entity newflash;
newflash = spawn();
newflash.pflags = PFLAGS_FULLDYNAMIC;
newflash.light_lev = 720;
newflash.color = '2.2 2.2 1.6';
newflash.skin = 201;
newflash.owner = self;
self.flashlight = newflash;
newflash.think = flashlight_think;
newflash.nextthink = time;
};
void(float flashstate) flashlight_state =
{
player_flashlight();
};
What am I doing wrong?
(201 is a cubemap which I "borrowed" from Frika's horror speedmod because I needed some graphics to work with real quick. Hope you don't mind, Frika :oops: )
-

Nash - Posts: 95
- Joined: Fri Oct 19, 2007 5:56 pm
- Location: Kuala Lumpur, Malaysia
The player shadow is really annoying... I'm not really sure how to fix it
You could give the player an EF_NOSHADOW (I think) flag but that disables shadows from other lights as well... There might be a method to fix this in DarkPlaces but I'm not aware of it.
As for the world not casting shadows, remember that the light is coming from your viewpoint, so the shadows are behind all the objects. Try turning on chase_active, you should be able to see shadows then.
As for the world not casting shadows, remember that the light is coming from your viewpoint, so the shadows are behind all the objects. Try turning on chase_active, you should be able to see shadows then.
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
Regarding the player shadows... I guess my mod doesn't really need it (it's a single player-only mod), so I just used cl_noplayershadow 1.
As for the world and entity shadows not showing up... you're right. Just had to fiddle around with the offsets to get the shadows to appear the way I want them to.
Please excuse the ugly coding. I'm pretty much a programming n00b, I'm struggling to understand a lot of the stuff I'm doing here with QuakeC. I hate copy + pasting stuff I don't understand but I *think* I know what I'm doing here.
As for the world and entity shadows not showing up... you're right. Just had to fiddle around with the offsets to get the shadows to appear the way I want them to.
- Code: Select all
// flashlight code
// player flashlight state
.float flashlight_state;
.entity flashlight;
void() flashlight_think =
{
makevectors (self.owner.v_angle);
traceline (self.owner.origin , (self.owner.origin + (v_forward * 64)) , FALSE, self);
setorigin(self, trace_endpos + (v_forward * -64));
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 = 800;
newflashlight.color = '1.5 1.5 1.5';
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;
}
};
Please excuse the ugly coding. I'm pretty much a programming n00b, I'm struggling to understand a lot of the stuff I'm doing here with QuakeC. I hate copy + pasting stuff I don't understand but I *think* I know what I'm doing here.
-

Nash - Posts: 95
- Joined: Fri Oct 19, 2007 5:56 pm
- Location: Kuala Lumpur, Malaysia
Nah you don't want to do it quite like that.
Change the setorigin line to something more along the lines of
setorigin(self, trace_endpos + v_forward * -4);
or something small like that. Otherwise when you go up to a wall the flashlight is coming from way behind you (and behind a wall if there is a wall behind you).
I would skip the traceline though. The fact that you are now sourcing it from 'self.owner.origin', not 'self.owner.origin + self.owner.view_ofs' is probably enough to get satisfying visible shadows.
Change the setorigin line to something more along the lines of
setorigin(self, trace_endpos + v_forward * -4);
or something small like that. Otherwise when you go up to a wall the flashlight is coming from way behind you (and behind a wall if there is a wall behind you).
I would skip the traceline though. The fact that you are now sourcing it from 'self.owner.origin', not 'self.owner.origin + self.owner.view_ofs' is probably enough to get satisfying visible shadows.
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
Flashlight can be found here now,
http://renegadec.digitalfunk.org/Quake%20Mods/
Thanks for the interest.
http://renegadec.digitalfunk.org/Quake%20Mods/
Thanks for the interest.
-

RenegadeC - Posts: 391
- Joined: Fri Oct 15, 2004 10:19 pm
- Location: The freezing hell; Canada
22 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest