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: case EV_RAILTRAIL:
DEBUGNAME("EV_RAILTRAIL"); DEBUGNAME("EV_RAILTRAIL");
cent->currentState.weapon = WP_RAILGUN; cent->currentState.weapon = WP_RAILGUN;
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 the end was on a nomark surface, don't make an explosion
CG_RailTrail( ci, es->origin2, es->pos.trBase );
if ( es->eventParm != 255 ) { if ( es->eventParm != 255 ) {
ByteToDir( es->eventParm, dir ); ByteToDir( es->eventParm, dir );
CG_MissileHitWall( es->weapon, es->clientNum, position, dir, IMPACTSOUND_DEFAULT ); 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 #define SPACING 5
start[2] -= 4; 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(); le = CG_AllocLocalEntity();
re = &le->refEntity; re = &le->refEntity;
@ -249,9 +242,9 @@ void CG_RailTrail (clientInfo_t *ci, vec3_t start, vec3_t end) {
VectorCopy(end, re->oldorigin); VectorCopy(end, re->oldorigin);
re->shaderRGBA[0] = ci->color1[0] * 255; re->shaderRGBA[0] = ci->color1[0] * 255;
re->shaderRGBA[1] = ci->color1[1] * 255; re->shaderRGBA[1] = ci->color1[1] * 255;
re->shaderRGBA[2] = ci->color1[2] * 255; re->shaderRGBA[2] = ci->color1[2] * 255;
re->shaderRGBA[3] = 255; re->shaderRGBA[3] = 255;
le->color[0] = ci->color1[0] * 0.75; le->color[0] = ci->color1[0] * 0.75;
le->color[1] = ci->color1[1] * 0.75; le->color[1] = ci->color1[1] * 0.75;
@ -260,60 +253,73 @@ void CG_RailTrail (clientInfo_t *ci, vec3_t start, vec3_t end) {
AxisClear( re->axis ); AxisClear( re->axis );
VectorMA(move, 20, vec, move); if (cg_oldRail.integer)
VectorCopy(move, next_move); {
VectorScale (vec, SPACING, vec);
if (cg_oldRail.integer != 0) {
// nudge down a bit so it isn't exactly in center // nudge down a bit so it isn't exactly in center
re->origin[2] -= 8; re->origin[2] -= 8;
re->oldorigin[2] -= 8; re->oldorigin[2] -= 8;
return; 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; skip = -1;
j = 18; j = 18;
for (i = 0; i < len; i += SPACING) { for (i = 0; i < len; i += SPACING)
if (i != skip) { {
if (i != skip)
{
skip = i + SPACING; skip = i + SPACING;
le = CG_AllocLocalEntity(); le = CG_AllocLocalEntity();
re = &le->refEntity; re = &le->refEntity;
le->leFlags = LEF_PUFF_DONT_SCALE; le->leFlags = LEF_PUFF_DONT_SCALE;
le->leType = LE_MOVE_SCALE_FADE; le->leType = LE_MOVE_SCALE_FADE;
le->startTime = cg.time; le->startTime = cg.time;
le->endTime = cg.time + (i>>1) + 600; le->endTime = cg.time + (i>>1) + 600;
le->lifeRate = 1.0 / (le->endTime - le->startTime); le->lifeRate = 1.0 / (le->endTime - le->startTime);
re->shaderTime = cg.time / 1000.0f; re->shaderTime = cg.time / 1000.0f;
re->reType = RT_SPRITE; re->reType = RT_SPRITE;
re->radius = 1.1f; re->radius = 1.1f;
re->customShader = cgs.media.railRingsShader; re->customShader = cgs.media.railRingsShader;
re->shaderRGBA[0] = ci->color2[0] * 255; re->shaderRGBA[0] = ci->color2[0] * 255;
re->shaderRGBA[1] = ci->color2[1] * 255; re->shaderRGBA[1] = ci->color2[1] * 255;
re->shaderRGBA[2] = ci->color2[2] * 255; re->shaderRGBA[2] = ci->color2[2] * 255;
re->shaderRGBA[3] = 255; re->shaderRGBA[3] = 255;
le->color[0] = ci->color2[0] * 0.75; le->color[0] = ci->color2[0] * 0.75;
le->color[1] = ci->color2[1] * 0.75; le->color[1] = ci->color2[1] * 0.75;
le->color[2] = ci->color2[2] * 0.75; le->color[2] = ci->color2[2] * 0.75;
le->color[3] = 1.0f; le->color[3] = 1.0f;
le->pos.trType = TR_LINEAR; le->pos.trType = TR_LINEAR;
le->pos.trTime = cg.time; le->pos.trTime = cg.time;
VectorCopy( move, move2); VectorCopy( move, move2);
VectorMA(move2, RADIUS , axis[j], move2); VectorMA(move2, RADIUS , axis[j], move2);
VectorCopy(move2, le->pos.trBase); VectorCopy(move2, le->pos.trBase);
le->pos.trDelta[0] = axis[j][0]*6; le->pos.trDelta[0] = axis[j][0]*6;
le->pos.trDelta[1] = axis[j][1]*6; le->pos.trDelta[1] = axis[j][1]*6;
le->pos.trDelta[2] = axis[j][2]*6; le->pos.trDelta[2] = axis[j][2]*6;
} }
VectorAdd (move, vec, move); 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; weapon_t weaponNum;
weaponInfo_t *weapon; weaponInfo_t *weapon;
centity_t *nonPredictedCent; centity_t *nonPredictedCent;
// int col; orientation_t lerped;
weaponNum = cent->currentState.weapon; 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 ); CG_AddWeaponWithPowerups( &gun, cent->currentState.powerups );