mirror of
https://github.com/ENSL/NS.git
synced 2025-01-18 23:41:51 +00:00
Mantis 1104:
- Added an optimistic latency-based prediction for alien energy usage for weapons, making missing attacks much less frequent. The prediction takes into account the player's latency and adrenaline upgrade, and adds that to the test performed by AvHMUHasEnoughAlienEnergy so that the client may predict how much energy the player has on the server when the +attack reaches it. git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@335 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
parent
162e23928f
commit
06bd7805bc
3 changed files with 26 additions and 5 deletions
|
@ -53,6 +53,8 @@
|
||||||
extern int g_runfuncs;
|
extern int g_runfuncs;
|
||||||
#include "cl_dll/com_weapons.h"
|
#include "cl_dll/com_weapons.h"
|
||||||
|
|
||||||
|
#include "common/net_api.h"
|
||||||
|
|
||||||
#include "pm_shared/pm_defs.h"
|
#include "pm_shared/pm_defs.h"
|
||||||
#include "pm_shared/pm_shared.h"
|
#include "pm_shared/pm_shared.h"
|
||||||
#include "pm_shared/pm_movevars.h"
|
#include "pm_shared/pm_movevars.h"
|
||||||
|
@ -266,8 +268,19 @@ BOOL AvHAlienWeapon::IsUseable(void)
|
||||||
// Make sure we have enough energy for this attack
|
// Make sure we have enough energy for this attack
|
||||||
float theEnergyCost = this->GetEnergyForAttack();
|
float theEnergyCost = this->GetEnergyForAttack();
|
||||||
float& theFuser = this->GetEnergyLevel();
|
float& theFuser = this->GetEnergyLevel();
|
||||||
|
float theLatency = 0.0f;
|
||||||
if(AvHMUHasEnoughAlienEnergy(theFuser, theEnergyCost) && this->GetEnabledState())
|
#ifdef AVH_CLIENT
|
||||||
|
// tankefugl: 991 -- added latency-based prediction for the ammount of energy available to the alien
|
||||||
|
net_status_s current_status;
|
||||||
|
gEngfuncs.pNetAPI->Status(¤t_status);
|
||||||
|
theLatency = max(0.0f, current_status.latency);
|
||||||
|
|
||||||
|
int theNumLevels = AvHGetAlienUpgradeLevel(this->m_pPlayer->pev->iuser4, MASK_UPGRADE_5);
|
||||||
|
if(theNumLevels > 0)
|
||||||
|
theLatency *= (1.0 + theNumLevels * BALANCE_VAR(kAdrenalineEnergyPercentPerLevel));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(AvHMUHasEnoughAlienEnergy(theFuser, theEnergyCost, theLatency) && this->GetEnabledState())
|
||||||
{
|
{
|
||||||
theIsUseable = TRUE;
|
theIsUseable = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,12 +285,20 @@ float AvHMUGetWalkSpeedFactor(AvHUser3 inUser3)
|
||||||
return theMoveSpeed;
|
return theMoveSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AvHMUHasEnoughAlienEnergy(float& ioFuser, float inNormAmount)
|
// tankefugl: 991 -- added latency-based prediction for the ammount of energy available to the alien
|
||||||
|
bool AvHMUHasEnoughAlienEnergy(float& ioFuser, float inNormAmount, float latency)
|
||||||
{
|
{
|
||||||
bool theSuccess = false;
|
bool theSuccess = false;
|
||||||
|
|
||||||
float theCurrentEnergy = ioFuser/kNormalizationNetworkFactor;
|
float theCurrentEnergy = ioFuser/kNormalizationNetworkFactor;
|
||||||
if(theCurrentEnergy >= inNormAmount)
|
float thePredictedByLatency = 0.0f;
|
||||||
|
|
||||||
|
#ifdef AVH_CLIENT
|
||||||
|
float theAlienEnergyRate = (float)BALANCE_VAR(kAlienEnergyRate);
|
||||||
|
float theUpgradeFactor = 1.0f;
|
||||||
|
thePredictedByLatency = (latency / 1000) * theAlienEnergyRate * theUpgradeFactor;
|
||||||
|
#endif
|
||||||
|
if((theCurrentEnergy + thePredictedByLatency) >= inNormAmount)
|
||||||
{
|
{
|
||||||
theSuccess = true;
|
theSuccess = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ bool AvHMUGiveAlienEnergy(float& ioFuser, float inNormAmount);
|
||||||
|
|
||||||
bool AvHMUGetEnergyCost(AvHWeaponID inWeaponID, float& outEnergyCost);
|
bool AvHMUGetEnergyCost(AvHWeaponID inWeaponID, float& outEnergyCost);
|
||||||
float AvHMUGetWalkSpeedFactor(AvHUser3 inUser3);
|
float AvHMUGetWalkSpeedFactor(AvHUser3 inUser3);
|
||||||
bool AvHMUHasEnoughAlienEnergy(float& ioFuser, float inNormAmount);
|
bool AvHMUHasEnoughAlienEnergy(float& ioFuser, float inNormAmount, float latency = 0.0f);
|
||||||
void AvHMUUpdateAlienEnergy(float inTimePassed, int inUser3, int inUser4, float& ioFuser);
|
void AvHMUUpdateAlienEnergy(float inTimePassed, int inUser3, int inUser4, float& ioFuser);
|
||||||
void AvHMUUpdateJetpackEnergy(bool inIsJetpacking, float theTimePassed, float& ioJetpackEnergy);
|
void AvHMUUpdateJetpackEnergy(bool inIsJetpacking, float theTimePassed, float& ioJetpackEnergy);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue