Add blood pools to the effect queue system.

This commit is contained in:
Mari the Deer 2025-03-16 21:02:13 +01:00
commit 9757aed5e6
10 changed files with 63 additions and 25 deletions

View file

@ -53,9 +53,6 @@ Class SWWMHandler : EventHandler
transient ui Vector2 oldplayerpos;
transient ui bool do_trace_steps;
// for bloody footsteps
mkBloodPool bloodpools;
enum EProfileTimer
{
PT_WORLDTICK,

View file

@ -445,7 +445,7 @@ extend Class SWWMHandler
Console.Printf("Only the net arbitrator can call this event.");
return;
}
int n = casings_cnt+chips_cnt+blods_cnt+meats_cnt;
int n = casings_cnt+chips_cnt+blods_cnt+meats_cnt+pools_cnt;
CleanQueues();
Console.Printf("%d effects cleared.",n);
return;

View file

@ -12,6 +12,8 @@ extend Class SWWMHandler
int blods_cnt, oldmaxblood, blods_realcnt;
mkFlyingGib meats, meats_end;
int meats_cnt, oldmaxgibs, meats_realcnt;
mkBloodPool pools, pools_end;
int pools_cnt, oldmaxpools, pools_realcnt;
static void QueueCasing( SWWMCasing c )
{
@ -149,6 +151,40 @@ extend Class SWWMHandler
m.prevmeat = null;
m.nextmeat = null;
}
static void QueuePool( mkBloodPool p )
{
let hnd = SWWMHandler(EventHandler.Find('SWWMHandler'));
if ( !hnd ) return;
hnd.pools_cnt++;
if ( !hnd.pools )
{
// this is the initial one
hnd.pools = p;
hnd.pools_end = p;
}
else
{
hnd.pools_end.nextpool = p;
p.prevpool = hnd.pools_end;
hnd.pools_end = p;
}
while ( hnd.pools && (swwm_maxpools >= 0) && (hnd.pools_cnt > swwm_maxpools) )
DeQueuePool(hnd.pools);
}
static void DeQueuePool( mkBloodPool p )
{
let hnd = SWWMHandler(EventHandler.Find('SWWMHandler'));
if ( !hnd || !hnd.pools ) return;
if ( (hnd.pools != p) && !p.prevpool && !p.nextpool ) return;
hnd.pools_cnt--;
if ( !p.prevpool ) hnd.pools = p.nextpool;
else p.prevpool.nextpool = p.nextpool;
if ( p == hnd.pools_end ) hnd.pools_end = p.prevpool;
if ( p.nextpool ) p.nextpool.prevpool = p.prevpool;
p.killme = true;
p.prevpool = null;
p.nextpool = null;
}
private void CleanQueues()
{
@ -156,6 +192,7 @@ extend Class SWWMHandler
while ( chips ) DeQueueChip(chips);
while ( blods ) DeQueueBlod(blods);
while ( meats ) DeQueueMeat(meats);
while ( pools ) DeQueuePool(pools);
}
private void RecheckQueues()
@ -168,6 +205,8 @@ extend Class SWWMHandler
DeQueueBlod(blods);
while ( meats && (meats_cnt > swwm_maxgibs) )
DeQueueMeat(meats);
while ( pools && (pools_cnt > swwm_maxpools) )
DeQueuePool(pools);
}
private void QueueMaintenance()
@ -192,9 +231,15 @@ extend Class SWWMHandler
while ( meats && (swwm_maxgibs >= 0) && (meats_cnt > swwm_maxgibs) )
DeQueueMeat(meats);
}
if ( swwm_maxpools != oldmaxpools )
{
while ( pools && (swwm_maxpools >= 0) && (pools_cnt > swwm_maxpools) )
DeQueuePool(pools);
}
oldmaxcasings = swwm_maxcasings;
oldmaxdebris = swwm_maxdebris;
oldmaxblood = swwm_maxblood;
oldmaxgibs = swwm_maxgibs;
oldmaxpools = swwm_maxpools;
}
}

View file

@ -81,7 +81,7 @@ extend Class Demolitionist
}
// part 2: check for stepping on a blood pool, make feet bloody
if ( !hnd ) hnd = SWWMHandler(EventHandler.Find('SWWMHandler'));
for ( mkBloodPool p=hnd.bloodpools; p; p=p.nextpool )
for ( mkBloodPool p=hnd.pools; p; p=p.nextpool )
{
// vertical distance fast check
if ( abs(checkpos.z-p.pos.z) > 8. )

View file

@ -893,21 +893,14 @@ Class mkBloodPool : SWWMNonInteractiveActor
double basesz, sz, accel;
Color stepcol;
mkBloodPool prevpool, nextpool;
bool bRaised; // dead body was revived, fade out faster
bool killme, bRaised;
Property BaseAccel : accel;
override void OnDestroy()
{
SWWMHandler.DeQueuePool(self);
Super.OnDestroy();
if ( prevpool )
{
prevpool.nextpool = nextpool;
if ( nextpool ) nextpool.prevpool = prevpool;
}
let hnd = SWWMHandler(EventHandler.Find('SWWMHandler'));
if ( !hnd || (hnd.bloodpools != self) ) return;
hnd.bloodpools = nextpool;
}
override void PostBeginPlay()
@ -918,13 +911,8 @@ Class mkBloodPool : SWWMNonInteractiveActor
basesz = scale.x;
sz = .01;
A_SetScale(sz);
A_QueueCorpse();
SWWMUtility.SetToSlope(self,FRandom[Blood](0,360));
let hnd = SWWMHandler(EventHandler.Find('SWWMHandler'));
if ( !hnd ) return;
nextpool = hnd.bloodpools;
hnd.bloodpools = self;
if ( nextpool ) nextpool.prevpool = self;
SWWMHandler.QueuePool(self);
}
override void Tick()
@ -939,12 +927,14 @@ Class mkBloodPool : SWWMNonInteractiveActor
if ( fz != pos.z ) SetOrigin((pos.x,pos.y,fz),true);
if ( (waterlevel > 0) || GetFloorTerrain().isliquid )
A_FadeOut();
if ( !master ) A_FadeOut(.01);
else if ( (master.Health > 0) || bRaised )
if ( killme ) A_FadeOut(.01);
if ( master && (master.Health > 0) )
{
bRaised = true;
A_FadeOut();
master = null;
}
if ( bRaised || !master )
A_FadeOut();
if ( accel <= 0. ) return;
sz += accel;
double fact = min(special1++/1200.,1.);