8 void IT_Write(
entity e,
int i,
float f) {
11 WriteHeader(
MSG_ONE, itemstime);
24 float f = ReadFloat();
26 ItemsTime_time[i] = f;
34 ItemsTime_time[it.m_id] = -1;
39 int autocvar_hud_panel_itemstime = 2;
40 float autocvar_hud_panel_itemstime_dynamicsize = 1;
41 float autocvar_hud_panel_itemstime_ratio = 2;
43 int autocvar_hud_panel_itemstime_iconalign;
44 bool autocvar_hud_panel_itemstime_progressbar = 0;
45 float autocvar_hud_panel_itemstime_progressbar_maxtime = 30;
46 string autocvar_hud_panel_itemstime_progressbar_name =
"progressbar";
47 float autocvar_hud_panel_itemstime_progressbar_reduced;
48 bool autocvar_hud_panel_itemstime_hidespawned = 1;
49 bool autocvar_hud_panel_itemstime_hidebig =
false;
50 int autocvar_hud_panel_itemstime_text = 1;
51 #define hud_panel_itemstime_hidebig autocvar_hud_panel_itemstime_hidebig 53 #define hud_panel_itemstime_hidebig false 67 || it.instanceOfPowerup
79 it_times[it.m_id] = -1;
84 void Item_ItemsTime_ResetTimes()
87 it_times[it.m_id] = (it_times[it.m_id] == -1) ? -1 : 0;
92 void Item_ItemsTime_ResetTimesForPlayer(
entity e)
95 IT_Write(e, it.m_id, (it_times[it.m_id] == -1) ? -1 : 0);
100 void Item_ItemsTime_SetTimesForPlayer(
entity e)
103 IT_Write(e, it.m_id, it_times[it.m_id]);
110 if (!autocvar_sv_itemstime)
114 if (item.instanceOfGameItem)
116 if (!item.instanceOfWeaponPickup)
117 it_times[item.
m_id] = t;
130 bool isavailable = (t == 0);
133 if(!(it.itemdef == e.itemdef || ((STAT(WEAPONS, e) &
WEPSET_SUPERWEAPONS) && (STAT(WEAPONS, it) & WEPSET_SUPERWEAPONS))))
135 if (it.scheduledrespawntime <=
time)
137 else if (t == 0 || it.scheduledrespawntime < t)
138 t = it.scheduledrespawntime;
147 Item_ItemsTime_ResetTimes();
152 Item_ItemsTime_SetTime(it, 0);
161 Item_ItemsTime_SetTimesForPlayer(player);
173 Item_ItemsTime_SetTimesForPlayer(player);
182 Item_ItemsTime_ResetTimesForPlayer(player);
191 void HUD_ItemsTime_Export(
int fh)
203 void DrawItemsTimeItem(
vector myPos,
vector mySize,
float ar,
string item_icon,
float item_time,
bool item_available,
float item_availableTime)
209 if (autocvar_hud_panel_itemstime_hidespawned == 2)
211 else if (item_available)
212 picalpha =
blink(0.85, 0.15, 5);
224 if (autocvar_hud_panel_itemstime_iconalign)
227 picpos = myPos +
eX * (ar - 1) * mySize_y;
231 numpos = myPos +
eX * mySize_y;
235 if (t > 0 && autocvar_hud_panel_itemstime_progressbar)
238 if (autocvar_hud_panel_itemstime_progressbar_reduced)
241 p_size =
vec2(((ar - 1)/ar) * mySize.x, mySize.y);
251 if(autocvar_hud_panel_itemstime_text)
258 picpos.x = myPos.x + mySize.x / 2 - mySize.y / 2;
260 if (item_availableTime)
265 float Item_ItemsTime_GetTime(
int item)
271 case ITEM_ArmorMega.m_id:
return time + 0;
272 case ITEM_HealthMega.m_id:
return time + 8;
273 case ITEM_Strength.m_id:
return time + 0;
274 case ITEM_Shield.m_id:
return time + 4;
280 return ItemsTime_time[item];
294 if (autocvar_hud_panel_itemstime_hidespawned == 1)
297 count += (Item_ItemsTime_GetTime(it.m_id) >
time || -Item_ItemsTime_GetTime(it.m_id) >
time);
301 else if (autocvar_hud_panel_itemstime_hidespawned == 2)
304 count += (Item_ItemsTime_GetTime(it.m_id) >
time);
311 count += (Item_ItemsTime_GetTime(it.m_id) != -1);
313 count += (Item_ItemsTime_GetTime(
REGISTRY_MAX(Items)) != -1);
331 float ar =
max(2, autocvar_hud_panel_itemstime_ratio) + 1;
333 columns =
ceil(count/rows);
335 vector itemstime_size =
vec2(mySize.x / columns, mySize.y / rows);
339 if (autocvar_hud_panel_itemstime_dynamicsize)
346 if (itemstime_size.x / itemstime_size.y < ar)
348 newSize = rows * itemstime_size.x / ar;
349 pos.y += (mySize.y - newSize) / 2;
351 itemstime_size.y = mySize.y / rows;
355 newSize = columns * itemstime_size.y * ar;
356 pos.x += (mySize.x - newSize) / 2;
358 itemstime_size.x = mySize.x / columns;
365 if (itemstime_size.x/itemstime_size.y > ar)
367 newSize = ar * itemstime_size.y;
368 offset.x = itemstime_size.x - newSize;
370 itemstime_size.x = newSize;
374 newSize = 1/ar * itemstime_size.x;
375 offset.y = itemstime_size.y - newSize;
377 itemstime_size.y = newSize;
384 float row = 0, column = 0;
393 float item_time = Item_ItemsTime_GetTime(id);
396 item_available = true;
397 item_time = -item_time;
400 item_available = (item_time <=
time);
402 if (Item_ItemsTime_GetTime(
id) >= 0)
404 if (
time <= Item_ItemsTime_GetTime(
id))
405 ItemsTime_availableTime[
id] = 0;
406 else if (ItemsTime_availableTime[
id] == 0)
407 ItemsTime_availableTime[
id] =
time;
409 else if (ItemsTime_availableTime[
id] == 0)
410 ItemsTime_availableTime[
id] =
time;
412 float f = (
time - ItemsTime_availableTime[id]) * 2;
413 f = (f > 1) ? 0 :
bound(0, f, 1);
415 if (autocvar_hud_panel_itemstime_hidespawned == 1)
416 if (!(Item_ItemsTime_GetTime(
id) >
time || -Item_ItemsTime_GetTime(
id) >
time))
419 if (autocvar_hud_panel_itemstime_hidespawned == 2)
420 if (!(Item_ItemsTime_GetTime(
id) >
time))
423 DrawItemsTimeItem(pos +
vec2(column * (itemstime_size.x + offset.x), row * (itemstime_size.y + offset.y)), itemstime_size, ar, icon, item_time, item_available, f);
437 icon =
"superweapons";
void Item_ItemsTime_SetTime(entity e, float t)
#define IL_EACH(this, cond, body)
WepSet WEPSET_SUPERWEAPONS
void Item_ItemsTime_SetTimesForAllPlayers()
void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
void ClientConnect(entity this)
ClientConnect
ERASEABLE float blink(float base, float range, float freq)
float HUD_GetRowCount(int item_count, vector size, float item_aspect)
bool autocvar__hud_configure
#define FOREACH_CLIENT(cond, body)
#define hud_panel_itemstime_hidebig
#define NET_HANDLE(id, param)
#define STATIC_INIT(func)
during worldspawn
bool Item_ItemsTime_Allow(GameItem it)
float Item_ItemsTime_UpdateTime(entity e, float t)
#define IS_REAL_CLIENT(v)
REGISTER_MUTATOR(itemstime, true)
#define HUD_Panel_DrawBg()
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
const float DRAWFLAG_NORMAL
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define REGISTER_NET_TEMP(id)
float hud_configure_menu_open
#define MUTATOR_HOOKFUNCTION(...)
bool Item_ItemsTime_SpectatorOnly(GameItem it)
float autocvar_hud_progressbar_alpha
#define HUD_Write_Cvar(cvar)
#define FOREACH(list, cond, body)
void HUD_Panel_LoadCvars()