From aaa9bcd806027e53a21eff75b82d1e305e8e40eb Mon Sep 17 00:00:00 2001 From: Marisa the Magician Date: Sun, 19 Feb 2023 20:24:02 +0100 Subject: [PATCH] Tweak golden shell drop chance math. --- language.version | 4 ++-- zscript/handler/swwm_handler_worldthings.zsc | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/language.version b/language.version index 19b94e10b..6ef889971 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r749 \cu(Sat 18 Feb 12:00:36 CET 2023)\c-"; -SWWM_SHORTVER="\cw1.3pre r749 \cu(2023-02-18 12:00:36)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r750 \cu(Sun 19 Feb 20:26:45 CET 2023)\c-"; +SWWM_SHORTVER="\cw1.3pre r750 \cu(2023-02-19 20:26:45)\c-"; diff --git a/zscript/handler/swwm_handler_worldthings.zsc b/zscript/handler/swwm_handler_worldthings.zsc index f3427ec1b..aba0d4652 100644 --- a/zscript/handler/swwm_handler_worldthings.zsc +++ b/zscript/handler/swwm_handler_worldthings.zsc @@ -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.); }