From: Mario Date: Mon, 30 Dec 2019 14:53:05 +0000 (+1000) Subject: If the player has no weapon, return "none" in the chat, also report health 2342 as... X-Git-Tag: xonotic-v0.8.5~1105^2~60 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=88dc68266e930228049dbd37ae93e51677c9c1f6;p=xonotic%2Fxonotic-data.pk3dir.git If the player has no weapon, return "none" in the chat, also report health 2342 as "observing" during intermission --- diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 38ce9f3e5..6082dbc9b 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -7,6 +7,7 @@ #include "ipban.qh" #include #include "../common/t_items.qh" +#include "mapvoting.qh" #include "resources.qh" #include "items.qh" #include "player.qh" @@ -233,13 +234,25 @@ string PlayerHealth(entity this) float myhealth = floor(GetResource(this, RES_HEALTH)); if(myhealth == -666) return "spectating"; - else if(myhealth == -2342) + else if(myhealth == -2342 || (myhealth == 2342 && mapvote_initialized)) return "observing"; else if(myhealth <= 0 || IS_DEAD(this)) return "dead"; return ftos(myhealth); } +string WeaponNameFromWeaponentity(entity this, .entity weaponentity) +{ + entity wepent = this.(weaponentity); + if(!wepent) + return "none"; + else if(wepent.m_weapon != WEP_Null) + return wepent.m_weapon.m_name; + else if(wepent.m_switchweapon != WEP_Null) + return wepent.m_switchweapon.m_name; + return "none"; //Weapons_from(wepent.cnt).m_name; +} + string formatmessage(entity this, string msg) { float p, p1, p2; @@ -297,7 +310,7 @@ string formatmessage(entity this, string msg) case "l": replacement = NearestLocation(this.origin); break; case "y": replacement = NearestLocation(cursor); break; case "d": replacement = NearestLocation(this.death_origin); break; - case "w": replacement = ((this.(weaponentity).m_weapon == WEP_Null) ? ((this.(weaponentity).m_switchweapon == WEP_Null) ? Weapons_from(this.(weaponentity).cnt) : this.(weaponentity).m_switchweapon) : this.(weaponentity).m_weapon).m_name; break; + case "w": replacement = WeaponNameFromWeaponentity(this, weaponentity); break; case "W": replacement = AmmoNameFromWeaponentity(this.(weaponentity).m_weapon); break; case "x": replacement = ((cursor_ent.netname == "" || !cursor_ent) ? "nothing" : cursor_ent.netname); break; case "s": replacement = ftos(vlen(this.velocity - this.velocity_z * '0 0 1')); break;