]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/sv_main.qc
Merge branch 'master' into mirceakitsune/sandbox
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / sv_main.qc
index 15f43ad9eb730f980a1c40827213b13106c84a55..7ec4b49d671db22414e9f5b043b9071de1c3a735 100644 (file)
@@ -1,28 +1,31 @@
-
 void CreatureFrame (void)
 {
-       local entity oldself;
-       local float dm;
+       entity oldself;
+       float dm;
+       
        oldself = self;
-       for(self = world; (self = findfloat(self, iscreature, TRUE)); )
+       for(self = world; (self = findfloat(self, damagedbycontents, TRUE)); )
        {
-               if (self.movetype == MOVETYPE_NOCLIP)
-                       continue;
+               if (self.movetype == MOVETYPE_NOCLIP) { continue; }
+               
                float vehic = (self.vehicle_flags & VHF_ISVEHICLE);
-               if (self.waterlevel)
+               float projectile = (self.flags & FL_PROJECTILE);
+               
+               if (self.watertype <= CONTENT_WATER && self.waterlevel > 0) // workaround a retarded bug made by id software :P (yes, it's that old of a bug)
                {
                        if (!(self.flags & FL_INWATER))
                        {
                                self.flags |= FL_INWATER;
                                self.dmgtime = 0;
                        }
-                       if(!vehic) // vehicles don't drown
+
+                       if(!vehic && !projectile) // vehicles and projectiles don't drown
                        {
                                if (self.waterlevel != WATERLEVEL_SUBMERGED)
                                {
-                                       if(self.air_finished < time + 9)
+                                       if(self.air_finished < time)
                                                PlayerSound(playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND);
-                                       self.air_finished = time + 12;
+                                       self.air_finished = time + autocvar_g_balance_contents_drowndelay;
                                        self.dmg = 2;
                                }
                                else if (self.air_finished < time)
@@ -30,31 +33,40 @@ void CreatureFrame (void)
                                        if (!self.deadflag)
                                        if (self.pain_finished < time)
                                        {
-                                               Damage (self, world, world, 5, DEATH_DROWN, self.origin, '0 0 0');
+                                               Damage (self, world, world, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN, self.origin, '0 0 0');
                                                self.pain_finished = time + 0.5;
                                        }
                                }
                        }
+                       
                        if (self.dmgtime < time)
                        {
-                               self.dmgtime = time + 0.2;
-                               if (self.watertype == CONTENT_LAVA)
+                               self.dmgtime = time + autocvar_g_balance_contents_damagerate; 
+                               
+                               if (!projectile)
                                {
-                                       if (self.watersound_finished < time)
+                                       if (self.watertype == CONTENT_LAVA)
                                        {
-                                               self.watersound_finished = time + 0.5;
-                                               sound (self, CH_PLAYER, "player/lava.wav", VOL_BASE, ATTN_NORM);
+                                               if (self.watersound_finished < time)
+                                               {
+                                                       self.watersound_finished = time + 0.5;
+                                                       sound (self, CH_PLAYER, "player/lava.wav", VOL_BASE, ATTN_NORM);
+                                               }
+                                               Damage (self, world, world, autocvar_g_balance_contents_playerdamage_lava * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_LAVA, self.origin, '0 0 0');
                                        }
-                                       Damage (self, world, world, 6 * self.waterlevel, DEATH_LAVA, self.origin, '0 0 0');
-                               }
-                               else if (self.watertype == CONTENT_SLIME)
-                               {
-                                       if (self.watersound_finished < time)
+                                       else if (self.watertype == CONTENT_SLIME)
                                        {
-                                               self.watersound_finished = time + 0.5;
-                                               sound (self, CH_PLAYER, "player/slime.wav", VOL_BASE, ATTN_NORM);
+                                               if (self.watersound_finished < time)
+                                               {
+                                                       self.watersound_finished = time + 0.5;
+                                                       sound (self, CH_PLAYER, "player/slime.wav", VOL_BASE, ATTN_NORM);
+                                               }
+                                               Damage (self, world, world, autocvar_g_balance_contents_playerdamage_slime * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0');
                                        }
-                                       Damage (self, world, world, 2 * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0');
+                               }
+                               else if ((self.watertype == CONTENT_LAVA) || (self.watertype == CONTENT_SLIME))
+                               {
+                                       Damage (self, world, world, autocvar_g_balance_contents_projectiledamage * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0');
                                }
                        }
                }
@@ -70,7 +82,7 @@ void CreatureFrame (void)
                        self.dmg = 2;
                }
 
-               if(!vehic) // vehicles don't get falling damage
+               if(!vehic && !projectile) // vehicles don't get falling damage
                {
                        // check for falling damage
                        float velocity_len = vlen(self.velocity);
@@ -116,8 +128,8 @@ void CreatureFrame (void)
                                }
                        }
                }
-
-               self.oldvelocity = self.velocity;
+               
+        self.oldvelocity = self.velocity;
        }
        self = oldself;
 }
@@ -219,17 +231,10 @@ void StartFrame (void)
        RuneMatchGivePoints();
        bot_serverframe();
 
-       if(autocvar_spawn_debugview)
-       {
-               RandomSelection_Init();
-               for(self = world; (self = find(self, classname, "player")); )
-                       RandomSelection_Add(self, 0, string_null, 1, 0);
-               self = RandomSelection_chosen_ent;
-               SelectSpawnPoint(0);
-       }
-
        FOR_EACH_PLAYER(self)
                self.porto_forbidden = max(0, self.porto_forbidden - 1);
+
+       MUTATOR_CALLHOOK(SV_StartFrame);
 }
 
 .vector originjitter;
@@ -263,7 +268,7 @@ void SV_OnEntityPreSpawnFunction()
                        s = substring(s, 1, -1);
                }
 
-               n = tokenize(s);
+               n = tokenize_console(s);
                for(i = 0; i < n; ++i)
                {
                        s = argv(i);