Xonotic
disablerelay.qc
Go to the documentation of this file.
1 #include "disablerelay.qh"
2 #ifdef SVQC
3 void trigger_disablerelay_use(entity this, entity actor, entity trigger)
4 {
5  if(this.active != ACTIVE_ACTIVE)
6  return;
7 
8  int a = 0, b = 0;
9 
10  for(entity e = NULL; (e = find(e, targetname, this.target)); )
11  {
12  if(e.active == ACTIVE_ACTIVE)
13  {
14  e.active = ACTIVE_NOT;
15  ++a;
16  }
17  else if(e.active == ACTIVE_NOT)
18  {
19  e.active = ACTIVE_ACTIVE;
20  ++b;
21  }
22  }
23 
24  if((!a) == (!b))
25  LOG_INFO("Invalid use of trigger_disablerelay: ", ftos(a), " relays were on, ", ftos(b), " relays were off!");
26 }
27 
28 spawnfunc(trigger_disablerelay)
29 {
30  this.reset = spawnfunc_trigger_disablerelay; // this spawnfunc resets fully
31  this.active = ACTIVE_ACTIVE;
32  this.use = trigger_disablerelay_use;
33 }
34 #endif
entity() spawn
spawnfunc(info_player_attacker)
Definition: sv_assault.qc:283
const int ACTIVE_ACTIVE
Definition: defs.qh:37
#define NULL
Definition: post.qh:17
#define LOG_INFO(...)
Definition: log.qh:70
string targetname
Definition: progsdefs.qc:194
int active
Definition: defs.qh:34
#define use
Definition: csprogsdefs.qh:50
string target
Definition: progsdefs.qc:193
const int ACTIVE_NOT
Definition: defs.qh:36