[DP] Bumpy movement problem

Discuss programming in the QuakeC language.
Post Reply
Nash
Posts: 95
Joined: Fri Oct 19, 2007 5:56 pm
Location: Kuala Lumpur, Malaysia
Contact:

[DP] Bumpy movement problem

Post by Nash »

I'm new to QuakeC, so to teach myself the language, I decided to go for something simple first... like making a Doom 3-style cubemap flashlight (let's not get into the "flashlight sux" argument; the mod this is intended for will have nothing to do with Quake anyway).

But I notice that when the player moves up stairs, the flashlight bumps up and down really hard, like as if it's not keeping up with the player's movement.

Is there a way to interpolate the flashlight's position just like how the player's view is interpolated as he moves up and down?

Code: Select all

// 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;
		}
	};
My second problem is also related to the above; I notice corpses and gibs and stuff like that have very jerky movement when they are placed on lifts (it's easy to see if you kill the grunt in the first lift in E1M1). Is there any way to fix that, too?

Thanks.
FrikaC
Site Admin
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Post by FrikaC »

I'm new to QuakeC, so to teach myself the language, I decided to go for something simple first... like making a Doom 3-style cubemap flashlight.
You need to re-evaluate what something simple is.
Chris
Posts: 79
Joined: Sat Aug 05, 2006 5:31 am

Post by Chris »

For keeping up with the player it may be because you have

self.nextthink = time;

which in actuality isn't the fastest possible run through that code.

Workarounds would be akin to you "attach light to entity out in front " simply make an entity, tag it to (player origin / nonexistant tag on player), offset it forward on the player, and give it the light effects you desire.

see: SetAttachment function in dpextensions.qc

Also possibly moving the light closer to player kind of changes the illusion. You could lower light_lev and set it to v_forward by 10 units.
Nash
Posts: 95
Joined: Fri Oct 19, 2007 5:56 pm
Location: Kuala Lumpur, Malaysia
Contact:

Post by Nash »

But I thought setattachment won't draw the attachment in first persion view if it's attached to the player?
ajay
Posts: 559
Joined: Fri Oct 29, 2004 6:44 am
Location: Swindon, UK

Post by ajay »

Nash; ok if I use this in my own mod?
cheers
skite2001
Posts: 17
Joined: Mon Nov 17, 2008 5:40 pm

Post by skite2001 »

is there a new "updated" code out there maybe?
if i use this code on my mod with darkplaces, the complete screen got brighter instead of only a "light-stripe" as seen on doom3 flashlight.
seems actually that "http://www.inside3d.com/qctut/qctut-8.shtml" looks better, if there is no fix for this
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

the code above uses a cubemap for the light effect.
if you provide only the code and not the cubemap then you get a uniform light that shines in all directions and not just infront.
Post Reply