Skip to content

Commit e735e51

Browse files
committed
Fix #505, basilisks and cockatrice now require mirror shield, kurask and turoth now require their regular stuff
1 parent 23acc14 commit e735e51

File tree

3 files changed

+114
-31
lines changed

3 files changed

+114
-31
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package game.combat.npcHooks
2+
3+
import api.combat.npc.NpcCombatHandler.combat
4+
import api.predef.*
5+
import io.luna.Luna
6+
import io.luna.game.model.mob.Player
7+
import io.luna.util.RandomUtils
8+
9+
if (Luna.settings().skills().slayerEquipmentNeeded()) {
10+
11+
/**
12+
* Basilisk NPC ids.
13+
*/
14+
val BASILISK = setOf(1616, 1617)
15+
16+
/**
17+
* Cockatrice NPC ids.
18+
*/
19+
val COCKATRICE = setOf(1608, 1609)
20+
21+
/**
22+
* The mirror shield item id.
23+
*/
24+
val MIRROR_SHIELD = 4156
25+
26+
for (id in BASILISK + COCKATRICE) {
27+
/**
28+
* Handles basilisk and cockatrice attack effects.
29+
*
30+
* When a player is attacked without a mirror shield equipped, the NPC has a chance to apply stat drains to one
31+
* or more combat skills and notify the player that they have been weakened.
32+
*/
33+
combat(id) {
34+
attack {
35+
melee {
36+
if (other is Player && other.equipment.shield?.id != MIRROR_SHIELD && RandomUtils.random()) {
37+
if (RandomUtils.random()) {
38+
other.attack.adjustLevel(-rand(10, 20))
39+
}
40+
if (RandomUtils.random()) {
41+
other.strength.adjustLevel(-rand(10, 20))
42+
}
43+
if (RandomUtils.random()) {
44+
other.defence.adjustLevel(-rand(10, 20))
45+
}
46+
if (RandomUtils.random()) {
47+
other.ranged.adjustLevel(-rand(10, 20))
48+
}
49+
if (RandomUtils.random()) {
50+
other.magic.adjustLevel(-rand(10, 20))
51+
}
52+
other.sendMessage("You have been weakened.")
53+
}
54+
it
55+
}
56+
}
57+
}
58+
}
59+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package game.combat.npcHooks
2+
3+
import api.combat.npc.NpcCombatHandler.combat
4+
import api.predef.*
5+
import io.luna.Luna
6+
import io.luna.game.model.mob.Player
7+
import io.luna.game.model.mob.combat.AmmoType
8+
9+
if (Luna.settings().skills().slayerEquipmentNeeded()) {
10+
11+
/**
12+
* Turoth NPC ids.
13+
*/
14+
val TUROTH = setOf(1626, 1627, 1628, 1629, 1630, 1631, 1632)
15+
16+
/**
17+
* Kurask NPC ids.
18+
*/
19+
val KURASK = setOf(1608, 1609)
20+
21+
/**
22+
* The leaf-bladed spear item id.
23+
*/
24+
val LEAF_BLADED_SPEAR = 4158
25+
26+
/**
27+
* Determines whether the player is attacking with broad arrows from a ranged weapon.
28+
*
29+
* This is used as part of the Turoth and Kurask equipment restriction check.
30+
*
31+
* @param plr The attacking player.
32+
* @return `true` if the player is using a ranged weapon with broad arrows, otherwise `false`.
33+
*/
34+
fun usingBroadArrows(plr: Player): Boolean =
35+
// TODO Implement broad arrow data.
36+
plr.combat.ranged.ammo.type == AmmoType.BROAD_ARROW && plr.combat.weapon.isRanged
37+
38+
for (id in TUROTH + KURASK) {
39+
/**
40+
* Handles Turoth and Kurask combat restrictions.
41+
*
42+
* When slayer equipment restrictions are enabled, players must use either a leaf-bladed spear or broad arrows
43+
* from a ranged weapon to deal damage. Any other attack is negated.
44+
*/
45+
combat(id) {
46+
defend {
47+
if (other is Player && other.equipment.weapon?.id != LEAF_BLADED_SPEAR &&
48+
!usingBroadArrows(other)) {
49+
damage = null
50+
other.sendMessage("Your attack seems to have no effect...")
51+
}
52+
}
53+
}
54+
}
55+
}

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

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)