Healthbar / Damnum backport from sidemods.

This commit is contained in:
Mari the Deer 2022-08-22 17:36:57 +02:00
commit b40d8d0633
1743 changed files with 683 additions and 869 deletions

View file

@ -63,7 +63,15 @@ extend Class SWWMHandler
// damage numbers, combat tracking, etc.
private void DoDamageHandling( WorldEvent e )
{
SWWMScoreObj.SpawnFromHandler(self,-e.Damage,e.Thing.Vec3Offset(FRandom[ScoreBits](-8,8),FRandom[ScoreBits](-8,8),FRandom[ScoreBits](-8,8)+e.Thing.Height/2),ST_Damage);
SWWMDamNum.SpawnFromHandler(self,e.Damage,e.Thing.Vec3Offset(FRandom[ScoreBits](-8,8),FRandom[ScoreBits](-8,8),FRandom[ScoreBits](-8,8)+e.Thing.Height/2),e.DamageType);
// combat tracker updates if either an ally of the player is hit, or an ally hit this enemy
// (this automatically also does the same for the player itself, of course)
for ( int i=0; i<MAXPLAYERS; i++ )
{
if ( !playeringame[i] || !players[i].mo ) continue;
if ( players[i].mo.IsFriend(e.Thing) || (e.DamageSource && players[i].mo.IsFriend(e.DamageSource)) )
SWWMQuickCombatTracker.Update(self,players[i],e.Thing,e.Damage);
}
// stats
if ( e.Thing.player )
{

View file

@ -126,9 +126,6 @@ extend Class SWWMHandler
spreecount[e.playernumber] = 0;
tookdamage[e.playernumber] = false;
lastkill[e.playernumber] = int.min;
// reset combat tracker
if ( !swwm_notrack )
SWWMCombatTracker.Spawn(self,players[e.playernumber].mo,true);
// reset score (optional) if inventory should be cleared
if ( swwm_resetscore && level.info.flags2&LEVEL2_RESETINVENTORY && !e.IsReturn )
c.credits = 0;
@ -152,8 +149,5 @@ extend Class SWWMHandler
spreecount[e.playernumber] = 0;
tookdamage[e.playernumber] = false;
lastkill[e.playernumber] = int.min;
// reset combat tracker
if ( !swwm_notrack )
SWWMCombatTracker.Spawn(self,players[e.playernumber].mo,true);
}
}

View file

