Fix a self assignment bug in Weapons_AddItem(), added userinfo spraycolor support, fix accidentally double-drawing p_ models and add cvar sv_friendlyFire

This commit is contained in:
Marco Cawthorne 2022-04-19 21:58:13 -07:00
parent 1c58be4cdb
commit c24c8b2435
Signed by: eukara
GPG key ID: C196CD8BA993248A
5 changed files with 29 additions and 9 deletions

View file

@ -186,6 +186,8 @@ Weapons_Draw(player pl)
if (g_weapons[i].updateammo != __NULL__) if (g_weapons[i].updateammo != __NULL__)
g_weapons[i].updateammo(pl); g_weapons[i].updateammo(pl);
pl.gflags |= GF_SEMI_TOGGLED;
} }
void void
@ -204,6 +206,9 @@ Weapons_Primary(player pl)
if (pl.flags & FL_NOATTACK) if (pl.flags & FL_NOATTACK)
return; return;
if (pl.gflags & GF_SEMI_TOGGLED)
return;
if (g_weapons[i].primary != __NULL__) if (g_weapons[i].primary != __NULL__)
g_weapons[i].primary(pl); g_weapons[i].primary(pl);

View file

@ -71,8 +71,8 @@ player::predraw(void)
if (autocvar_cl_thirdperson == TRUE || !this_us) { if (autocvar_cl_thirdperson == TRUE || !this_us) {
Voice_Draw3D(this); Voice_Draw3D(this);
Player_PreDraw(this, TRUE); Player_PreDraw(this, TRUE);
if (p_model) //if (p_model)
addentity(p_model); // addentity(p_model);
//addentity(this); //addentity(this);
} else { } else {
Player_PreDraw(this, FALSE); Player_PreDraw(this, FALSE);

View file

@ -89,6 +89,7 @@ CSEv_Spraylogo(void)
#ifdef CLIENT #ifdef CLIENT
class CSpraylogo class CSpraylogo
{ {
vector m_vecColor;
vector m_vecPosition; vector m_vecPosition;
vector m_vecAngles; vector m_vecAngles;
int m_iOwnerID; int m_iOwnerID;
@ -104,7 +105,7 @@ const string g_spray_mat = \
"polygonOffset\n" \ "polygonOffset\n" \
"{\n" \ "{\n" \
"map $rt:%s\n" \ "map $rt:%s\n" \
"blendfunc blendFunc GL_DST_COLOR GL_ZERO\n" \ "blendfunc GL_DST_COLOR GL_ZERO\n" \
"rgbGen vertex\n" \ "rgbGen vertex\n" \
"}\n" \ "}\n" \
"}"; "}";
@ -137,14 +138,21 @@ CSpraylogo::predraw(void)
vector width; vector width;
vector height; vector height;
vector light; vector light;
vector color;
vector combined;
color = stov(getplayerkeyvalue(m_iOwnerID, "spraycolor"));
light = (getlight(m_vecPosition) / 255);
light = getlight(m_vecPosition) / 255; /* unrolling this because the compiler spat out garbage */
combined[0] = m_vecColor[0] * light[0];
combined[1] = m_vecColor[1] * light[1];
combined[2] = m_vecColor[2] * light[2];
/* TODO: handle spray dimensions independently */ /* TODO: handle spray dimensions independently */
makevectors(m_vecAngles); makevectors(m_vecAngles);
width = v_up / 64; width = v_up / 64;
height = v_forward / 64; height = v_forward / 64;
adddecal(m_strName, m_vecPosition, width, height, light, 1.0f); adddecal(m_strName, m_vecPosition, width, height, combined, 1.0f);
} }
return (PREDRAW_NEXT); return (PREDRAW_NEXT);
} }
@ -165,5 +173,6 @@ Spray_Parse(void)
spSelf.m_iOwnerID = readentitynum() - 1; spSelf.m_iOwnerID = readentitynum() - 1;
spSelf.m_strName = sprintf("spray_%i", spSelf.m_iOwnerID); spSelf.m_strName = sprintf("spray_%i", spSelf.m_iOwnerID);
spSelf.m_m_strPath = sprintf("simg_%i", spSelf.m_iOwnerID); spSelf.m_m_strPath = sprintf("simg_%i", spSelf.m_iOwnerID);
spSelf.m_vecColor = stov(getplayerkeyvalue(spSelf.m_iOwnerID, "spraycolor"));
} }
#endif #endif

View file

@ -14,6 +14,8 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
var bool autocvar_sv_friendlyFire = false;
/* init */ /* init */
void void
CGameRules::InitPostEnts(void) CGameRules::InitPostEnts(void)
@ -210,6 +212,14 @@ CGameRules::DamageApply(entity t, entity c, float dmg, int w, damageType_t type)
if (eTarget.flags & FL_CLIENT && eTarget.flags & FL_GODMODE) if (eTarget.flags & FL_CLIENT && eTarget.flags & FL_GODMODE)
return; return;
/* friendly fire */
if (autocvar_sv_friendlyFire == false)
if (IsTeamPlay()) {
if (t.flags & FL_CLIENT && c.flags & FL_CLIENT)
if (t.team == c.team)
return;
}
/* already dead, please avoid recursion */ /* already dead, please avoid recursion */
if (eTarget.GetHealth() <= 0) if (eTarget.GetHealth() <= 0)
return; return;

View file

@ -123,8 +123,6 @@ int
Weapons_AddItem(base_player pl, int w, int startammo) Weapons_AddItem(base_player pl, int w, int startammo)
{ {
int value; int value;
entity oldself = self;
self = pl;
/* let's check if we've got a limit */ /* let's check if we've got a limit */
int maxit; int maxit;
@ -139,7 +137,6 @@ Weapons_AddItem(base_player pl, int w, int startammo)
/* we're over the slot limit. */ /* we're over the slot limit. */
if (c >= maxit) { if (c >= maxit) {
self = oldself;
return (0); return (0);
} }
} }
@ -194,7 +191,6 @@ Weapons_AddItem(base_player pl, int w, int startammo)
} }
Weapons_RefreshAmmo(pl); Weapons_RefreshAmmo(pl);
self = oldself;
return value; return value;
} }