Zakk wisheth - Thilo answereth (#4070)

Use cg_drawWeapon 2/3 to make weapon left-handed/centered
This commit is contained in:
Thilo Schulz 2009-11-09 12:23:03 +00:00
parent 3cb58d7cc5
commit eee5498019
2 changed files with 76 additions and 45 deletions

View file

@ -923,8 +923,18 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
case EV_RAILTRAIL:
DEBUGNAME("EV_RAILTRAIL");
cent->currentState.weapon = WP_RAILGUN;
// if the end was on a nomark surface, don't make an explosion
if(es->clientNum == cg.snap->ps.clientNum && !cg.renderingThirdPerson)
{
if(cg_drawGun.integer == 2)
VectorMA(es->origin2, 8, cg.refdef.viewaxis[1], es->origin2);
else if(cg_drawGun.integer == 3)
VectorMA(es->origin2, 4, cg.refdef.viewaxis[1], es->origin2);
}
CG_RailTrail(ci, es->origin2, es->pos.trBase);
// if the end was on a nomark surface, don't make an explosion
if ( es->eventParm != 255 ) {
ByteToDir( es->eventParm, dir );
CG_MissileHitWall( es->weapon, es->clientNum, position, dir, IMPACTSOUND_DEFAULT );

View file

@ -225,13 +225,6 @@ void CG_RailTrail (clientInfo_t *ci, vec3_t start, vec3_t end) {
#define SPACING 5
start[2] -= 4;
VectorCopy (start, move);
VectorSubtract (end, start, vec);
len = VectorNormalize (vec);
PerpendicularVector(temp, vec);
for (i = 0 ; i < 36; i++) {
RotatePointAroundVector(axis[i], vec, temp, i * 10);//banshee 2.4 was 10
}
le = CG_AllocLocalEntity();
re = &le->refEntity;
@ -260,21 +253,34 @@ void CG_RailTrail (clientInfo_t *ci, vec3_t start, vec3_t end) {
AxisClear( re->axis );
VectorMA(move, 20, vec, move);
VectorCopy(move, next_move);
VectorScale (vec, SPACING, vec);
if (cg_oldRail.integer != 0) {
if (cg_oldRail.integer)
{
// nudge down a bit so it isn't exactly in center
re->origin[2] -= 8;
re->oldorigin[2] -= 8;
return;
}
VectorCopy (start, move);
VectorSubtract (end, start, vec);
len = VectorNormalize (vec);
PerpendicularVector(temp, vec);
for (i = 0 ; i < 36; i++)
{
RotatePointAroundVector(axis[i], vec, temp, i * 10);//banshee 2.4 was 10
}
VectorMA(move, 20, vec, move);
VectorCopy(move, next_move);
VectorScale (vec, SPACING, vec);
skip = -1;
j = 18;
for (i = 0; i < len; i += SPACING) {
if (i != skip) {
for (i = 0; i < len; i += SPACING)
{
if (i != skip)
{
skip = i + SPACING;
le = CG_AllocLocalEntity();
re = &le->refEntity;
@ -313,7 +319,7 @@ void CG_RailTrail (clientInfo_t *ci, vec3_t start, vec3_t end) {
VectorAdd (move, vec, move);
j = j + ROTATION < 36 ? j + ROTATION : (j + ROTATION) % 36;
j = (j + ROTATION) % 36;
}
}
@ -1227,7 +1233,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
weapon_t weaponNum;
weaponInfo_t *weapon;
centity_t *nonPredictedCent;
// int col;
orientation_t lerped;
weaponNum = cent->currentState.weapon;
@ -1275,7 +1281,22 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
}
}
CG_PositionEntityOnTag( &gun, parent, parent->hModel, "tag_weapon");
trap_R_LerpTag(&lerped, parent->hModel, parent->oldframe, parent->frame,
1.0 - parent->backlerp, "tag_weapon");
VectorCopy(parent->origin, gun.origin);
VectorMA(gun.origin, lerped.origin[0], parent->axis[0], gun.origin);
// Make weapon appear left-handed for 2 and centered for 3
if(ps && cg_drawGun.integer == 2)
VectorMA(gun.origin, -lerped.origin[1], parent->axis[1], gun.origin);
else if(!ps || cg_drawGun.integer != 3)
VectorMA(gun.origin, lerped.origin[1], parent->axis[1], gun.origin);
VectorMA(gun.origin, lerped.origin[2], parent->axis[2], gun.origin);
MatrixMultiply(lerped.axis, ((refEntity_t *)parent)->axis, gun.axis);
gun.backlerp = parent->backlerp;
CG_AddWeaponWithPowerups( &gun, cent->currentState.powerups );