seta hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight 0.1 "weight of latest data point"
seta hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold 0.5 "threshold for fps change when to update instantly, to make big fps changes update faster"
+seta hud_panel_itemstime_maxtime "30" "when left time is at least this amount, the status bar is full"
+
// hud panel aliases
alias hud_panel_radar_rotate "toggle hud_panel_radar_rotation 0 1 2 3 4"
alias +hud_panel_radar_maximized "cl_cmd hud_panel_radar_maximized 1"
seta hud_panel_centerprint_fade_subsequent_passtwo_minalpha "" "minimum factor that the second pass can fade to"
seta hud_panel_centerprint_fade_subsequent_minfontsize "" "minimum factor for the font size from the subsequent fading effects"
seta hud_panel_centerprint_fade_minfontsize "" "minimum factor for the font size from the fading in/out effects"
+
+seta hud_panel_itemstime "" "enable/disable this panel"
+seta hud_panel_itemstime_pos "" "position of this base of the panel"
+seta hud_panel_itemstime_size "" "size of this panel"
+seta hud_panel_itemstime_bg "" "if set to something else than \"\" = override default background"
+seta hud_panel_itemstime_bg_color "" "if set to something else than \"\" = override default panel background color"
+seta hud_panel_itemstime_bg_color_team "" "override panel color with team color in team based games"
+seta hud_panel_itemstime_bg_alpha "" "if set to something else than \"\" = override default panel background alpha"
+seta hud_panel_itemstime_bg_border "" "if set to something else than \"\" = override default size of border around the background"
+seta hud_panel_itemstime_bg_padding "" "if set to something else than \"\" = override default padding of contents from border"
+seta hud_panel_itemstime_iconalign "" "0 = align icons to the left, 1 = align icons to the right"
+seta hud_panel_itemstime_progressbar "" "use progressbar behind icons"
+seta hud_panel_itemstime_progressbar_name "" "name of progressbar to use behind icons"
+seta hud_panel_itemstime_progressbar_xoffset "" "percentage of item width to offset progressbar with"
+seta hud_panel_itemstime_text "" "show text/icons"
+
seta hud_progressbar_acceleration_color "0.5 0.75 1"
seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5"
-seta _hud_panelorder "15 12 9 10 5 6 14 0 7 4 11 2 1 3 8 13 16 "
+seta _hud_panelorder "15 12 9 10 5 6 14 0 7 4 11 2 1 3 8 13 16 17 "
seta hud_configure_grid "1"
seta hud_configure_grid_xsize "0.010000"
seta hud_panel_centerprint_fade_subsequent_minfontsize "0.75"
seta hud_panel_centerprint_fade_minfontsize "0"
+seta hud_panel_itemstime 1
+seta hud_panel_itemstime_pos "0.000000 0.420000"
+seta hud_panel_itemstime_size "0.150000 0.270000"
+seta hud_panel_itemstime_bg "border_itemstime"
+seta hud_panel_itemstime_bg_color ""
+seta hud_panel_itemstime_bg_color_team ""
+seta hud_panel_itemstime_bg_alpha ""
+seta hud_panel_itemstime_bg_border ""
+seta hud_panel_itemstime_bg_padding ""
+seta hud_panel_itemstime_iconalign "0"
+seta hud_panel_itemstime_progressbar "0"
+seta hud_panel_itemstime_progressbar_name "progressbar"
+seta hud_panel_itemstime_progressbar_xoffset "0"
+seta hud_panel_itemstime_text "1"
+
menu_sync
float autocvar_hud_panel_healtharmor_text;
float autocvar_hud_panel_infomessages;
float autocvar_hud_panel_infomessages_flip;
+float autocvar_hud_panel_itemstime;
+float autocvar_hud_panel_itemstime_iconalign;
+float autocvar_hud_panel_itemstime_maxitemstime;
+float autocvar_hud_panel_itemstime_onlycurrent;
+float autocvar_hud_panel_itemstime_progressbar;
+string autocvar_hud_panel_itemstime_progressbar_name;
+float autocvar_hud_panel_itemstime_progressbar_xoffset;
+float autocvar_hud_panel_itemstime_text;
float autocvar_hud_panel_modicons;
float autocvar_hud_panel_modicons_dom_layout;
float autocvar_hud_panel_notify;
}
}
+
+// ItemsTime (#17)
+//
+const float ITEMSTIME_MAXITEMS = 9;
+float item_timeleft[ITEMSTIME_MAXITEMS];
+string GetItemsTimePicture(float i)
+{
+ switch(i)
+ {
+ case 0: return "armor";
+ case 1: return "health";
+ case 2: return "shield";
+ case 3: return "strength";
+ case 4: return "health";
+ case 5: return "strength";
+ case 6: return "shield";
+ case 7: case 8: return "ammo_fuel"; // FIXME: proper image for jetpack and fuel regen
+ default: return "";
+ }
+}
+
+void DrawItemsTimeItem(vector myPos, vector mySize, float itemcode)
+{
+ float t;
+ t = item_timeleft[itemcode];
+
+ vector color;
+ if(t < 5)
+ color = '0.7 0 0';
+ else if(t < 10)
+ color = '0.7 0.7 0';
+ else
+ color = '1 1 1';
+
+ vector picpos, numpos;
+ if(autocvar_hud_panel_itemstime_iconalign)
+ {
+ numpos = myPos;
+ picpos = myPos + eX * 2 * mySize_y;
+ }
+ else
+ {
+ numpos = myPos + eX * mySize_y;
+ picpos = myPos;
+ }
+
+ if(autocvar_hud_panel_itemstime_progressbar)
+ HUD_Panel_DrawProgressBar(myPos + eX * autocvar_hud_panel_itemstime_progressbar_xoffset * mySize_x, mySize - eX * autocvar_hud_panel_itemstime_progressbar_xoffset * mySize_x, autocvar_hud_panel_itemstime_progressbar_name, t/autocvar_hud_panel_itemstime_maxitemstime, 0, 0, color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+
+ if(autocvar_hud_panel_itemstime_text)
+ drawstring_aspect(numpos, ftos(t), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawpic_aspect_skin(picpos, GetItemsTimePicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+}
+
+void HUD_ItemsTime(void)
+{
+ if(!autocvar__hud_configure)
+ {
+ if(!autocvar_hud_panel_itemstime) return;
+ if(spectatee_status == 0) return;
+
+ item_timeleft[0] = floor(getstatf(STAT_ARMOR_LARGE_TIME) - time + 1);
+ item_timeleft[1] = floor(getstatf(STAT_HEALTH_MEGA_TIME) - time + 1);
+ item_timeleft[2] = floor(getstatf(STAT_STRENGTH_TIME) - time + 1);
+ item_timeleft[3] = floor(getstatf(STAT_INVISIBLE_TIME) - time + 1);
+ item_timeleft[4] = floor(getstatf(STAT_EXTRALIFE_TIME) - time + 1);
+ item_timeleft[5] = floor(getstatf(STAT_SPEED_TIME) - time + 1);
+ item_timeleft[6] = floor(getstatf(STAT_SHIELD_TIME) - time + 1);
+ item_timeleft[7] = floor(getstatf(STAT_FUELREGEN_TIME) - time + 1);
+ item_timeleft[8] = floor(getstatf(STAT_JETPACK_TIME) - time + 1);
+ }
+ else
+ {
+ hud_configure_active_panel = HUD_PANEL_ITEMSTIME;
+
+ // do not show here mutators-dependent items
+ item_timeleft[0] = 25;
+ item_timeleft[1] = 8;
+ item_timeleft[2] = 0;
+ item_timeleft[3] = 0;
+ item_timeleft[4] = 0;
+ item_timeleft[5] = 34;
+ item_timeleft[6] = 4;
+ item_timeleft[7] = 19;
+ item_timeleft[8] = 46;
+ }
+
+ float i;
+ float count;
+ for (i = 0; i < ITEMSTIME_MAXITEMS; ++i)
+ count += (item_timeleft[i] > 0);
+ if (count == 0)
+ return;
+
+ HUD_Panel_UpdateCvars(itemstime);
+ HUD_Panel_ApplyFadeAlpha();
+ vector pos, mySize;
+ pos = panel_pos;
+ mySize = panel_size;
+
+ HUD_Panel_DrawBg(1);
+ if(panel_bg_padding)
+ {
+ pos += '1 1 0' * panel_bg_padding;
+ mySize -= '2 2 0' * panel_bg_padding;
+ }
+
+ float rows, columns, row, column;
+ vector itemstime_size;
+
+ rows = mySize_y/mySize_x;
+ rows = bound(1, floor((sqrt(4 * (3/1) * rows * count + rows * rows) + rows + 0.5) / 2), count);
+ // ^^^ itemstime item aspect goes here
+
+ columns = ceil(count/rows);
+
+ itemstime_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
+
+ local noref vector offset; // fteqcc sucks
+ float newSize;
+ if(itemstime_size_x/itemstime_size_y > 3)
+ {
+ newSize = 3 * itemstime_size_y;
+ offset_x = itemstime_size_x - newSize;
+ pos_x += offset_x/2;
+ itemstime_size_x = newSize;
+ }
+ else
+ {
+ newSize = 1/3 * itemstime_size_x;
+ offset_y = itemstime_size_y - newSize;
+ pos_y += offset_y/2;
+ itemstime_size_y = newSize;
+ }
+
+ for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) {
+ if (item_timeleft[i] <= 0)
+ continue;
+ DrawItemsTimeItem(pos + eX * column * (itemstime_size_x + offset_x) + eY * row * (itemstime_size_y + offset_y), itemstime_size, i);
+ ++row;
+ if(row >= rows)
+ {
+ row = 0;
+ column = column + 1;
+ }
+ }
+}
+
/*
==================
Main HUD system
HUD_Physics(); break;\
case (HUD_PANEL_CENTERPRINT):\
HUD_CenterPrint(); break;\
+ case (HUD_PANEL_ITEMSTIME):\
+ HUD_ItemsTime(); break;\
} ENDS_WITH_CURLY_BRACE
void HUD_Main (void)
float hud_draw_maximized;
float hud_panel_radar_maximized;
+float hud_panel_itemstime;
vector mousepos;
vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdateCvars(infomessages) break; \
case HUD_PANEL_PHYSICS: HUD_Panel_UpdateCvars(physics); break;\
case HUD_PANEL_CENTERPRINT: HUD_Panel_UpdateCvars(centerprint); break;\
+ case HUD_PANEL_ITEMSTIME: HUD_Panel_UpdateCvars(itemstime); break;\
}
#define HUD_Panel_UpdateCvarsForId(id) \
case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdatePosSize(infomessages) break;\
case HUD_PANEL_PHYSICS: HUD_Panel_UpdatePosSize(physics); break;\
case HUD_PANEL_CENTERPRINT: HUD_Panel_UpdatePosSize(centerprint); break;\
+ case HUD_PANEL_ITEMSTIME: HUD_Panel_UpdatePosSize(itemstime); break;\
}
#define HUD_Panel_UpdatePosSizeForId(id) \
HUD_Write_PanelCvar_q("_fade_subsequent_minfontsize");
HUD_Write_PanelCvar_q("_fade_minfontsize");
break;
+ case HUD_PANEL_ITEMSTIME:
+ HUD_Write_PanelCvar_q("_iconalign");
+ HUD_Write_PanelCvar_q("_progressbar");
+ HUD_Write_PanelCvar_q("_progressbar_name");
+ HUD_Write_PanelCvar_q("_progressbar_xoffset");
+ HUD_Write_PanelCvar_q("_text");
+ break;
}
HUD_Write("\n");
}
const float STAT_SECRETS_TOTAL = 70;
const float STAT_SECRETS_FOUND = 71;
+const float STAT_ARMOR_LARGE_TIME = 80;
+const float STAT_HEALTH_MEGA_TIME = 81;
+const float STAT_STRENGTH_TIME = 82;
+const float STAT_INVISIBLE_TIME = 83;
+const float STAT_EXTRALIFE_TIME = 84;
+const float STAT_SPEED_TIME = 85;
+const float STAT_SHIELD_TIME = 86;
+const float STAT_FUELREGEN_TIME = 87;
+const float STAT_JETPACK_TIME = 88;
+
// mod stats (1xx)
const float STAT_REDALIVE = 100;
const float STAT_BLUEALIVE = 101;
float HUD_PANEL_INFOMESSAGES = 14;
float HUD_PANEL_PHYSICS = 15;
float HUD_PANEL_CENTERPRINT = 16;
-float HUD_PANEL_NUM = 17; // always last panel id + 1, please increment when adding a new panel
+float HUD_PANEL_ITEMSTIME = 17;
+float HUD_PANEL_NUM = 18; // always last panel id + 1, please increment when adding a new panel
string HUD_PANELNAME_WEAPONS = "weapons";
string HUD_PANELNAME_AMMO = "ammo";
string HUD_PANELNAME_INFOMESSAGES = "infomessages";
string HUD_PANELNAME_PHYSICS = "physics";
string HUD_PANELNAME_CENTERPRINT = "centerprint";
+string HUD_PANELNAME_ITEMSTIME = "itemstime";
float HUD_MENU_ENABLE = 0;
case HUD_PANEL_INFOMESSAGES: panel_name = HUD_PANELNAME_INFOMESSAGES; break; \
case HUD_PANEL_PHYSICS: panel_name = HUD_PANELNAME_PHYSICS; break; \
case HUD_PANEL_CENTERPRINT: panel_name = HUD_PANELNAME_CENTERPRINT; break; \
+ case HUD_PANEL_ITEMSTIME: panel_name = HUD_PANELNAME_ITEMSTIME; break; \
} ENDS_WITH_CURLY_BRACE
// Get name of specified panel id
if(clienttype(self) == CLIENTTYPE_REAL)
{
+ Item_GetItemsTime(self);
msg_entity = self;
WriteByte(MSG_ONE, SVC_SETVIEW);
WriteEntity(MSG_ONE, self);
return; // spawn failed
}
+ Item_ClearItemsTime();
+
RemoveGrapplingHook(self); // Wazat's Grappling Hook
self.classname = "player";
.float species;
+.float scheduledrespawntime;
.float respawntime;
.float respawntimejitter;
//.float chasecam;
.float (float act_state) setactive;
.entity realowner;
+.float item_armor_large_time;
+.float item_health_mega_time;
+.float item_strength_time;
+.float item_invisible_time;
+.float item_extralife_time;
+.float item_speed_time;
+.float item_shield_time;
+.float item_fuelregen_time;
+.float item_jetpack_time;
+
.float nex_charge;
.float nex_charge_rottime;
.float nex_chargepool_ammo;
addstat(STAT_HAGAR_LOAD, AS_INT, hagar_load);
+ addstat(STAT_ARMOR_LARGE_TIME, AS_FLOAT, item_armor_large_time);
+ addstat(STAT_HEALTH_MEGA_TIME, AS_FLOAT, item_health_mega_time);
+ addstat(STAT_STRENGTH_TIME, AS_FLOAT, item_strength_time);
+ addstat(STAT_INVISIBLE_TIME, AS_FLOAT, item_invisible_time);
+ addstat(STAT_EXTRALIFE_TIME, AS_FLOAT, item_extralife_time);
+ addstat(STAT_SPEED_TIME, AS_FLOAT, item_speed_time);
+ addstat(STAT_SHIELD_TIME, AS_FLOAT, item_shield_time);
+ addstat(STAT_FUELREGEN_TIME, AS_FLOAT, item_fuelregen_time);
+ addstat(STAT_JETPACK_TIME, AS_FLOAT, item_jetpack_time);
+
if(g_ca || g_freezetag)
{
addstat(STAT_REDALIVE, AS_INT, redalive_stat);
setorigin(e, e.origin);
}
+float it_armor_large_time;
+float it_health_mega_time;
+float it_strength_time;
+float it_invisible_time;
+float it_extralife_time;
+float it_speed_time;
+float it_shield_time;
+float it_fuelregen_time;
+float it_jetpack_time;
+
+void Item_ClearItemsTime()
+{
+ self.item_armor_large_time = 0;
+ self.item_health_mega_time = 0;
+ self.item_strength_time = 0;
+ self.item_invisible_time = 0;
+ self.item_extralife_time = 0;
+ self.item_speed_time = 0;
+ self.item_shield_time = 0;
+ self.item_fuelregen_time = 0;
+ self.item_jetpack_time = 0;
+}
+void Item_GetItemsTime(entity e)
+{
+ e.item_armor_large_time = it_armor_large_time;
+ e.item_health_mega_time = it_health_mega_time;
+ e.item_strength_time = it_strength_time;
+ e.item_invisible_time = it_invisible_time;
+ e.item_extralife_time = it_extralife_time;
+ e.item_speed_time = it_speed_time;
+ e.item_shield_time = it_shield_time;
+ e.item_fuelregen_time = it_fuelregen_time;
+ e.item_jetpack_time = it_jetpack_time;
+}
+void Item_UpdateTime(entity e, float t)
+{
+ if(g_minstagib)
+ {
+ switch(e.items)
+ {
+ case IT_STRENGTH://"item-invis"
+ if (it_invisible_time > time && t > it_invisible_time)
+ return;
+ it_invisible_time = t;
+ return;
+ case IT_NAILS://"item-extralife"
+ if (it_extralife_time > time && t > it_extralife_time)
+ return;
+ it_extralife_time = t;
+ return;
+ case IT_INVINCIBLE://"item-speed"
+ if (it_speed_time > time && t > it_speed_time)
+ return;
+ it_speed_time = t;
+ return;
+ }
+ }
+ else
+ {
+ switch(e.items)
+ {
+ case IT_HEALTH:
+ if (e.classname == "item_health_mega")
+ {
+ if (it_health_mega_time > time && t > it_health_mega_time)
+ return;
+ it_health_mega_time = t;
+ }
+ return;
+ case IT_ARMOR:
+ if (e.classname == "item_armor_large")
+ {
+ if (it_armor_large_time > time && t > it_armor_large_time)
+ return;
+ it_armor_large_time = t;
+ }
+ return;
+ case IT_STRENGTH://"item-strength"
+ if (it_strength_time > time && t > it_strength_time)
+ return;
+ it_strength_time = t;
+ return;
+ case IT_INVINCIBLE://"item-shield"
+ if (it_shield_time > time && t > it_shield_time)
+ return;
+ it_shield_time = t;
+ return;
+ }
+ }
+ switch(e.items)
+ {
+ case IT_FUEL_REGEN://"item-fuelregen"
+ if (it_fuelregen_time > time && t > it_fuelregen_time)
+ return;
+ it_fuelregen_time = t;
+ return;
+ case IT_JETPACK://"item-jetpack"
+ if (it_jetpack_time > time && t > it_jetpack_time)
+ return;
+ it_jetpack_time = t;
+ return;
+ }
+}
+
void Item_Respawn (void)
{
+ float t;
+ entity head;
Item_Show(self, 1);
if(!g_minstagib && self.items == IT_STRENGTH)
sound (self, CH_TRIGGER, "misc/strength_respawn.wav", VOL_BASE, ATTN_NORM); // play respawn sound
sound (self, CH_TRIGGER, "misc/itemrespawn.wav", VOL_BASE, ATTN_NORM); // play respawn sound
setorigin (self, self.origin);
+ if (self.flags & FL_POWERUP || self.classname == "item_armor_large" || self.classname == "item_health_mega")
+ {
+ for(t = 0, head = world; (head = find(head, classname, self.classname)); )
+ {
+ // in minstagib .classname is "minstagib" for every item
+ if (g_minstagib && self.items != head.items)
+ continue;
+ if (head.scheduledrespawntime > time)
+ if (t == 0 || head.scheduledrespawntime < t)
+ t = head.scheduledrespawntime;
+ }
+ Item_UpdateTime(self, t);
+ FOR_EACH_REALCLIENT(head)
+ {
+ if (head.classname != "player")
+ Item_GetItemsTime(head);
+ }
+ }
+
//pointparticles(particleeffectnum("item_respawn"), self.origin + self.mins_z * '0 0 1' + '0 0 48', '0 0 0', 1);
pointparticles(particleeffectnum("item_respawn"), self.origin + 0.5 * (self.mins + self.maxs), '0 0 0', 1);
}
{
e.think = Item_RespawnCountdown;
e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);
+ e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS;
e.count = 0;
}
else
{
e.think = Item_Respawn;
e.nextthink = time + t;
+ e.scheduledrespawntime = e.nextthink;
+ }
+ Item_UpdateTime(e, e.scheduledrespawntime);
+ FOR_EACH_REALCLIENT(e)
+ {
+ if (e.classname != "player")
+ Item_GetItemsTime(e);
}
}