From f9d68ef17129948afd01850cc04d5a8c9e549f96 Mon Sep 17 00:00:00 2001 From: thirdmadman Date: Sat, 7 Oct 2023 14:33:04 +0200 Subject: [PATCH] feat: correct smoke dissolve time --- src/app/data/UnitTypes.ts | 6 +++--- src/app/engine/PhysicEngine.ts | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/data/UnitTypes.ts b/src/app/data/UnitTypes.ts index 287dba6..7ca0235 100644 --- a/src/app/data/UnitTypes.ts +++ b/src/app/data/UnitTypes.ts @@ -181,14 +181,14 @@ export const UnitTypesArray = [ unitIsFlammable: false, unitDefaultFlameSustainability: 1, unitDefaultFireHP: 0, - unitDefaultHealth: 10, + unitDefaultHealth: 100, unitDurability: 0, unitDensity: 0.00061, unitDefaultColor: { minRandomColor: 0x0a, - maxRandomColor: 0x52, + maxRandomColor: 0x10, colorShiftNumbers: 0xfff, - baseColor: 0x818181 + 0x99000000, + baseColor: 0x818181 + 0x77000000, }, unitTransformations: { toFreeze: null, diff --git a/src/app/engine/PhysicEngine.ts b/src/app/engine/PhysicEngine.ts index 63c434d..08de750 100644 --- a/src/app/engine/PhysicEngine.ts +++ b/src/app/engine/PhysicEngine.ts @@ -117,7 +117,12 @@ export class PhysicEngine { const isToDestroy = currentWorld[x][y]?.unitTypeName === 'gray-smoke' && currentWorld[x][y + 1]?.getUnitType().unitIsStatic; - if (isToDestroy) currentWorld[x][y]!.unitState.unitHealth -= 1; + if (isToDestroy) { + const random = getRandomInt(0, currentWorld[x][y]?.getUnitType().unitDefaultHealth || 1); + if (random >= (currentWorld[x][y]?.unitState?.unitHealth || 1)) { + currentWorld[x][y]!.unitState.unitHealth -= 1; + } + } if (isUpperEmpty) { replaceUnit(x, y, x, y + 1);