Bug fixes for getting stuck in Creature of Fenkenstrain

This commit is contained in:
Oven Bread
2023-11-12 13:43:26 +00:00
committed by Ryan
parent b2eb9cfdc9
commit 26245dfb10
2 changed files with 16 additions and 14 deletions
@@ -21,9 +21,9 @@ class CreatureOfFenkenstrainListeners : InteractionListener {
companion object { companion object {
private val itemToAttribute = hashMapOf( private val itemToAttribute = hashMapOf(
Items.ARMS_4195 to CreatureOfFenkenstrain.attributeArms, Items.ARMS_4195 to CreatureOfFenkenstrain.attributeArms,
Items.LEGS_4196 to CreatureOfFenkenstrain.attributeArms, Items.LEGS_4196 to CreatureOfFenkenstrain.attributeLegs,
Items.TORSO_4194 to CreatureOfFenkenstrain.attributeArms, Items.TORSO_4194 to CreatureOfFenkenstrain.attributeTorso,
Items.DECAPITATED_HEAD_4197 to CreatureOfFenkenstrain.attributeArms Items.DECAPITATED_HEAD_4197 to CreatureOfFenkenstrain.attributeHead
) )
enum class Graves(val location: Location, val graveName: String, val unearthText: String, val unearthItem: Int?) { enum class Graves(val location: Location, val graveName: String, val unearthText: String, val unearthItem: Int?) {
@@ -106,8 +106,8 @@ class CreatureOfFenkenstrainListeners : InteractionListener {
override fun pulse(): Boolean { override fun pulse(): Boolean {
player.animate(Animation(-1)) player.animate(Animation(-1))
if(grave?.unearthItem != null && if(grave?.unearthItem != null &&
!hasAnItem(player, grave.unearthItem).exists() && !hasAnItem(player, grave.unearthItem).exists()
!getAttribute(player, itemToAttribute[grave.unearthItem] ?: "", false)) { /* && !getAttribute(player, itemToAttribute[grave.unearthItem] ?: "", false) */) {
sendItemDialogue(player, grave.unearthItem, grave.unearthText) sendItemDialogue(player, grave.unearthItem, grave.unearthText)
addItemOrDrop(player, grave.unearthItem) addItemOrDrop(player, grave.unearthItem)
} else { } else {
@@ -26,6 +26,12 @@ class DrFenkenstrainDialogue (player: Player? = null) : DialoguePlugin(player) {
class DrFenkenstrainDialogueFile : DialogueBuilderFile() { class DrFenkenstrainDialogueFile : DialogueBuilderFile() {
companion object { companion object {
private fun allPartsSubmitted(player: Player): Boolean {
return getAttribute(player, CreatureOfFenkenstrain.attributeArms, false) &&
getAttribute(player, CreatureOfFenkenstrain.attributeLegs, false) &&
getAttribute(player, CreatureOfFenkenstrain.attributeTorso, false) &&
getAttribute(player, CreatureOfFenkenstrain.attributeHead, false)
}
private fun reqArms(player: Player): Boolean { private fun reqArms(player: Player): Boolean {
return !getAttribute(player, CreatureOfFenkenstrain.attributeArms, false) && inInventory(player, Items.ARMS_4195) return !getAttribute(player, CreatureOfFenkenstrain.attributeArms, false) && inInventory(player, Items.ARMS_4195)
} }
@@ -47,9 +53,8 @@ class DrFenkenstrainDialogueFile : DialogueBuilderFile() {
.goto(returnJoin) .goto(returnJoin)
branch.onValue(1) branch.onValue(1)
.betweenStage { _, player, _, _ -> .betweenStage { _, player, _, _ ->
if (removeItem(player, item)) { setAttribute(player, attributeToSet, true)
setAttribute(player, attributeToSet, true) removeItem(player, item)
}
} }
.npcl(successMsg) .npcl(successMsg)
.goto(returnJoin) .goto(returnJoin)
@@ -131,10 +136,10 @@ class DrFenkenstrainDialogueFile : DialogueBuilderFile() {
.options().let { optionBuilder -> .options().let { optionBuilder ->
val continuePath = b.placeholder() val continuePath = b.placeholder()
optionBuilder.optionIf("I have some body parts for you.") { player -> return@optionIf reqArms(player) || reqLegs(player) || reqTorso(player) || reqHead(player) } optionBuilder.optionIf("I have some body parts for you.") { player -> return@optionIf allPartsSubmitted(player) || reqArms(player) || reqLegs(player) || reqTorso(player) || reqHead(player) }
.playerl("I have some body parts for you.") .playerl("I have some body parts for you.")
.goto(continuePath) // Continue down below. .goto(continuePath) // Continue down below.
optionBuilder.optionIf("Do you know where I could find body parts?") { player -> return@optionIf !(reqArms(player) || reqLegs(player) || reqTorso(player) || reqHead(player)) } optionBuilder.optionIf("Do you know where I could find body parts?") { player -> return@optionIf !(allPartsSubmitted(player) || reqArms(player) || reqLegs(player) || reqTorso(player) || reqHead(player)) }
.playerl("Do you know where I could find body parts?") .playerl("Do you know where I could find body parts?")
.npcl("The soil of Morytania is unique in its ability to preserve the bodies of the dead, which is one reason why I have chosen to carry out my experiments here.") .npcl("The soil of Morytania is unique in its ability to preserve the bodies of the dead, which is one reason why I have chosen to carry out my experiments here.")
.npcl("I recommend digging up some graves in the local area. To the south-east you will find the Haunted Woods; I believe there are many graves there.") .npcl("I recommend digging up some graves in the local area. To the south-east you will find the Haunted Woods; I believe there are many graves there.")
@@ -168,10 +173,7 @@ class DrFenkenstrainDialogueFile : DialogueBuilderFile() {
// Dialogue path to look for head. // Dialogue path to look for head.
.let{ builder -> return@let hasPart(builder, Item(Items.DECAPITATED_HEAD_4198, 1), CreatureOfFenkenstrain.attributeHead, "Fantastic, you've brought me a head.") } .let{ builder -> return@let hasPart(builder, Item(Items.DECAPITATED_HEAD_4198, 1), CreatureOfFenkenstrain.attributeHead, "Fantastic, you've brought me a head.") }
.branch { player -> .branch { player ->
return@branch if (getAttribute(player, CreatureOfFenkenstrain.attributeHead, false) && return@branch if (allPartsSubmitted(player)) { 1 } else { 0 }
getAttribute(player, CreatureOfFenkenstrain.attributeLegs, false) &&
getAttribute(player, CreatureOfFenkenstrain.attributeTorso, false) &&
getAttribute(player, CreatureOfFenkenstrain.attributeHead, false)) { 1 } else { 0 }
}.let{ branch -> }.let{ branch ->
// Failure branch // Failure branch
branch.onValue(0) branch.onValue(0)