mirror of
https://github.com/ReactionQuake3/reaction.git
synced 2024-11-22 20:31:11 +00:00
No more default 800 gravity on items
Thrown knife+Glass fix - NiceAss
This commit is contained in:
parent
8b181630b7
commit
95a9f25d00
6 changed files with 161 additions and 28 deletions
|
@ -5,6 +5,10 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.30 2002/01/14 01:20:45 niceass
|
||||
// No more default 800 gravity on items
|
||||
// Thrown knife+Glass fix - NiceAss
|
||||
//
|
||||
// Revision 1.29 2002/01/11 20:20:58 jbravo
|
||||
// Adding TP to main branch
|
||||
//
|
||||
|
@ -1355,7 +1359,7 @@ void G_BounceItem( gentity_t *ent, trace_t *trace ) {
|
|||
|
||||
// reflect the velocity on the trace plane
|
||||
hitTime = level.previousTime + ( level.time - level.previousTime ) * trace->fraction;
|
||||
BG_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );
|
||||
G_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );
|
||||
dot = DotProduct( velocity, trace->plane.normal );
|
||||
VectorMA( velocity, -2*dot, trace->plane.normal, ent->s.pos.trDelta );
|
||||
|
||||
|
@ -1407,7 +1411,7 @@ void G_RunItem( gentity_t *ent ) {
|
|||
}
|
||||
|
||||
// get current position
|
||||
BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );
|
||||
G_EvaluateTrajectory( &ent->s.pos, level.time, origin );
|
||||
|
||||
// trace a line from the previous position to the current position
|
||||
if ( ent->clipmask ) {
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.35 2002/01/14 01:20:45 niceass
|
||||
// No more default 800 gravity on items
|
||||
// Thrown knife+Glass fix - NiceAss
|
||||
//
|
||||
// Revision 1.34 2002/01/11 20:20:58 jbravo
|
||||
// Adding TP to main branch
|
||||
//
|
||||
|
@ -779,6 +783,9 @@ void DropPortalDestination( gentity_t *ent );
|
|||
|
||||
void G_BreakGlass( gentity_t *ent, vec3_t point, int mod );//Blaze: Breakable glass
|
||||
void G_RunDlight ( gentity_t *ent ); // Elder: dlight running
|
||||
void G_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result );
|
||||
void G_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result );
|
||||
void G_GravityChange(void);
|
||||
|
||||
//
|
||||
// g_weapon.c
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.17 2002/01/14 01:20:45 niceass
|
||||
// No more default 800 gravity on items
|
||||
// Thrown knife+Glass fix - NiceAss
|
||||
//
|
||||
// Revision 1.16 2002/01/11 20:20:58 jbravo
|
||||
// Adding TP to main branch
|
||||
//
|
||||
|
@ -418,7 +422,7 @@ void G_UpdateCvars( void ) {
|
|||
|
||||
if ( cv->modificationCount != cv->vmCvar->modificationCount ) {
|
||||
cv->modificationCount = cv->vmCvar->modificationCount;
|
||||
|
||||
if (Q_stricmp (cv->cvarName, "g_gravity") == 0) G_GravityChange();
|
||||
if ( cv->trackChange ) {
|
||||
trap_SendServerCommand( -1, va("print \"Server: %s changed to %s\n\"",
|
||||
cv->cvarName, cv->vmCvar->string ) );
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.19 2002/01/14 01:20:45 niceass
|
||||
// No more default 800 gravity on items
|
||||
// Thrown knife+Glass fix - NiceAss
|
||||
//
|
||||
// Revision 1.18 2002/01/11 19:48:30 jbravo
|
||||
// Formatted the source in non DOS format.
|
||||
//
|
||||
|
@ -754,3 +758,112 @@ void DropPortalSource( gentity_t *player ) {
|
|||
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
================
|
||||
G_EvaluateTrajectory
|
||||
|
||||
================
|
||||
*/
|
||||
void G_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) {
|
||||
float deltaTime;
|
||||
float phase;
|
||||
|
||||
switch( tr->trType ) {
|
||||
case TR_STATIONARY:
|
||||
case TR_INTERPOLATE:
|
||||
VectorCopy( tr->trBase, result );
|
||||
break;
|
||||
case TR_LINEAR:
|
||||
deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
|
||||
VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
|
||||
break;
|
||||
case TR_SINE:
|
||||
deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;
|
||||
phase = sin( deltaTime * M_PI * 2 );
|
||||
VectorMA( tr->trBase, phase, tr->trDelta, result );
|
||||
break;
|
||||
case TR_LINEAR_STOP:
|
||||
if ( atTime > tr->trTime + tr->trDuration ) {
|
||||
atTime = tr->trTime + tr->trDuration;
|
||||
}
|
||||
deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
|
||||
if ( deltaTime < 0 ) {
|
||||
deltaTime = 0;
|
||||
}
|
||||
VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
|
||||
break;
|
||||
case TR_GRAVITY:
|
||||
deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
|
||||
VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
|
||||
result[2] -= 0.5 * (float)g_gravity.integer * deltaTime * deltaTime;
|
||||
break;
|
||||
default:
|
||||
Com_Error( ERR_DROP, "G_EvaluateTrajectory: unknown trType: %i", tr->trTime );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
G_EvaluateTrajectoryDelta
|
||||
|
||||
For determining velocity at a given time
|
||||
================
|
||||
*/
|
||||
void G_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result ) {
|
||||
float deltaTime;
|
||||
float phase;
|
||||
|
||||
switch( tr->trType ) {
|
||||
case TR_STATIONARY:
|
||||
case TR_INTERPOLATE:
|
||||
VectorClear( result );
|
||||
break;
|
||||
case TR_LINEAR:
|
||||
VectorCopy( tr->trDelta, result );
|
||||
break;
|
||||
case TR_SINE:
|
||||
deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;
|
||||
phase = cos( deltaTime * M_PI * 2 ); // derivative of sin = cos
|
||||
phase *= 0.5;
|
||||
VectorScale( tr->trDelta, phase, result );
|
||||
break;
|
||||
case TR_LINEAR_STOP:
|
||||
if ( atTime > tr->trTime + tr->trDuration ) {
|
||||
VectorClear( result );
|
||||
return;
|
||||
}
|
||||
VectorCopy( tr->trDelta, result );
|
||||
break;
|
||||
case TR_GRAVITY:
|
||||
deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
|
||||
VectorCopy( tr->trDelta, result );
|
||||
result[2] -= (float)g_gravity.integer * deltaTime;
|
||||
break;
|
||||
default:
|
||||
Com_Error( ERR_DROP, "G_EvaluateTrajectoryDelta: unknown trType: %i", tr->trTime );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
G_EvaluateTrajectoryDelta - By NiceAss
|
||||
|
||||
Will update all ET_MISSILE entities with TR_GRAVITY on a g_gravity change.
|
||||
================*/
|
||||
void G_GravityChange(void) {
|
||||
int i;
|
||||
gentity_t *ent;
|
||||
ent = &g_entities[0];
|
||||
for (i=0 ; i<level.num_entities ; i++, ent++) {
|
||||
if ( ent->s.pos.trType == TR_GRAVITY &&
|
||||
ent->s.eType == ET_MISSILE )
|
||||
{
|
||||
G_EvaluateTrajectoryDelta( &ent->s.pos, level.time, ent->s.pos.trDelta );
|
||||
VectorCopy( ent->r.currentOrigin, ent->s.pos.trBase );
|
||||
ent->s.pos.trTime = level.time;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,10 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.21 2002/01/14 01:20:45 niceass
|
||||
// No more default 800 gravity on items
|
||||
// Thrown knife+Glass fix - NiceAss
|
||||
//
|
||||
// Revision 1.20 2002/01/11 19:48:30 jbravo
|
||||
// Formatted the source in non DOS format.
|
||||
//
|
||||
|
@ -32,7 +36,7 @@ void G_BounceMissile( gentity_t *ent, trace_t *trace ) {
|
|||
|
||||
// reflect the velocity on the trace plane
|
||||
hitTime = level.previousTime + ( level.time - level.previousTime ) * trace->fraction;
|
||||
BG_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );
|
||||
G_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );
|
||||
dot = DotProduct( velocity, trace->plane.normal );
|
||||
VectorMA( velocity, -2*dot, trace->plane.normal, ent->s.pos.trDelta );
|
||||
|
||||
|
@ -62,7 +66,7 @@ void G_ExplodeMissile( gentity_t *ent ) {
|
|||
vec3_t dir;
|
||||
vec3_t origin;
|
||||
|
||||
BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );
|
||||
G_EvaluateTrajectory( &ent->s.pos, level.time, origin );
|
||||
SnapVector( origin );
|
||||
G_SetOrigin( ent, origin );
|
||||
|
||||
|
@ -338,7 +342,7 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
|
|||
//g_entities[ent->r.ownerNum].client->grenHits++;
|
||||
hitClient = qtrue;
|
||||
}
|
||||
BG_EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity );
|
||||
G_EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity );
|
||||
if ( VectorLength( velocity ) == 0 ) {
|
||||
velocity[2] = 1; // stepped on a grenade
|
||||
}
|
||||
|
@ -465,22 +469,19 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
|
|||
//spawn a knife at its trajectory end-point
|
||||
xr_item = BG_FindItemForWeapon( WP_KNIFE );
|
||||
|
||||
BG_EvaluateTrajectoryDelta(&ent->s.pos, level.time, knifeVelocity);
|
||||
G_EvaluateTrajectoryDelta(&ent->s.pos, level.time, knifeVelocity);
|
||||
|
||||
if (other->s.eType == ET_BREAKABLE) {
|
||||
//VectorScale(knifeVelocity, -0.25, knifeVelocity);
|
||||
//Blaze: Moved from above, now deal the damage to the glass, and let the knife drop
|
||||
if ( ent->s.weapon == WP_KNIFE && other->s.eType == ET_BREAKABLE ) {
|
||||
BG_EvaluateTrajectory( &ent->s.pos, level.time, origin);
|
||||
//velocity[0] = 0;
|
||||
//velocity[1] = 0;
|
||||
//velocity[2] = 0;
|
||||
G_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity, origin, THROW_DAMAGE, 0, MOD_KNIFE_THROWN);
|
||||
}
|
||||
// NiceAss: Cut its velocity in half.
|
||||
VectorScale( ent->s.pos.trDelta, .6, ent->s.pos.trDelta);
|
||||
VectorCopy(trace->endpos, origin);
|
||||
G_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity, origin, THROW_DAMAGE, 0, MOD_KNIFE_THROWN);
|
||||
|
||||
// NiceAss: Find current position and set it.
|
||||
VectorCopy(trace->endpos, ent->s.pos.trBase);
|
||||
ent->s.pos.trTime = level.time;
|
||||
// And cut the velocity down.
|
||||
VectorScale(ent->s.pos.trDelta, .2, ent->s.pos.trDelta);
|
||||
return;
|
||||
/*
|
||||
/* OLD METHOD
|
||||
//breakable "hit"; make it fall to the ground
|
||||
xr_drop = LaunchItem(xr_item, trace->endpos, velocity, FL_DROPPED_ITEM);
|
||||
|
||||
|
@ -568,7 +569,7 @@ void G_ExplodeMissile( gentity_t *ent ) {
|
|||
vec3_t dir;
|
||||
vec3_t origin;
|
||||
|
||||
BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );
|
||||
G_EvaluateTrajectory( &ent->s.pos, level.time, origin );
|
||||
SnapVector( origin );
|
||||
G_SetOrigin( ent, origin );
|
||||
|
||||
|
@ -604,7 +605,7 @@ void G_RunMissile( gentity_t *ent ) {
|
|||
int passent;
|
||||
|
||||
// get current position
|
||||
BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );
|
||||
G_EvaluateTrajectory( &ent->s.pos, level.time, origin );
|
||||
|
||||
// if this missile bounced off an invulnerability sphere
|
||||
if ( ent->target_ent ) {
|
||||
|
@ -656,7 +657,7 @@ void G_RunMissile( gentity_t *ent ) {
|
|||
{
|
||||
vec3_t knifeVelocity;
|
||||
|
||||
BG_EvaluateTrajectoryDelta(&ent->s.pos, level.time, knifeVelocity);
|
||||
G_EvaluateTrajectoryDelta(&ent->s.pos, level.time, knifeVelocity);
|
||||
vectoangles(knifeVelocity, ent->s.angles);
|
||||
ent->s.angles[0] += level.time % 360;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.19 2002/01/14 01:20:44 niceass
|
||||
// No more default 800 gravity on items
|
||||
// Thrown knife+Glass fix - NiceAss
|
||||
//
|
||||
// Revision 1.18 2002/01/11 19:48:30 jbravo
|
||||
// Formatted the source in non DOS format.
|
||||
//
|
||||
|
@ -472,8 +476,8 @@ void G_MoverTeam( gentity_t *ent ) {
|
|||
pushed_p = pushed;
|
||||
for (part = ent ; part ; part=part->teamchain) {
|
||||
// get current position
|
||||
BG_EvaluateTrajectory( &part->s.pos, level.time, origin );
|
||||
BG_EvaluateTrajectory( &part->s.apos, level.time, angles );
|
||||
G_EvaluateTrajectory( &part->s.pos, level.time, origin );
|
||||
G_EvaluateTrajectory( &part->s.apos, level.time, angles );
|
||||
VectorSubtract( origin, part->r.currentOrigin, move );
|
||||
VectorSubtract( angles, part->r.currentAngles, amove );
|
||||
if ( !G_MoverPush( part, move, amove, &obstacle ) ) {
|
||||
|
@ -486,8 +490,8 @@ void G_MoverTeam( gentity_t *ent ) {
|
|||
for ( part = ent ; part ; part = part->teamchain ) {
|
||||
part->s.pos.trTime += level.time - level.previousTime;
|
||||
part->s.apos.trTime += level.time - level.previousTime;
|
||||
BG_EvaluateTrajectory( &part->s.pos, level.time, part->r.currentOrigin );
|
||||
BG_EvaluateTrajectory( &part->s.apos, level.time, part->r.currentAngles );
|
||||
G_EvaluateTrajectory( &part->s.pos, level.time, part->r.currentOrigin );
|
||||
G_EvaluateTrajectory( &part->s.apos, level.time, part->r.currentAngles );
|
||||
trap_LinkEntity( part );
|
||||
}
|
||||
|
||||
|
@ -611,8 +615,8 @@ void SetMoverState( gentity_t *ent, moverState_t moverState, int time ) {
|
|||
ent->s.apos.trType = TR_LINEAR_STOP;
|
||||
break;
|
||||
}
|
||||
BG_EvaluateTrajectory( &ent->s.pos, level.time, ent->r.currentOrigin );
|
||||
BG_EvaluateTrajectory( &ent->s.apos, level.time, ent->r.currentAngles );
|
||||
G_EvaluateTrajectory( &ent->s.pos, level.time, ent->r.currentOrigin );
|
||||
G_EvaluateTrajectory( &ent->s.apos, level.time, ent->r.currentAngles );
|
||||
|
||||
trap_LinkEntity( ent );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue