]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/sv_main.qc
cl_teamradar_foreground_alpha cvar
[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                                         self.flags = self.flags + FL_INWATER;
17                                         self.dmgtime = 0;
18                                 }
19                                 if (self.waterlevel != 3)
20                                 {
21                                         if(self.air_finished < time + 9)
22                                                 PlayerSound(playersound_gasp, CHAN_PLAYER, 0);
23                                         self.air_finished = time + 12;
24                                         self.dmg = 2;
25                                 }
26                                 else if (self.air_finished < time)
27                                 {       // drown!
28                                         if (!self.deadflag)
29                                         if (self.pain_finished < time)
30                                         {
31                                                 Damage (self, world, world, 5, DEATH_DROWN, self.origin, '0 0 0');
32                                                 self.pain_finished = time + 0.5;
33                                         }
34                                 }
35                                 if (self.dmgtime < time)
36                                 {
37                                         self.dmgtime = time + 0.1;
38                                         if (self.watertype == CONTENT_LAVA)
39                                         {
40                                                 if (self.watersound_finished < time)
41                                                 {
42                                                         self.watersound_finished = time + 0.5;
43                                                         sound (self, CHAN_PLAYER, "player/lava.wav", VOL_BASE, ATTN_NORM);
44                                                 }
45                                                 Damage (self, world, world, 6 * self.waterlevel, DEATH_LAVA, self.origin, '0 0 0');
46                                         }
47                                         else if (self.watertype == CONTENT_SLIME)
48                                         {
49                                                 if (self.watersound_finished < time)
50                                                 {
51                                                         self.watersound_finished = time + 0.5;
52                                                         sound (self, CHAN_PLAYER, "player/slime.wav", VOL_BASE, ATTN_NORM);
53                                                 }
54                                                 Damage (self, world, world, 2 * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0');
55                                         }
56                                 }
57                         }
58                         else
59                         {
60                                 if (self.flags & FL_INWATER)
61                                 {
62                                         // play leave water sound
63                                         self.flags = self.flags - FL_INWATER;
64                                         self.dmgtime = 0;
65                                 }
66                                 self.air_finished = time + 12;
67                                 self.dmg = 2;
68                         }
69                         // check for falling damage
70                         if(!self.hook.state)
71                         {
72                                 dm = vlen(self.oldvelocity) - vlen(self.velocity); // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
73                                 if (self.deadflag)
74                                         dm = (dm - cvar("g_balance_falldamage_deadminspeed")) * cvar("g_balance_falldamage_factor");
75                                 else
76                                         dm = min((dm - cvar("g_balance_falldamage_minspeed")) * cvar("g_balance_falldamage_factor"), cvar("g_balance_falldamage_maxdamage"));
77                                 if (dm > 0)
78                                 {
79                                         Damage (self, world, world, dm, DEATH_FALL, self.origin, '0 0 0');
80                                 }
81                                 else if(vlen(self.velocity) > 100000 && cvar("developer"))
82                                 {
83                                         dprint(strcat(self.netname, " became too fast, please investigate: ", vtos(self.spawnorigin), "\n"));
84                                         Damage (self, world, world, 50000, DEATH_SHOOTING_STAR, self.origin, '0 0 0');
85                                 }
86                         }
87
88                         // play stupid sounds
89                         if (g_footsteps)
90                         if (!gameover)
91                         if (self.flags & FL_ONGROUND)
92                         if (vlen(self.velocity) > sv_maxspeed * 0.6)
93                         if (!self.deadflag)
94                         if (time < self.lastground + 0.2)
95                         {
96                                 if((time > self.nextstep) || (time < (self.nextstep - 10.0)))
97                                 {
98                                         self.nextstep = time + 0.3 + random() * 0.1;
99                                         trace_dphitq3surfaceflags = 0;
100                                         tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self);
101                                         /*
102                                         if(trace_fraction == 1)
103                                                 dprint("nohit\n");
104                                         else
105                                                 dprint(ftos(trace_dphitq3surfaceflags), "\n");
106                                         */
107                                         if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)
108                                         {
109                                                 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
110                                                         GlobalSound(globalsound_metalstep, CHAN_PLAYER, 0);
111                                                 else
112                                                         GlobalSound(globalsound_step, CHAN_PLAYER, 0);
113                                         }
114                                 }
115                         }
116                         self.oldvelocity = self.velocity;
117                 }
118                 self = findfloat(self, iscreature, TRUE);
119         }
120         self = oldself;
121 }
122
123
124 /*
125 =============
126 StartFrame
127
128 Called before each frame by the server
129 =============
130 */
131 void RuneMatchGivePoints();
132 float RedirectionThink();
133 entity SelectSpawnPoint (float anypoint);
134 void StartFrame (void)
135 {
136         remove = remove_builtin; // not during spawning!
137
138         dprint_load(); // load dprint status from cvar
139
140         if(RedirectionThink())
141                 return;
142
143         UncustomizeEntitiesRun();
144         InitializeEntitiesRun();
145
146         sv_maxairspeed = cvar("sv_maxairspeed");
147         sv_maxspeed = cvar ("sv_maxspeed");
148         sv_friction = cvar ("sv_friction");
149         sv_accelerate = cvar ("sv_accelerate");
150         sv_airaccelerate = cvar("sv_airaccelerate");
151         sv_airaccel_sideways_friction = cvar("sv_airaccel_sideways_friction");
152         sv_airaccel_qw = cvar("sv_airaccel_qw");
153
154         sv_stopspeed = cvar ("sv_stopspeed");
155         teamplay = cvar ("teamplay");
156         skill = cvar("skill");
157
158         Spawnqueue_Check();
159
160         // if in warmup stage and limit for warmup is hit start match
161         if (inWarmupStage
162             && 0 < g_warmup_limit
163             && time >= g_warmup_limit)
164         {
165                 ReadyRestart();
166                 return;
167         }
168
169         CreatureFrame ();
170         CheckRules_World ();
171
172         AuditTeams();
173
174         RuneMatchGivePoints();
175         bot_serverframe();
176
177         if(cvar("spawn_debugview"))
178         {
179                 RandomSelection_Init();
180                 for(self = world; (self = find(self, classname, "player")); )
181                         RandomSelection_Add(self, 0, 1, 0);
182                 self = RandomSelection_chosen_ent;
183                 SelectSpawnPoint(0);
184         }
185
186         FOR_EACH_PLAYER(self)
187                 self.porto_forbidden = max(0, self.porto_forbidden - 1);
188 }