Skip to content

Commit 601e839

Browse files
committed
Combat script for ghasts!
1 parent 29adf01 commit 601e839

File tree

1 file changed

+16
-11
lines changed
  • src/main/kotlin/game/game/combat/npcHooks

1 file changed

+16
-11
lines changed

src/main/kotlin/game/game/combat/npcHooks/ghast.kts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,26 @@ val BONUS_DAMAGE_RANGE = 1..5
2525

2626
// A small chance to deal extra damage and spoil food upon attack.
2727
combat(1053, 3609, 3610, 3611) {
28-
28+
// Determine how the ghast will attack.
2929
attack {
30-
if (RandomUtils.roll(ROT_FOOD_CHANCE)) {
31-
// Not 100% faithful to old rs, but good enough?
32-
other.damage(rand(BONUS_DAMAGE_RANGE))
33-
if (other is Player) {
34-
for ((index, item) in other.inventory.withIndex()) {
35-
if (item != null && Food.COOKED_TO_FOOD.containsKey(item.id)) {
36-
other.inventory[index] = ROTTEN_FOOD
37-
other.sendMessage("Some of your food goes bad!")
38-
break
30+
// Use a melee attack.
31+
melee {
32+
// Right when the attack launches, try to spoil some enemy food and deal bonus damage.
33+
if (RandomUtils.roll(ROT_FOOD_CHANCE)) {
34+
// Not 100% faithful to old rs, but good enough?
35+
other.damage(rand(BONUS_DAMAGE_RANGE))
36+
if (other is Player) {
37+
println(other)
38+
for ((index, item) in other.inventory.withIndex()) {
39+
if (item != null && Food.COOKED_TO_FOOD.containsKey(item.id)) {
40+
other.inventory[index] = ROTTEN_FOOD
41+
other.sendMessage("Some of your food goes bad!")
42+
break
43+
}
3944
}
4045
}
4146
}
47+
it // Damage is unchanged.
4248
}
43-
default()
4449
}
4550
}

0 commit comments

Comments
 (0)