From: terencehill Date: Thu, 9 Apr 2020 15:49:47 +0000 (+0200) Subject: Set air_finished to 0 while player is out of water instead of updating it to time... X-Git-Tag: xonotic-v0.8.5~1126 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=af6d36701da5864e21894d0776de06725355d4bc;p=xonotic%2Fxonotic-data.pk3dir.git Set air_finished to 0 while player is out of water instead of updating it to time + autocvar_g_balance_contents_drowndelay every frame. Remove the redundant field air_finished, rename the field pointer air_finished_stat to air_finished --- diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 21069a949..b3cac72e5 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -163,6 +163,8 @@ bool racer_frame(entity this, float dt) int cont = Mod_Q1BSP_SuperContentsFromNativeContents(pointcontents(vehic.origin)); if(!(cont & DPCONTENTS_WATER)) + vehic.air_finished = 0; + else if (!vehic.air_finished) vehic.air_finished = time + autocvar_g_vehicle_racer_water_time; if(IS_DEAD(vehic)) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 9b6b6c4c1..271c80396 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -337,7 +337,7 @@ void PutObserverInServer(entity this) this.strength_finished = 0; this.invincible_finished = 0; this.superweapons_finished = 0; - this.air_finished_stat = 0; + this.air_finished = 0; //this.dphitcontentsmask = 0; this.dphitcontentsmask = DPCONTENTS_SOLID; if (autocvar_g_playerclip_collisions) @@ -648,7 +648,7 @@ void PutPlayerInServer(entity this) STAT(BUFFS, this) = 0; STAT(BUFF_TIME, this) = 0; - this.air_finished = time + autocvar_g_balance_contents_drowndelay; + this.air_finished = 0; this.waterlevel = WATERLEVEL_NONE; this.watertype = CONTENT_EMPTY; @@ -1685,7 +1685,7 @@ void SpectateCopy(entity this, entity spectatee) this.strength_finished = spectatee.strength_finished; this.invincible_finished = spectatee.invincible_finished; this.superweapons_finished = spectatee.superweapons_finished; - this.air_finished_stat = spectatee.air_finished_stat; + this.air_finished = spectatee.air_finished; STAT(PRESSED_KEYS, this) = STAT(PRESSED_KEYS, spectatee); STAT(WEAPONS, this) = STAT(WEAPONS, spectatee); this.punchangle = spectatee.punchangle; @@ -2610,22 +2610,23 @@ void DrownPlayer(entity this) if (this.waterlevel != WATERLEVEL_SUBMERGED || this.vehicle) { - if(this.air_finished < time) + if(this.air_finished && this.air_finished < time) PlayerSound(this, playersound_gasp, CH_PLAYER, VOL_BASE, VOICETYPE_PLAYERSOUND); - this.air_finished = time + autocvar_g_balance_contents_drowndelay; - this.air_finished_stat = 0; + this.air_finished = 0; } - else if (this.air_finished < time) - { // drown! - if (this.pain_finished < time) - { - Damage (this, NULL, NULL, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN.m_id, DMG_NOWEP, this.origin, '0 0 0'); - this.pain_finished = time + 0.5; + else + { + if (!this.air_finished) + this.air_finished = time + autocvar_g_balance_contents_drowndelay; + if (this.air_finished < time) + { // drown! + if (this.pain_finished < time) + { + Damage (this, NULL, NULL, autocvar_g_balance_contents_playerdamage_drowning * autocvar_g_balance_contents_damagerate, DEATH_DROWN.m_id, DMG_NOWEP, this.origin, '0 0 0'); + this.pain_finished = time + 0.5; + } } - this.air_finished_stat = this.air_finished; } - else - this.air_finished_stat = this.air_finished; } .bool move_qcphysics; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 3b5acfbd0..c7ed5a568 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -51,7 +51,7 @@ float server_is_dedicated; .float crouch; // Crouching or not? const .float superweapons_finished = _STAT(SUPERWEAPONS_FINISHED); -const .float air_finished_stat = _STAT(AIR_FINISHED); +const .float air_finished = _STAT(AIR_FINISHED); .float cnt; // used in too many places .float count; @@ -93,7 +93,6 @@ const float MAX_DAMAGEEXTRARADIUS = 16; .float railgunhitsolidbackup; .vector railgunhitloc; -.float air_finished; .float dmgtime; .float killcount; diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index 367cc99b7..3aef76e49 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -80,6 +80,8 @@ void CreatureFrame_Liquids(entity this) } CreatureFrame_hotliquids(this); + if (!this.air_finished) + this.air_finished = time + autocvar_g_balance_contents_drowndelay; } else { @@ -89,7 +91,7 @@ void CreatureFrame_Liquids(entity this) this.flags &= ~FL_INWATER; this.dmgtime = 0; } - this.air_finished = time + autocvar_g_balance_contents_drowndelay; + this.air_finished = 0; } }