Skip to content

Commit

Permalink
Implemented earthquake bombs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Jan 22, 2024
1 parent d272d2f commit 553dc31
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 6 deletions.
7 changes: 4 additions & 3 deletions simalq/tile/__init__.hy
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
(.insert (at pos) 0 @)
(object.__setattr__ @ "pos" pos))

(defmeth replace [new-stem]
(setv t ((get Tile.types new-stem) :pos @pos))
(defmeth replace [new-stem #** kwargs]
(setv t ((get Tile.types new-stem) :pos @pos #** kwargs))
(setv (get (at @pos) (.index (at @pos) @)) t)
(object.__setattr__ @ "pos" None)
(@hook-pos-set t.pos None))
Expand Down Expand Up @@ -224,6 +224,7 @@
(un! k))))
~@(gfor
[k v] (.items (dict :mapsym mapsym #** kwargs))
:setv k (un! k)
; Treat `(meth …)` and `(property-meth …)` forms specially.
(cond
(and (isinstance v hy.models.Expression) (= (get v 0) 'meth))
Expand All @@ -233,7 +234,7 @@
`(hy.R.simalq/macros.defmeth [property] ~(hy.models.Symbol k)
~@(cut v 1 None))
True
`(setv ~(hy.models.Symbol (un! k)) ~v)))))
`(setv ~(hy.models.Symbol k) ~v)))))


(defn tiletype [cls]
Expand Down
41 changes: 41 additions & 0 deletions simalq/tile/item.hy
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(require
hyrule [branch]
simalq.macros [unless defmeth]
simalq.tile [deftile])
(import
Expand Down Expand Up @@ -444,6 +445,46 @@
:flavor "Heavy ordnance. Kills monsters dead, with a bomb pattern that would put a feather in Colonel Cathcart's cap.\n\n \"Kaboom?\"\n \"Yes, Rico. Kaboom.\"")
(deftile "0 " "an earthquake bomb" Usable
:color 'dark-orange
:iq-ix 157
:acquirement-points 200
:!quake-damage-monster 3
:!quake-damage-wall 2
:!new-cracked-wall-starting-hp 4
:!use-burst-size 2
:!shot-burst-size 1
:!bomb-burst (meth [target size]
(for [
p (burst-damage target :damage-type DamageType.Fire
:amount (* [@quake-damage-monster] (+ size 1))
:color 'dark-orange)
tile (list (at p))]
; Contra IQ, we leave empty floor alone and don't create holes.
(branch (in tile.stem it)
["wall" "trapped wall"]
(.replace tile "cracked wall" :hp @new-cracked-wall-starting-hp)
["cracked wall"]
(.damage tile @quake-damage-wall None)
["breakable wall (meridional)" "breakable wall (zonal)" "fading wall"]
(.rm-from-map tile)
["pillar"]
(.replace tile "broken pillar"))))
:use (meth [target]
(doc f"Explodes in a size-{@use-burst-size} burst that does {@quake-damage-monster} fire damage to monsters and {@quake-damage-wall} damage to cracked walls. Furthermore, the blast turns normal walls and trapped walls into cracked walls with {@new-cracked-wall-starting-hp} HP, instantly destroys breakable walls and fading walls, and breaks pillars.")
(@bomb-burst target @use-burst-size))
:hook-player-shot (meth []
(doc f"As when used, but with a smaller size-{@shot-burst-size} burst.")
(@bomb-burst @pos @shot-burst-size)
(@rm-from-map))
:flavor "Magic and technology have combined into an explosive that can make the earth itself tremble in a limited area. The methodology was originally developed as an alternative to fracking, but it proved more useful in military applications.\n\n You were too tricky for your own good, Thanos!")
(defclass Artifact [Item]
(setv
color-bg 'magenta)
Expand Down
1 change: 0 additions & 1 deletion simalq/tile/unimplemented.hy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
[151 "passwall_amulet"]
[152 "random_gate"]
[154 "wand_of_flame"]
[157 "earthquake_bomb"]
[158 "ring_of_protection"]
[159 "amulet_of_poisonous_touch"]
[163 "archmage"]
Expand Down
8 changes: 6 additions & 2 deletions simalq/util.hy
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@
1]`, which means that 3 damage is dealt at the center, 2 damage is
dealt at distance 1 from the center, and so on. But note that this
damage is only dealt to non-player tiles. The player gets the
separate number `player-amount`, regardless of distance."
separate number `player-amount`, regardless of distance.
Return the result from `burst`."

(import
simalq.geometry [burst at dist]
Expand All @@ -172,4 +174,6 @@
(for [p b tile (at p) :if (isinstance tile Damageable)]
(.damage tile
(if (is tile G.player) player-amount (get amount (dist center p)))
damage-type)))
damage-type))

b)
25 changes: 25 additions & 0 deletions tests/test_item.hy
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,31 @@
(check "super-bomb" 'use 3 3 2 2 1 1 0))


(defn test-earthquake-bomb []
(init [
:map "
██| #2█1
↑↓#1←→.
@ ╷ o ."
:map-marks {
"o " ["orc" :hp 10]
"#1" ["cracked wall" :hp 10]
"#2" ["cracked wall" :hp 2]
"█1" "trapped wall"}])

; An earthquake bomb does 3 damage to monsters and 2 to cracked
; walls.
(use-item "earthquake bomb" 1 1)
(assert-textmap :map-marks {"##" "cracked wall"} :text "
##╷ . ##
. ##. .
@ ╷ o .")
(assert-hp [2 0] 7)
(assert-hp [1 1] 8)
(assert-hp [0 2] 4)
(assert-hp [3 2] 4))


(defn test-artifact-weapon []

; The sword artifact increases melee damage to 3. Multiple copies
Expand Down

0 comments on commit 553dc31

Please sign in to comment.