mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-13 23:26:07 +09:00
fix: bomb's item drop not obeying 'drop' itemproperty
This commit is contained in:
Binary file not shown.
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame
|
|||||||
|
|
||||||
import net.torvald.terrarum.BlockCodex
|
import net.torvald.terrarum.BlockCodex
|
||||||
import net.torvald.terrarum.ItemCodex
|
import net.torvald.terrarum.ItemCodex
|
||||||
|
import net.torvald.terrarum.OreCodex
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.ceilToInt
|
import net.torvald.terrarum.ceilToInt
|
||||||
import net.torvald.terrarum.gameworld.BlockLayerI16
|
import net.torvald.terrarum.gameworld.BlockLayerI16
|
||||||
@@ -239,18 +240,16 @@ object ExplosionManager {
|
|||||||
val lx = wx - (tx - CALC_RADIUS - 1)
|
val lx = wx - (tx - CALC_RADIUS - 1)
|
||||||
val ly = wy - (ty - CALC_RADIUS - 1)
|
val ly = wy - (ty - CALC_RADIUS - 1)
|
||||||
world.inflictTerrainDamage(wx, wy, mapBoomPow[lx, ly].blastToDmg().toDouble()).let { (tile, ore) ->
|
world.inflictTerrainDamage(wx, wy, mapBoomPow[lx, ly].blastToDmg().toDouble()).let { (tile, ore) ->
|
||||||
if (ore != null) {
|
if (ore != null || tile != null) {
|
||||||
// drop ore
|
// drop item
|
||||||
if (Math.random() < dropProbOre) {
|
val prob = if (ore != null) dropProbOre else dropProbNonOre
|
||||||
PickaxeCore.dropItem(ore, wx, wy)
|
if (Math.random() < prob) {
|
||||||
|
val drop = if (ore != null) OreCodex[ore].item else BlockCodex[tile].drop
|
||||||
|
PickaxeCore.dropItem(drop, wx, wy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tile != null) {
|
|
||||||
// drop tile
|
|
||||||
if (Math.random() < dropProbNonOre) {
|
|
||||||
PickaxeCore.dropItem(tile, wx, wy)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (tile != null) {
|
||||||
PickaxeCore.makeDust(tile, wx, wy, 8 + (5 * Math.random()).toInt())
|
PickaxeCore.makeDust(tile, wx, wy, 8 + (5 * Math.random()).toInt())
|
||||||
|
|
||||||
// drop random disc
|
// drop random disc
|
||||||
|
|||||||
@@ -105,10 +105,7 @@ object AxeCore {
|
|||||||
// tile busted
|
// tile busted
|
||||||
if (tileBroken != null) {
|
if (tileBroken != null) {
|
||||||
val drop = BlockCodex[tileBroken].drop
|
val drop = BlockCodex[tileBroken].drop
|
||||||
|
PickaxeCore.dropItem(drop, x, y)
|
||||||
if (drop.isNotBlank()) {
|
|
||||||
PickaxeCore.dropItem(drop, x, y)
|
|
||||||
}
|
|
||||||
|
|
||||||
PickaxeCore.makeDust(tile, x, y, 9)
|
PickaxeCore.makeDust(tile, x, y, 9)
|
||||||
PickaxeCore.makeNoise(actor, tile)
|
PickaxeCore.makeNoise(actor, tile)
|
||||||
|
|||||||
@@ -95,19 +95,19 @@ object PickaxeCore {
|
|||||||
x, y,
|
x, y,
|
||||||
Calculate.pickaxePower(actor, item?.material) * swingDmgToFrameDmg
|
Calculate.pickaxePower(actor, item?.material) * swingDmgToFrameDmg
|
||||||
).let { (tileBroken, oreBroken) ->
|
).let { (tileBroken, oreBroken) ->
|
||||||
|
|
||||||
// drop ore
|
// drop ore
|
||||||
if (oreBroken != null) {
|
if (oreBroken != null) {
|
||||||
if (Math.random() < dropProbability) {
|
if (Math.random() < dropProbability) {
|
||||||
val drop = OreCodex[oreBroken].item
|
val drop = OreCodex[oreBroken].item
|
||||||
if (drop.isNotBlank()) dropItem(drop, x, y)
|
dropItem(drop, x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// drop tile
|
// drop tile
|
||||||
else if (tileBroken != null) {
|
else if (tileBroken != null) {
|
||||||
if (Math.random() < dropProbability) {
|
if (Math.random() < dropProbability) {
|
||||||
val drop = BlockCodex[tileBroken].drop
|
val drop = BlockCodex[tileBroken].drop
|
||||||
if (drop.isNotBlank()) dropItem(drop, x, y)
|
dropItem(drop, x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// temperary: drop random disc
|
// temperary: drop random disc
|
||||||
@@ -139,6 +139,7 @@ object PickaxeCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun dropItem(item: ItemID, tx: Int, ty: Int) {
|
fun dropItem(item: ItemID, tx: Int, ty: Int) {
|
||||||
|
if (item.isBlank()) return
|
||||||
INGAME.queueActorAddition(
|
INGAME.queueActorAddition(
|
||||||
DroppedItem(
|
DroppedItem(
|
||||||
item,
|
item,
|
||||||
|
|||||||
@@ -100,9 +100,8 @@ object SledgehammerCore {
|
|||||||
if (tileBroken != null) {
|
if (tileBroken != null) {
|
||||||
if (Math.random() < dropProbability) {
|
if (Math.random() < dropProbability) {
|
||||||
val drop = BlockCodex[tileBroken].drop
|
val drop = BlockCodex[tileBroken].drop
|
||||||
if (drop.isNotBlank()) {
|
PickaxeCore.dropItem("wall@$drop", x, y)
|
||||||
PickaxeCore.dropItem("wall@$drop", x, y)
|
|
||||||
}
|
|
||||||
PickaxeCore.makeDust(wall, x, y, 9, WALL_OVERLAY_COLOUR)
|
PickaxeCore.makeDust(wall, x, y, 9, WALL_OVERLAY_COLOUR)
|
||||||
PickaxeCore.makeNoise(actor, wall)
|
PickaxeCore.makeNoise(actor, wall)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user