Swap ammo mould over to ContentAPI
This commit is contained in:
@@ -1265,6 +1265,13 @@ fun setQuestStage(player: Player, quest: String, stage: Int) {
|
|||||||
player.questRepository.setStage(QuestRepository.getQuests()[quest]!!, stage)
|
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
|
* Gets a scenery definition from the given ID
|
||||||
* @param id the ID of the scenery to get the definition for.
|
* @param id the ID of the scenery to get the definition for.
|
||||||
|
|||||||
+22
-21
@@ -1,5 +1,6 @@
|
|||||||
package rs09.game.interaction.item.withobject
|
package rs09.game.interaction.item.withobject
|
||||||
|
|
||||||
|
import api.*
|
||||||
import core.game.content.quest.members.dwarfcannon.DwarfCannon
|
import core.game.content.quest.members.dwarfcannon.DwarfCannon
|
||||||
import core.game.node.Node
|
import core.game.node.Node
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
@@ -13,20 +14,21 @@ import rs09.game.interaction.InteractionListener
|
|||||||
|
|
||||||
class AmmoMouldOnFurnace : 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
|
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 {
|
private fun cannonBallOnUseWithHandler(player: Player, used: Node, with: Node): Boolean {
|
||||||
player.faceLocation(with.centerLocation)
|
face(player, with.centerLocation)
|
||||||
if(!player.questRepository.isComplete(DwarfCannon.NAME)) {
|
|
||||||
player.dialogueInterpreter.sendDialogue("You need to complete the ${DwarfCannon.NAME} quest in order to do this.")
|
if(isQuestComplete(player, DwarfCannon.NAME)) {
|
||||||
|
sendDialogue(player, "You need to complete the ${DwarfCannon.NAME} quest in order to do this.")
|
||||||
return true
|
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.")
|
player.dialogueInterpreter.sendDialogue("You need a Smithing level of at least $levelRequirement in order to do this.")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (!player.inventory.contains(Items.AMMO_MOULD_4, 1)) {
|
if (!inInventory(player, Items.AMMO_MOULD_4)) {
|
||||||
player.dialogueInterpreter.sendDialogue("You need an ammo mould in order to make a cannon ball.")
|
sendDialogue(player,"You need an ammo mould in order to make a cannon ball.")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,25 +38,25 @@ class AmmoMouldOnFurnace : InteractionListener(){
|
|||||||
override fun pulse(): Boolean {
|
override fun pulse(): Boolean {
|
||||||
when(tick++){
|
when(tick++){
|
||||||
0 -> {
|
0 -> {
|
||||||
player.sendMessage("You heat the steel bar into a liquid state.")
|
sendMessage(player,"You heat the steel bar into a liquid state.")
|
||||||
player.animator.animate(Animation(3243)) // 899 would be preferable but the arms spaz out
|
animate(player, 3243) // 899 would be preferable but the arms spaz out
|
||||||
}
|
}
|
||||||
3 -> {
|
3 -> {
|
||||||
player.sendMessage("You pour the molten metal into your cannonball mould.")
|
sendMessage(player,"You pour the molten metal into your cannonball mould.")
|
||||||
player.animator.animate(Animation(827))
|
animate(player, 827)
|
||||||
}
|
}
|
||||||
4 -> {
|
4 -> {
|
||||||
player.sendMessage("The molten metal cools slowly to form 4 cannonballs.")
|
sendMessage(player,"The molten metal cools slowly to form 4 cannonballs.")
|
||||||
}
|
}
|
||||||
7 -> {
|
7 -> {
|
||||||
if (player.inventory.remove(used.asItem())) {
|
if (removeItem(player, used.asItem())) {
|
||||||
player.inventory.add(Item(Items.CANNONBALL_2, 4))
|
addItem(player, Items.CANNONBALL_2, 4)
|
||||||
player.getSkills().addExperience(Skills.SMITHING, 25.6, true)
|
rewardXP(player, Skills.SMITHING, 25.6)
|
||||||
}
|
}
|
||||||
player.animator.animate(Animation(827))
|
animate(player, 827)
|
||||||
}
|
}
|
||||||
10 -> {
|
10 -> {
|
||||||
if (--amount == 0 || !player.inventory.containsAtLeastOneItem(Items.STEEL_BAR_2353)) {
|
if (--amount == 0 || !inInventory(player, Items.STEEL_BAR_2353)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
tick = 0
|
tick = 0
|
||||||
@@ -69,15 +71,14 @@ class AmmoMouldOnFurnace : InteractionListener(){
|
|||||||
val dialogue: SkillDialogueHandler = object : SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, itemUsed) {
|
val dialogue: SkillDialogueHandler = object : SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, itemUsed) {
|
||||||
override fun create(amount: Int, index: Int) {
|
override fun create(amount: Int, index: Int) {
|
||||||
cannonBallPulse.amount = amount
|
cannonBallPulse.amount = amount
|
||||||
player.pulseManager.run(cannonBallPulse)
|
submitIndividualPulse(player, cannonBallPulse)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAll(index: Int): Int {
|
override fun getAll(index: Int): Int {
|
||||||
return player.inventory.getAmount(itemUsed)
|
return amountInInventory(player, itemUsed.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dialogue.open()
|
openDialogue(player, dialogue)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user