The 'Bare Handed player' saga

Discuss programming in the QuakeC language.
Post Reply
OneManClan
Posts: 247
Joined: Sat Feb 28, 2009 2:38 pm
Contact:

The 'Bare Handed player' saga

Post by OneManClan »

[DISCLAIMER: Normally I try to post easy-to-read, simplified examples (using foo bar etc) to get to the 'core' of a QuakeC problem, omitting irrelevant details, but the issue in this thread this has been a very complex puzzle for me to solve, so I AM putting some specific details, not because I expect anyone to solve it for me, but because (a) printing the issue in public (and hence needing to describe it correctly) forces me to think straight, and (b) there might have been something stupid/obvious I've missed, or even (c) a simpler solution which involves scrapping existing pre-VWEP 'legacy' (CustomTF) methods and rewriting new ones, so please feel free to ignore this (long) post, unless you're particularly interested in VWEPS, or making a 'bare handed' player. I'll be editing this post as I reread it and find better, and clearer way to describe the situation]

Hi all,

This bug/irregularity has been a saga, and in spite of help from both Xavior and Trickle, I've FAILED to resolve it.

OBJECTIVE
To be able to show players with 'empty hands', ie no weapons.


BACKGROUND INFO
The AGR mod is based on 'Classic' CustomTF (circa 2000), which used a custom server called cpqwsv. The AGR version has been successfully ported (thanks to the Gurus) to FTE. There are lots of 'legacy' team/colour/skin stuff in there I haven't changed, most I haven't even looked at, and frankly am not sure how they work, or even if they are relevant to this issue. VWEPS have been installed (details below) and are otherwise working great.


CURERENT VWEP IMPLEMENTATION
In world.qc we load the VWEPS (standard VWEP practice):

Code: Select all

precache_vwep_model ( );
In weapon.qc we sets the VWEP depending on self.current_weapon. Normally VWEP uses self.weaponmodel, but in CustomTF some weapons (eg light assault and super nailgun) had the same .weaponmodel but different 'animation frames' (I'm too newb to describe it properly) so self.current_weapon is used. Here's a link to the whole function.

Code: Select all

void () VWEPS_SetModel
In weapon.qc:

Code: Select all

void() W_SetCurrentAmmo  /* IIUC this function checks if you need to change weapons due to
1. run out of ammo
2. reloading
3. if you change your weapon*/
In engineer.qc, demoman.qc and other places, this is the current (legacy) method of removing a players weapon:

Code: Select all


// Save the current weapon and remove it
    self.weapon = self.current_weapon;
    self.current_weapon = 0; / this is the main number I've been playing with
    self.weaponmodel = ""; // I think this line only deals w the visual for the players first person view of his own weapon
    self.weaponframe = 0; // not sure what this does
And to restore it:

Code: Select all


// this restores the weapon
self.current_weapon = self.weapon;
THE PROBLEM
The normal (light assault/super nailgun) VWEP looks like this:
Image

'Weaponless' players (using the method above)are displayed with their VWEP weapons sticking out of their head, or at their feet:
Image

When I set self.vw_index to '0', it reverts to the crappy older prevwep mdl. The only way I've made it show 'bare hands' is to use the (IIRC) daedelus gun, which has an interesting frame where the weapon is behind the players back, and he does indeed have bare hands. Unfortunately this resulted in a bug where when a player got his weapon back, he was given a free sniper rifle, ie the one permanently set to 'fast fire' mode.

Options:
1. Revert back to the daedelus gun solution, and simply stop the 'sniper rifle' bug
2. Make a new invisible VWEP, and assign it to the bare handed player
3. When a bare handed player is needed, make the code bypass the VWEP stuff
4. Investigate possibly gratuitous calls to VWEPS_SetMode, and W_SetCurrentAmmo - something might be 'contradicting' the call to remove the weapon..

If you're still reading, and an obvious solution/suggestion doesn't come to mind, please relax, I'm sure I can solve this with more study of the existing code, and consultations w Xavior and Trickle.

thanks for listening :)


OneManClan
Last edited by OneManClan on Tue Jul 05, 2011 1:57 am, edited 1 time in total.
Error
InsideQC Staff
Posts: 865
Joined: Fri Nov 05, 2004 5:15 am
Location: VA, USA
Contact:

Post by Error »

easiest, but not best solution: make a null model and use that for weaponless.
andrewj
Posts: 133
Joined: Mon Aug 30, 2010 3:29 pm
Location: Australia

Re: The 'Bare Handed player' saga

Post by andrewj »

OneManClan wrote:OPTIONS
......
3. When a bare handed player is needed, make the code bypass the VWEP stuff
......
That's what I would do.

Find the mechanism used to attach a vwep to a model and unset the vwep when necessary. I have no idea what that mechanism is though -- perhaps it involves calling a builtin?
OneManClan
Posts: 247
Joined: Sat Feb 28, 2009 2:38 pm
Contact:

Re: The 'Bare Handed player' saga

Post by OneManClan »

Well it looks like 'going public' with this bug has helped! Since the Daedilus hack was the closest I'd come, I had another go at:
3. When a bare handed player is needed, make the code bypass the VWEP stuff
So, I reverted back to the 'use the daedelus' weapon method, BUT changed .vw_index rather than the .weaponmodel; hacky, because I wanted to keep ALL the VWEP stuff in VWEPS_SetModel(), but hey - whatever works, right? :? ... anyway, here's what making a player 'bare handed' looks like now:

Code: Select all

self.weapon = self.current_weapon;
	self.current_weapon = 0; // no weapon
	self.weaponmodel = "";
	self.weaponframe = 0;
	self.vw_index = 17;/* added this line.  Daedelus gun will appear, in the frame where the gun is behind the players back, no idea why this frame exists, but hey, it looks good, though you can (for a split second) *just* see the daedilus gun before it swings over the players back*/
And right at the top of VWEPS_SetModel, we bypass the entire function:

Code: Select all

if (self.job & #JOB_CHAPLAN && self.job & #JOB_ACTIVE)
				return;
				
	if (self.is_building == 1 || self.is_detpacking == 1)
				return;
I'm a little nervous because it's definitely a newbie hack, but (pending further testing) it works! :) There's one other minor issue, but I'll discuss it tomorrow maybe - I'm exhausted (but happy)

Thanks for the feedback guys :)
Post Reply