Added new field to item configs for overriding alchemy flag

Fixed alchemy for Fremennik items
This commit is contained in:
Trident101
2023-05-27 12:57:04 +00:00
committed by Ryan
parent 6dcec3c42f
commit c3c836de4d
4 changed files with 33 additions and 6 deletions
@@ -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!")
+15 -4
View File
@@ -276,7 +276,7 @@ public class ItemDefinition extends Definition<Item> {
}
if(itemId == 14958)
def.setStackable(true);
ItemDefinition.getDefinitions().put(itemId, def);
}
ItemDefinition.defineTemplates();
@@ -717,7 +717,7 @@ public class ItemDefinition extends Definition<Item> {
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<Item> {
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<Item> {
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<Item> {
public void setItemType(int itemType) {
this.itemType = itemType;
}
/**
* Gets the femaleWornModelId3 value.
* @return The femaleWornModelId3.
@@ -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())