Skip to content

Commit 29adf01

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

File tree

1 file changed

+45
-0
lines changed
  • src/main/kotlin/game/game/combat/npcHooks

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package game.combat.npcHooks
2+
3+
import api.combat.npc.NpcCombatHandler.combat
4+
import api.predef.*
5+
import game.skill.cooking.cookFood.Food
6+
import io.luna.game.model.item.Item
7+
import io.luna.game.model.mob.Player
8+
import io.luna.util.RandomUtils
9+
import io.luna.util.Rational
10+
11+
/**
12+
* The chance that a piece of food will be spoiled and bonus damage applied.
13+
*/
14+
val ROT_FOOD_CHANCE = Rational(3, 10)
15+
16+
/**
17+
* The rotten food item.
18+
*/
19+
val ROTTEN_FOOD = Item(2959)
20+
21+
/**
22+
* The bonus damage range.
23+
*/
24+
val BONUS_DAMAGE_RANGE = 1..5
25+
26+
// A small chance to deal extra damage and spoil food upon attack.
27+
combat(1053, 3609, 3610, 3611) {
28+
29+
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
39+
}
40+
}
41+
}
42+
}
43+
default()
44+
}
45+
}

0 commit comments

Comments
 (0)