From c3c836de4d55f21d3aac47e58b856ab8b286a2f3 Mon Sep 17 00:00:00 2001 From: Trident101 Date: Sat, 27 May 2023 12:57:04 +0000 Subject: [PATCH] Added new field to item configs for overriding alchemy flag Fixed alchemy for Fremennik items --- Server/data/configs/item_configs.json | 10 ++++++++++ .../skill/magic/modern/ModernListeners.kt | 4 ++-- .../core/cache/def/impl/ItemDefinition.java | 19 +++++++++++++++---- .../game/system/config/ItemConfigParser.kt | 6 ++++++ 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/Server/data/configs/item_configs.json b/Server/data/configs/item_configs.json index e5db63a46..b7e93f8e4 100644 --- a/Server/data/configs/item_configs.json +++ b/Server/data/configs/item_configs.json @@ -35379,6 +35379,7 @@ "durability": null, "name": "Sticky red goop", "tradeable": "true", + "alchemizable": "true", "archery_ticket_price": "0", "id": "3747" }, @@ -35388,6 +35389,7 @@ "durability": null, "name": "Fremennik helm", "weight": "2.7", + "alchemizable": "true", "archery_ticket_price": "0", "id": "3748", "absorb": "1,0,2", @@ -35512,6 +35514,7 @@ "durability": null, "name": "Fremennik blade", "weight": "1.8", + "alchemizable": "true", "archery_ticket_price": "0", "attack_speed": "4", "weapon_interface": "6", @@ -35526,6 +35529,7 @@ "name": "Fremennik shield", "destroy": "true", "weight": "2.2", + "alchemizable": "true", "archery_ticket_price": "0", "id": "3758", "bonuses": "0,0,0,-8,-2,27,31,29,-1,29,30,0,0,0,0", @@ -38237,6 +38241,7 @@ "durability": null, "name": "Arms", "weight": "2", + "alchemizable": "true", "archery_ticket_price": "0", "id": "4195" }, @@ -38244,6 +38249,7 @@ "examine": "A pair of lifeless, rotting legs.", "durability": null, "name": "Legs", + "alchemizable": "true", "archery_ticket_price": "0", "id": "4196" }, @@ -38252,6 +38258,7 @@ "durability": null, "name": "Decapitated head", "weight": "3", + "alchemizable": "true", "archery_ticket_price": "0", "id": "4197" }, @@ -38260,6 +38267,7 @@ "durability": null, "name": "Decapitated head", "weight": "3", + "alchemizable": "true", "archery_ticket_price": "0", "id": "4198" }, @@ -38268,6 +38276,7 @@ "examine": "A pickled brain, submerged inside a jar of vinegar.", "durability": null, "name": "Pickled brain", + "alchemizable": "true", "archery_ticket_price": "0", "id": "4199" }, @@ -92708,6 +92717,7 @@ { "durability": null, "name": "A jester stick", + "alchemizable": "true", "archery_ticket_price": "0", "id": "10840", "bonuses": "0,0,0,0,0,0,0,0,5,-5,0,0,0,0,0", diff --git a/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt b/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt index a6e6c563d..30d40ad92 100644 --- a/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt +++ b/Server/src/main/content/global/skill/magic/modern/ModernListeners.kt @@ -221,9 +221,9 @@ class ModernListeners : SpellListener("modern"){ setDelay(player,false) } - public fun alchemize(player: Player, item: Item, high: Boolean) : Boolean { + public fun alchemize(player: Player, item: Item, high: Boolean) : Boolean { if(item.name == "Coins") player.sendMessage("You can't alchemize something that's already gold!").also { return false } - if(!item.definition.isTradeable) player.sendMessage("You can't cast this spell on something like that.").also { return false } + if((!item.definition.isTradeable) && (!item.definition.isAlchemizable)) player.sendMessage("You can't cast this spell on something like that.").also { return false } if(player.zoneMonitor.isInZone("Alchemists' Playground")){ player.sendMessage("You can only alch items from the cupboards!") diff --git a/Server/src/main/core/cache/def/impl/ItemDefinition.java b/Server/src/main/core/cache/def/impl/ItemDefinition.java index 1c1d72e57..8588d8527 100644 --- a/Server/src/main/core/cache/def/impl/ItemDefinition.java +++ b/Server/src/main/core/cache/def/impl/ItemDefinition.java @@ -276,7 +276,7 @@ public class ItemDefinition extends Definition { } if(itemId == 14958) def.setStackable(true); - + ItemDefinition.getDefinitions().put(itemId, def); } ItemDefinition.defineTemplates(); @@ -717,7 +717,7 @@ public class ItemDefinition extends Definition { Integer level = requirements.get(skillId); return level == null ? 0 : level; } - + /** * Gets the wielding animation id (render animation id). * @return The wield animation id. @@ -1386,6 +1386,17 @@ public class ItemDefinition extends Definition { return getConfiguration(ItemConfigParser.LOW_ALCHEMY, (int)Math.rint(value * 0.4)); } + /** + * Checks if the item is alchemizable. + * @return {@code True} if so. + */ + public boolean isAlchemizable() { + if (!getConfiguration(ItemConfigParser.ALCHEMIZABLE, false)) { + return false; + } + return true; + } + /** * Checks if the item is tradeable. * @return {@code True} if so. @@ -1547,7 +1558,7 @@ public class ItemDefinition extends Definition { player.getPacketDispatch().sendString(BONUS_NAMES[index++] + bonusValue, 667, i); } player.getPacketDispatch().sendString("Attack bonus", 667, 34); - DecimalFormat dec = new DecimalFormat("#.#"); + DecimalFormat dec = new DecimalFormat("#.#"); player.getPacketDispatch().sendString(dec.format(player.getSettings().getWeight())+" kg", 667, 32); } @@ -1621,7 +1632,7 @@ public class ItemDefinition extends Definition { public void setItemType(int itemType) { this.itemType = itemType; } - + /** * Gets the femaleWornModelId3 value. * @return The femaleWornModelId3. diff --git a/Server/src/main/core/game/system/config/ItemConfigParser.kt b/Server/src/main/core/game/system/config/ItemConfigParser.kt index a6bbb7430..39645961d 100644 --- a/Server/src/main/core/game/system/config/ItemConfigParser.kt +++ b/Server/src/main/core/game/system/config/ItemConfigParser.kt @@ -40,6 +40,11 @@ class ItemConfigParser { */ const val TWO_HANDED = "two_handed" + /** + * The alchemisable configuration key. + */ + const val ALCHEMIZABLE = "alchemizable" + /** * The high-alchemy price item configuration key. */ @@ -268,6 +273,7 @@ class ItemConfigParser { "destroy", "lendable", "tradeable" -> configs.put(it.key.toString(),it.value.toString().toBoolean()) + "alchemizable", -> configs.put(it.key.toString(),it.value.toString().toBoolean()) //doubles "weight" -> configs.put(it.key.toString(),it.value.toString().toDouble())