mirror of
https://github.com/nzp-team/quakec.git
synced 2025-03-22 19:02:35 +00:00
SERVER: Restore weapon spread increasing over time
This commit is contained in:
parent
5e374479d8
commit
93ef51f665
8 changed files with 97 additions and 90 deletions
|
@ -2,8 +2,8 @@
|
|||
|
||||
../source/server/defs/fte.qc
|
||||
../source/shared/defs/custom.qc
|
||||
../source/shared/weapon_defines.qc
|
||||
../source/server/defs/custom.qc
|
||||
../source/shared/weapon_defines.qc
|
||||
../source/server/clientfuncs.qc
|
||||
../source/server/hash_table.qc
|
||||
|
||||
|
|
|
@ -4,13 +4,11 @@
|
|||
|
||||
../source/server/defs/standard.qc
|
||||
../source/shared/defs/custom.qc
|
||||
../source/shared/weapon_defines.qc
|
||||
../source/server/defs/custom.qc
|
||||
../source/shared/weapon_defines.qc
|
||||
../source/server/clientfuncs.qc
|
||||
../source/server/hash_table.qc
|
||||
|
||||
../source/server/non_fte_specifics.qc
|
||||
|
||||
../source/server/dummies.qc
|
||||
../source/server/rounds.qc
|
||||
../source/server/main.qc
|
||||
|
|
|
@ -249,23 +249,33 @@ void(entity who, float broadcast_time, float type, string str) BroadcastMessageT
|
|||
#endif // FTE
|
||||
}
|
||||
|
||||
// FIXME: basically a copy of CL_SendWeaponFire but for FTE
|
||||
void(entity who, float weapon) SendWeaponRecoil =
|
||||
void(entity who, float weapon) CL_SendWeaponFire =
|
||||
{
|
||||
#ifdef FTE
|
||||
float recoil_return_time = getWeaponRecoilReturn(weapon);
|
||||
vector weapon_recoil = GetWeaponRecoil(weapon);
|
||||
|
||||
vector Wep_Recoil;
|
||||
Wep_Recoil = GetWeaponRecoil(weapon);
|
||||
msg_entity = who;
|
||||
|
||||
#ifdef FTE
|
||||
|
||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, EVENT_WEAPONRECOIL);
|
||||
WriteCoord (MSG_MULTICAST, Wep_Recoil_x);
|
||||
WriteCoord (MSG_MULTICAST, Wep_Recoil_y);
|
||||
WriteCoord (MSG_MULTICAST, Wep_Recoil_z);
|
||||
msg_entity = who;
|
||||
WriteCoord (MSG_MULTICAST, weapon_recoil_x);
|
||||
WriteCoord (MSG_MULTICAST, weapon_recoil_y);
|
||||
WriteCoord (MSG_MULTICAST, weapon_recoil_z);
|
||||
multicast('0 0 0', MULTICAST_ONE);
|
||||
|
||||
#else
|
||||
|
||||
WriteByte(MSG_ONE, SVC_WEAPONFIRE);
|
||||
WriteLong(MSG_ONE, recoil_return_time); // FIXME: A long for this is overkill.
|
||||
WriteCoord(MSG_ONE, weapon_recoil_x);
|
||||
WriteCoord(MSG_ONE, weapon_recoil_y);
|
||||
WriteCoord(MSG_ONE, weapon_recoil_z);
|
||||
|
||||
#endif // FTE
|
||||
|
||||
self.recoil_delay = 60/recoil_return_time + time;
|
||||
}
|
||||
|
||||
void(float broadcast_time, float type, string str) BroadcastMessage =
|
||||
|
|
|
@ -51,11 +51,13 @@ float framecount;
|
|||
|
||||
float music_override;
|
||||
|
||||
.float recoil_delay;
|
||||
.float cur_spread;
|
||||
|
||||
#ifndef FTE
|
||||
|
||||
void(string com) SV_ParseClientCommand;
|
||||
.float gravity;
|
||||
.float recoil_delay;
|
||||
.float mapversion;
|
||||
.float ammo;
|
||||
.float frags;
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
server/non_fte_specifics.qc
|
||||
|
||||
Some of the misc. non-FTE QC functions.
|
||||
|
||||
Copyright (C) 2021-2024 NZ:P Team
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
|
||||
void() Do_Zombie_A = {};
|
||||
void() mystery_box;
|
||||
|
||||
void () CL_SendWeaponFire =
|
||||
{
|
||||
float return_time;
|
||||
vector Wep_Recoil;
|
||||
|
||||
Wep_Recoil = GetWeaponRecoil(self.weapon);
|
||||
|
||||
msg_entity = self;
|
||||
WriteByte(MSG_ONE, SVC_WEAPONFIRE);
|
||||
return_time = getWeaponRecoilReturn(self.weapon);
|
||||
WriteLong(MSG_ONE, return_time);
|
||||
WriteCoord (MSG_ONE, Wep_Recoil_x);
|
||||
WriteCoord (MSG_ONE, Wep_Recoil_y);
|
||||
WriteCoord (MSG_ONE, Wep_Recoil_z);
|
||||
//self.punchangle = Wep_Recoil;
|
||||
self.recoil_delay = 60/return_time + time;
|
||||
}
|
||||
|
||||
void() ParseClientCommand = {SV_ParseClientCommand(CMD_STRING);}
|
|
@ -301,3 +301,9 @@ void(string command_string) SV_ParseClientCommand =
|
|||
|
||||
#endif // FTE
|
||||
};
|
||||
|
||||
#ifndef FTE
|
||||
|
||||
void() ParseClientCommand = {SV_ParseClientCommand(CMD_STRING);}
|
||||
|
||||
#endif // FTE
|
|
@ -913,11 +913,7 @@ void (float shotcount, float sprd, float Damage, float side) FireTrace =
|
|||
|
||||
src = self.origin + self.view_ofs;
|
||||
|
||||
#ifndef FTE
|
||||
|
||||
CL_SendWeaponFire();
|
||||
|
||||
#endif // FTE
|
||||
CL_SendWeaponFire(self, self.weapon);
|
||||
|
||||
while (count < shotcount)
|
||||
{
|
||||
|
@ -1012,7 +1008,6 @@ void(float side) W_Fire =
|
|||
string modelname = "";
|
||||
string soundname;
|
||||
float spread;
|
||||
float is_moving;
|
||||
float delay;
|
||||
|
||||
//Update the basic vectors
|
||||
|
@ -1068,12 +1063,7 @@ void(float side) W_Fire =
|
|||
if (self.perks & P_DOUBLE && self.has_doubletap_damage_buff)
|
||||
shotcount *= 2;
|
||||
|
||||
if (self.velocity)
|
||||
is_moving = true;
|
||||
else
|
||||
is_moving = false;
|
||||
|
||||
spread = GetWeaponSpread(self.weapon, is_moving, self.stance);
|
||||
spread = WepDef_WeaponSpread(self.weapon, self.stance);
|
||||
|
||||
if (self.perks & P_DEAD) {
|
||||
spread *= 0.65;
|
||||
|
@ -1201,10 +1191,6 @@ void(float side) W_Fire =
|
|||
|
||||
self.effects = self.effects | EF_MUZZLEFLASH;
|
||||
|
||||
#else
|
||||
|
||||
SendWeaponRecoil(self, self.weapon);
|
||||
|
||||
#endif // FTE
|
||||
|
||||
}
|
||||
|
@ -1934,6 +1920,38 @@ void() CheckPlayer =
|
|||
|
||||
}
|
||||
|
||||
//
|
||||
// Wep_UpdateRecoilAndSpread()
|
||||
// Somewhat-intelligent serverside Weapon Recoil
|
||||
// update system that takes into account velocity
|
||||
// and how long the weapon has been fired.
|
||||
//
|
||||
void() Wep_UpdateRecoilAndSpread =
|
||||
{
|
||||
// Moving? Our weapon spread should be the maximum.
|
||||
if (self.velocity)
|
||||
self.cur_spread = WepDef_WeaponMaxSpread(self.weapon, self.stance);
|
||||
|
||||
// Slowly increase our spread based on how long the weapon
|
||||
// has been fired.
|
||||
else if (self.recoil_delay > time && self.recoil_delay)
|
||||
{
|
||||
self.cur_spread = self.cur_spread + 10;
|
||||
if (self.cur_spread >= WepDef_WeaponMaxSpread(self.weapon, self.stance))
|
||||
self.cur_spread = WepDef_WeaponMaxSpread(self.weapon, self.stance);
|
||||
}
|
||||
// Diminish spread over time as recoil decreases.
|
||||
else if (self.recoil_delay < time && self.recoil_delay)
|
||||
{
|
||||
self.cur_spread = self.cur_spread - 4;
|
||||
if (self.cur_spread <= 0)
|
||||
{
|
||||
self.cur_spread = 0;
|
||||
self.recoil_delay = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void () Weapon_Logic =
|
||||
{
|
||||
// HACK HACK: Don't let the frame updater take control of hold fire.
|
||||
|
@ -2250,6 +2268,7 @@ void () Weapon_Logic =
|
|||
|
||||
CheckImpulses();
|
||||
CheckPlayer();
|
||||
Wep_UpdateRecoilAndSpread();
|
||||
|
||||
// These are sent to clients in engine for stat
|
||||
// reference.
|
||||
|
|
|
@ -4046,17 +4046,6 @@ float(float wep) W_SpreadAffectedByADS =
|
|||
}
|
||||
}
|
||||
|
||||
float(float wep, float is_moving, float stance) GetWeaponSpread =
|
||||
{
|
||||
float magic_number = 1.15;
|
||||
|
||||
if (!is_moving) {
|
||||
return (CrossHairWeapon(wep, stance));
|
||||
} else {
|
||||
return (CrossHairMaxSpread(wep, stance)/2) * magic_number;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// W_IsLowAmmo(weapon, value, mag_not_reserve)
|
||||
// Determine if the weapon is low on ammo on the Magazine
|
||||
|
@ -4519,6 +4508,38 @@ float(float wep) GetWeaponZoomAmount =
|
|||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// WepDef_WeaponMaxSpread(weapon, stance)
|
||||
// Returns the maximum amount of Spread a Weapon
|
||||
// can output. This is based on data manipulation of
|
||||
// crosshair values.
|
||||
//
|
||||
float(float weapon, float stance) WepDef_WeaponMaxSpread =
|
||||
{
|
||||
return CrossHairMaxSpread(weapon, stance)/2.5;
|
||||
}
|
||||
|
||||
#ifndef CSQC
|
||||
|
||||
//
|
||||
// WepDef_WeaponSpread(weapon, stance)
|
||||
// Returns the general amount of Spread a Weapon
|
||||
// can output. This is based on data manipulation of
|
||||
// crosshair values.
|
||||
//
|
||||
|
||||
float(float weapon, float stance) WepDef_WeaponSpread =
|
||||
{
|
||||
// Early out.
|
||||
if (self.recoil_delay > time)
|
||||
return WepDef_WeaponMaxSpread(weapon, stance);
|
||||
|
||||
// Increase spread over time.
|
||||
return (CrossHairWeapon(weapon, stance)/2) + self.cur_spread;
|
||||
}
|
||||
|
||||
#endif // CSQC
|
||||
|
||||
//
|
||||
// WepDef_CalculateMeleeDamage(weapon, has_bowie)
|
||||
// Returns the amount of melee damage the Player can
|
||||
|
|
Loading…
Reference in a new issue