@ -257,40 +257,6 @@ extend Class SWWMHandler
Console.Printf("Extended hitboxes can't be re-enabled at runtime. Please restart the map.");
return;
}
else if ( e.Name ~== "swwmupdatetrackers" )
{
if ( multiplayer && (e.player != Net_Arbitrator) )
{
if ( e.player == consoleplayer )
Console.Printf("Only the net arbitrator can call this event.");
return;
}
if ( swwm_notrack )
{
int n = trackers_cnt;
while ( trackers )
{
let next = trackers.next;
trackers.Destroy(); // wow that's simple, all in one line
trackers = next;
}
trackers_cnt = 0;
Console.Printf("%d trackers removed.",n);
return;
}
int n = trackers_cnt;
let ti = ThinkerIterator.Create("Actor");
Actor a;
while ( a = Actor(ti.Next()) )
{
if ( (!a.bSHOOTABLE && !a.bISMONSTER) || (a is 'LampMoth') || (a is 'CompanionLamp') ) continue;
let trk = SWWMCombatTracker.Spawn(self,a,true);
if ( !a.player ) trk.maxhealth = max(a.health,a.GetSpawnHealth());
}
n = (trackers_cnt-n);
Console.Printf("%d trackers added.",n);
return;
}
else if ( e.Name ~== "swwmtrimsuckables" )
{
if ( multiplayer && (e.player != Net_Arbitrator) )

View file

@ -92,7 +92,8 @@ extend Class SWWMHandler
ui bool ui_initialized;
ui TextureID bbar_f, bbar_r, bbar_d;
ui double bossalpha;
ui DynamicValueInterpolator ihealth, ihealthr;
ui SmoothLinearValueInterpolator ihealth;
ui SmoothDynamicValueInterpolator ihealthr;
ui int thealth, hmax;
ui int oldhealth[30];
ui int cummdamage, lastcummtic; // please do not misread
@ -184,7 +185,7 @@ extend Class SWWMHandler
return MAP_EVMAP30;
return MAP_NONE;
}
private void VanillaBossSpawn( WorldEvent e, SWWMCombatTracker trk )
private void VanillaBossSpawn( WorldEvent e )
{
if ( bossmap == -1 ) bossmap = WhichVanillaBossMap();
if ( bossmap == MAP_DE1M8 )
@ -193,7 +194,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 3;
if ( trk ) trk.bBOSS = true;
e.Thing.GiveInventory('BossMarker',1);
}
bosstag = "$BT_BRUISERS";
@ -204,7 +204,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 5;
if ( trk ) trk.bBOSS = true;
e.Thing.GiveInventory('BossMarker',1);
}
bosstag = "$BT_CYBIE";
@ -215,7 +214,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 6;
if ( trk ) trk.bBOSS = true;
e.Thing.GiveInventory('BossMarker',1);
e.Thing.GiveInventory('EndgameBossMarker',1);
}
@ -227,7 +225,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 4;
if ( trk ) trk.bBOSS = true;
e.Thing.GiveInventory('BossMarker',1);
}
bosstag = "$BT_SPIDER2";
@ -238,7 +235,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 2;
if ( trk ) trk.bBOSS = true;
e.Thing.GiveInventory('BossMarker',1);
}
bosstag = "$BT_DIMPLE";
@ -250,7 +246,6 @@ extend Class SWWMHandler
bossbrainactor = e.Thing;
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 40; // goodbye, instakills
if ( trk ) trk.bBOSS = true;
e.Thing.GiveInventory('BossMarker',1);
e.Thing.GiveInventory('EndgameBossMarker',1);
}
@ -267,7 +262,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 4;
if ( trk ) trk.bBOSS = true;
e.Thing.GiveInventory('BossMarker',1);
}
bosstag = "$BT_CYBIE2";
@ -278,7 +272,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 4;
if ( trk ) trk.bBOSS = true;
e.Thing.GiveInventory('BossMarker',1);
}
bosstag = "$BT_LICHES";
@ -289,7 +282,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 3;
if ( trk ) trk.bBOSS = true;
e.Thing.GiveInventory('BossMarker',1);
}
bosstag = "$BT_MINOTAUR";
@ -300,7 +292,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 2;
if ( trk ) trk.bBOSS = true;
bosstag = "$BT_DSPARIL";
e.Thing.GiveInventory('BossMarker',1);
e.Thing.GiveInventory('EndgameBossMarker',1);
@ -312,7 +303,6 @@ extend Class SWWMHandler
initialized = false;
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 8;
if ( trk ) trk.bBOSS = true;
bosstag = "$BT_DSPARIL2";
e.Thing.GiveInventory('BossMarker',1);
e.Thing.GiveInventory('EndgameBossMarker',1);
@ -325,7 +315,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 2;
if ( trk ) trk.bBOSS = true;
bosstag = "$BT_CLERIC";
e.Thing.GiveInventory('BossMarker',1);
}
@ -336,7 +325,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 2;
if ( trk ) trk.bBOSS = true;
bosstag = "$BT_FIGHTER";
e.Thing.GiveInventory('BossMarker',1);
}
@ -347,7 +335,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 2;
if ( trk ) trk.bBOSS = true;
bosstag = "$BT_MAGE";
e.Thing.GiveInventory('BossMarker',1);
}
@ -358,7 +345,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 4;
if ( trk ) trk.bBOSS = true;
bosstag = "$BT_DRAGON";
e.Thing.GiveInventory('BossMarker',1);
}
@ -369,7 +355,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 8;
if ( trk ) trk.bBOSS = true;
bosstag = "$BT_HERESIARCH";
e.Thing.GiveInventory('BossMarker',1);
}
@ -380,7 +365,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 10;
if ( trk ) trk.bBOSS = true;
bosstag = "$BT_KORAX";
e.Thing.GiveInventory('BossMarker',1);
e.Thing.GiveInventory('EndgameBossMarker',1);
@ -392,7 +376,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 4;
if ( trk ) trk.bBOSS = true;
bosstag = "$BT_DEATHKINGS";
initialized = true; // healthbar shows from the start
e.Thing.GiveInventory('BossMarker',1);
@ -416,7 +399,6 @@ extend Class SWWMHandler
initialized = false;
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 5;
if ( trk ) trk.bBOSS = true;
bosstag = "$BT_ARCHANGELUS";
e.Thing.GiveInventory('BossMarker',1);
e.Thing.GiveInventory('EndgameBossMarker',1);
@ -429,7 +411,6 @@ extend Class SWWMHandler
initialized = false;
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 5;
if ( trk ) trk.bBOSS = true;
bosstag = "$BT_ARCHANGELUS";
e.Thing.GiveInventory('BossMarker',1);
e.Thing.GiveInventory('EndgameBossMarker',1);
@ -440,7 +421,6 @@ extend Class SWWMHandler
{
bossactors.Push(e.Thing);
e.Thing.StartHealth = e.Thing.Health *= 10;
if ( trk ) trk.bBOSS = true;
bosstag = "ROM3R-0.666";
e.Thing.GiveInventory('BossMarker',1);
e.Thing.GiveInventory('EndgameBossMarker',1);
@ -497,9 +477,9 @@ extend Class SWWMHandler
hmax = thealth;
for ( int i=0; i<30; i++ ) oldhealth[i] = thealth;
cummdamage = 0;
if ( !ihealth ) ihealth = DynamicValueInterpolator.Create(thealth,.1,1,1000);
if ( !ihealth ) ihealth = SmoothLinearValueInterpolator.Create(thealth,max(1,hmax/120));
else ihealth.Reset(thealth);
if ( !ihealthr ) ihealthr = DynamicValueInterpolator.Create(thealth,.5,1,1000);
if ( !ihealthr ) ihealthr = SmoothDynamicValueInterpolator.Create(thealth,.5,1,100);
else ihealthr.Reset(thealth);
return;
}
@ -534,7 +514,7 @@ extend Class SWWMHandler
ui void DrawBossBar( SWWMStatusBar bar )
{
if ( !ui_initialized || (bossalpha <= 0.) ) return;
if ( !mSmallFont ) mSmallFont = Font.GetFont('TewiFont');
if ( !mSmallFont ) mSmallFont = Font.GetFont('TewiFontOutline');
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);
@ -542,10 +522,10 @@ extend Class SWWMHandler
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 )
{
int rw = int(clamp((ihealthr.GetValue()*300.)/hmax,0.,300.));
int dw = int(clamp((ihealth.GetValue()*300.)/hmax,0.,300.));
Screen.DrawTexture(bbar_d,false,vpos.x,vpos.y,DTA_VirtualWidthF,bar.ss.x,DTA_VirtualHeightF,bar.ss.y,DTA_KeepRatio,true,DTA_Alpha,bossalpha,DTA_WindowRight,dw);
Screen.DrawTexture(bbar_r,false,vpos.x,vpos.y,DTA_VirtualWidthF,bar.ss.x,DTA_VirtualHeightF,bar.ss.y,DTA_KeepRatio,true,DTA_Alpha,bossalpha,DTA_WindowRight,rw);
double rw = clamp((ihealthr.GetValue(bar.FracTic)*300.)/hmax,0.,300.);
double dw = clamp((ihealth.GetValue(bar.FracTic)*300.)/hmax,0.,300.);
Screen.DrawTexture(bbar_d,false,vpos.x,vpos.y,DTA_VirtualWidthF,bar.ss.x,DTA_VirtualHeightF,bar.ss.y,DTA_KeepRatio,true,DTA_Alpha,bossalpha,DTA_WindowRightF,dw);
Screen.DrawTexture(bbar_r,false,vpos.x,vpos.y,DTA_VirtualWidthF,bar.ss.x,DTA_VirtualHeightF,bar.ss.y,DTA_KeepRatio,true,DTA_Alpha,bossalpha,DTA_WindowRightF,rw);
}
if ( (cummdamage > 0) && (gametic < lastcummtic+150) )
{

View file

@ -11,12 +11,12 @@ extend Class SWWMHandler
// for displaying beam-type projectiles
Array<Actor> beams;
// legendary monster markers (for the "has mutated" message)
Array<Inventory> legtrack;
override void WorldThingRevived( WorldEvent e )
{
if ( profiling ) ProfileTick();
// reattach combat tracker
if ( !swwm_notrack && (e.Thing.bSHOOTABLE || e.Thing.bISMONSTER) && !(e.Thing is 'LampMoth') && !(e.Thing is 'CompanionLamp') )
SWWMCombatTracker.Spawn(self,e.Thing,true);
// reattach headpats
if ( SWWMUtility.IdentifyingDog(e.Thing) || SWWMUtility.IdentifyingCaco(e.Thing)
|| SWWMUtility.IdentifyingDrug(e.Thing) || SWWMUtility.IdentifyingDoubleBoi(e.Thing) )
@ -275,6 +275,9 @@ extend Class SWWMHandler
p.target = e.Thing;
p.SetStateLabel("Pickup");
}
// for notification
if ( e.Thing.GetClassName() == "LDLegendaryMonsterTransformed" )
legtrack.Push(Inventory(e.Thing));
}
if ( swwm_doomfall && e.Thing.bISMONSTER && !e.Thing.bBOSS )
e.Thing.bFALLDAMAGE = true;
@ -396,9 +399,6 @@ extend Class SWWMHandler
let hp = Actor.Spawn("HeadpatTracker",e.Thing.pos);
hp.target = e.Thing;
}
SWWMCombatTracker trk = null;
if ( !swwm_notrack && (e.Thing.bSHOOTABLE || e.Thing.bISMONSTER) && !(e.Thing is 'LampMoth') && !(e.Thing is 'CompanionLamp') )
trk = SWWMCombatTracker.Spawn(self,e.Thing);
if ( swwm_shadows && !(e.Thing is 'LampMoth') && (e.Thing.bSHOOTABLE || e.Thing.bISMONSTER || (e.Thing is 'Inventory') || (e.Thing is 'CompanionLamp')) && ((e.Thing is 'Demolitionist') || (e.Thing.SpawnState.sprite == e.Thing.GetSpriteIndex('XZW1'))) )
SWWMShadow.Track(e.Thing);
// Ynykron vortex optimization (faster than a thinker iterator)
@ -427,13 +427,7 @@ extend Class SWWMHandler
}
else if ( e.Thing.GetClass() == "LostSoul" )
e.Thing.bNOBLOOD = true;
VanillaBossSpawn(e,trk);
// inflation check
if ( trk )
{
trk.maxhealth = trk.lasthealth = e.Thing.Health;
trk.intp.Reset(trk.lasthealth);
}
VanillaBossSpawn(e);
if ( profiling ) ProfileTock(PT_WORLDTHINGSPAWNED);
}
}

