Mapper-settable boss healthbar support.

This commit is contained in:
Mari the Deer 2022-09-11 13:58:49 +02:00
commit a4830f6008
8 changed files with 84 additions and 13 deletions

View file

@ -122,6 +122,52 @@ extend Class SWWMHandler
MAP_EVMAP30 // eviternity
};
static play void AddBoss( int tid, String tag, bool endgame = false )
{
let hnd = SWWMHandler(EventHandler.Find("SWWMHandler"));
if ( !hnd ) return;
hnd.bossactors.Clear();
hnd.initialized = false;
let ai = level.CreateActorIterator(tid);
Actor a;
while ( a = ai.Next() )
{
hnd.bossactors.Push(a);
a.GiveInventory('BossMarker',1);
if ( endgame ) a.GiveInventory('EndgameBossMarker',1);
// boss brain type actors need to set an eye so we can detect when they "aggro"
if ( a is 'BossBrain' )
{
hnd.bossbrainactor = a;
// look for boss eyes
let eye = Actor(ThinkerIterator.Create("BossEye").Next());
hnd.bossviewactor = eye;
}
}
if ( hnd.bossactors.Size() == 0 ) return;
hnd.bosstag = (tag!="")?tag:hnd.bossactors[0].GetTag();
}
static play void AddBossActor( Actor a, String tag, bool endgame = false )
{
if ( !a ) return;
let hnd = SWWMHandler(EventHandler.Find("SWWMHandler"));
if ( !hnd ) return;
hnd.bossactors.Clear();
hnd.initialized = false;
hnd.bossactors.Push(a);
a.GiveInventory('BossMarker',1);
hnd.bosstag = (tag!="")?tag:a.GetTag();
// boss brain type actors need to set an eye so we can detect when they "aggro"
if ( a is 'BossBrain' )
{
hnd.bossbrainactor = a;
// look for boss eyes
let eye = Actor(ThinkerIterator.Create("BossEye").Next());
hnd.bossviewactor = eye;
}
}
private clearscope int WhichVanillaBossMap() const
{
String mapsum = level.GetChecksum();
@ -472,7 +518,7 @@ extend Class SWWMHandler
for ( int i=0; i<bossactors.Size(); i++ )
{
if ( !bossactors[i] ) continue;
thealth += max(0,bossactors[i].Health);
thealth += max(0,bossactors[i].SpawnHealth());
}
hmax = thealth;
for ( int i=0; i<30; i++ ) oldhealth[i] = thealth;
@ -518,7 +564,7 @@ extend Class SWWMHandler
if ( !bbar_f ) bbar_f = TexMan.CheckForTexture("graphics/HUD/BossHealthBarBox.png",TexMan.Type_Any);
if ( !bbar_r ) bbar_r = TexMan.CheckForTexture("graphics/HUD/BossHealthBar.png",TexMan.Type_Any);
if ( !bbar_d ) bbar_d = TexMan.CheckForTexture("graphics/HUD/BossHealthBarDecay.png",TexMan.Type_Any);
Vector2 vpos = ((bar.ss.x-300)/2.,bar.ss.y-(bar.margin+35));
Vector2 vpos = ((bar.ss.x-300)/2.,bar.ss.y-(bar.margin+50));
Screen.DrawTexture(bbar_f,false,vpos.x-2,vpos.y-2,DTA_VirtualWidthF,bar.ss.x,DTA_VirtualHeightF,bar.ss.y,DTA_KeepRatio,true,DTA_Alpha,bossalpha);
if ( hmax )
{
@ -533,7 +579,13 @@ extend Class SWWMHandler
string dnum = String.Format("%d",cummdamage);
Screen.DrawText(mSmallFont,Font.CR_RED,vpos.x+300-mSmallFont.StringWidth(dnum),vpos.y-(mSmallFont.GetHeight()+2),dnum,DTA_VirtualWidthF,bar.ss.x,DTA_VirtualHeightF,bar.ss.y,DTA_KeepRatio,true,DTA_Alpha,bossalpha*calph);
}
Screen.DrawText(mSmallFont,Font.CR_WHITE,vpos.x,vpos.y-(mSmallFont.GetHeight()+2),StringTable.Localize(swwm_funtags?(bosstag.."_FUN"):bosstag),DTA_VirtualWidthF,bar.ss.x,DTA_VirtualHeightF,bar.ss.y,DTA_KeepRatio,true,DTA_Alpha,bossalpha);
String bname = bosstag;
if ( (bname.Left(1) == "$") && swwm_funtags )
{
String fun = bname.."_FUN";
if ( !(StringTable.Localize(fun) ~== fun.Mid(1)) ) bname == fun;
}
Screen.DrawText(mSmallFont,Font.CR_WHITE,vpos.x,vpos.y-(mSmallFont.GetHeight()+2),StringTable.Localize(bname),DTA_VirtualWidthF,bar.ss.x,DTA_VirtualHeightF,bar.ss.y,DTA_KeepRatio,true,DTA_Alpha,bossalpha);
}
// can't use this until I actually figure out how to make those walls damageable