Tweak golden shell drop chance math.

This commit is contained in:
Mari the Deer 2023-02-19 20:24:02 +01:00
commit 7b6f367bfa
2 changed files with 10 additions and 8 deletions

View file

@ -52,7 +52,7 @@ extend Class SWWMHandler
return false;
}
static bool ShouldSpawnGold()
static int ShouldSpawnGold()
{
int totalneeded = 0;
// check "free space" in player inventories
@ -71,7 +71,7 @@ extend Class SWWMHandler
if ( g.Owner ) continue;
totalneeded -= g.Amount;
}
return (totalneeded > 0);
return max(0,totalneeded);
}
override void WorldThingDied( WorldEvent e )
@ -89,12 +89,14 @@ extend Class SWWMHandler
let ti = ThinkerIterator.Create(e.Thing.GetClass());
while ( ti.Next() ) dropweight++;
int minchance = max(1,6-(e.Thing.GetSpawnHealth()/1000));
dropweight = max(minchance,dropweight/4);
dropweight = max(minchance,dropweight/2);
// make sure the gold shell is "worth spawning", too
if ( !Random[GoldDrop](0,dropweight) && ShouldSpawnGold() )
// (also, chance should be reduced as you acquire more shells)
int gchance = int(ceil(ShouldSpawnGold()/2.));
if ( !Random[GoldDrop](0,dropweight) && Random[GoldDrop](0,gchance) )
{
let g = Actor.Spawn("GoldShell",e.Thing.Vec3Offset(0,0,e.Thing.Height/2));
double ang = FRandom[SpareShells](0,360);
let g = Actor.Spawn("GoldShell",e.Thing.Vec3Offset(0,0,e.Thing.Height/2.));
double ang = FRandom[SpareShells](0.,360.);
g.vel.xy = Actor.AngleToVector(ang,FRandom[SpareShells](.4,.8));
g.vel.z = FRandom[SpareShells](2.,4.);
}