swwmgz_m/zscript/hud/swwm_hud_status.zsc
Marisa the Magician 80db58b0d0 Bump zscript ver to 4.14.1, plus a whole lot of stuff.
- Try to get rid of all implicit casts from string to name, color or class.
 - Use FindClass where needed.
 - Used a map in a case where a dictionary was unneeded.
 - Use new bounce flags where needed.
 - Replace Legacy of Rust weapons/ammo.
2025-03-13 14:50:58 +01:00

227 lines
11 KiB
Text

// "Status bar" proper
extend Class SWWMStatusBar
{
private void FlushStatus()
{
int hp = CPlayer.Health;
HealthInter.Reset(hp);
for ( int i=9; i>0; i-- )
LagHealth[i] = hp;
LagHealthInter.Reset(hp);
let d = Demolitionist(CPlayer.mo);
if ( d )
{
FuelInter.Reset(d.dashfuel/2);
DashInter.Reset((40-d.dashcooldown)*3);
}
else
{
FuelInter.Reset(0);
DashInter.Reset(0);
}
}
private void TickStatusInterpolators()
{
int hp = CPlayer.Health;
HealthInter.Update(hp);
// flash 'em
if ( hp > LastHealth ) HealthFlash = gametic+25;
// lag
if ( hp > LastHealth )
{
for ( int i=9; i>0; i-- )
LagHealth[i] = hp;
}
LagHealth[0] = LastHealth = hp;
LagHealthInter.Update(LagHealth[9]);
for ( int i=9; i>0; i-- )
LagHealth[i] = LagHealth[i-1];
// fuel/dash
let d = Demolitionist(CPlayer.mo);
if ( d )
{
FuelInter.Update(d.dashfuel/2);
DashInter.Update((40-d.dashcooldown)*3);
}
else
{
FuelInter.Update(0);
DashInter.Update(0);
}
}
private void TickStatus()
{
// low health pulsing
if ( (CPlayer.health <= 0) || (CPlayer.health > 25) )
PulsePhase = 0;
else
{
PulsePhase--;
if ( (PulsePhase < 0) || (PulsePhase > CPlayer.health*2+25) )
PulsePhase = CPlayer.health*2+25;
}
}
private int GetRandom()
{
return (rss = (rss<<1)*35447+(rss/87));
}
private double RandomShiver()
{
int sd = GetRandom();
return ((abs(sd)%11)-5)*.1;
}
private int GetFaceTex( Demolitionist demo )
{
let facestate = demo.facestate;
let paindir = demo.paindir;
let facetimer = demo.facetimer;
let blinktime = demo.blinktime;
if ( CPlayer.Health <= 0 ) return 11;
if ( (isInvulnerable() || demo.FindInventory('InvinciballPower')) && (facestate >= FS_PAIN) ) return 12;
if ( facestate == FS_OUCH ) return 10;
if ( facestate == FS_PAIN ) return (paindir==1)?8:(paindir==-1)?9:7;
if ( facestate == FS_GRIN ) return 5;
if ( facestate == FS_EVIL ) return 6;
if ( facestate == FS_SAD ) return 17;
if ( facestate == FS_WINK ) return 18;
if ( facestate == FS_BLINK ) return ((facetimer>28)||(facetimer<2))?3:4;
switch ( blinktime )
{
case -1:
case -3:
return 3;
break;
case -2:
return 4;
break;
}
return (CPlayer.Health<=25)?17:2;
}
private void DrawMugshot()
{
rss = MSTime()*128;
let demo = Demolitionist(CPlayer.mo);
if ( !demo ) return;
double paintime = clamp((demo.lastdamagetimer-(gametic+Fractic))/double(GameTicRate),0.,1.);
double noiz = min(demo.lastdamage*.5*paintime,3.);
Vector2 shake = (RandomShiver(),RandomShiver())*noiz;
if ( !CPlayer.mo.FindInventory('GhostPower') )
{
int facecol = CVar.GetCVar('swwm_tagcolor',CPlayer).GetInt();
if ( (facecol < 0) || (facecol > 15) ) facecol = 0;
Screen.DrawTexture(FaceTex[0],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcWidth,32,DTA_SrcHeight,32,DTA_DestWidth,32,DTA_DestHeight,32,DTA_SrcX,32*(facecol%4),DTA_SrcY,32*(facecol/4));
bool raging = CPlayer.mo.FindInventory('RagekitPower');
bool angy = CPlayer.mo.FindInventory('AngeryPower');
if ( raging && angy ) Screen.DrawTexture(FaceTex[16],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
else if ( raging ) Screen.DrawTexture(FaceTex[15],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
else if ( angy ) Screen.DrawTexture(FaceTex[13],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
Screen.DrawTexture(FaceTex[1],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Color,Color(255,255,0,0),DTA_Alpha,min(1.,noiz));
if ( (CPlayer.Health > 0) && (isInvulnerable() || CPlayer.mo.FindInventory('InvinciballPower')) )
Screen.DrawTexture(FaceTex[1],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,.8+.1*sin(gametic+fractic));
}
else
{
Screen.DrawTexture(FaceTex[0],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcWidth,32,DTA_SrcHeight,32,DTA_DestWidth,32,DTA_DestHeight,32,DTA_FillColor,Color(0,0,0),DTA_Alpha,.25*(1.-min(1.,noiz)));
Screen.DrawTexture(FaceTex[1],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_FillColor,Color(255,0,0),DTA_Alpha,.25*min(1.,noiz));
}
Screen.DrawTexture(FaceTex[GetFaceTex(demo)],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
if ( CPlayer.mo.FindInventory('BarrierPower') ) Screen.DrawTexture(FaceTex[14],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,.5,DTA_LegacyRenderStyle,STYLE_Add);
}
private void DrawStatus()
{
DrawMugshot();
int ox = 36;
int oy = 5;
Screen.DrawTexture(StatusTex,false,xmargin+ox,ss.y-(ymargin+22+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
String str;
double ht = clamp(HealthInter.GetValue(fractic),0,10000);
str = String.Format("%3d",clamp(round(ht),0,999));
double hw = min(ht,100);
double bhw = hw;
int hcolor = MCR_RED;
if ( round(ht) > 500 ) hcolor = MCR_GOLD;
else if ( round(ht) > 200 ) hcolor = MCR_PURPLE;
else if ( round(ht) > 100 ) hcolor = MCR_AQUA;
if ( isInvulnerable() || CPlayer.mo.FindInventory('InvinciballPower') )
{
Screen.DrawTexture(HealthTex[0],false,xmargin+3+ox,ss.y-(ymargin+19+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw,DTA_ColorOverlay,Color(255,0,0,0));
Screen.DrawTexture(HealthTex[4],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw);
hcolor = MCR_WHITE;
}
else
{
Screen.DrawTexture(HealthTex[0],false,xmargin+3+ox,ss.y-(ymargin+19+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw,DTA_ColorOverlay,Color(255,0,0,0));
Screen.DrawTexture(HealthTex[0],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw);
if ( ht > 100 )
{
hw = min(ht-100,100);
Screen.DrawTexture(HealthTex[1],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw);
}
if ( ht > 200 )
{
hw = min(ht-200,300)/3.;
Screen.DrawTexture(HealthTex[2],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw);
}
if ( ht > 500 )
{
hw = min(ht-500,500)/5.;
Screen.DrawTexture(HealthTex[3],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw);
}
}
if ( CPlayer.mo.FindInventory('DivineSpriteEffect') )
{
double falph = clamp((ht-1000)/6000.,0.,1.);
Screen.DrawTexture(HealthTex[5],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,falph,DTA_LegacyRenderStyle,STYLE_Add);
String tst;
double alph = .1;
int trl = 9;
for ( double alph = .1; alph <= .5; alph += .1 )
{
tst = "AAA";
SWWMUtility.ObscureText(tst,(gametic-trl)/3,minihud:true);
trl--;
Screen.DrawText(MiniHUDFont,mhudfontcol[MCR_WHITE],xmargin+107+ox,ss.y-(ymargin+20+oy),tst,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,falph*alph,DTA_LegacyRenderStyle,STYLE_Add);
}
Screen.DrawText(MiniHUDFont,mhudfontcol[hcolor],xmargin+107+ox,ss.y-(ymargin+20+oy),String.Format("%3d",clamp(round(ht),0,999)),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,1.-falph);
}
else
{
Screen.DrawText(MiniHUDFont,mhudfontcol[hcolor],xmargin+107+ox,ss.y-(ymargin+20+oy),String.Format("%3d",clamp(round(ht),0,999)),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
int f = HealthFlash;
if ( f && (gametic < f) )
{
double alph = max((f-(gametic+FracTic))/25.,0.)**1.5;
Screen.DrawTexture(HealthTex[7],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,bhw,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
Screen.DrawText(MiniHUDFont,mhudfontcol[MCR_FLASH],xmargin+107+ox,ss.y-(ymargin+20+oy),str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph);
}
if ( (CPlayer.health > 0) && (CPlayer.health <= 25) && (PulsePhase <= 15) && (hcolor != MCR_WHITE) )
{
double alph = clamp(sin((PulsePhase-FracTic)*12.),0.,1.);
Screen.DrawTexture(HealthTex[6],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw,DTA_Alpha,alph);
Screen.DrawText(MiniHUDFont,mhudfontcol[MCR_REDFLASH],xmargin+107+ox,ss.y-(ymargin+20+oy),str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph);
}
ht = clamp(LagHealthInter.GetValue(fractic),0,1000);
double hwl = min(ht,100);
if ( hwl > bhw )
{
Screen.DrawTexture(HealthTex[8],false,xmargin+3+ox,ss.y-(ymargin+19+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowLeftF,bhw,DTA_WindowRightF,hwl,DTA_ColorOverlay,Color(255,0,0,0));
Screen.DrawTexture(HealthTex[8],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowLeftF,bhw,DTA_WindowRightF,hwl);
}
}
double ft = clamp(FuelInter.GetValue(fractic),0,120);
Screen.DrawTexture(FuelTex[swwm_superfuel],false,xmargin+3+ox,ss.y-(ymargin+7+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,ft,DTA_ColorOverlay,Color(255,0,0,0));
Screen.DrawTexture(FuelTex[swwm_superfuel],false,xmargin+2+ox,ss.y-(ymargin+8+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,ft);
let d = Demolitionist(CPlayer.mo);
bool blink = (!d || (d.dashfuel > 20) || ((gametic%10) < 5));
double dt = clamp(DashInter.GetValue(fractic),0,120);
Screen.DrawTexture(DashTex,false,xmargin+3+ox,ss.y-(ymargin+4+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,dt,DTA_ColorOverlay,Color(255,0,0,0));
Screen.DrawTexture(DashTex,false,xmargin+2+ox,ss.y-(ymargin+5+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,dt,DTA_ColorOverlay,Color(blink?0:96,0,0,0));
}
}