Xonotic
sv_vampirehook.qc File Reference
#include "sv_vampirehook.qh"
+ Include dependency graph for sv_vampirehook.qc:

Go to the source code of this file.

Functions

 MUTATOR_HOOKFUNCTION (vh, GrappleHookThink)
 
 REGISTER_MUTATOR (vh, expr_evaluate(autocvar_g_vampirehook))
 

Variables

string autocvar_g_vampirehook
 
float autocvar_g_vampirehook_damage
 
float autocvar_g_vampirehook_damagerate
 
float autocvar_g_vampirehook_health_steal
 
bool autocvar_g_vampirehook_teamheal
 
float last_dmg
 

Function Documentation

◆ MUTATOR_HOOKFUNCTION()

MUTATOR_HOOKFUNCTION ( vh  ,
GrappleHookThink   
)

Definition at line 13 of file sv_vampirehook.qc.

References autocvar_g_vampirehook_damage, autocvar_g_vampirehook_damagerate, autocvar_g_vampirehook_teamheal, Damage(), DIFF_TEAM, DMG_NOWEP, entity(), GetResource(), IS_PLAYER, M_ARGV, min(), RES_HEALTH, SAME_TEAM, SetResourceExplicit(), TakeResource(), and time.

14 {
15  entity thehook = M_ARGV(0, entity);
16 
17  entity dmgent = ((SAME_TEAM(thehook.owner, thehook.aiment) && autocvar_g_vampirehook_teamheal) ? thehook.owner : thehook.aiment);
18 
19  if(IS_PLAYER(thehook.aiment))
20  if(thehook.last_dmg < time)
21  if(!STAT(FROZEN, thehook.aiment))
22  if(time >= game_starttime)
23  if(DIFF_TEAM(thehook.owner, thehook.aiment) || autocvar_g_vampirehook_teamheal)
24  if(GetResource(thehook.aiment, RES_HEALTH) > 0)
26  {
27  thehook.last_dmg = time + autocvar_g_vampirehook_damagerate;
28  thehook.owner.hitsound_damage_dealt += autocvar_g_vampirehook_damage;
29  Damage(dmgent, thehook, thehook.owner, autocvar_g_vampirehook_damage, WEP_HOOK.m_id, DMG_NOWEP, thehook.origin, '0 0 0');
30  entity targ = ((SAME_TEAM(thehook.owner, thehook.aiment)) ? thehook.aiment : thehook.owner);
31  // TODO: we can't do this due to an issue with globals and the mutator arguments
32  //Heal(targ, thehook.owner, autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max);
34 
35  if(dmgent == thehook.owner)
36  TakeResource(dmgent, RES_HEALTH, autocvar_g_vampirehook_damage); // FIXME: friendly fire?!
37  }
38 }
float autocvar_g_vampirehook_damage
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
entity() spawn
#define DIFF_TEAM(a, b)
Definition: teams.qh:240
#define DMG_NOWEP
Definition: damage.qh:126
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
Definition: cl_resources.qc:31
float autocvar_g_vampirehook_damagerate
RES_HEALTH
Definition: ent_cs.qc:126
bool autocvar_g_vampirehook_teamheal
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: damage.qc:583
#define SAME_TEAM(a, b)
Definition: teams.qh:239
#define M_ARGV(x, type)
Definition: events.qh:17
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float autocvar_g_vampirehook_health_steal
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( vh  ,
expr_evaluate(autocvar_g_vampirehook  
)

Variable Documentation

◆ autocvar_g_vampirehook

string autocvar_g_vampirehook

Definition at line 3 of file sv_vampirehook.qc.

◆ autocvar_g_vampirehook_damage

float autocvar_g_vampirehook_damage

Definition at line 7 of file sv_vampirehook.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_vampirehook_damagerate

float autocvar_g_vampirehook_damagerate

Definition at line 8 of file sv_vampirehook.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_vampirehook_health_steal

float autocvar_g_vampirehook_health_steal

Definition at line 9 of file sv_vampirehook.qc.

◆ autocvar_g_vampirehook_teamheal

bool autocvar_g_vampirehook_teamheal

Definition at line 6 of file sv_vampirehook.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ last_dmg

float last_dmg

Definition at line 11 of file sv_vampirehook.qc.