[EDIT: 'VWEP' is short for ''visible weapon'. It refers the weapon you see in *other* players hands. I'm not sure if it's the 'standard jargon', because I didn't see any definitions anywhere they have been discussed. More info (but no definition)here]
Rather than getting into long, detailed (and possibly pointless) descriptions of everything I've tried (which hasn't worked!), I would like take a step back, and ask the following, 'open ended' question:
Q: What is the best (easiest, simplest, fastest, and smartest) way to implement VWEPS with Blender + CSQC?
So far, IIUC [disclaimer: this is newbie speculation] there seem to be two basic strategies:
Method 1: 'VWEP Follows the Hand-bone'
Make the VWEP (with no bone), and attach it to the players hand in CSQC. The players hand does all the movements. I tried this but found it impossible to align/position the VWEP in CSQC [Edit: one shouldn't be trying to position the asset in code, it should 'arrive' correctly positioned. More info in the posts below]. It appears attached to the players hand but the angles are wrong. I experimented with HEAPS of positions/settings/values, and I STILL can't figure out exactly how the Blender position of the iqm (ie at the time of export), relates to the CSQC positioning (at the time of attachment to the hand-bone).
Method 2: 'VWEP Self Animates'
Attach the VWEP to the players hand *in Blender*, delete the player model, and export the VWEP with all the player's animations. So now you have an instant 'self animating' VWEP. Import it into CSQC, and let the players current animation determine the VWEPS 'complimentary' animation. There's no need to animate them in CSQC. This is basically how SSQC VWEPS work. I haven't done this because I *assumed* that Method 1 was the 'way to do it'. ie thats what functions like gettaginfo(), and gettagindex() are for.. Hmm
Method 3: '??'
< this space available>
My current VWEP implementation is based on Hattify(), the CSQC Hat Method I just posted . Is it obsolete/inefficient/sub-optimal? :? [edit answer = yes, re the positioning bit] It does work ... apart from the wrongly angled VWEP:
Code: Select all
// self is the player entity .. we're here as a result of :
// deltalisten("progs/player.mdl", PutVWEPOnPlayer, 0);
local vector vwep_pos;
if(isnew)
{
self.vwep = spawn();
}
str = GetCurrentVWEP();
setmodel(self.vwep, str);
// give vwep_position the value of self's "right hand" bone position
vwep_pos = gettaginfo(self, gettagindex (self, "Hand_R"));
//v_forward, v_right, v_up all auto-generated by gettagindex
//[edit: the following 3 lines are VERY difficult to use! AND you shouldn't do aligning in the code]
vwep_pos += v_forward * 0; //
vwep_pos -= v_right * 0; // moves vwep up [edit: no, it doesnt]
vwep_pos += v_up * 0; // move vwep forward away from players face
// put the vwep on!
setorigin(self.vwep, vwep_pos);
// make self be the vwep for a sec
olself = self;
self = self.vwep;
// so we can rotate it, to compensate for Blender orientation differential
rotatevectorsbyangle ('0 0 0'); // no value worked :( [edit: dont fix broken assett in code]
self = olself;
// make vwep turn and tilt based on self's angles
self.vwep.angles = vectoangles(v_forward, v_up );
self.vwep.renderflags = self.renderflags; // make it so player cant see their own vwep
self.vwep.drawmask = 1; // draw the vwep!