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