Inside3D!
     

I made a flashlight!
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
Nash



Joined: 19 Oct 2007
Posts: 95
Location: Kuala Lumpur, Malaysia

PostPosted: Fri Oct 19, 2007 7:09 pm    Post subject: Reply with quote

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:

Code:

// 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: )
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Sajt



Joined: 16 Oct 2004
Posts: 1027

PostPosted: Fri Oct 19, 2007 9:03 pm    Post subject: Reply with quote

The player shadow is really annoying... I'm not really sure how to fix it Sad 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.
_________________
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.
Back to top
View user's profile Send private message
Nash



Joined: 19 Oct 2007
Posts: 95
Location: Kuala Lumpur, Malaysia

PostPosted: Fri Oct 19, 2007 9:19 pm    Post subject: Reply with quote

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.

Code:

// 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.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Sajt



Joined: 16 Oct 2004
Posts: 1027

PostPosted: Fri Oct 19, 2007 11:10 pm    Post subject: Reply with quote

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.
_________________
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.
Back to top
View user's profile Send private message
Nash



Joined: 19 Oct 2007
Posts: 95
Location: Kuala Lumpur, Malaysia

PostPosted: Sat Oct 20, 2007 3:20 pm    Post subject: Reply with quote

Thanks for the tips, Sajt. :)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
RenegadeC



Joined: 15 Oct 2004
Posts: 370
Location: The freezing hell; Canada

PostPosted: Tue Oct 23, 2007 5:24 am    Post subject: Reply with quote

Flashlight can be found here now,
http://renegadec.digitalfunk.org/Quake%20Mods/

Thanks for the interest.
Back to top
View user's profile Send private message AIM Address MSN Messenger
Nash



Joined: 19 Oct 2007
Posts: 95
Location: Kuala Lumpur, Malaysia

PostPosted: Wed Oct 24, 2007 10:44 am    Post subject: Reply with quote

Thanks. And what a surprise, Envenom's on it too! I've been looking for it for quite a while. :)
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> General Discussion All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group