Implemented ::addxp command (admin), add xp to a skill
Implemented ::charge command (admin), get and set the charge of an item Implemented ::setslayertask command (admin), set the slayer task npc with optional quantity
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package content.data
|
||||
|
||||
import core.api.toIntArray
|
||||
import core.cache.def.impl.ItemDefinition
|
||||
import org.rs09.consts.Items
|
||||
|
||||
/**
|
||||
* Represents a distinct charged item, i.e. items with (#).
|
||||
* Not to be confused with items with internal charge, like degradation.
|
||||
* @author RiL
|
||||
*/
|
||||
enum class ChargedItem(val ids: IntArray) {
|
||||
AMULET_OF_GLORY((Items.AMULET_OF_GLORY4_1712 downTo Items.AMULET_OF_GLORY_1704 step 2).toIntArray()),
|
||||
RING_OF_DUELLING((Items.RING_OF_DUELLING8_2552..Items.RING_OF_DUELLING1_2566 step 2).toIntArray()),
|
||||
GAMES_NECKLACE((Items.GAMES_NECKLACE8_3853..Items.GAMES_NECKLACE1_3867 step 2).toIntArray()),
|
||||
BROODOO_SHIELDA((Items.BROODOO_SHIELD_10_6215..Items.BROODOO_SHIELD_6235 step 2).toIntArray()),
|
||||
BROODOO_SHIELDB((Items.BROODOO_SHIELD_10_6237..Items.BROODOO_SHIELD_6257 step 2).toIntArray()),
|
||||
BROODOO_SHIELDC((Items.BROODOO_SHIELD_10_6259..Items.BROODOO_SHIELD_6279 step 2).toIntArray()),
|
||||
ROD_OF_IVANDIS((Items.ROD_OF_IVANDIS10_7639..Items.ROD_OF_IVANDIS1_7648).toIntArray()),
|
||||
BLACK_MASK((Items.BLACK_MASK_10_8901..Items.BLACK_MASK_8921 step 2).toIntArray()),
|
||||
AMULET_OF_GLORYT((Items.AMULET_OF_GLORYT4_10354..Items.AMULET_OF_GLORYT_10362 step 2).toIntArray()),
|
||||
CASTLEWAR_BRACE((Items.CASTLEWAR_BRACE3_11079..Items.CASTLEWAR_BRACE1_11083 step 2).toIntArray()),
|
||||
FORINTHRY_BRACE((Items.FORINTHRY_BRACE5_11095..Items.FORINTHRY_BRACE1_11103 step 2).toIntArray()),
|
||||
SKILLS_NECKLACE((Items.SKILLS_NECKLACE4_11105..Items.SKILLS_NECKLACE_11113 step 2).toIntArray()),
|
||||
COMBAT_BRACELET((Items.COMBAT_BRACELET4_11118..Items.COMBAT_BRACELET_11126 step 2).toIntArray()),
|
||||
DIGSITE_PENDANT((Items.DIGSITE_PENDANT_5_11194 downTo Items.DIGSITE_PENDANT_1_11190).toIntArray()),
|
||||
VOID_SEAL((Items.VOID_SEAL8_11666..Items.VOID_SEAL1_11673).toIntArray()),
|
||||
AMULET_OF_FARMING((Items.AMULET_OF_FARMING8_12622 downTo Items.AMULET_OF_FARMING1_12608 step 2).toIntArray()),
|
||||
IVANDIS_FLAIL((Items.IVANDIS_FLAIL_30_13117..Items.IVANDIS_FLAIL_1_13146).toIntArray()),
|
||||
RING_OF_SLAYING((Items.RING_OF_SLAYING8_13281..Items.RING_OF_SLAYING1_13288).toIntArray()),
|
||||
RING_OF_WEALTH((Items.RING_OF_WEALTH4_14646 downTo Items.RING_OF_WEALTH_14638 step 2).toIntArray());
|
||||
|
||||
/**
|
||||
* Get the item id for a specific [charge].
|
||||
* If [charge] is outside the valid range, return the item id with the closest charge.
|
||||
*/
|
||||
fun forCharge(charge: Int): Int {
|
||||
return ids[maxCharge() - if (charge < 1) 1 + maxCharge() - ids.size else if (charge > maxCharge()) maxCharge() else charge]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max charge of this ChargedItem.
|
||||
*/
|
||||
fun maxCharge(): Int = maxCharges[ordinal]
|
||||
|
||||
companion object {
|
||||
private val CHARGE_REGEX = Regex("""\(\D?(\d+)\)""")
|
||||
private val idMap = HashMap<Int, ChargedItem>()
|
||||
private val maxCharges = IntArray(values().size)
|
||||
|
||||
init {
|
||||
values().forEach { chargedItem ->
|
||||
maxCharges[chargedItem.ordinal] = getMaxCharge(chargedItem)
|
||||
chargedItem.ids.forEach { idMap[it] = chargedItem }
|
||||
}
|
||||
}
|
||||
|
||||
private fun getMaxCharge(chargedItem: ChargedItem): Int {
|
||||
return CHARGE_REGEX.find(ItemDefinition.forId(chargedItem.ids.first()).name)!!.groups[1]!!.value.toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the item id is a charged item.
|
||||
*/
|
||||
fun contains(id: Int): Boolean = idMap.containsKey(id)
|
||||
|
||||
/**
|
||||
* Get the ChargedItem enum for an item id, or null if it's not a charged item.
|
||||
*/
|
||||
fun forId(id: Int): ChargedItem? = idMap[id]
|
||||
|
||||
/**
|
||||
* Get the charge value of an item id, or null if it's not a charged item.
|
||||
*/
|
||||
fun getCharge(id: Int): Int? {
|
||||
val chargedItem = forId(id) ?: return null
|
||||
return chargedItem.maxCharge() - chargedItem.ids.indexOf(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import core.game.interaction.IntType
|
||||
|
||||
class HatStand : InteractionListener {
|
||||
|
||||
val hats = ItemDefinition.getDefinitions().values.filter { it.getConfiguration("equipment_slot",0) == EquipmentSlot.HAT.ordinal }.map { it.id }.toIntArray()
|
||||
val hats = ItemDefinition.getDefinitions().values.filter { it.getConfiguration("equipment_slot",0) == EquipmentSlot.HEAD.ordinal }.map { it.id }.toIntArray()
|
||||
val hat_stand = 374
|
||||
|
||||
override fun defineListeners() {
|
||||
|
||||
@@ -112,7 +112,7 @@ class MiningListener : InteractionListener {
|
||||
chance = (chance / 1.5).toInt()
|
||||
altered = true
|
||||
}
|
||||
val necklace = getItemFromEquipment(player, EquipmentSlot.AMULET)
|
||||
val necklace = getItemFromEquipment(player, EquipmentSlot.NECK)
|
||||
if (necklace != null && necklace.id in 1705..1713) {
|
||||
chance = (chance / 1.5).toInt()
|
||||
altered = true
|
||||
|
||||
@@ -178,7 +178,7 @@ class MiningSkillPulse(private val player: Player, private val node: Node) : Pul
|
||||
chance = (chance / 1.5).toInt()
|
||||
altered = true
|
||||
}
|
||||
val necklace = getItemFromEquipment(player, EquipmentSlot.AMULET)
|
||||
val necklace = getItemFromEquipment(player, EquipmentSlot.NECK)
|
||||
if (necklace != null && necklace.id in 1705..1713) {
|
||||
chance = (chance / 1.5).toInt()
|
||||
altered = true
|
||||
|
||||
@@ -24,10 +24,10 @@ object SlayerEquipmentFlags {
|
||||
else if(hasItem(player, Items.NOSE_PEG_4168)) flags = 1
|
||||
else if(hasItem(player, Items.EARMUFFS_4166)) flags = flags or (1 shl 1)
|
||||
else if(hasItem(player, Items.FACE_MASK_4164)) flags = flags or (1 shl 2)
|
||||
else if((getItemFromEquipment(player, EquipmentSlot.HAT)?.id ?: 0) in blackMasks) flags = flags or (1 shl 3)
|
||||
else if((getItemFromEquipment(player, EquipmentSlot.HEAD)?.id ?: 0) in blackMasks) flags = flags or (1 shl 3)
|
||||
else if(hasItem(player, Items.SPINY_HELMET_4551)) flags = flags or (1 shl 4)
|
||||
|
||||
if((getItemFromEquipment(player, EquipmentSlot.AMULET)?.id ?: 0) == Items.WITCHWOOD_ICON_8923) flags = flags or (1 shl 7)
|
||||
if((getItemFromEquipment(player, EquipmentSlot.NECK)?.id ?: 0) == Items.WITCHWOOD_ICON_8923) flags = flags or (1 shl 7)
|
||||
if((getItemFromEquipment(player, EquipmentSlot.SHIELD)?.id ?: 0) == Items.MIRROR_SHIELD_4156) flags = flags or (1 shl 8)
|
||||
SlayerManager.getInstance(player).flags.equipmentFlags = flags
|
||||
}
|
||||
@@ -78,7 +78,7 @@ object SlayerEquipmentFlags {
|
||||
}
|
||||
|
||||
private fun hasItem(player: Player, id: Int): Boolean{
|
||||
return (getItemFromEquipment(player, EquipmentSlot.HAT)?.id ?: 0) == id
|
||||
return (getItemFromEquipment(player, EquipmentSlot.HEAD)?.id ?: 0) == id
|
||||
}
|
||||
|
||||
fun isSlayerEq(item: Int): Boolean{
|
||||
|
||||
@@ -158,7 +158,7 @@ class CastleWarsListeners : InteractionListener {
|
||||
|
||||
private fun capeOrHelmetError(player: Player): String? {
|
||||
val wornCape = getItemFromEquipment(player, EquipmentSlot.CAPE)?.id ?: -1
|
||||
val wornHelmet = getItemFromEquipment(player, EquipmentSlot.HAT)?.id ?: -1
|
||||
val wornHelmet = getItemFromEquipment(player, EquipmentSlot.HEAD)?.id ?: -1
|
||||
|
||||
if (wornCape != -1 || wornHelmet != -1) return "You can't wear hats, capes, or helms in the arena."
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user