diff --git a/src/g_func_decs.h b/src/g_func_decs.h index 7afda26..245693c 100644 --- a/src/g_func_decs.h +++ b/src/g_func_decs.h @@ -90,7 +90,7 @@ extern void NoAmmoWeaponChange ( edict_t * ent ) ; extern void ChangeWeapon ( edict_t * ent ) ; extern qboolean Pickup_Weapon ( edict_t * ent , edict_t * other ) ; extern void PlayerNoise ( edict_t * who , vec3_t where , int type ) ; -extern void P_ProjectSource ( gclient_t * client , vec3_t point , vec3_t distance , vec3_t forward , vec3_t right , vec3_t result ) ; +extern void P_ProjectSource ( edict_t * ent , vec3_t distance , vec3_t forward , vec3_t right , vec3_t result ) ; extern void ClientEndServerFrame ( edict_t * ent ) ; extern void WhatsIt ( edict_t * ent ) ; extern void G_SetClientFrame ( edict_t * ent ) ; diff --git a/src/g_local.h b/src/g_local.h index 0c7fc3c..0ac1b86 100644 --- a/src/g_local.h +++ b/src/g_local.h @@ -773,6 +773,8 @@ extern cvar_t *vid_ref; extern cvar_t *zoomrate; extern cvar_t *zoomsnap; +extern cvar_t *aimfix; + extern int max_modelindex; extern int max_soundindex; @@ -1281,7 +1283,7 @@ void ClientEndServerFrame (edict_t *ent); // p_weapon.c // void PlayerNoise(edict_t *who, vec3_t where, int type); -void P_ProjectSource (gclient_t *client, vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result); +void P_ProjectSource (edict_t *ent, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result); void kick_attack (edict_t *ent); // ROGUE diff --git a/src/g_main.c b/src/g_main.c index aba630a..fb30fba 100644 --- a/src/g_main.c +++ b/src/g_main.c @@ -102,6 +102,8 @@ cvar_t *vid_ref; cvar_t *zoomrate; cvar_t *zoomsnap; +cvar_t *aimfix; + void SpawnEntities (char *mapname, char *entities, char *spawnpoint); void ClientThink (edict_t *ent, usercmd_t *cmd); qboolean ClientConnect (edict_t *ent, char *userinfo); diff --git a/src/g_save.c b/src/g_save.c index 54f494e..fb1e934 100644 --- a/src/g_save.c +++ b/src/g_save.c @@ -421,6 +421,9 @@ void InitGame (void) bounce_bounce = gi.cvar("bounce_bounce", "0.5", 0); bounce_minv = gi.cvar("bounce_minv", "60", 0); + /* others */ + aimfix = gi.cvar("aimfix", "0", CVAR_ARCHIVE); + // items InitItems (); diff --git a/src/p_weapon.c b/src/p_weapon.c index 905f5c7..2015fe5 100644 --- a/src/p_weapon.c +++ b/src/p_weapon.c @@ -11,9 +11,11 @@ static byte is_silenced; void weapon_grenade_fire (edict_t *ent, qboolean held); -void P_ProjectSource (gclient_t *client, vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result) +void P_ProjectSource (edict_t *ent, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result) { - vec3_t _distance; + gclient_t *client = ent->client; + float *point = ent->s.origin; + vec3_t _distance; VectorCopy (distance, _distance); // DWH @@ -25,6 +27,22 @@ void P_ProjectSource (gclient_t *client, vec3_t point, vec3_t distance, vec3_t f else if (client->pers.hand == CENTER_HANDED) _distance[1] = 0; G_ProjectSource (point, _distance, forward, right, result); + + + // Berserker: fix - now the projectile hits exactly where the scope is pointing. + if (aimfix->value) + { + vec3_t start, end; + VectorSet(start, ent->s.origin[0], ent->s.origin[1], ent->s.origin[2] + ent->viewheight); + VectorMA(start, 8192, forward, end); + + trace_t tr = gi.trace(start, NULL, NULL, end, ent, MASK_SHOT); + if (tr.fraction < 1) + { + VectorSubtract(tr.endpos, result, forward); + VectorNormalize(forward); + } + } } /* @@ -663,7 +681,7 @@ void weapon_grenade_fire (edict_t *ent, qboolean held) VectorSet(offset, 8, 8, ent->viewheight-8); AngleVectors (ent->client->v_angle, forward, right, NULL); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + P_ProjectSource (ent, offset, forward, right, start); timer = ent->client->grenade_time - level.time; speed = GRENADE_MINSPEED + (GRENADE_TIMER - timer) * ((GRENADE_MAXSPEED - GRENADE_MINSPEED) / GRENADE_TIMER); @@ -824,7 +842,7 @@ void weapon_grenadelauncher_fire (edict_t *ent) VectorSet(offset, 8, 8, ent->viewheight-8); AngleVectors (ent->client->v_angle, forward, right, NULL); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + P_ProjectSource (ent, offset, forward, right, start); VectorScale (forward, -2, ent->client->kick_origin); ent->client->kick_angles[0] = -1; @@ -929,7 +947,7 @@ void Weapon_RocketLauncher_Fire (edict_t *ent) ent->client->kick_angles[0] = -1; VectorSet(offset, 8, 8, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + P_ProjectSource (ent, offset, forward, right, start); if(ent->client->pers.fire_mode) { edict_t *target; @@ -1001,7 +1019,7 @@ void Blaster_Fire (edict_t *ent, vec3_t g_offset, int damage, qboolean hyper, in AngleVectors (ent->client->v_angle, forward, right, NULL); VectorSet(offset, 24, 8, ent->viewheight-8); VectorAdd (offset, g_offset, offset); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + P_ProjectSource (ent, offset, forward, right, start); VectorScale (forward, -2, ent->client->kick_origin); ent->client->kick_angles[0] = -1; @@ -1187,7 +1205,7 @@ void Machinegun_Fire (edict_t *ent) VectorAdd (ent->client->v_angle, ent->client->kick_angles, angles); AngleVectors (angles, forward, right, NULL); VectorSet(offset, 0, 8, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + P_ProjectSource (ent, offset, forward, right, start); fire_bullet (ent, start, forward, damage, kick, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_MACHINEGUN); gi.WriteByte (svc_muzzleflash); @@ -1323,7 +1341,7 @@ void Chaingun_Fire (edict_t *ent) r = 7 + crandom()*4; u = crandom()*4; VectorSet(offset, 0, r, u + ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + P_ProjectSource (ent, offset, forward, right, start); fire_bullet (ent, start, forward, damage, kick, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, MOD_CHAINGUN); } @@ -1378,7 +1396,7 @@ void weapon_shotgun_fire (edict_t *ent) ent->client->kick_angles[0] = -2; VectorSet(offset, 0, 8, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + P_ProjectSource (ent, offset, forward, right, start); if (is_quad) { @@ -1428,7 +1446,7 @@ void weapon_supershotgun_fire (edict_t *ent) ent->client->kick_angles[0] = -2; VectorSet(offset, 0, 8, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + P_ProjectSource (ent, offset, forward, right, start); if (is_quad) { @@ -1507,7 +1525,7 @@ void weapon_railgun_fire (edict_t *ent) ent->client->kick_angles[0] = -3; VectorSet(offset, 0, 7, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + P_ProjectSource (ent, offset, forward, right, start); fire_rail (ent, start, forward, damage, kick); // send muzzle flash @@ -1588,7 +1606,7 @@ void weapon_bfg_fire (edict_t *ent) ent->client->v_dmg_time = level.time + DAMAGE_TIME; VectorSet(offset, 8, 8, ent->viewheight-8); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + P_ProjectSource (ent, offset, forward, right, start); fire_bfg (ent, start, forward, damage, 400, damage_radius); ent->client->ps.gunframe++; @@ -1635,7 +1653,7 @@ void kick_attack (edict_t * ent ) VectorScale (forward, 0, ent->client->kick_origin); VectorSet(offset, 0, 0, ent->viewheight-20); - P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); + P_ProjectSource (ent, offset, forward, right, start); VectorMA( start, 25, forward, end );