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