Xonotic
sv_vampire.qc
Go to the documentation of this file.
1 #include "sv_vampire.qh"
2 
6 
8 
9 MUTATOR_HOOKFUNCTION(vampire, PlayerDamage_SplitHealthArmor)
10 {
11  // NOTE: vampire buff PlayerDamage_SplitHealthArmor code is similar
12  entity frag_attacker = M_ARGV(1, entity);
13  entity frag_target = M_ARGV(2, entity);
14  float health_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
15  float armor_take = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
16  float damage_take = (autocvar_g_vampire_use_total_damage) ? health_take + armor_take : health_take;
17 
18  if (!StatusEffects_active(STATUSEFFECT_SpawnShield, frag_target) && frag_target != frag_attacker
19  && IS_PLAYER(frag_attacker) && !IS_DEAD(frag_target) && !STAT(FROZEN, frag_target))
20  {
21  GiveResource(frag_attacker, RES_HEALTH, autocvar_g_vampire_factor * damage_take);
22  }
23 }
24 
25 MUTATOR_HOOKFUNCTION(vampire, BuildMutatorsString)
26 {
27  M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Vampire");
28 }
29 
30 MUTATOR_HOOKFUNCTION(vampire, BuildMutatorsPrettyString)
31 {
32  M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Vampire");
33 }
REGISTER_MUTATOR(vampire, expr_evaluate(autocvar_g_vampire) &&!MUTATOR_IS_ENABLED(mutator_instagib))
string autocvar_g_vampire
Definition: sv_vampire.qc:3
entity() spawn
#define MUTATOR_IS_ENABLED(this)
Definition: base.qh:176
RES_HEALTH
Definition: ent_cs.qc:126
float autocvar_g_vampire_factor
Definition: sv_vampire.qc:4
bool autocvar_g_vampire_use_total_damage
Definition: sv_vampire.qc:5
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
#define IS_DEAD(s)
Definition: utils.qh:26
void GiveResource(entity receiver, Resource res_type, float amount)
Gives an entity some resource.
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
MUTATOR_HOOKFUNCTION(vampire, PlayerDamage_SplitHealthArmor)
Definition: sv_vampire.qc:9
#define IS_PLAYER(v)
Definition: utils.qh:9
ERASEABLE bool expr_evaluate(string s)
Evaluate an expression of the form: [+ | -]? [var[op]val | [op]var | val | var] ...
Definition: cvar.qh:48