Xonotic
sv_breakablehook.qc
Go to the documentation of this file.
1 #include "sv_breakablehook.qh"
2 
4 #include <server/hook.qh>
5 
6 REGISTER_MUTATOR(breakablehook, cvar("g_breakablehook"));
7 
8 bool autocvar_g_breakablehook; // allow toggling mid match?
10 
11 MUTATOR_HOOKFUNCTION(breakablehook, Damage_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, DMG_NOWEP, frag_target.realowner.origin, '0 0 0'); // TODO: should get weapon entity from mutator hook
26  RemoveHook(frag_target);
27  return; // dead
28  }
29  }
30 }
const int HITTYPE_SPLASH
automatically set by RadiusDamage
Definition: all.qh:27
entity() spawn
REGISTER_MUTATOR(breakablehook, cvar("g_breakablehook"))
#define DIFF_TEAM(a, b)
Definition: teams.qh:240
bool autocvar_g_breakablehook
#define DMG_NOWEP
Definition: damage.qh:126
MUTATOR_HOOKFUNCTION(breakablehook, Damage_Calculate)
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: damage.qc:583
#define M_ARGV(x, type)
Definition: events.qh:17
bool autocvar_g_breakablehook_owner
void RemoveHook(entity this)
Definition: hook.qc:96