Xonotic
rotating.qc
Go to the documentation of this file.
1 #include "rotating.qh"
2 #ifdef SVQC
3 
4 void func_rotating_setactive(entity this, int astate)
5 {
6  if (astate == ACTIVE_TOGGLE)
7  {
8  if(this.active == ACTIVE_ACTIVE)
9  this.active = ACTIVE_NOT;
10  else
11  this.active = ACTIVE_ACTIVE;
12  }
13  else
14  this.active = astate;
15 
16  if(this.active == ACTIVE_NOT)
17  {
18  this.avelocity = '0 0 0';
19  stopsound(this, CH_AMBIENT_SINGLE);
20  }
21  else
22  {
23  this.avelocity = this.pos1;
24  if(this.noise && this.noise != "")
25  {
27  }
28  }
29 }
30 
31 void func_rotating_reset(entity this)
32 {
33  // TODO: reset angles as well?
34 
36  {
37  this.setactive(this, ACTIVE_NOT);
38  }
39  else
40  {
41  this.setactive(this, ACTIVE_ACTIVE);
42  }
43 }
44 
45 void func_rotating_init_for_player(entity this, entity player)
46 {
47  if (this.noise && this.noise != "" && this.active == ACTIVE_ACTIVE && IS_REAL_CLIENT(player))
48  {
49  msg_entity = player;
50  soundto (MSG_ONE, this, CH_AMBIENT_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE, 0);
51  }
52 }
53 
54 /*QUAKED spawnfunc_func_rotating (0 .5 .8) ? - - X_AXIS Y_AXIS
55 Brush model that spins in place on one axis (default Z).
56 speed : speed to rotate (in degrees per second)
57 noise : path/name of looping .wav file to play.
58 dmg : Do this much damage every .dmgtime interval when blocked
59 dmgtime : See above.
60 */
61 
62 spawnfunc(func_rotating)
63 {
64  if (this.noise && this.noise != "")
65  {
66  precache_sound(this.noise);
67  }
68 
69  this.setactive = func_rotating_setactive;
70 
71  if (!this.speed)
72  this.speed = 100;
74  this.avelocity = '0 0 1' * this.speed;
75  else if (this.spawnflags & FUNC_ROTATING_YAXIS)
76  this.avelocity = '1 0 0' * this.speed;
77  else // Z
78  this.avelocity = '0 1 0' * this.speed;
79 
80  this.pos1 = this.avelocity;
81 
82  if(this.dmg && (this.message == ""))
83  this.message = " was squished";
84  if(this.dmg && (this.message2 == ""))
85  this.message2 = "was squished by";
86 
87 
88  if(this.dmg && (!this.dmgtime))
89  this.dmgtime = 0.25;
90 
91  this.dmgtime2 = time;
92 
93  if (!InitMovingBrushTrigger(this))
94  return;
95  // no EF_LOWPRECISION here, as rounding angles is bad
96 
97  setblocked(this, generic_plat_blocked);
98 
99  // wait for targets to spawn
100  this.nextthink = this.ltime + 999999999;
101  setthink(this, SUB_NullThink); // for PushMove
102 
103  this.reset = func_rotating_reset;
104  this.reset(this);
105 
106  // maybe send sound to new players
107  IL_PUSH(g_initforplayer, this);
108  this.init_for_player = func_rotating_init_for_player;
109 }
110 #endif
float speed
Definition: subs.qh:41
string noise
Definition: progsdefs.qc:209
const int ACTIVE_TOGGLE
Definition: defs.qh:40
entity() spawn
float dmg
Definition: platforms.qh:6
const int FUNC_ROTATING_YAXIS
Definition: rotating.qh:5
spawnfunc(info_player_attacker)
Definition: sv_assault.qc:283
vector avelocity
Definition: csprogsdefs.qc:105
float ltime
Definition: progsdefs.qc:107
float spawnflags
Definition: progsdefs.qc:191
IntrusiveList g_initforplayer
Definition: client.qh:373
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
entity msg_entity
Definition: progsdefs.qc:63
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
const int ACTIVE_ACTIVE
Definition: defs.qh:37
string message
Definition: powerups.qc:19
const float VOL_BASE
Definition: sound.qh:36
float nextthink
Definition: csprogsdefs.qc:121
void SUB_NullThink(entity this)
Definition: subs.qc:3
float dmgtime
Definition: platforms.qh:7
#define _sound(e, c, s, v, a)
Definition: sound.qh:50
float dmgtime2
Definition: platforms.qh:8
void generic_plat_blocked(entity this, entity blocker)
Definition: platforms.qc:3
int active
Definition: defs.qh:34
vector pos1
Definition: subs.qh:50
#define setthink(e, f)
const int ACTIVE_NOT
Definition: defs.qh:36
float time
Definition: csprogsdefs.qc:16
const int CH_AMBIENT_SINGLE
Definition: sound.qh:25
const int FUNC_ROTATING_STARTOFF
Definition: rotating.qh:6
const int FUNC_ROTATING_XAXIS
Definition: rotating.qh:4
const float ATTEN_IDLE
Definition: sound.qh:32