return w_deathtypestring;
}
-float killnotify_times[10];
-float killnotify_deathtype[10];
-float killnotify_actiontype[10]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
-string killnotify_attackers[10];
-string killnotify_victims[10];
+#define KN_MAX_ENTRIES 10
+float kn_index;
+float killnotify_times[KN_MAX_ENTRIES];
+float killnotify_deathtype[KN_MAX_ENTRIES];
+float killnotify_actiontype[KN_MAX_ENTRIES]; // 0 = "Y [used by] X", 1 = "X [did action to] Y"
+string killnotify_attackers[KN_MAX_ENTRIES];
+string killnotify_victims[KN_MAX_ENTRIES];
void HUD_KillNotify_Push(string attacker, string victim, float actiontype, float wpn)
{
- float i;
- for (i = 9; i > 0; --i) {
- killnotify_times[i] = killnotify_times[i-1];
- killnotify_deathtype[i] = killnotify_deathtype[i-1];
- killnotify_actiontype[i] = killnotify_actiontype[i-1];
- if(killnotify_attackers[i])
- strunzone(killnotify_attackers[i]);
- killnotify_attackers[i] = strzone(killnotify_attackers[i-1]);
- if(killnotify_victims[i])
- strunzone(killnotify_victims[i]);
- killnotify_victims[i] = strzone(killnotify_victims[i-1]);
- }
- killnotify_times[0] = time;
- killnotify_deathtype[0] = wpn;
- killnotify_actiontype[0] = actiontype;
- if(killnotify_attackers[0])
- strunzone(killnotify_attackers[0]);
- killnotify_attackers[0] = strzone(attacker);
- if(killnotify_victims[0])
- strunzone(killnotify_victims[0]);
- killnotify_victims[0] = strzone(victim);
+ --kn_index;
+ if (kn_index == -1)
+ kn_index = KN_MAX_ENTRIES-1;
+ killnotify_times[kn_index] = time;
+ killnotify_deathtype[kn_index] = wpn;
+ killnotify_actiontype[kn_index] = actiontype;
+ if(killnotify_attackers[kn_index])
+ strunzone(killnotify_attackers[kn_index]);
+ killnotify_attackers[kn_index] = strzone(attacker);
+ if(killnotify_victims[kn_index])
+ strunzone(killnotify_victims[kn_index]);
+ killnotify_victims[kn_index] = strzone(victim);
}
void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s1 = attacker, s2 = victim
} else if(msg == MSG_KILL) {
w = DEATH_WEAPONOF(type);
if(WEP_VALID(w)) {
- HUD_KillNotify_Push(s1, s2, 1, type);
+ if((w == WEP_CAMPINGRIFLE || w == WEP_MINSTANEX) && type & HITTYPE_HEADSHOT) // all headshot weapons go here
+ HUD_KillNotify_Push(s1, s2, 1, DEATH_HEADSHOT);
+ else
+ HUD_KillNotify_Push(s1, s2, 1, type);
+
if (alsoprint)
print("^1", sprintf(Weapon_KillMessage(type), strcat(s2, "^1"), strcat(s1, "^1")), "\n"); // default order: victim, killer
}
}
float entries, height;
- entries = bound(1, floor(10 * mySize_y/mySize_x), 10);
+ entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
height = mySize_y/entries;
vector fontsize;
float width_attacker;
string attacker, victim;
- float i, j, w;
- float flip = cvar("hud_panel_notify_flip");
- for(j = 0; j < entries; ++j)
+ float i, j, w, step, limit;
+ if(cvar("hud_panel_notify_flip")) //order items from the top down
{
- s = "";
- if(flip)
- i = j;
- else // rather nasty hack for ordering items from the bottom up
- i = entries - j - 1;
+ i = 0;
+ step = +1;
+ limit = entries;
+ }
+ else //order items from the bottom up
+ {
+ i = entries - 1;
+ step = -1;
+ limit = -1;
+ }
- if(fadetime)
+ for(j = kn_index; i != limit; i += step, ++j)
+ {
+ if(autocvar__hud_configure)
{
- if(killnotify_times[j] + when > time)
- a = 1;
- else
- a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
+ if (step == +1)
+ a = i;
+ else // inverse order
+ a = entries - 1 - i;
+ attacker = textShortenToWidth(strcat("Player", ftos(a+1)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
+ victim = textShortenToWidth(strcat("Player", ftos(a+2)), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
+ s = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
+ a = bound(0, (when - a) / 4, 1);
+ goto hud_config_notifyprint;
+ }
+
+ if (j == KN_MAX_ENTRIES)
+ j = 0;
+
+ if(killnotify_times[j] + when > time)
+ a = 1;
+ else if(fadetime)
+ {
+ a = bound(0, (killnotify_times[j] + when + fadetime - time) / fadetime, 1);
+ if(!a)
+ {
+ break;
+ }
}
else
{
- if(killnotify_times[j] + when > time)
- a = 1;
- else
- a = 0;
+ break;
}
+ s = "";
+
w = -1;
w = DEATH_WEAPONOF(killnotify_deathtype[j]);
// TODO: maybe print in team colors?
//
// Y [used by] X
- if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
+ if(killnotify_actiontype[j] == 0)
{
- attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
- pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
- weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
-
if(killnotify_deathtype[j] == DEATH_GENERIC)
{
s = "notify_death";
s = "notify_blue_captured";
}
}
- if(s != "" && a)
+ attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
+ pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
+ weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
+
+ if(s != "")
{
drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
// X [did action to] Y
else
{
- if(autocvar__hud_configure)
- {
- attacker = textShortenToWidth("Player1", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
- victim = textShortenToWidth("Player2", 0.48 * mySize_x - height, fontsize, stringwidth_colors);
- a = bound(0, (when - j) / 4, 1);
- }
- else
- {
- attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
- victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
- }
- width_attacker = stringwidth(attacker, TRUE, fontsize);
- pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
- pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
- weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
-
- if(autocvar__hud_configure) // example actions for config mode
- {
- s = "weaponelectro";
- }
- else if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
+ if(killnotify_deathtype[j] & HITTYPE_SECONDARY && w == WEP_LASER)
{
s = "notify_melee_laser";
}
{
s = "notify_void";
}
+ else if(killnotify_deathtype[j] == DEATH_HEADSHOT)
+ {
+ s = "notify_headshot";
+ }
else if(killnotify_deathtype[j] == RACE_SERVER_RECORD)
{
s = "race_newrecordserver";
{
s = "race_newfail";
}
- if(s != "" && a)
+
+ attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
+ victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
+:hud_config_notifyprint
+ width_attacker = stringwidth(attacker, TRUE, fontsize);
+ pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
+ pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
+ weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
+
+ if(s != "")
{
drawpic_aspect_skin(weap_pos, s, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
}
// draw the progress bars
- drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
- drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+ if(vote_yescount && vote_needed)
+ {
+ drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
+ drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+ }
- drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
- drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+ if(vote_nocount && vote_needed)
+ {
+ drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
+ drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+ }
drawresetcliparea();