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