Swap ammo mould over to ContentAPI

This commit is contained in:
ceikry 2021-12-31 09:51:49 -06:00
parent 46d0406581
commit b7f0c64f95
2 changed files with 29 additions and 21 deletions

View file

@ -1265,6 +1265,13 @@ fun setQuestStage(player: Player, quest: String, stage: Int) {
player.questRepository.setStage(QuestRepository.getQuests()[quest]!!, stage)
}
/**
* Check if a quest is complete
*/
fun isQuestComplete(player: Player, quest: String): Boolean {
return player.questRepository.getStage(quest) == 100
}
/**
* Gets a scenery definition from the given ID
* @param id the ID of the scenery to get the definition for.

View file

@ -1,5 +1,6 @@
package rs09.game.interaction.item.withobject
import api.*
import core.game.content.quest.members.dwarfcannon.DwarfCannon
import core.game.node.Node
import core.game.node.entity.player.Player
@ -13,20 +14,21 @@ import rs09.game.interaction.InteractionListener
class AmmoMouldOnFurnace : InteractionListener(){
private val furnaces = intArrayOf(4304, 6189, 11010, 11666, 12100, 12809, 18497, 26814, 30021, 30510, 36956, 37651) // abstract when smelting converted to kotlin
val levelRequirement = 35
private val levelRequirement = 35
private fun cannonBallOnUseWithHandler(player: Player, used: Node, with: Node): Boolean {
player.faceLocation(with.centerLocation)
if(!player.questRepository.isComplete(DwarfCannon.NAME)) {
player.dialogueInterpreter.sendDialogue("You need to complete the ${DwarfCannon.NAME} quest in order to do this.")
face(player, with.centerLocation)
if(isQuestComplete(player, DwarfCannon.NAME)) {
sendDialogue(player, "You need to complete the ${DwarfCannon.NAME} quest in order to do this.")
return true
}
if (player.getSkills().getLevel(Skills.SMITHING) < levelRequirement) {
if (getDynLevel(player, Skills.SMITHING) < levelRequirement) {
player.dialogueInterpreter.sendDialogue("You need a Smithing level of at least $levelRequirement in order to do this.")
return true
}
if (!player.inventory.contains(Items.AMMO_MOULD_4, 1)) {
player.dialogueInterpreter.sendDialogue("You need an ammo mould in order to make a cannon ball.")
if (!inInventory(player, Items.AMMO_MOULD_4)) {
sendDialogue(player,"You need an ammo mould in order to make a cannon ball.")
return true
}
@ -36,25 +38,25 @@ class AmmoMouldOnFurnace : InteractionListener(){
override fun pulse(): Boolean {
when(tick++){
0 -> {
player.sendMessage("You heat the steel bar into a liquid state.")
player.animator.animate(Animation(3243)) // 899 would be preferable but the arms spaz out
sendMessage(player,"You heat the steel bar into a liquid state.")
animate(player, 3243) // 899 would be preferable but the arms spaz out
}
3 -> {
player.sendMessage("You pour the molten metal into your cannonball mould.")
player.animator.animate(Animation(827))
sendMessage(player,"You pour the molten metal into your cannonball mould.")
animate(player, 827)
}
4 -> {
player.sendMessage("The molten metal cools slowly to form 4 cannonballs.")
sendMessage(player,"The molten metal cools slowly to form 4 cannonballs.")
}
7 -> {
if (player.inventory.remove(used.asItem())) {
player.inventory.add(Item(Items.CANNONBALL_2, 4))
player.getSkills().addExperience(Skills.SMITHING, 25.6, true)
if (removeItem(player, used.asItem())) {
addItem(player, Items.CANNONBALL_2, 4)
rewardXP(player, Skills.SMITHING, 25.6)
}
player.animator.animate(Animation(827))
animate(player, 827)
}
10 -> {
if (--amount == 0 || !player.inventory.containsAtLeastOneItem(Items.STEEL_BAR_2353)) {
if (--amount == 0 || !inInventory(player, Items.STEEL_BAR_2353)) {
return true
}
tick = 0
@ -69,15 +71,14 @@ class AmmoMouldOnFurnace : InteractionListener(){
val dialogue: SkillDialogueHandler = object : SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, itemUsed) {
override fun create(amount: Int, index: Int) {
cannonBallPulse.amount = amount
player.pulseManager.run(cannonBallPulse)
submitIndividualPulse(player, cannonBallPulse)
}
override fun getAll(index: Int): Int {
return player.inventory.getAmount(itemUsed)
return amountInInventory(player, itemUsed.id)
}
}
dialogue.open()
openDialogue(player, dialogue)
return true
}