]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
csqc items (needed for simple items)
authorJakob MG <jakob_mg@hotmail.com>
Sun, 25 Mar 2012 18:42:36 +0000 (20:42 +0200)
committerJakob MG <jakob_mg@hotmail.com>
Sun, 25 Mar 2012 18:42:36 +0000 (20:42 +0200)
qcsrc/client/Main.qc
qcsrc/client/progs.src
qcsrc/common/constants.qh
qcsrc/server/t_items.qc

index 12343e6a24bac333753628e7ca63fe473f126318..86eda75170f11814a07bfc4a6e4c3b795ae785e0 100644 (file)
@@ -752,7 +752,8 @@ void CSQC_Ent_Update(float bIsNewEntity)
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
                case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
                case ENT_CLIENT_TURRET: ent_turret(); break; 
-               case ENT_CLIENT_MODEL: CSQCModel_Read(bIsNewEntity); break; 
+               case ENT_CLIENT_MODEL: CSQCModel_Read(bIsNewEntity); break;
+               case ENT_CLIENT_ITEM: ItemRead(bIsNewEntity); break;  
                default:
                        //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
                        error(sprintf(_("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n"), self.enttype, num_for_edict(self), self.classname));
index d3a3a07d811e95d7ad75847cdbf056ecdb9a51d3..a0b4826a6fd425ff71bd5354484e633dc274d811 100644 (file)
@@ -53,6 +53,7 @@ projectile.qh
 sortlist.qc
 miscfunctions.qc
 teamplay.qc
+../server/t_items.qc
 
 teamradar.qc
 hud_config.qc
index e70a83c391d7b992ce0091e91efc89504fa31c4d..a5c8ccb33be92f255fcc2558771971434008ba1d 100644 (file)
@@ -97,6 +97,7 @@ const float ENT_CLIENT_ACCURACY = 30;
 const float ENT_CLIENT_SHOWNAMES = 31;
 const float ENT_CLIENT_WARPZONE_TELEPORTED = 32;
 const float ENT_CLIENT_MODEL = 33;
+const float ENT_CLIENT_ITEM = 34;
 
 const float ENT_CLIENT_TURRET = 40;
 const float ENT_CLIENT_AUXILIARYXHAIR = 50;
