X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fsv_main.qc;h=aebea7523f66fea9e67d93ee485024bffeb9ff36;hb=6f6a9d3ce8a4fd3c10f7421ba27e4bfc944c8f9b;hp=c73f0355f8ad6ba1bd927e53c68e3e457e060d32;hpb=2f2147a6c665f04d1b6e860dce8a8a093e7d2b9e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index c73f0355f..e0722e7ed 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -1,26 +1,31 @@ - void CreatureFrame (void) { - local entity oldself; - local float dm, maxspeed; + entity oldself; + float dm; + oldself = self; - self = findfloat(world, iscreature, TRUE); - while (self) + for(self = world; (self = findfloat(self, damagedbycontents, TRUE)); ) { - if (self.movetype != MOVETYPE_NOCLIP) + if (self.movetype == MOVETYPE_NOCLIP) { continue; } + + float vehic = (self.vehicle_flags & VHF_ISVEHICLE); + 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.waterlevel) + if (!(self.flags & FL_INWATER)) + { + self.flags |= FL_INWATER; + self.dmgtime = 0; + } + + if(!vehic && !projectile) // vehicles and projectiles don't drown { - if (!(self.flags & FL_INWATER)) - { - self.flags |= FL_INWATER; - self.dmgtime = 0; - } if (self.waterlevel != WATERLEVEL_SUBMERGED) { - if(self.air_finished < time + 9) - PlayerSound(playersound_gasp, CHAN_PLAYER, VOICETYPE_PLAYERSOUND); - self.air_finished = time + 12; + if(self.air_finished < time) + PlayerSound(playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND); + self.air_finished = time + autocvar_g_balance_contents_drowndelay; self.dmg = 2; } else if (self.air_finished < time) @@ -28,48 +33,62 @@ 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) + } + + if (self.dmgtime < time) + { + self.dmgtime = time + autocvar_g_balance_contents_damagerate; + + if (!projectile) { - self.dmgtime = time + 0.2; if (self.watertype == CONTENT_LAVA) { if (self.watersound_finished < time) { self.watersound_finished = time + 0.5; - sound (self, CHAN_PLAYER, "player/lava.wav", VOL_BASE, ATTN_NORM); + sound (self, CH_PLAYER, "player/lava.wav", VOL_BASE, ATTN_NORM); } - Damage (self, world, world, 6 * self.waterlevel, DEATH_LAVA, self.origin, '0 0 0'); + Damage (self, world, world, autocvar_g_balance_contents_playerdamage_lava * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_LAVA, self.origin, '0 0 0'); } else if (self.watertype == CONTENT_SLIME) { if (self.watersound_finished < time) { self.watersound_finished = time + 0.5; - sound (self, CHAN_PLAYER, "player/slime.wav", VOL_BASE, ATTN_NORM); + sound (self, CH_PLAYER, "player/slime.wav", VOL_BASE, ATTN_NORM); } - Damage (self, world, world, 2 * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0'); + Damage (self, world, world, autocvar_g_balance_contents_playerdamage_slime * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0'); } } - } - else - { - if (self.flags & FL_INWATER) + else if ((self.watertype == CONTENT_LAVA) || (self.watertype == CONTENT_SLIME)) { - // play leave water sound - self.flags &~= FL_INWATER; - self.dmgtime = 0; + Damage (self, world, world, autocvar_g_balance_contents_projectiledamage * autocvar_g_balance_contents_damagerate * self.waterlevel, DEATH_SLIME, self.origin, '0 0 0'); } - self.air_finished = time + 12; - self.dmg = 2; } + } + else + { + if (self.flags & FL_INWATER) + { + // play leave water sound + self.flags &~= FL_INWATER; + self.dmgtime = 0; + } + self.air_finished = time + 12; + self.dmg = 2; + } + + if(!vehic && !projectile) // vehicles don't get falling damage + { // check for falling damage + float velocity_len = vlen(self.velocity); if(!self.hook.state && !g_ca && !(g_cts && !autocvar_g_cts_selfdamage)) { - dm = vlen(self.oldvelocity) - vlen(self.velocity); // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage. + dm = vlen(self.oldvelocity) - velocity_len; // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage. if (self.deadflag) dm = (dm - autocvar_g_balance_falldamage_deadminspeed) * autocvar_g_balance_falldamage_factor; else @@ -78,15 +97,13 @@ void CreatureFrame (void) Damage (self, world, world, dm, DEATH_FALL, self.origin, '0 0 0'); } - maxspeed = autocvar_g_maxspeed; - if(maxspeed > 0 && vlen(self.velocity) > maxspeed) + if(autocvar_g_maxspeed > 0 && velocity_len > autocvar_g_maxspeed) Damage (self, world, world, 100000, DEATH_SHOOTING_STAR, self.origin, '0 0 0'); - // play stupid sounds if (g_footsteps) if (!gameover) if (self.flags & FL_ONGROUND) - if (vlen(self.velocity) > autocvar_sv_maxspeed * 0.6) + if (velocity_len > autocvar_sv_maxspeed * 0.6) if (!self.deadflag) if (time < self.lastground + 0.2) { @@ -104,15 +121,15 @@ void CreatureFrame (void) if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS) { if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) - GlobalSound(globalsound_metalstep, CHAN_PLAYER, VOICETYPE_PLAYERSOUND); + GlobalSound(globalsound_metalstep, CH_PLAYER, VOICETYPE_PLAYERSOUND); else - GlobalSound(globalsound_step, CHAN_PLAYER, VOICETYPE_PLAYERSOUND); + GlobalSound(globalsound_step, CH_PLAYER, VOICETYPE_PLAYERSOUND); } } } - self.oldvelocity = self.velocity; } - self = findfloat(self, iscreature, TRUE); + + self.oldvelocity = self.velocity; } self = oldself; } @@ -225,6 +242,8 @@ void StartFrame (void) FOR_EACH_PLAYER(self) self.porto_forbidden = max(0, self.porto_forbidden - 1); + + MUTATOR_CALLHOOK(SV_StartFrame); } .vector originjitter; @@ -232,10 +251,11 @@ void StartFrame (void) .float anglejitter; .string gametypefilter; .string cvarfilter; +float DoesQ3ARemoveThisEntity(); void SV_OnEntityPreSpawnFunction() { if(self.gametypefilter != "") - if not(isGametypeInFilter(game, teams_matter, self.gametypefilter)) + if not(isGametypeInFilter(game, teamplay, have_team_spawns, self.gametypefilter)) { remove(self); return; @@ -257,7 +277,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); @@ -350,6 +370,12 @@ void SV_OnEntityPreSpawnFunction() } } + if(DoesQ3ARemoveThisEntity()) + { + remove(self); + return; + } + // support special -1 and -2 angle from radiant if (self.angles == '0 -1 0') self.angles = '-90 0 0'; @@ -377,3 +403,20 @@ void SV_OnEntityPreSpawnFunction() return; } } + +void WarpZone_PostInitialize_Callback(void) +{ + // create waypoint links for warpzones + entity e; + for(e = world; (e = find(e, classname, "trigger_warpzone")); ) + { + vector src, dst; + src = (e.absmin + e.absmax) * 0.5; + makevectors(e.warpzone_angles); + src = src + ((e.warpzone_origin - src) * v_forward) * v_forward + 16 * v_right; + dst = (e.enemy.absmin + e.enemy.absmax) * 0.5; + makevectors(e.enemy.warpzone_angles); + dst = dst + ((e.enemy.warpzone_origin - dst) * v_forward) * v_forward - 16 * v_right; + waypoint_spawnforteleporter_v(e, src, dst, 0); + } +}