From: Lyberta Date: Mon, 11 Jun 2018 13:34:14 +0000 (+0300) Subject: Merge branch 'Lyberta/GunGame' into Lyberta/master X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=247f3e7a76caa83ce6faeec1e0f5d782a88f9fb0;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'Lyberta/GunGame' into Lyberta/master --- 247f3e7a76caa83ce6faeec1e0f5d782a88f9fb0 diff --cc qcsrc/client/hud/panel/modicons.qc index 35270fc42,806caf72b..887845706 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@@ -720,120 -753,26 +753,123 @@@ void HUD_Mod_GG(vector pos, vector mySi pic_pos = pos + eY * 0.25 * mySize.y; pic_size = vec2(mySize.x, 0.5 * mySize.y); } - string weapon_pic = string_null; - FOREACH(Weapons, it != WEP_Null, + float weapon_change_elapsed_time = time - gg_weapon_change_time; + // Weapon transition phase. 0 at the start of transition. 1 at the end. + float phase = bound(0, weapon_change_elapsed_time / + gg_weapon_transition_duration, 1); + + // Draw current weapon picture. Fading in if phase is less than 1. + if (gg_current_weapon_picture) { - if (it.m_id == stat_weapon) - { - weapon_pic = it.model2; - break; - } - }); - if (!weapon_pic) + drawpic_aspect_skin(pic_pos, gg_current_weapon_picture, pic_size, + '1 1 1', phase, DRAWFLAG_NORMAL); + } + // Draw previous weapon picture on top of current one so it gives a nice + // fade out effect. + if ((phase < 1) && gg_previous_weapon_picture) { - return; + drawpic_aspect_skin_expanding(pic_pos, gg_previous_weapon_picture, + pic_size, '1 1 1', 1 - phase, DRAWFLAG_NORMAL, phase); } - drawpic_aspect_skin(pic_pos, weapon_pic, pic_size, '1 1 1', 1, - DRAWFLAG_NORMAL); } +// Lyberta: surv +void HUD_Mod_SURV(vector mypos, vector mysize) +{ + mod_active = 1; // required in each mod function that always shows something + float defenderhealth = STAT(SURV_DEFENDER_HEALTH); + // Draw a health bar + float margin = mysize.y / 10; // Leave a small margin to be stylish + vector healthbarpos = mypos; + healthbarpos.x += margin; + healthbarpos.y += margin; + vector healthbarsize = mysize; + healthbarsize.x -= margin * 2; + healthbarsize.y -= margin * 2; + vector healthbarcolor; + healthbarcolor.z = 0; + if (defenderhealth > 0.5) + { + healthbarcolor.x = defenderhealth * -2 + 2; + healthbarcolor.y = 1; + } + else + { + healthbarcolor.x = 1; + healthbarcolor.y = defenderhealth; + } + HUD_Panel_DrawProgressBar(healthbarpos, healthbarsize, "progressbar", + defenderhealth, false, 0, healthbarcolor, 0.50, DRAWFLAG_NORMAL); + // Draw defender picture + int defenderteam = STAT(SURV_DEFENDER_TEAM); + string defenderpic = ""; + vector defendercolor; + switch (defenderteam) + { + case 1: + { + defenderpic = "player_red"; + defendercolor = '1 0 0'; + break; + } + case 2: + { + defenderpic = "player_blue"; + defendercolor = '0 0 1'; + break; + } + default: + { + defendercolor = '1 1 1'; + break; + } + } + vector picpos = mypos; + vector picsize = mysize; + picsize.x = picsize.y; + drawpic_aspect_skin(picpos, defenderpic, picsize, '1 1 1', 1, + DRAWFLAG_NORMAL); + // Draw number of defenders + int numalive = STAT(SURV_DEFENDERS_ALIVE); + vector alivepos = mypos; + alivepos.x += picsize.x; + vector alivesize = picsize; + drawstring_aspect(alivepos, ftos(numalive), alivesize, defendercolor, 1, + DRAWFLAG_NORMAL); + // Draw the time left + float roundtime = STAT(SURV_ROUND_TIME); + if (roundtime < 0) + { + roundtime = 0; + } + vector roundtimepos = mypos; + roundtimepos.x += picsize.x * 2; + vector roundtimesize = mysize; + roundtimesize.x = mysize.x - picsize.x * 2; + drawstring_aspect(roundtimepos, seconds_tostring(roundtime), roundtimesize, + '1 1 1', 1, DRAWFLAG_NORMAL); + if (autocvar_developer == 0) + { + return; + } + // Debug info below + int redalive = STAT(REDALIVE); + int bluealive = STAT(BLUEALIVE); + int yellowalive = STAT(YELLOWALIVE); + int pinkalive = STAT(PINKALIVE); + string message = strcat(ftos(redalive), "/", ftos(yellowalive)); + vector redpos = mypos; + redpos.y += mysize.y; + vector statsize = mysize; + statsize.x /= 2; + drawstring_aspect(redpos, message, statsize, '1 0 0', 1, DRAWFLAG_NORMAL); + message = strcat(ftos(bluealive), "/", ftos(pinkalive)); + vector bluepos = mypos; + bluepos.x += mysize.x / 2; + bluepos.y += mysize.y; + drawstring_aspect(bluepos, message, statsize, '0 0 1', 1, DRAWFLAG_NORMAL); +} + void HUD_ModIcons_SetFunc() { HUD_ModIcons_GameType = gametype.m_modicons;