View file

@ -9,7 +9,6 @@ extend Class SWWMHandler
transient String curlang;
transient bool curfuntags;
SWWMSimpleTracker strackers;
int strackers_cnt;
bool mnotify;
bool allkills, allitems, allsecrets;
bool mapclear;
@ -18,15 +17,18 @@ extend Class SWWMHandler
String lastmus;
int lastorder;
bool lastloop;
transient ThinkerIterator cti;
transient ThinkerIterator cti, qti;
private void LangRefresh()
{
if ( (language != curlang) || (swwm_funtags != curfuntags) )
{
// manually refresh some tags if language has changed
for ( SWWMCombatTracker t=trackers; t; t=t.next )
t.UpdateTag(self);
if ( !qti ) qti = ThinkerIterator.Create("SWWMQuickCombatTracker",Thinker.STAT_INVENTORY);
else qti.Reinit();
SWWMQuickCombatTracker qt;
while ( qt=SWWMQuickCombatTracker(qti.Next()) )
qt.UpdateTag(self);
for ( SWWMInterest p=intpoints; p; p=p.next )
{
if ( (p.type != INT_Key) || !p.trackedkey ) continue;
@ -229,25 +231,23 @@ extend Class SWWMHandler
if ( soprev ) soprev.next = sonext;
else scorenums = sonext;
so.Destroy();
scorenums_cnt--;
}
else soprev = so;
so = sonext;
}
so = damnums;
soprev = null;
while ( so )
SWWMDamNum dn = damnums;
SWWMDamNum dnprev = null, dnnext;
while ( dn )
{
sonext = so.next;
if ( so.Tick() )
dnnext = dn.next;
if ( dn.Tick() )
{
if ( soprev ) soprev.next = sonext;
else damnums = sonext;
so.Destroy();
damnums_cnt--;
if ( dnprev ) dnprev.next = dnnext;
else damnums = dnnext;
dn.Destroy();
}
else soprev = so;
so = sonext;
else dnprev = dn;
dn = dnnext;
}
// interest markers
SWWMInterest ip = intpoints;
@ -260,29 +260,10 @@ extend Class SWWMHandler
if ( ipprev ) ipprev.next = ipnext;
else intpoints = ipnext;
ip.Destroy();
intpoints_cnt--;
}
else ipprev = ip;
ip = ipnext;
}
// combat trackers
SWWMCombatTracker trk = trackers;
SWWMCombatTracker trkprev = null, trknext;
int dbar = swwm_damagetarget;
while ( trk )
{
trknext = trk.next;
trk.dbar = dbar;
if ( trk.Tick() )
{
if ( trkprev ) trkprev.next = trknext;
else trackers = trknext;
trk.Destroy();
trackers_cnt--;
}
else trkprev = trk;
trk = trknext;
}
}
// "simple" tracking (used by the minimap)
@ -296,7 +277,6 @@ extend Class SWWMHandler
strackers.Destroy();
strackers = next;
}
strackers_cnt = 0;
return;
}
// update trackers for anything around the player
@ -432,7 +412,6 @@ extend Class SWWMHandler
if ( !prev ) strackers = trk.next;
else prev.next = trk.next;
trk.Destroy();
strackers_cnt--;
}
else prev = trk;
trk = next;