]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/breakablehook/breakablehook.qc
3719001a40f9869647fb02946b08c8f962d333d0
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / breakablehook / breakablehook.qc
1 #ifdef IMPLEMENTATION
2 #include <common/deathtypes/all.qh>
3 #include <server/g_hook.qh>
4
5 REGISTER_MUTATOR(breakablehook, cvar("g_breakablehook"));
6
7 bool autocvar_g_breakablehook; // allow toggling mid match?
8 bool autocvar_g_breakablehook_owner;
9
10 MUTATOR_HOOKFUNCTION(breakablehook, PlayerDamage_Calculate)
11 {
12         if(frag_target.classname == "grapplinghook")
13         {
14                 if((!autocvar_g_breakablehook)
15                 || (!autocvar_g_breakablehook_owner && frag_attacker == frag_target.realowner)
16                         ) { frag_damage = 0; }
17
18                 // hurt the owner of the hook
19                 if(DIFF_TEAM(frag_attacker, frag_target.realowner))
20                 {
21                         Damage (frag_target.realowner, frag_attacker, frag_attacker, 5, WEP_HOOK.m_id | HITTYPE_SPLASH, frag_target.realowner.origin, '0 0 0');
22                         RemoveGrapplingHook(frag_target.realowner);
23                         return false; // dead
24                 }
25         }
26
27         return false;
28 }
29 #endif