fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
+ fputs(fh, strcat("seta hud_bg_color_team \"", cvar_string("hud_bg_color_team"), "\"", "\n"));
fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
+ fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
fputs(fh, "\n");
fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
+ fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color_team \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color_team")), "\"", "\n"));
fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
fclose(fh);
}
-vector HUD_Panel_CheckLimitSize(float id, vector mySize)
+vector HUD_Panel_GetMinSize(float id)
{
+ vector mySize;
+ // note: please only set mySize_y on aspect ratio forced panels
switch(id) {
case 0:
- mySize_x = max(mySize_y * (1/10), mySize_x); // at least 1/10 * height
- mySize_y = max(mySize_x * (1/26), mySize_y); // at least 1/26 * width
+ mySize_x = 1/10; // at least 1/10 * height
+ mySize_y = 1/26; // at least 1/26 * width
break;
case 1:
if(cvar("hud_inventory_onlycurrent"))
- mySize_y = mySize_x * (2/5); // 2/5 width
+ mySize_y = 2/5; // 2/5 width
else
- mySize_x = max(mySize_y * 0.7, mySize_x); // at least 0.7 * height
+ mySize_x = 0.7; // at least 0.7 * height
break;
case 3:
if(cvar("hud_healtharmor") == 2)
- mySize_y = 0.23 * mySize_x; // 0.23 * width, trial and error...
+ mySize_y = 0.23; // 0.23 * width, trial and error...
break;
case 5:
- mySize_y = (1/4.1) * mySize_x; // 1/4.1 * width, trial and error...
+ mySize_y = 1/4.1; // 1/4.1 * width, trial and error...
break;
case 7:
- mySize_y = (1/4) * mySize_x; // 1/4 * width
+ mySize_y = 1/4; // 1/4 * width
break;
case 8:
- mySize_y = (1/4) * mySize_x; // 1/4 * width
+ mySize_y = 1/4; // 1/4 * width
break;
case 9:
- mySize_y = (1/4) * mySize_x; // 1/4 * width
+ mySize_y = 1/4; // 1/4 * width
break;
case 10:
- mySize_y = (1/2) * mySize_x; // 1/2 * width
+ mySize_y = 1/2; // 1/2 * width
break;
case 11:
- mySize_y = 0.5898 * mySize_x; // 0.5898 * width, reason: bg has weird dimensions...
+ mySize_y = 0.5898; // 0.5898 * width, reason: bg has weird dimensions...
break;
}
+ if(!mySize_x)
+ mySize_x = 1/mySize_y;
return mySize;
}
float f;
vector color_vec;
string color;
- color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
+
+ // fetch per-panel color
+ if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
+ f = stof(getplayerkey(self.sv_entnum, "colors"));
+ color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
+ }
+ else
+ color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
color_vec = stov(color);
- if(color == "") {
+
+ if(color == "") { // fetch default color
color = cvar_string("hud_bg_color");
color_vec = stov(color);
- if(color == "shirt") {
+ if(teamplay && cvar(strcat("hud_bg_color_team"))) {
+ f = stof(getplayerkey(self.sv_entnum, "colors"));
+ color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_bg_color_team");
+ }
+ else if(color == "shirt") {
f = stof(getplayerkey(self.sv_entnum, "colors"));
color_vec = colormapPaletteColor(floor(f / 16), 0);
}
string color;
color = cvar_string("hud_dock_color");
color_vec = stov(color);
- if(color == "shirt") {
+ if(teamplay && cvar(strcat("hud_dock_color_team"))) {
+ f = stof(getplayerkey(self.sv_entnum, "colors"));
+ color_vec = colormapPaletteColor(mod(f, 16), 1) * cvar("hud_dock_color_team");
+ }
+ else if(color == "shirt") {
f = stof(getplayerkey(self.sv_entnum, "colors"));
color_vec = colormapPaletteColor(floor(f / 16), 0);
}
return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
}
-float resizeCorner; // 1 = topleft, 2 = topright, 3 = bottomleft, 4 = bottomright
-// check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
-vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize)
+// check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
+vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
{
float i;
vector myTarget;
- myTarget = mySize;
+ myTarget = myPos;
vector targPos;
vector targSize;
if(i == id || !HUD_Panel_CheckActive(i))
continue;
- targPos = HUD_Panel_GetPos(i);
- targSize = HUD_Panel_GetSize(i);
-
targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
targCenter_x = targPos_x + 0.5 * targSize_x;
targCenter_y = targPos_y + 0.5 * targSize_y;
- if(myCenter_x < targCenter_x && myCenter_y < targCenter_y && resizeCorner != 1) // top left (of target panel)
+ if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
{
if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
- myTarget_x = targPos_x - myPos_x;
+ myTarget_x = targPos_x - mySize_x;
else // push it upwards
- myTarget_y = targPos_y - myPos_y;
+ myTarget_y = targPos_y - mySize_y;
}
- else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y && resizeCorner != 2) // top right
+ else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
{
if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
myTarget_x = targPos_x + targSize_x;
else // push it upwards
- myTarget_y = targPos_y - myPos_y;
+ myTarget_y = targPos_y - mySize_y;
}
else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
{
if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
- myTarget_x = targPos_x - myPos_x;
+ myTarget_x = targPos_x - mySize_x;
else // push it downwards
myTarget_y = targPos_y + targSize_y;
}
return myTarget;
}
-// TODO: checkResize
-float HUD_Panel_SetSize(float id, vector mySize)
+void HUD_Panel_SetPos(float id, vector pos)
{
- float didntresize;
-
- vector oldSize;
- oldSize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
+ vector oldPos;
+ oldPos = HUD_Panel_GetPos(id);
- vector myPos;
- myPos = HUD_Panel_GetPos(id);
+ vector mySize;
+ mySize = HUD_Panel_GetSize(id);
- // check for collisions
if(cvar("hud_configure_checkcollisions"))
- mySize = HUD_Panel_CheckResize(id, HUD_Panel_GetPos(id), mySize);
-
- mySize_x = bound(0.025 * vid_conwidth, mySize_x, vid_conwidth - myPos_x);
- mySize_y = bound(0.025 * vid_conheight, mySize_y, vid_conheight - myPos_y);
-
- // cap against panel's own limits
- mySize = HUD_Panel_CheckLimitSize(id, mySize);
+ pos = HUD_Panel_CheckMove(id, pos, mySize);
- //mySize_x = bound(0.025 * vid_conwidth, mySize_x, vid_conwidth);
- //mySize_y = bound(0.025 * vid_conheight, mySize_y, vid_conheight);
+ pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
+ pos_y = bound(0, pos_y, vid_conheight - mySize_y);
if(cvar("hud_configure_grid"))
{
- mySize_x = floor(mySize_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
- mySize_y = floor(mySize_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
+ pos_x = floor(pos_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
+ pos_y = floor(pos_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
}
- // TODO: is this needed?
- // this is to check if (and how) SetPos should be called
- if(mySize_x == oldSize_x && mySize_y == oldSize_y)
- didntresize = 3; // didnt resize either
- else if(mySize_x == oldSize_x && mySize_y != oldSize_y)
- didntresize = 2; // resized Y
- else if(mySize_y == oldSize_y && mySize_x != oldSize_x)
- didntresize = 1; // resized X
+ if (pos_x + 0.5 * mySize_x > 0.5 * vid_conwidth)
+ pos_x = pos_x - vid_conwidth;
+ if (pos_y + 0.5 * mySize_y > 0.5 * vid_conheight)
+ pos_y = pos_y - vid_conheight;
string s;
- s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
- cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
- return didntresize;
+ s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
+
+ cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
}
-// check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
-vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
+// check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
+vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize)
{
float i;
vector myTarget;
- myTarget = myPos;
+ myTarget = mySize;
vector targPos;
vector targSize;
if(i == id || !HUD_Panel_CheckActive(i))
continue;
+ targPos = HUD_Panel_GetPos(i);
+ targSize = HUD_Panel_GetSize(i);
+
targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
targCenter_x = targPos_x + 0.5 * targSize_x;
targCenter_y = targPos_y + 0.5 * targSize_y;
- if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
+ if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of target panel)
{
if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
- myTarget_x = targPos_x - mySize_x;
+ myTarget_x = targPos_x - myPos_x;
else // push it upwards
- myTarget_y = targPos_y - mySize_y;
+ myTarget_y = targPos_y - myPos_y;
}
else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
{
if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
myTarget_x = targPos_x + targSize_x;
else // push it upwards
- myTarget_y = targPos_y - mySize_y;
+ myTarget_y = targPos_y - myPos_y;
}
else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
{
if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
- myTarget_x = targPos_x - mySize_x;
+ myTarget_x = targPos_x - myPos_x;
else // push it downwards
myTarget_y = targPos_y + targSize_y;
}
return myTarget;
}
-void HUD_Panel_SetPos(float id, vector pos, float didntresize)
+void HUD_Panel_SetPosSize(float id, vector resizeorigin)
{
+ vector mySize, myPos;
vector oldPos;
- oldPos = HUD_Panel_GetPos(id);
- if(didntresize == 2)
- pos_x = oldPos_x;
- else if(didntresize == 1)
- pos_y = oldPos_y;
- else if(didntresize == 3)
- return;
- vector mySize;
- mySize = HUD_Panel_GetSize(id);
+ if(resizeCorner == 1) {
+ mySize_x = resizeorigin_x - (mousepos_x - panel_click_distance_x);
+ mySize_y = resizeorigin_y - (mousepos_y - panel_click_distance_y);
+ } else if(resizeCorner == 2) {
+ mySize_x = mousepos_x + panel_click_distance_x - resizeorigin_x;
+ mySize_y = panel_click_distance_y + resizeorigin_y - mousepos_y;
+ } else if(resizeCorner == 3) {
+ mySize_x = resizeorigin_x + panel_click_distance_x - mousepos_x;
+ mySize_y = mousepos_y + panel_click_distance_y - resizeorigin_y;
+ } else { // resizeCorner == 4
+ mySize_x = mousepos_x - (resizeorigin_x - panel_click_distance_x);
+ mySize_y = mousepos_y - (resizeorigin_y - panel_click_distance_y);
+ }
- if(cvar("hud_configure_checkcollisions"))
- pos = HUD_Panel_CheckMove(id, pos, mySize);
+ // minimum panel size cap
+ mySize_x = max(0.025 * vid_conwidth, mySize_x);
+ mySize_y = max(0.025 * vid_conheight, mySize_y);
- pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
- pos_y = bound(0, pos_y, vid_conheight - mySize_y);
+ // cap against panel's own limits
+ vector minSize;
+ minSize = HUD_Panel_GetMinSize(id); // mySize_x at least minSize_x * mySize_y, and vice versa
+
+ mySize_x = max(minSize_x * mySize_y, mySize_x);
+ mySize_y = max(minSize_y * mySize_x, mySize_y);
+
+ // collision testing|
+ // -----------------+
+
+ // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
+ if(resizeCorner == 1) {
+ myPos_x = resizeorigin_x - mySize_x;
+ myPos_y = resizeorigin_y - mySize_y;
+ } else if(resizeCorner == 2) {
+ myPos_x = resizeorigin_x;
+ myPos_y = resizeorigin_y - mySize_y;
+ } else if(resizeCorner == 3) {
+ myPos_x = resizeorigin_x - mySize_x;
+ myPos_y = resizeorigin_y;
+ } else { // resizeCorner == 4
+ myPos_x = resizeorigin_x;
+ myPos_y = resizeorigin_y;
+ }
+
+ // left/top screen edges
+ mySize_x = min(myPos_x + mySize_x, mySize_x);
+ mySize_y = min(myPos_y + mySize_y, mySize_y);
+
+ // bottom/right screen edges
+ mySize_x = min(vid_conwidth - myPos_x, mySize_x);
+ mySize_y = min(vid_conheight - myPos_y, mySize_y);
+
+ if(cvar("hud_configure_checkcollisions")) {
+ oldPos = myPos;
+ mySize = HUD_Panel_CheckResize(id, myPos, mySize);
+ myPos = HUD_Panel_CheckMove(id, myPos, mySize); // touching myPos won't do anything... unless we make it change mySize somehow, see next line
+ mySize = mySize - myPos + oldPos; // TODO: this is still borked in some situations :(
+ }
if(cvar("hud_configure_grid"))
{
- pos_x = floor(pos_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
- pos_y = floor(pos_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
+ mySize_x = floor(mySize_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
+ mySize_y = floor(mySize_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
}
- if (pos_x + 0.5 * mySize_x > 0.5 * vid_conwidth)
- pos_x = pos_x - vid_conwidth;
- if (pos_y + 0.5 * mySize_y > 0.5 * vid_conheight)
- pos_y = pos_y - vid_conheight;
+ // do another pos check, as size might have changed by now
+ if(resizeCorner == 1) {
+ myPos_x = resizeorigin_x - mySize_x;
+ myPos_y = resizeorigin_y - mySize_y;
+ } else if(resizeCorner == 2) {
+ myPos_x = resizeorigin_x;
+ myPos_y = resizeorigin_y - mySize_y;
+ } else if(resizeCorner == 3) {
+ myPos_x = resizeorigin_x - mySize_x;
+ myPos_y = resizeorigin_y;
+ } else { // resizeCorner == 4
+ myPos_x = resizeorigin_x;
+ myPos_y = resizeorigin_y;
+ }
string s;
- s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
+ s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
+ cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
+ s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
}
return false;
}
-vector mousepos, mouseprevpos;
-vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
-vector panel_click_pos; // panel pos (saved only upon a click)
-vector panel_click_size; // panel size (saved only upon a click)
-float highlightedPanel;
-float highlightedAction; // 0 = nothing, 1 = move, 2 = resize
void HUD_Panel_Mouse()
{
if(mouseClicked == 0) {
{
if(prevMouseClicked == 0)
{
- panel_click_distance = mousepos - panelPos;
- panel_click_pos = panelPos;
- panel_click_size = panelSize;
+ if(highlightedAction == 1)
+ panel_click_distance = mousepos - panelPos;
+ else if(highlightedAction == 2)
+ {
+ if(resizeCorner == 1) {
+ panel_click_distance = mousepos - panelPos;
+ panel_click_resizeorigin = panelPos + panelSize;
+ } else if(resizeCorner == 2) {
+ panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
+ panel_click_distance_y = mousepos_y - panelPos_y;
+ panel_click_resizeorigin = panelPos + eY * panelSize_y;
+ } else if(resizeCorner == 3) {
+ panel_click_distance_x = mousepos_x - panelPos_x;
+ panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
+ panel_click_resizeorigin = panelPos + eX * panelSize_x;
+ } else if(resizeCorner == 4) {
+ panel_click_distance = panelSize - mousepos + panelPos;
+ panel_click_resizeorigin = panelPos;
+ }
+ }
}
if(highlightedAction == 1)
- HUD_Panel_SetPos(i, mousepos - panel_click_distance, 0);
+ HUD_Panel_SetPos(i, mousepos - panel_click_distance);
else if(highlightedAction == 2)
- {
- float didntresize; // panel too big/too small, dont resize (also has to affect moving)
- if(resizeCorner == 1) {
- didntresize = HUD_Panel_SetSize(i, panelSize + mouseprevpos - mousepos);
- HUD_Panel_SetPos(i, mousepos - panel_click_distance, didntresize);
- }
- if(resizeCorner == 2) {
- didntresize = HUD_Panel_SetSize(i, eY * panel_click_size_y + eX * (mousepos_x - panelPos_x - (panel_click_distance_x - panel_click_size_x))
- + eY * (panel_click_distance_y + (panel_click_pos_y - mousepos_y)));
- HUD_Panel_SetPos(i, eX * panelPos_x + eY * (mousepos_y - panel_click_distance_y), didntresize);
- }
- if(resizeCorner == 3) {
- didntresize = HUD_Panel_SetSize(i, panelSize + eX * (mouseprevpos_x - mousepos_x) + eY * (mousepos_y - mouseprevpos_y));
- HUD_Panel_SetPos(i, eX * (mousepos_x - panel_click_distance_x) + eY * panelPos_y, didntresize);
- }
- if(resizeCorner == 4) {
- HUD_Panel_SetSize(i, mousepos - panelPos - (panel_click_distance - panel_click_size));
- }
- }
+ HUD_Panel_SetPosSize(i, panel_click_resizeorigin);
}
}
}
- mouseprevpos = mousepos;
prevMouseClicked = mouseClicked;
}
-/*void HUD_DrawDockEdge(float id, vector p1, vector p2, float target)
-{
- vector pos;
- vector size;
-
- pos =
-*/ // maybe one day, since this will be quite complicated
-
// Weapon icons (#0)
//
float weaponspace[10];
// ___TODO___ !!!
// Notification area (#4)
//
+
+string Weapon_SuicideMessage(float deathtype)
+{
+ float w;
+ w = DEATH_WEAPONOF(deathtype);
+
+ switch (w)
+ {
+ case 1:
+ return "lasered himself to hell";
+ case 2:
+ return "did the impossible";
+ case 3:
+ return "did the impossible";
+ case 4:
+ if(deathtype & HITTYPE_SECONDARY)
+ return "tried out his own grenade";
+ return "detonated";
+ }
+ // TODO: was blasted by?
+ return strcat("[no kill message for weapon ", ftos(w), "!]");
+}
+
+string Weapon_KillMessage(float deathtype)
+{
+ float w;
+ w = DEATH_WEAPONOF(deathtype);
+
+ switch (w)
+ {
+ case 1:
+ return "was lasered to death by";
+ case 2:
+ return "was gunned by";
+ case 3:
+ if(deathtype & HITTYPE_SECONDARY)
+ return "was sniped by";
+ return "was riddled full of holes by";
+ case 4:
+ if(deathtype & HITTYPE_BOUNCE)
+ return "didn't see #'s grenade";
+ return "almost dodged #'s grenade";
+ }
+ return strcat("[no suicide message for weapon ", ftos(w), "!]");
+}
+
+float killnotify_times[10];
+float killnotify_deathtype[10];
+string killnotify_attackers[10];
+string killnotify_victims[10];
+void HUD_KillNotify_Push(string attacker, string victim, float wpn)
+{
+ float i;
+ for (i = 9; i > 0; --i) {
+ killnotify_times[i] = killnotify_times[i-1];
+ killnotify_deathtype[i] = killnotify_deathtype[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;
+ 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);
+}
+
+void HUD_KillNotify(string s1, string s2, string s3, float type, float msg)
+{
+ float w;
+ if(msg == MSG_SUICIDE) {
+ HUD_KillNotify_Push(s1, "", DEATH_KILL);
+
+ // TODO: cl_gentle
+ w = DEATH_WEAPONOF(type);
+ if(WEP_VALID(w)) {
+ if (!HUD_Panel_CheckActive(4) || cvar("hud_notify_print"))
+ print("^1", s1, "^1 ", Weapon_SuicideMessage(type), "\n");
+ }
+ else if (type == DEATH_KILL)
+ print ("^1",s1, "^1 couldn't take it anymore\n");
+ else if (type == DEATH_ROT)
+ print ("^1",s1, "^1 died\n");
+ else if (type == DEATH_NOAMMO)
+ print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
+ else if (type == DEATH_CAMP)
+ print ("^1",s1, "^1 thought they found a nice camping ground\n");
+ else if (type == DEATH_MIRRORDAMAGE)
+ print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
+ else if (type == DEATH_CHEAT)
+ print ("^1",s1, "^1 unfairly eliminated themself\n");
+ else if (type == DEATH_FIRE)
+ print ("^1",s1, "^1 burned to death\n");
+ else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET)
+ print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
+ if (stof(s2) > 2) // killcount > 2
+ print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
+ } else if(msg == MSG_KILL) {
+ w = DEATH_WEAPONOF(type);
+ if(WEP_VALID(w)) {
+ HUD_KillNotify_Push(s2, s1, w);
+ if (!HUD_Panel_CheckActive(4) || cvar("hud_notify_print"))
+ print("^1", s1, "^1 ", Weapon_KillMessage(type), "\n");
+ }
+ else if(type == KILL_TEAM || type == KILL_TEAM_SPREE) {
+ if(cvar("cl_gentle")) {
+ print ("^1", s1, "^1 took action against a team mate\n");
+ } else {
+ print ("^1", s1, "^1 mows down a team mate\n");
+ }
+ if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
+ if(cvar("cl_gentle"))
+ print ("^1",s1,"^1 ended a ",s2," scoring spree by going against a team mate\n");
+ else
+ print ("^1",s1,"^1 ended a ",s2," kill spree by killing a team mate\n");
+ }
+ else if (stof(s2) > 2) {
+ if(cvar("cl_gentle"))
+ print ("^1",s1,"'s ^1",s2," scoring spree was ended by a team mate!\n");
+ else
+ print ("^1",s1,"'s ^1",s2," kill spree was ended by a team mate!\n");
+ }
+ }
+ else if(type == KILL_FIRST_BLOOD)
+ print("^1",s1, "^1 drew first blood", "\n");
+ else if (type == DEATH_TELEFRAG)
+ print ("^1",s1, "^1 was telefragged by ", s2, "\n");
+ else if (type == DEATH_DROWN) {
+ HUD_KillNotify_Push(s2, s1, DEATH_FALL);
+ print ("^1",s1, "^1 was drowned by ", s2, "\n");
+ }
+ else if (type == DEATH_SLIME) {
+ HUD_KillNotify_Push(s2, s1, DEATH_FALL);
+ print ("^1",s1, "^1 was slimed by ", s2, "\n");
+ }
+ else if (type == DEATH_LAVA) {
+ HUD_KillNotify_Push(s2, s1, DEATH_FALL);
+ print ("^1",s1, "^1 was cooked by ", s2, "\n");
+ }
+ else if (type == DEATH_FALL) {
+ HUD_KillNotify_Push(s2, s1, DEATH_FALL);
+ print ("^1",s1, "^1 was grounded by ", s2, "\n");
+ }
+ else if (type == DEATH_SHOOTING_STAR) {
+ HUD_KillNotify_Push(s2, s1, DEATH_FALL);
+ print ("^1",s1, "^1 was shot into space by ", s2, "\n");
+ }
+ else if (type == DEATH_SWAMP) {
+ HUD_KillNotify_Push(s2, s1, DEATH_FALL);
+ print ("^1",s1, "^1 was conserved by ", s2, "\n");
+ }
+ else if (type == DEATH_HURTTRIGGER && s3 != "")
+ {
+ HUD_KillNotify_Push(s2, s1, DEATH_FALL);
+ // p ?!?! :o
+ //if(p < 0)
+ print("^1", s1, "^1 ", s3, " ", s2, "\n");
+ //else
+ // bprint("^1", s1, "^1 ", substring(s3, 0, p), s2, "^1", substring(s3, p+1, strlen(s3) - (p+1)), "\n");
+ }
+ else if(type == DEATH_SBCRUSH)
+ print ("^1",s1, "^1 was crushed by ^1", s2, "\n");
+ else if(type == DEATH_SBMINIGUN)
+ print ("^1",s1, "^1 got shredded by ^1", s2, "\n");
+ else if(type == DEATH_SBROCKET)
+ print ("^1",s1, "^1 was blased to bits by ^1", s2, "\n");
+ else if(type == DEATH_SBBLOWUP)
+ print ("^1",s1, "^1 got cought in the destruction of ^1", s2, "'s vehicle\n");
+
+ else if(type == DEATH_WAKIGUN)
+ print ("^1",s1, "^1 was bolted down by ^1", s2, "\n");
+ else if(type == DEATH_WAKIROCKET)
+ print ("^1",s1, "^1 could find no shelter from ^1", s2, "'s rockets\n");
+ else if(type == DEATH_WAKIBLOWUP)
+ print ("^1",s1, "^1 dies when ^1", s2, "'s wakizashi dies.\n");
+
+ else if(type == DEATH_TURRET)
+ print ("^1",s1, "^1 was pushed into the line of fire by ^1", s2, "\n");
+ else if(type == DEATH_TOUCHEXPLODE)
+ print ("^1",s1, "^1 was pushed into an accident by ^1", s2, "\n");
+ else if(type == DEATH_CHEAT)
+ print ("^1",s1, "^1 was unfairly eliminated by ^1", s2, "\n");
+ else if (type == DEATH_FIRE)
+ print ("^1",s1, "^1 was burnt to death by ^1", s2, "\n");
+ else if (type == DEATH_CUSTOM)
+ print ("^1",s1, "^1 ", s2, "\n");
+ else
+ print ("^1",s1, "^1 was fragged by ", s2, "\n");
+ } else if(msg == MSG_SPREE) {
+ if(type == KILL_END_SPREE) {
+ if(cvar("cl_gentle"))
+ print ("^1",s1,"'s ^1", s2, " scoring spree was ended by ", s3, "\n");
+ else
+ print ("^1",s1,"'s ^1", s2, " kill spree was ended by ", s3, "\n");
+ } else if(type == KILL_SPREE) {
+ if(cvar("cl_gentle"))
+ print ("^1",s1,"^1 made ",s2," scores in a row\n");
+ else
+ print ("^1",s1,"^1 has ",s2," frags in a row\n");
+ } else if(type == KILL_SPREE_3) {
+ if(cvar("cl_gentle"))
+ print (s1,"^7 made a ^1TRIPLE SCORE\n");
+ else
+ print (s1,"^7 made a ^1TRIPLE FRAG\n");
+ } else if(type == KILL_SPREE_5) {
+ if(cvar("cl_gentle"))
+ print (s1,"^7 unleashes ^1SCORING RAGE\n");
+ else
+ print (s1,"^7 unleashes ^1RAGE\n");
+ } else if(type == KILL_SPREE_10) {
+ if(cvar("cl_gentle"))
+ print (s1,"^7 made ^1TEN SCORES IN A ROW!\n");
+ else
+ print (s1,"^7 starts the ^1MASSACRE!\n");
+ } else if(type == KILL_SPREE_15) {
+ if(cvar("cl_gentle"))
+ print (s1,"^7 made ^1FIFTEEN SCORES IN A ROW!\n");
+ else
+ print (s1,"^7 executes ^1MAYHEM!\n");
+ } else if(type == KILL_SPREE_20) {
+ if(cvar("cl_gentle"))
+ print (s1,"^7 made ^1TWENTY SCORES IN A ROW!\n");
+ else
+ print (s1,"^7 is a ^1BERSERKER!\n");
+ } else if(type == KILL_SPREE_25) {
+ if(cvar("cl_gentle"))
+ print (s1,"^7 made ^1TWENTY FIFE SCORES IN A ROW!\n");
+ else
+ print (s1,"^7 inflicts ^1CARNAGE!\n");
+ } else if(type == KILL_SPREE_30) {
+ if(cvar("cl_gentle"))
+ print (s1,"^7 made ^1THIRTY SCORES IN A ROW!\n");
+ else
+ print (s1,"^7 unleashes ^1ARMAGEDDON!\n");
+ }
+ } else if(msg == MSG_KILL_ACTION) { // wtf is this? isnt it basically the same as MSG_SUICIDE?
+ HUD_KillNotify_Push(s1, "", DEATH_KILL);
+ if (type == DEATH_DROWN) {
+ if(cvar("cl_gentle"))
+ print ("^1",s1, "^1 was in the water for too long\n");
+ else
+ print ("^1",s1, "^1 drowned\n");
+ }
+ else if (type == DEATH_SLIME)
+ print ("^1",s1, "^1 was slimed\n");
+ else if (type == DEATH_LAVA) {
+ if(cvar("cl_gentle"))
+ print ("^1",s1, "^1 found a hot place\n");
+ else
+ print ("^1",s1, "^1 turned into hot slag\n");
+ }
+ else if (type == DEATH_FALL) {
+ if(cvar("cl_gentle"))
+ print ("^1",s1, "^1 tested gravity (and it worked)\n");
+ else
+ print ("^1",s1, "^1 hit the ground with a crunch\n");
+ }
+ else if (type == DEATH_SHOOTING_STAR)
+ print ("^1",s1, "^1 became a shooting star\n");
+ else if (type == DEATH_SWAMP) {
+ if(cvar("cl_gentle"))
+ print ("^1",s1, "^1 discovered a swamp\n");
+ else
+ print ("^1",s1, "^1 is now conserved for centuries to come\n");
+ }
+ else if(type == DEATH_TURRET)
+ print ("^1",s1, "^1 was mowed down by a turret \n");
+ else if (type == DEATH_CUSTOM)
+ print ("^1",s1, "^1 ", s2, "\n");
+ else if(type == DEATH_TOUCHEXPLODE)
+ print ("^1",s1, "^1 died in an accident\n");
+ else if(type == DEATH_CHEAT)
+ print ("^1",s1, "^1 was unfairly eliminated\n");
+ else if(type == DEATH_FIRE) {
+ if(cvar("cl_gentle"))
+ print ("^1",s1, "^1 felt a little hot\n");
+ else
+ print ("^1",s1, "^1 burnt to death\n");
+ }
+ else {
+ if(cvar("cl_gentle"))
+ print ("^1",s1, "^1 needs a restart\n");
+ else
+ print ("^1",s1, "^1 died\n");
+ }
+ } else if(msg == MSG_KILL_ACTION_SPREE) {
+ HUD_KillNotify_Push(s1, "", DEATH_KILL);
+ if(cvar("cl_gentle"))
+ print ("^1",s1,"^1 needs a restart after a ",s2," scoring spree\n");
+ else
+ print ("^1",s1,"^1 died with a ",s2," kill spree\n");
+ }
+}
+
+#define DAMAGE_CENTERPRINT_SPACER NEWLINES
+
+void HUD_Centerprint(string s1, float type)
+{
+ if (type == DEATH_TEAMCHANGE) {
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
+ } else if (type == DEATH_AUTOTEAMCHANGE) {
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You have been moved into a different team to improve team balance\nYou are now on: ", s1));
+ } else if (type == DEATH_CAMP) {
+ if(cvar("cl_gentle"))
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Reconsider your tactics, camper!"));
+ else
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Die camper!"));
+ } else if (type == DEATH_NOAMMO) {
+ if(cvar("cl_gentle"))
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You are reinserted into the game for running out of ammo..."));
+ else
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You were killed for running out of ammo..."));
+ } else if (type == DEATH_ROT) {
+ if(cvar("cl_gentle"))
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to preserve your health"));
+ else
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You grew too old without taking your medicine"));
+ } else if (type == DEATH_MIRRORDAMAGE) {
+ if(cvar("cl_gentle"))
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!"));
+ else
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!"));
+ } else if (type == DEATH_QUIET) {
+ // do nothing
+ } else if (type == DEATH_KILL) {
+ if(cvar("cl_gentle"))
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!"));
+ else
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!"));
+ } else if (type == KILL_TEAM) {
+ if(cvar("cl_gentle")) {
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You went against a team mate!"));
+ } else {
+ centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "^1Moron! You fragged ", s1, ", a team mate!"));
+ }
+ }
+}
+
void HUD_Notify (void)
{
float id = 4;
mySize -= '2 2 0' * padding;
}
+ float entries, height;
+ entries = 8 * mySize_y/mySize_x;
+ height = mySize_y/entries;
+
+ vector fontsize;
+ fontsize = '0.33 0.33 0' * height;
+
+ float a;
+ float when;
+ when = 5;
+ float fadetime;
+ fadetime = 2;
+
+ float i;
+ for(i = 0; i <= entries; ++i)
+ {
+ a = bound(0, when + (fadetime - (time - killnotify_times[i]))/fadetime, 1);
+ drawcolorcodedstring(pos + eY * 0.33 * height + eY * i * height, textShortenToWidth(killnotify_attackers[i], 0.5 * mySize_x - height, fontsize, stringwidth_colors), fontsize, hud_alpha_fg * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos + eY * 0.33 * height + eX * 0.5 * mySize_x + eX * height + eY * i * height, textShortenToWidth(killnotify_victims[i], 0.5 * mySize_x - height, fontsize, stringwidth_colors), fontsize, hud_alpha_fg * a, DRAWFLAG_NORMAL);
+
+ if(WEP_VALID(killnotify_deathtype[i]))
+ {
+ self = get_weaponinfo(killnotify_deathtype[i]);
+ drawpic_skin(pos + eX * 0.5 * mySize_x - eX * (mySize_y/entries) + eY * i * (mySize_y/entries), strcat("weapon", self.netname), '2 1 0' * (mySize_y/entries), '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
+ }
+ else if(killnotify_deathtype[i] == DEATH_KILL)
+ {
+ drawpic_skin(pos + eX * 0.5 * mySize_x - eX * (mySize_y/entries) + eY * i * (mySize_y/entries), "notify_selfkill", '2 1 0' * (mySize_y/entries), '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
+ }
+ else if(killnotify_deathtype[i] == DEATH_FALL)
+ {
+ drawpic_skin(pos + eX * 0.5 * mySize_x - eX * (mySize_y/entries) + eY * i * (mySize_y/entries), "notify_pushoffedge", '2 1 0' * (mySize_y/entries), '1 1 1', hud_alpha_fg * a, DRAWFLAG_NORMAL);
+ }
+ }
+ /* This will come later.
string s;
entity tm;
if(spectatee_status && !intermission)
}
}
}
+ */
}
// Timer (#5)
float scale2d, normalsize, bigsize;
float f;
- teamradar_origin2d = pos + 0.5 * mySize; // TODO: stupid compat, should be removed (hint: code seems to assume origin to be in center, where panelhud code uses pos as topleft pixel)
+ teamradar_origin2d = pos + 0.5 * mySize;
teamradar_size2d = mySize;
if(minimapname == "")
hud_configure = cvar("_hud_configure");
// Drawing stuff
+
+ // HUD configure visible grid
+ if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
+ {
+ float i;
+ // x-axis
+ for(i = 0; i < vid_conwidth/cvar("hud_configure_grid_x"); ++i)
+ {
+ drawfill(eX * i * cvar("hud_configure_grid_x"), eX + eY * vid_conheight, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
+ }
+ // y-axis
+ for(i = 0; i < vid_conheight/cvar("hud_configure_grid_y"); ++i)
+ {
+ drawfill(eY * i * cvar("hud_configure_grid_y"), eY + eX * vid_conwidth, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
+ }
+ }
+
if(cvar_string("hud_dock") != "")
drawpic_skin('0 0 0', cvar_string("hud_dock"), eX * vid_conwidth + eY * vid_conheight, HUD_Panel_Dock_GetColor(), cvar("hud_dock_alpha"), DRAWFLAG_NORMAL);