]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/rotating.qc
Bot AI: reduce powerup rating value
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / rotating.qc
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                 {
26                         _sound(this, CH_AMBIENT_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
27                 }
28         }
29 }
30
31 void func_rotating_reset(entity this)
32 {
33         // TODO: reset angles as well?
34
35         if(this.spawnflags & FUNC_ROTATING_STARTOFF)
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);
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 mutch dmg every .dmgtime intervall 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;
73         if (this.spawnflags & FUNC_ROTATING_XAXIS)
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