index 1e9d6a753c426c0708a8c6e6b79b6ec86f027950..ac3ac7cda8cb0c68265a46c407d2dbc02d9479b5 100644 (file)
@@ -1,3 +1,115 @@
+#define ISF_SETUP 0xFFFFFF
+#define ISF_LOCATION 2
+#define ISF_STATUS   4
+#define ISF_MODEL    8
+#define ISF_RESPAWN  16 // for item watch
+
+#ifdef CSQC
+.float lastupdate;
+.vector colormod;
+void ItemDraw()
+{
+    float _delta = time - self.lastupdate;
+    self.lastupdate = time;
+    if(_delta >= 0.1)
+        return;
+    
+    if(self.solid == SOLID_TRIGGER)
+    {
+        self.alpha = 0.5;
+        self.colormod = '-1 -1 -1';
+    }
+    else
+    {
+        self.alpha = 1;
+        self.colormod = '1 1 1';
+    }
+    
+    self.angles += '0 180 0' * _delta;
+    setorigin(self, '0 0 16' + self.oldorigin + '0 0 8' * sin(time * 2));
+}
+
+void ItemDrawSimple()
+{
+    
+}
+
+void ItemRead(float _IsNew)
+{
+    float sf = ReadByte();
+    float _taken = (self.solid == SOLID_TRIGGER) ? TRUE: FALSE;
+    
+    if(sf & ISF_LOCATION)
+    {
+        self.origin_x = ReadCoord();
+        self.origin_y = ReadCoord();
+        self.origin_z = ReadCoord();
+        setorigin(self, self.origin);
+        self.oldorigin = self.origin;
+    }
+    
+    if(sf & ISF_STATUS)
+    {
+        _taken = ReadByte();
+        if(_taken)
+            self.solid = SOLID_NOT;
+        else
+            self.solid = SOLID_TRIGGER;
+    }
+    
+    if(sf & ISF_MODEL) // handle simple itens here
+    {
+        if(self.mdl)
+            strunzone(self.mdl);
+        else
+        {
+            self.draw      = ItemDraw;
+            //self.draw_flag = DRAWFLAG_NORMAL;
+            self.drawmask = MASK_NORMAL;
+            self.movetype  = MOVETYPE_NOCLIP;
+        }
+        
+        self.mdl = strzone(ReadString());
+        setmodel(self, self.mdl);
+    }
+}
+#endif
+
+#ifdef SVQC
+float ItemSend(entity to, float sf)
+{
+       WriteByte(MSG_ENTITY, ENT_CLIENT_ITEM);
+       
+       WriteByte(MSG_ENTITY, sf);
+
+       //WriteByte(MSG_ENTITY, self.cnt);
+    if(sf & ISF_LOCATION)
+    {
+        WriteCoord(MSG_ENTITY, self.origin_x);
+        WriteCoord(MSG_ENTITY, self.origin_y);
+        WriteCoord(MSG_ENTITY, self.origin_z);
+    }
+
+    if(sf & ISF_STATUS)
+        WriteByte(MSG_ENTITY, (self.solid == SOLID_TRIGGER) ? TRUE: FALSE);
+
+    if(sf & ISF_MODEL)
+        WriteString(MSG_ENTITY, self.mdl);
+        
+            
+    //if(sf & ISF_RESPAWN)
+    
+    
+    /*
+    WriteByte(MSG_ENTITY, rint(self.colormod_x * 255));
+    WriteByte(MSG_ENTITY, rint(self.colormod_y * 255));
+    WriteByte(MSG_ENTITY, rint(self.colormod_z * 255));
+    */
+    
+    return TRUE;
+}
+
+
 float have_pickup_item(void)
 {
        // minstagib: only allow filtered items
@@ -106,6 +218,8 @@ float Item_Customize()
 
 void Item_Show (entity e, float mode)
 {
+    self.SendFlags |= ISF_STATUS;
+    
        e.effects &~= EF_ADDITIVE | EF_STARDUST | EF_FULLBRIGHT | EF_NODEPTHTEST;
        if (mode > 0)
        {
@@ -115,7 +229,7 @@ void Item_Show (entity e, float mode)
                e.colormod = '0 0 0';
                self.glowmod = self.colormod;
                e.alpha = 0;
-               e.customizeentityforclient = func_null;
+               //e.customizeentityforclient = func_null;
 
                e.spawnshieldtime = 1;
        }
@@ -127,7 +241,7 @@ void Item_Show (entity e, float mode)
                e.colormod = '0 0 0';
                self.glowmod = self.colormod;
                e.alpha = 0;
-               e.customizeentityforclient = func_null;
+               //e.customizeentityforclient = func_null;
 
                e.spawnshieldtime = 1;
        }
@@ -139,7 +253,7 @@ void Item_Show (entity e, float mode)
                e.colormod = '0 0 0';
                self.glowmod = self.colormod;
                e.effects |= EF_STARDUST;
-               e.customizeentityforclient = Item_Customize;
+               //e.customizeentityforclient = Item_Customize;
 
                e.spawnshieldtime = 0; // field indicates whether picking it up may give you anything other than the weapon
        }
@@ -151,7 +265,7 @@ void Item_Show (entity e, float mode)
                e.colormod = stov(autocvar_g_ghost_items_color);
                e.glowmod = e.colormod;
                e.alpha = g_ghost_items;
-               e.customizeentityforclient = func_null;
+               //e.customizeentityforclient = func_null;
 
                e.spawnshieldtime = 1;
        }
@@ -163,7 +277,7 @@ void Item_Show (entity e, float mode)
                e.colormod = '0 0 0';
                e.glowmod = e.colormod;
                e.alpha = 0;
-               e.customizeentityforclient = func_null;
+               //e.customizeentityforclient = func_null;
 
                e.spawnshieldtime = 1;
        }
@@ -912,6 +1026,13 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
        }
        else
                Item_Reset();
+    
+    if(self.classname == "droppedweapon")
+        return;
+        
+    //self.SendFlags = 0xFFFFFF;
+    Net_LinkEntity(self, FALSE, 0, ItemSend);
+
 }
 
 /* replace items in minstagib
@@ -1816,3 +1937,4 @@ float GiveItems(entity e, float beginarg, float endarg)
 
        return got;
 }
+#endif