#include <lib/csqcmodel/common.qh>
#include <lib/warpzone/common.qh>
-bool autocvar_cl_ghost_items_vehicle = true;
.vector item_glowmod;
.bool item_simple; // probably not really needed, but better safe than sorry
.float alpha;
.bool pushable;
-void Item_SetAlpha(entity this)
-{
- bool veh_hud = (hud && autocvar_cl_ghost_items_vehicle);
-
- if(!veh_hud && (this.ItemStatus & ITS_AVAILABLE))
- {
- this.alpha = 1;
- this.colormod = '1 1 1';
- this.glowmod = this.item_glowmod;
- }
- else
- {
- this.alpha = autocvar_cl_ghost_items;
- this.colormod = this.glowmod = autocvar_cl_ghost_items_color;
- }
-
- if((!veh_hud) && (this.ItemStatus & ITS_STAYWEP))
- {
- this.colormod = this.glowmod = autocvar_cl_weapon_stay_color;
- this.alpha = autocvar_cl_weapon_stay_alpha;
- }
-
- this.drawmask = ((this.alpha <= 0) ? 0 : MASK_NORMAL);
-}
void ItemDraw(entity this)
{
}
}
- Item_SetAlpha(this);
-}
-
-void Item_PreDraw(entity this)
-{
- if(warpzone_warpzones_exist)
+ // set alpha based on distance
+ this.alpha = 1;
+ this.drawmask = 0;
+ if(this.fade_end && !warpzone_warpzones_exist)
{
- setpredraw(this, func_null); // no need to keep running this
- return;
+ vector org = getpropertyvec(VF_ORIGIN);
+ if(vdist(org - this.origin, >, this.fade_end))
+ this.alpha = 0; // save on some processing
+ else if(autocvar_cl_items_fadedist > 0)
+ {
+ this.fade_start = max(500, this.fade_end - autocvar_cl_items_fadedist);
+ if(vdist(org - this.origin, >, this.fade_start))
+ this.alpha = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1);
+ }
}
- float alph;
- vector org = getpropertyvec(VF_ORIGIN);
- //if(!checkpvs(org, this)) // this makes sense as long as we don't support recursive warpzones
- //alph = 0; // this shouldn't be needed, since items behind walls are culled anyway
- if(this.fade_start)
+
+ if(!this.alpha)
+ return;
+
+ // modify alpha based on availability and vehicle hud
+ if(this.ItemStatus & ITS_AVAILABLE)
{
- if(vdist(org - this.origin, >, this.fade_end))
- alph = 0; // save on some processing
- else if(vdist(org - this.origin, <, this.fade_start))
- alph = 1; // more processing saved
+ if(hud) // apparently this means we're in a vehicle lol
+ {
+ this.alpha *= autocvar_cl_items_vehicle_alpha;
+ this.colormod = this.glowmod = autocvar_cl_items_vehicle_color;
+ }
+ else if(this.ItemStatus & ITS_STAYWEP)
+ {
+ this.alpha *= autocvar_cl_weapon_stay_alpha;
+ this.colormod = this.glowmod = autocvar_cl_weapon_stay_color;
+ }
else
- alph = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1);
+ {
+ this.colormod = '1 1 1';
+ this.glowmod = this.item_glowmod;
+ }
}
else
- alph = 1;
- //printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs));
- if(!hud && (this.ItemStatus & ITS_AVAILABLE))
- this.alpha = alph;
- if(alph <= 0)
- this.drawmask = 0;
- //else
- //this.drawmask = MASK_NORMAL; // reset by the setalpha function
+ {
+ this.alpha *= autocvar_cl_ghost_items;
+ this.colormod = this.glowmod = autocvar_cl_ghost_items_color;
+ }
+
+ this.drawmask = this.alpha <= 0 ? 0 : MASK_NORMAL;
}
void ItemRemove(entity this)
{
this.ItemStatus = ReadByte();
- Item_SetAlpha(this);
-
if(this.ItemStatus & ITS_ALLOWFB)
this.effects |= EF_FULLBRIGHT;
else
if(sf & ISF_MODEL)
{
- this.drawmask = MASK_NORMAL;
set_movetype(this, MOVETYPE_TOSS);
if (isnew) IL_PUSH(g_drawables, this);
this.draw = ItemDraw;
//this.flags |= FL_ITEM;
this.fade_end = ReadShort();
- this.fade_start = ReadShort();
- if(!warpzone_warpzones_exist && this.fade_start && !autocvar_cl_items_nofade)
- setpredraw(this, Item_PreDraw);
strfree(this.mdl);
// enable menu syncing - must be after files that call menu_sync on startup - see alias menu_sync ""
alias menu_sync "menu_cmd sync"
-seta cl_items_nofade 0
+seta cl_items_fadedist 500 "distance, relative to the server's g_items_maxdist, at which far away items will start to fade out; 0 disables fading effect"
+seta cl_items_vehicle_alpha 0.75 "Alpha of items seen from inside a vehicle"
+seta cl_items_vehicle_color "2 0.5 0.5" "Colour of items seen from inside a vehicle"
seta cl_animate_items 1
seta cl_ghost_items 0.45 "enable ghosted items (when between 0 and 1, overrides the alpha value)"
seta cl_ghost_items_color "-1 -1 -1" "color of ghosted items (colormod format: 0 0 0 leaves the color unchanged, negative values allowed)"
-seta cl_ghost_items_vehicle 1 "show ghosted items when inside a vehicle even when the item is available, to indicate that it can't be picked up"
seta cl_simple_items 0 "enable simple items (if server allows)"
set cl_simpleitems_postfix "_luma" "posfix to add fo model name when simple items are enabled"
set cl_weapon_stay_color "2 0.5 0.5" "Color of picked up weapons when g_weapon_stay > 0 (colormod format: 0 0 0 leaves the color unchanged, negative values allowed)"