Xonotic
sv_stale_move_negation.qc File Reference
+ Include dependency graph for sv_stale_move_negation.qc:

Go to the source code of this file.

Functions

 AUTOCVAR (g_smneg, bool, false, "Stale-move negation: penalize repeated use of the same weapon")
 
 AUTOCVAR (g_smneg_bonus, bool, true, "Stale-move negation: allow weapons to become stronger than their baseline")
 
 AUTOCVAR (g_smneg_bonus_asymptote, float, 4, "Stale-move negation: damage = infinity at this bonus level")
 
 AUTOCVAR (g_smneg_cooldown_factor, float, 1/4, "Stale-move negation: penalty cooldown factor")
 
 MUTATOR_HOOKFUNCTION (mutator_smneg, BuildMutatorsString)
 
 MUTATOR_HOOKFUNCTION (mutator_smneg, BuildMutatorsPrettyString)
 
 MUTATOR_HOOKFUNCTION (mutator_smneg, Damage_Calculate)
 
 REGISTER_MUTATOR (mutator_smneg, autocvar_g_smneg)
 
float smneg_multiplier (float weight)
 

Variables

float x_smneg_weight [REGISTRY_MAX(Weapons)]
 

Function Documentation

◆ AUTOCVAR() [1/4]

AUTOCVAR ( g_smneg  ,
bool  ,
false  ,
"Stale-move negation: penalize repeated use of the same weapon  
)

◆ AUTOCVAR() [2/4]

AUTOCVAR ( g_smneg_bonus  ,
bool  ,
true  ,
"Stale-move negation: allow weapons to become stronger than their baseline"   
)

◆ AUTOCVAR() [3/4]

AUTOCVAR ( g_smneg_bonus_asymptote  ,
float  ,
 
)

◆ AUTOCVAR() [4/4]

AUTOCVAR ( g_smneg_cooldown_factor  ,
float  ,
1/  4,
"Stale-move negation: penalty cooldown factor"   
)

◆ MUTATOR_HOOKFUNCTION() [1/3]

MUTATOR_HOOKFUNCTION ( mutator_smneg  ,
BuildMutatorsString   
)

Definition at line 9 of file sv_stale_move_negation.qc.

References M_ARGV, and strcat().

9  {
10  M_ARGV(0, string) = strcat(M_ARGV(0, string), ":StaleMoveNegation");
11 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [2/3]

MUTATOR_HOOKFUNCTION ( mutator_smneg  ,
BuildMutatorsPrettyString   
)

Definition at line 13 of file sv_stale_move_negation.qc.

References M_ARGV, and strcat().

13  {
14  M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Stale-move negation");
15 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [3/3]

MUTATOR_HOOKFUNCTION ( mutator_smneg  ,
Damage_Calculate   
)

Definition at line 32 of file sv_stale_move_negation.qc.

References CS(), DEATH_WEAPONOF, entity(), FOREACH, M_ARGV, Weapon::m_id, smneg_multiplier(), and vector().

32  {
33  float deathtype = M_ARGV(3, float);
34  Weapon w = DEATH_WEAPONOF(deathtype);
35  if (w == WEP_Null) return;
36 
37  entity frag_attacker = M_ARGV(1, entity);
38  entity c = CS(frag_attacker);
39  float weight = c.x_smneg_weight[w.m_id];
40  float f = smneg_multiplier(weight);
41  float frag_damage = M_ARGV(4, float) = f * M_ARGV(4, float);
42  M_ARGV(6, vector) = f * M_ARGV(6, vector); // force
43 
44  c.x_smneg_weight[w.m_id] = weight + frag_damage;
45  float restore = frag_damage * autocvar_g_smneg_cooldown_factor;
46  FOREACH(Weapons, it != WEP_Null && it != w, {
47  c.x_smneg_weight[it.m_id] -= restore;
48  });
49 }
entity() spawn
ClientState CS(Client this)
Definition: state.qh:47
#define DEATH_WEAPONOF(t)
Definition: all.qh:41
#define M_ARGV(x, type)
Definition: events.qh:17
vector(float skel, float bonenum) _skel_get_boneabs_hidden
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41
int m_id
Definition: weapon.qh:42
#define FOREACH(list, cond, body)
Definition: iter.qh:19
float smneg_multiplier(float weight)
+ Here is the call graph for this function:

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( mutator_smneg  ,
autocvar_g_smneg   
)

◆ smneg_multiplier()

float smneg_multiplier ( float  weight)

Definition at line 19 of file sv_stale_move_negation.qc.

References M_PI, max(), and start_health.

Referenced by MUTATOR_HOOKFUNCTION().

19  {
20  float a = autocvar_g_smneg_bonus_asymptote;
21  float x = max(
22  (!autocvar_g_smneg_bonus ? 0 : (-a + .1)),
23  weight / start_health
24  );
25  float z = (M_PI / 5) * a;
26  float f = (x > 0)
27  ? (atan(z / x) / (M_PI / 2))
28  : (tan(-(x / z)) + 1);
29  return f;
30 }
const float M_PI
Definition: csprogsdefs.qc:269
float start_health
Definition: world.qh:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ x_smneg_weight

float x_smneg_weight[REGISTRY_MAX(Weapons)]

Definition at line 17 of file sv_stale_move_negation.qc.