-#define ISF_SETUP 0xFFFFFF
#define ISF_LOCATION 2
-#define ISF_STATUS 4
-#define ISF_MODEL 8
-#define ISF_RESPAWN 16 // for item watch
-#define ISF_FLAGS 32
+#define ISF_MODEL 4
+#define ISF_STATUS 8
+ #define ITS_ANIMATED 2
+ #define ITS_AVAILABLE 4
+ #define ITS_POWERUP 8
+ #define ITS_ALLOWFB 16
+
+.float ItemStatus;
#ifdef CSQC
-// FIXME: Move this to ../common/constants.qh?
-float FL_FLY = 1;
-float FL_SWIM = 2;
-float FL_CLIENT = 8;
-float FL_INWATER = 16;
-float FL_MONSTER = 32;
-float FL_GODMODE = 64;
-float FL_NOTARGET = 128;
-float FL_ITEM = 256;
-float FL_ONGROUND = 512;
-float FL_PARTIALGROUND = 1024;
-float FL_WATERJUMP = 2048;
-float FL_JUMPRELEASED = 4096;
-float FL_WEAPON = 8192;
-float FL_POWERUP = 16384;
-float FL_PROJECTILE = 32768;
-float FL_TOSSED = 65536;
-float FL_NO_WEAPON_STAY = 131072;
-float FL_SPAWNING = 262144;
-/////
-
-.float lastupdate;
.vector colormod;
void ItemDraw()
{
- float _delta = time - self.lastupdate;
- self.lastupdate = time;
- if(_delta >= 0.1)
- return;
-
- if(self.solid == SOLID_TRIGGER)
+ if(self.ItemStatus & ITS_AVAILABLE)
{
- self.alpha = 0.5;
- self.colormod = '-1 -1 -1';
+ self.alpha = 1;
+ self.colormod = '1 1 1';
}
else
{
- self.alpha = 1;
- self.colormod = '1 1 1';
+ self.alpha = 0.5;
+ self.colormod = '-1 -1 -1';
}
- if(self.flags & FL_WEAPON)
+ if(self.ItemStatus & ITS_ANIMATED)
{
- self.angles += '0 180 0' * _delta;
- setorigin(self, '0 0 16' + self.oldorigin + '0 0 8' * sin(time * 2));
+ self.angles += '0 180 0' * frametime;
+ setorigin(self, '0 0 10' + self.oldorigin + '0 0 8' * sin(time * 2));
}
}
void ItemRead(float _IsNew)
{
float sf = ReadByte();
- float _taken = (self.solid == SOLID_TRIGGER) ? TRUE: FALSE;
-
+
if(sf & ISF_LOCATION)
{
self.origin_x = ReadCoord();
self.oldorigin = self.origin;
}
- if(sf & ISF_STATUS)
- {
- _taken = ReadByte();
- if(_taken)
- self.solid = SOLID_NOT;
- else
- self.solid = SOLID_TRIGGER;
- }
+ if(sf & ISF_STATUS) // need to read/write status frist so model can handle simple, fb etc.
+ self.ItemStatus = ReadByte();
- if(sf & ISF_MODEL) // handle simple itens here
+ if(sf & ISF_MODEL) // handle simple items, fullbright and so on here
{
if(self.mdl)
strunzone(self.mdl);
- else
- {
- self.draw = ItemDraw;
- self.drawmask = MASK_NORMAL;
- self.movetype = MOVETYPE_NOCLIP;
- }
-
- self.mdl = strzone(ReadString());
+
+ self.draw = ItemDraw;
+ self.drawmask = MASK_NORMAL;
+ self.movetype = MOVETYPE_NOCLIP;
+ self.mdl = strzone(ReadString());
setmodel(self, self.mdl);
}
-
- if(sf & ISF_FLAGS)
- self.flags = ReadCoord();
}
#endif
}
if(sf & ISF_STATUS)
- WriteByte(MSG_ENTITY, (self.solid == SOLID_TRIGGER) ? TRUE: FALSE);
+ WriteByte(MSG_ENTITY, self.ItemStatus);
if(sf & ISF_MODEL)
WriteString(MSG_ENTITY, self.mdl);
- if(sf & ISF_FLAGS)
- WriteCoord(MSG_ENTITY, self.flags);
-
return TRUE;
}
//e.customizeentityforclient = func_null;
e.spawnshieldtime = 1;
+ self.ItemStatus |= ITS_AVAILABLE;
}
else if (mode < 0)
{
//e.customizeentityforclient = func_null;
e.spawnshieldtime = 1;
+ self.ItemStatus &~= ITS_AVAILABLE;
}
else if((e.flags & FL_WEAPON) && !(e.flags & FL_NO_WEAPON_STAY) && g_weapon_stay)
{
//e.customizeentityforclient = Item_Customize;
e.spawnshieldtime = 0; // field indicates whether picking it up may give you anything other than the weapon
+ self.ItemStatus |= ITS_AVAILABLE;
}
else if(g_ghost_items)
{
//e.customizeentityforclient = func_null;
e.spawnshieldtime = 1;
+ self.ItemStatus &~= ITS_AVAILABLE;
}
else
{
//e.customizeentityforclient = func_null;
e.spawnshieldtime = 1;
+ self.ItemStatus &~= ITS_AVAILABLE;
}
if (e.items & (IT_STRENGTH | IT_INVINCIBLE))
+ {
e.effects |= EF_ADDITIVE | EF_FULLBRIGHT;
+ self.ItemStatus |= ITS_POWERUP;
+ }
+
if (autocvar_g_nodepthtestitems)
e.effects |= EF_NODEPTHTEST;
+
if (autocvar_g_fullbrightitems)
+ {
e.effects |= EF_FULLBRIGHT;
+ self.ItemStatus |= ITS_ALLOWFB;
+ }
// relink entity (because solid may have changed)
setorigin(e, e.origin);
if (_switchweapon)
if (player.switchweapon != w_getbestweapon(player))
W_SwitchWeapon_Force(player, w_getbestweapon(player));
- self.SendFlags |= ISF_STATUS;
+
return 1;
}
}
}
e = RandomSelection_chosen_ent;
- self.SendFlags |= ISF_MODEL;
+
}
else
e = self;
self.touch = Item_Touch;
setmodel (self, self.mdl); // precision set below
self.effects |= EF_LOWPRECISION;
+
if((itemflags & FL_POWERUP) || self.health || self.armorvalue)
- setsize (self, '-16 -16 0', '16 16 48');
+ setsize (self, '-16 -16 0', '16 16 48');
else
setsize (self, '-16 -16 0', '16 16 32');
+
+ if(itemflags & FL_POWERUP)
+ self.ItemStatus |= ITS_ANIMATED;
+
if(itemflags & FL_WEAPON)
- self.modelflags |= MF_ROTATE;
-
- if (self.classname != "droppedweapon") // if dropped, colormap is already set up nicely
- if (itemflags & FL_WEAPON)
{
- // neutral team color for pickup weapons
- self.colormap = 1024; // color shirt=0 pants=0 grey
+ self.modelflags |= MF_ROTATE;
+ self.ItemStatus |= ITS_ANIMATED;
+
+ if (self.classname != "droppedweapon") // if dropped, colormap is already set up nicely
+ self.colormap = 1024; // color shirt=0 pants=0 grey
}
self.state = 0;