]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/vampirehook/sv_vampirehook.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / vampirehook / sv_vampirehook.qc
1 #include "sv_vampirehook.qh"
2
3 string autocvar_g_vampirehook;
4 REGISTER_MUTATOR(vh, expr_evaluate(autocvar_g_vampirehook));
5
6 bool autocvar_g_vampirehook_teamheal;
7 float autocvar_g_vampirehook_damage;
8 float autocvar_g_vampirehook_damagerate;
9 float autocvar_g_vampirehook_health_steal;
10
11 .float last_dmg;
12
13 MUTATOR_HOOKFUNCTION(vh, GrappleHookThink)
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 (thehook.aiment.health > 0) {
25                                                         if (autocvar_g_vampirehook_damage) {
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
35                                                                 if (dmgent == thehook.owner) {
36                                                                         dmgent.health -= autocvar_g_vampirehook_damage; // FIXME: friendly fire?!
37                                                                 }
38                                                         }
39                                                 }
40                                         }
41                                 }
42                         }
43                 }
44         }
45 }