From 943f9d6c035310ffe1548b9e810431148c299025 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 14 Jul 2021 00:17:47 -0400 Subject: [PATCH] LITH explodes when overcharged, update charge graphics --- src/simulation/elements/LITH.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/simulation/elements/LITH.cpp b/src/simulation/elements/LITH.cpp index 0dfdb2580..6afc69536 100644 --- a/src/simulation/elements/LITH.cpp +++ b/src/simulation/elements/LITH.cpp @@ -168,8 +168,9 @@ static int update(UPDATE_FUNC_ARGS) sim->part_change_type(i, x, y, PT_PLSM); sim->part_change_type(ID(neighborData), x + rx, y + ry, PT_PLSM); sim->pv[y / CELL][x / CELL] += 4.0; + return 0; } - return 0; + break; } } } @@ -199,6 +200,9 @@ static int update(UPDATE_FUNC_ARGS) Particle &neighbor = parts[ID(neighborData)]; int &neighborStoredEnergy = neighbor.ctype; + // Transfer overcharge explosion status to nearby LITH + if (burnTimer < 1000 && storedEnergy > 90 && neighbor.life > 1000) + burnTimer = 1024; if (storedEnergy > neighborStoredEnergy) { int transfer = storedEnergy - neighborStoredEnergy; @@ -209,17 +213,22 @@ static int update(UPDATE_FUNC_ARGS) } } } + + // Overcharged - begin explosion + if (burnTimer < 1000 && storedEnergy >= 100) + burnTimer = 1024; if (burnTimer == 1000) { + burnTimer = 0; sim->part_change_type(i, x, y, PT_LAVA); if (carbonationFactor < 3) { - self.temp = 500.f; + self.temp = 500.f + storedEnergy * 10; self.ctype = PT_LITH; } else { - self.temp = 2000.f; + self.temp = 2000.f + storedEnergy * 10; self.ctype = PT_GLAS; } } @@ -228,6 +237,7 @@ static int update(UPDATE_FUNC_ARGS) static int graphics(GRAPHICS_FUNC_ARGS) { + // Exploding lith if (cpart->life >= 1000) { int colour = 0xFFA040; @@ -236,12 +246,13 @@ static int graphics(GRAPHICS_FUNC_ARGS) *colb = PIXB(colour); *pixel_mode |= PMODE_FLARE | PMODE_GLOW; } - else if (cpart->ctype && RNG::Ref().chance(cpart->ctype, 100)) + // Charged lith + else if (cpart->ctype > 0) { - int colour = 0x50A0FF; - *colr = PIXR(colour); - *colg = PIXG(colour); - *colb = PIXB(colour); + int mult = RNG::Ref().between(cpart->ctype / 3, cpart->ctype) / 15; + mult = std::min(6, mult); + *colr -= 30 * mult; + *colb += 20 * mult; *pixel_mode |= PMODE_FLARE | PMODE_GLOW; } return 0;