Tag colors and animated face using A_ChangeModel.

This commit is contained in:
Mari the Deer 2022-07-26 18:36:38 +02:00
commit 2d2dcf7ad5
28 changed files with 350 additions and 189 deletions

View file

@ -65,19 +65,6 @@ Enum EMiniHUDFontColor
NUM_MINIHUD_COLOR
};
Enum EDemoFaceState
{
FS_DEFAULT,
FS_EVIL,
FS_GRIN,
FS_WINK,
FS_BLINK,
FS_SAD,
FS_PAIN,
FS_OUCH,
FS_DEAD // UNUSED
};
Class SWWMStatusBar : BaseStatusBar
{
TextureID StatusTex, WeaponTex, ScoreTex, InventoryTex, ChatTex[6],
@ -188,10 +175,6 @@ Class SWWMStatusBar : BaseStatusBar
SmoothDynamicValueInterpolator HealthInter, FuelInter, DashInter;
SmoothLinearValueInterpolator LagHealthInter;
EDemoFaceState facestate;
int paindir;
int facetimer;
int blinktime;
transient ui int rss;
override void FlushNotify()
@ -1043,89 +1026,9 @@ Class SWWMStatusBar : BaseStatusBar
qsort_playerscore(a,p+1,h);
}
private void UpdateMugState()
{
let d = Demolitionist(CPlayer.mo);
if ( !d ) return;
// damage handling
if ( d.lastdamagetic && (d.lastdamagetic == gametic) )
{
if ( d.lastdamage > 70 )
{
facestate = FS_OUCH;
facetimer = (d.lastdamagetimer-gametic)+10;
}
else if ( facestate < FS_OUCH )
{
facestate = FS_PAIN;
facetimer = (d.lastdamagetimer-gametic)+10;
paindir = 0;
// paraphrased from vanilla, with some tweaks
if ( CPlayer.attacker && (CPlayer.attacker != d) && d )
{
double atkang = d.AngleTo(CPlayer.attacker);
double angdiff = Actor.deltaangle(CPlayer.mo.angle,atkang);
if ( abs(angdiff) < 135 )
{
if ( angdiff > 45 ) paindir = -1;
else if ( angdiff < -45 ) paindir = 1;
}
}
}
}
if ( d.lastgrin && (d.lastgrin == gametic) && (facestate < FS_SAD) )
{
facestate = FS_GRIN;
facetimer = 50;
}
if ( d.lastwink && (d.lastwink == gametic) && (facestate < FS_SAD) )
{
facestate = FS_WINK;
facetimer = 20;
}
if ( d.lastblink && (d.lastblink == gametic) && (facestate < FS_PAIN) )
{
facestate = FS_BLINK;
facetimer = 30;
}
if ( d.lastsad && (d.lastsad == gametic) && (facestate <= FS_SAD) )
{
facestate = FS_SAD;
facetimer = 50;
}
if ( CPlayer.mo.FindInventory("RagekitPower") && (facestate < FS_PAIN) )
{
facestate = FS_EVIL;
facetimer = 10;
}
if ( facetimer > 0 )
{
facetimer--;
if ( facetimer <= 0 )
{
facestate = FS_DEFAULT;
blinktime = 30;
}
}
if ( !(gametic&1) )
{
if ( blinktime <= 0 )
{
blinktime--;
if ( blinktime < -3 )
{
rss = int(MSTimeF());
blinktime = (abs(GetRandom())%10)?(40+abs(GetRandom())%40):6;
}
}
else blinktime--;
}
}
// separated so they can be auto-ticked by the demolitionist menu
void TickInterpolators()
{
UpdateMugState();
ScoreInter.Update(SWWMCredits.Get(CPlayer));
int hp = CPlayer.Health;
HealthInter.Update(hp);
@ -1553,7 +1456,6 @@ Class SWWMStatusBar : BaseStatusBar
FaceTex[17] = TexMan.CheckForTexture("graphics/HUD/DemoFace_Sad.png",TexMan.Type_Any);
FaceTex[18] = TexMan.CheckForTexture("graphics/HUD/DemoFace_Wink.png",TexMan.Type_Any);
// other expressions will be added when needed
blinktime = 30;
mSmallFont = Font.GetFont('TewiFont');
mBigFont = Font.GetFont('TewiFontOutline');
mTinyFont = Font.GetFont('MiniwiFont');
@ -3026,10 +2928,14 @@ Class SWWMStatusBar : BaseStatusBar
return ((abs(sd)%11)-5)*.1;
}
private int GetFaceTex()
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() || CPlayer.mo.FindInventory("InvinciballPower")) && (facestate >= FS_PAIN) ) return 12;
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;
@ -3075,7 +2981,7 @@ Class SWWMStatusBar : BaseStatusBar
Screen.DrawTexture(FaceTex[0],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_FillColor,Color(0,0,0),DTA_Alpha,.25*(1.-min(1.,noiz)));
Screen.DrawTexture(FaceTex[1],false,margin+shake.x,ss.y-(margin+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()],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
Screen.DrawTexture(FaceTex[GetFaceTex(demo)],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
if ( CPlayer.mo.FindInventory("BarrierPower") ) Screen.DrawTexture(FaceTex[14],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,.5,DTA_LegacyRenderStyle,STYLE_Add);
}