diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/PickaxeGeneric.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/PickaxeGeneric.kt index da462764a..788e6c211 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameitems/PickaxeGeneric.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/PickaxeGeneric.kt @@ -79,23 +79,31 @@ object PickaxeCore { } // filter passed, do the job - val swingDmgToFrameDmg = delta.toDouble() / actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!! + val actionInterval = actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!! + val swingDmgToFrameDmg = delta.toDouble() / actionInterval val (oreOnTile, _) = INGAME.world.getTileFromOre(x, y) INGAME.world.inflictTerrainDamage( x, y, Calculate.pickaxePower(actor, item?.material) * swingDmgToFrameDmg - )?.let { tileBroken -> - if (Math.random() < dropProbability) { - val drop = if (oreOnTile != Block.AIR) - OreCodex[oreOnTile].item - else - BlockCodex[tileBroken].drop + ).let { tileBroken -> + // tile busted + if (tileBroken != null) { + if (Math.random() < dropProbability) { + val drop = if (oreOnTile != Block.AIR) + OreCodex[oreOnTile].item + else + BlockCodex[tileBroken].drop - if (drop.isNotBlank()) { - INGAME.queueActorAddition(DroppedItem(drop, (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED)) + if (drop.isNotBlank()) { + INGAME.queueActorAddition(DroppedItem(drop, (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED)) + } + makeDust(tile, x, y, 9) } - makeDust(tile, x, y, 9) + } + // tile not busted + if (Math.random() < actionInterval) { + makeDust(tile, x, y, 1) } } diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/SledgehammerCore.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/SledgehammerCore.kt index 85bbf9942..c1a906e04 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameitems/SledgehammerCore.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/SledgehammerCore.kt @@ -88,18 +88,26 @@ object SledgehammerCore { } // filter passed, do the job - val swingDmgToFrameDmg = delta.toDouble() / actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!! + val actionInterval = actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!! + val swingDmgToFrameDmg = delta.toDouble() / actionInterval INGAME.world.inflictWallDamage( x, y, Calculate.pickaxePower(actor, item?.material) * swingDmgToFrameDmg - )?.let { tileBroken -> - if (Math.random() < dropProbability) { - val drop = BlockCodex[tileBroken].drop - if (drop.isNotBlank()) { - INGAME.queueActorAddition(DroppedItem("wall@$drop", (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED)) + ).let { tileBroken -> + // tile busted + if (tileBroken != null) { + if (Math.random() < dropProbability) { + val drop = BlockCodex[tileBroken].drop + if (drop.isNotBlank()) { + INGAME.queueActorAddition(DroppedItem("wall@$drop", (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED)) + } + PickaxeCore.makeDust(wall, x, y, 9, App.tileMaker.wallOverlayColour) } - PickaxeCore.makeDust(wall, x, y, 9, App.tileMaker.wallOverlayColour) + } + // tile not busted + if (Math.random() < actionInterval) { + PickaxeCore.makeDust(wall, x, y, 1, App.tileMaker.wallOverlayColour) } }