From 99692b5401d387012fae0cac096bba507a3e8919 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Tue, 20 Jul 2021 06:49:38 +1000 Subject: [PATCH] Add support for skinned, coloured item models (intended for powerups) --- qcsrc/client/items/items.qc | 2 ++ qcsrc/common/items/item/pickup.qh | 2 ++ qcsrc/server/items/items.qc | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/qcsrc/client/items/items.qc b/qcsrc/client/items/items.qc index 064be587e..f94d36cf6 100644 --- a/qcsrc/client/items/items.qc +++ b/qcsrc/client/items/items.qc @@ -229,6 +229,8 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew) precache_model(this.mdl); _setmodel(this, this.mdl); + this.skin = ReadByte(); + setsize(this, '-16 -16 0', '16 16 48'); } diff --git a/qcsrc/common/items/item/pickup.qh b/qcsrc/common/items/item/pickup.qh index 7e3199407..d21923e25 100644 --- a/qcsrc/common/items/item/pickup.qh +++ b/qcsrc/common/items/item/pickup.qh @@ -22,6 +22,8 @@ PROPERTY(float, g_pickup_respawntimejitter_powerup) CLASS(Pickup, GameItem) #ifdef GAMEQC ATTRIB(Pickup, m_model, Model); + ATTRIB(Pickup, m_skin, int); + ATTRIB(Pickup, m_color, vector); ATTRIB(Pickup, m_sound, Sound, SND_ITEMPICKUP); #endif ATTRIB(Pickup, netname, string); diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index 610c864b1..faea9449e 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -63,9 +63,9 @@ bool ItemSend(entity this, entity to, int sf) LOG_TRACE("^1WARNING!^7 this.mdl is unset for item ", this.classname, "expect a crash just about now"); WriteString(MSG_ENTITY, this.mdl); + WriteByte(MSG_ENTITY, bound(0, this.skin, 255)); } - if(sf & ISF_COLORMAP) { WriteShort(MSG_ENTITY, this.colormap); @@ -1071,6 +1071,10 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default setmodel(this, MDL_Null); // precision set below //this.effects |= EF_LOWPRECISION; + // support skinned models for powerups + this.skin = def.m_skin; + this.glowmod = def.m_color; + setsize (this, this.pos1 = def.m_mins, this.pos2 = def.m_maxs); this.SendFlags |= ISF_SIZE; -- 2.39.2