]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/vampirehook/sv_vampirehook.qc
Merge branch 'master' into terencehill/spectatee_status_update
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / vampirehook / sv_vampirehook.qc
1 #include "sv_vampirehook.qh"
2
3 REGISTER_MUTATOR(vh, cvar("g_vampirehook"));
4
5 bool autocvar_g_vampirehook_teamheal;
6 float autocvar_g_vampirehook_damage;
7 float autocvar_g_vampirehook_damagerate;
8 float autocvar_g_vampirehook_health_steal;
9
10 .float last_dmg;
11
12 MUTATOR_HOOKFUNCTION(vh, GrappleHookThink)
13 {
14         entity thehook = M_ARGV(0, entity);
15
16         entity dmgent = ((SAME_TEAM(thehook.owner, thehook.aiment) && autocvar_g_vampirehook_teamheal) ? thehook.owner : thehook.aiment);
17
18         if(IS_PLAYER(thehook.aiment))
19         if(thehook.last_dmg < time)
20         if(!STAT(FROZEN, thehook.aiment))
21         if(time >= game_starttime)
22         if(DIFF_TEAM(thehook.owner, thehook.aiment) || autocvar_g_vampirehook_teamheal)
23         if(thehook.aiment.health > 0)
24         if(autocvar_g_vampirehook_damage)
25         {
26                 thehook.last_dmg = time + autocvar_g_vampirehook_damagerate;
27                 thehook.owner.damage_dealt += autocvar_g_vampirehook_damage;
28                 Damage(dmgent, thehook, thehook.owner, autocvar_g_vampirehook_damage, WEP_HOOK.m_id, thehook.origin, '0 0 0');
29                 if(SAME_TEAM(thehook.owner, thehook.aiment))
30                         thehook.aiment.health = min(thehook.aiment.health + autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max);
31                 else
32                         thehook.owner.health = min(thehook.owner.health + autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max);
33
34                 if(dmgent == thehook.owner)
35                         dmgent.health -= autocvar_g_vampirehook_damage; // FIXME: friendly fire?!
36         }
37 }