centerprints now are managed independently per line
[divverent/nexuiz.git] / data / qcsrc / server / sv_main.qc
1
2 void CreatureFrame (void)
3 {
4         local entity oldself;
5         local float dm;
6         oldself = self;
7         self = findfloat(world, iscreature, TRUE);
8         while (self)
9         {
10                 if (self.movetype != MOVETYPE_NOCLIP)
11                 {
12                         if (self.waterlevel)
13                         {
14                                 if (!(self.flags & FL_INWATER))
15                                 {
16                                         //if (self.watertype == CONTENT_LAVA)
17                                         //      sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
18                                         //if (self.watertype == CONTENT_WATER)
19                                         //      sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
20                                         //if (self.watertype == CONTENT_SLIME)
21                                         //      sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
22                                         self.flags = self.flags + FL_INWATER;
23                                         self.dmgtime = 0;
24                                 }
25                                 if (self.waterlevel != 3)
26                                 {
27                                         self.air_finished = time + 12;
28                                         self.dmg = 2;
29                                 }
30                                 else if (self.air_finished < time)
31                                 {       // drown!
32                                         if (!self.deadflag)
33                                         if (self.pain_finished < time)
34                                         {
35                                                 Damage (self, world, world, 5, DEATH_DROWN, self.origin, '0 0 0');
36                                                 self.pain_finished = time + 0.5;
37                                         }
38                                 }
39                                 if (self.dmgtime < time)
40                                 {
41                                         self.dmgtime = time + 0.1;
42                                         if (self.watertype == CONTENT_LAVA)
43                                         {
44                                                 if (self.watersound_finished < time)
45                                                 {
46                                                         self.watersound_finished = time + 0.5;
47                                                         sound (self, CHAN_BODY, "player/lava.wav", 1, ATTN_NORM);
48                                                 }
49                                                 Damage (self, world, world, 6 * self.waterlevel, DEATH_LAVA, self.origin, '0 0 0');
50                                         }
51                                         else if (self.watertype == CONTENT_SLIME)
52                                         {
53                                                 if (self.watersound_finished < time)
54                                                 {
55                                                         self.watersound_finished = time + 0.5;
56                                                         sound (self, CHAN_BODY, "player/slime.wav", 1, ATTN_NORM);
57                                                 }
58                                                 Damage (self, world, world, 2 * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0');
59                                         }
60                                 }
61                         }
62                         else
63                         {
64                                 if (self.flags & FL_INWATER)
65                                 {
66                                         // play leave water sound
67                                         self.flags = self.flags - FL_INWATER;
68                                         self.dmgtime = 0;
69                                 }
70                                 self.air_finished = time + 12;
71                                 self.dmg = 2;
72                         }
73                         // check for falling damage
74                         if(!self.hook.state)
75                         {
76                                 dm = vlen(self.velocity - self.oldvelocity);
77                                 if (self.deadflag)
78                                         dm = (dm - cvar("g_balance_falldamage_deadminspeed")) * cvar("g_balance_falldamage_factor");
79                                 else
80                                 {
81                                         if (self.oldvelocity_z < self.velocity_z - 100)
82                                         {
83                                                 local float soundrandom;
84                                                 soundrandom = random() * 4;
85                                                 if (soundrandom < 1)
86                                                         sound (self, CHAN_BODY, "misc/hitground1.ogg", 1, ATTN_NORM);
87                                                 else if (soundrandom < 2)
88                                                         sound (self, CHAN_BODY, "misc/hitground2.ogg", 1, ATTN_NORM);
89                                                 else if (soundrandom < 3)
90                                                         sound (self, CHAN_BODY, "misc/hitground3.ogg", 1, ATTN_NORM);
91                                                 else if (soundrandom < 4)
92                                                         sound (self, CHAN_BODY, "misc/hitground4.ogg", 1, ATTN_NORM);
93                                                 self.nextstep = time + 0.3 + random() * 0.1;
94                                         }
95                                         dm = min((dm - cvar("g_balance_falldamage_minspeed")) * cvar("g_balance_falldamage_factor"), cvar("g_balance_falldamage_maxdamage"));
96                                 }
97                                 if (dm > 0)
98                                         Damage (self, world, world, dm, DEATH_FALL, self.origin, '0 0 0');
99                                 else if(vlen(self.velocity) > 100000 && cvar("developer"))
100                                 {
101                                         dprint(strcat(self.netname, " became too fast, please investigate: ", vtos(self.spawnorigin), "\n"));
102                                         Damage (self, world, world, 50000, DEATH_SHOOTING_STAR, self.origin, '0 0 0');
103                                 }
104                         }
105
106                         // play stupid sounds
107                         if (cvar("g_footsteps"))
108                         if (!gameover)
109                         if (self.flags & FL_ONGROUND)
110                         if (vlen(self.velocity) > sv_maxspeed * 0.6)
111                         if (!self.deadflag)
112                         {
113                                 if((time > self.nextstep) || (time < (self.nextstep - 10.0)))
114                                 {
115                                         local float steprandom;
116                                         self.nextstep = time + 0.3 + random() * 0.1;
117                                         steprandom = random() * 6;
118                                         if (steprandom < 1)
119                                                 sound (self, CHAN_BODY, "misc/footstep01.wav", 1, ATTN_NORM);
120                                         else if (steprandom < 2)
121                                                 sound (self, CHAN_BODY, "misc/footstep02.wav", 1, ATTN_NORM);
122                                         else if (steprandom < 3)
123                                                 sound (self, CHAN_BODY, "misc/footstep03.wav", 1, ATTN_NORM);
124                                         else if (steprandom < 4)
125                                                 sound (self, CHAN_BODY, "misc/footstep04.wav", 1, ATTN_NORM);
126                                         else if (steprandom < 5)
127                                                 sound (self, CHAN_BODY, "misc/footstep05.wav", 1, ATTN_NORM);
128                                         else if (steprandom <= 6)
129                                                 sound (self, CHAN_BODY, "misc/footstep06.wav", 1, ATTN_NORM);
130                                 }
131                         }
132                         self.oldvelocity = self.velocity;
133                 }
134                 self = findfloat(self, iscreature, TRUE);
135         }
136         self = oldself;
137 }
138
139
140 /*
141 =============
142 StartFrame
143
144 Called before each frame by the server
145 =============
146 */
147 void RuneMatchGivePoints();
148 void StartFrame (void)
149 {
150         sv_maxairspeed = cvar("sv_maxairspeed");
151         sv_maxspeed = cvar ("sv_maxspeed");
152         sv_friction = cvar ("sv_friction");
153         sv_accelerate = cvar ("sv_accelerate");
154         sv_airaccelerate = cvar("sv_airaccelerate");
155         sv_airaccel_sideways_friction = cvar("sv_airaccel_sideways_friction");
156         sv_airaccel_qw = cvar("sv_airaccel_qw");
157
158         sv_stopspeed = cvar ("sv_stopspeed");
159         teamplay = cvar ("teamplay");
160         skill = cvar("skill");
161
162         Spawnqueue_Check();
163
164         CreatureFrame ();
165         CheckRules_World ();
166
167         AuditTeams();
168
169         RuneMatchGivePoints();
170         bot_serverframe();
171 }