Skip to content

Commit 32df62f

Browse files
committed
rockslug.kts combat script
1 parent b70f8ff commit 32df62f

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package game.combat.npcHooks
2+
3+
import api.combat.npc.NpcCombatHandler.combat
4+
import io.luna.game.action.impl.LockedAction
5+
import io.luna.game.model.mob.Player
6+
import io.luna.game.model.mob.block.Animation
7+
import io.luna.game.model.mob.block.Animation.AnimationPriority
8+
import io.luna.game.model.mob.block.Graphic
9+
import io.luna.game.model.mob.combat.damage.CombatDamageRequest
10+
11+
/**
12+
* The lowest health a rockslug can be reduced to through normal damage.
13+
*/
14+
val HITPOINTS_THRESHOLD = 5
15+
16+
/**
17+
* The bag of salt item id.
18+
*/
19+
val BAG_OF_SALT = 4161
20+
21+
/**
22+
* The animation played when a player uses salt on a weakened rockslug.
23+
*/
24+
val SALT_ANIMATION = Animation(1574)
25+
26+
/**
27+
* The graphic displayed when salt is used on a weakened rockslug.
28+
*/
29+
val SALT_GRAPHIC = Graphic(327, 0, 0)
30+
31+
/*
32+
* Handles rockslug finishing behaviour.
33+
*
34+
* When an incoming hit would reduce a rockslug to or below the finishing threshold, the normal damage is cancelled and
35+
* the slug is left at 1 hitpoint. If the attacker is a player carrying a bag of salt, the player performs the
36+
* salting sequence and the slug is killed shortly after.
37+
*
38+
* If the player does not have salt, they will always hit 0.
39+
*/
40+
combat(1622, 1623) {
41+
defend {
42+
val damageAmount = damage?.rawAmount ?: 0
43+
if (other is Player && npc.health - damageAmount <= HITPOINTS_THRESHOLD) {
44+
45+
if (other.inventory.remove(BAG_OF_SALT)) {
46+
damage = null
47+
npc.combat.isDisabled = true
48+
npc.walking.isLocked = true
49+
npc.health = 1
50+
other.combat.target = null
51+
other.submitAction(object : LockedAction(other, false, 1) {
52+
override fun run(): Boolean {
53+
if (executions == 0) {
54+
other.animation(SALT_ANIMATION)
55+
npc.graphic(SALT_GRAPHIC)
56+
other.sendMessage("You pour some salt on the Rockslug.")
57+
npc.animation(Animation(npc.combatDef().deathAnimation, AnimationPriority.HIGH))
58+
} else if (executions == 1) {
59+
npc.health = 0
60+
return true
61+
}
62+
return false
63+
}
64+
})
65+
} else {
66+
damage = CombatDamageRequest.zero(other, npc).resolve()
67+
}
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)