diff --git a/data/definitions/variables-custom.yml b/data/definitions/variables-custom.yml index 438a19381..ce0eb2d3d 100644 --- a/data/definitions/variables-custom.yml +++ b/data/definitions/variables-custom.yml @@ -25,7 +25,7 @@ cooks_assistant_flour: persist: true cooks_assistant_talked_to_millie: format: boolean - persist: true + persist: true bone_delay: format: int recover_special_delay: @@ -473,4 +473,4 @@ equip_longbow: format: boolean equip_crossbow: persist: true - format: boolean \ No newline at end of file + format: boolean diff --git a/data/definitions/variables-player.yml b/data/definitions/variables-player.yml index b88e69e75..a0bf9b934 100644 --- a/data/definitions/variables-player.yml +++ b/data/definitions/variables-player.yml @@ -605,7 +605,9 @@ prince_ali_rescue: completed: 110 task_reward_items: id: 1959 - format: int + format: bitwise + persist: true + values: [ magic_staff, red_dye ] stat_advance_selected_skill: id: 261 format: int diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts index e82e87ebb..c539cc5ea 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts @@ -2,11 +2,14 @@ package world.gregs.voidps.world.activity.achievement import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.sendScript +import world.gregs.voidps.engine.client.variable.BitwiseValues +import world.gregs.voidps.engine.data.definition.VariableDefinitions import world.gregs.voidps.engine.entity.World.name import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.inventoryFull +import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.inventory import world.gregs.voidps.engine.inv.transact.TransactionError @@ -88,18 +91,41 @@ suspend fun NPCOption.whatIsTaskSystem() { player.interfaces.sendVisibility("task_system", "ok", true) } +val variables: VariableDefinitions by inject() + suspend fun NPCOption.claim(inventoryId: String) { npc("I'll just fill your $inventoryId with what you need, then.") val inventory = player.inventories.inventory(inventoryId) - var coins = 1234 + val progress = player["task_progress_overall", 0] + val rewards = progress - player["task_progress_rewarded", 0] + var coins = 0 + for (i in 0 until rewards) { + coins += when { + progress + i < 10 -> 10 + progress + i < 25 -> 40 + progress + i < 50 -> 160 + progress + i < 75 -> 640 + else -> 2560 + } + } + val values = (variables.get("task_reward_items")!!.values as BitwiseValues).values inventory.transaction { add("coins", coins) + if (player.contains("task_reward_items")) { + for (value in values) { + if (player.containsVarbit("task_reward_items", value)) { + add(value as String) + } + } + } } when (inventory.transaction.error) { is TransactionError.Full -> player.inventoryFull() TransactionError.None -> { player.message("You receive $coins coins.") npc("There you go.") + player["task_progress_rewarded"] = player["task_progress_overall", 0] + player.clear("task_reward_items") if (coins > 100) { player["must_be_funny_in_a_rich_mans_world_task"] = true } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/LumbridgeBeginnerTasks.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/LumbridgeBeginnerTasks.kts index 664469dfd..ce2c28400 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/LumbridgeBeginnerTasks.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/LumbridgeBeginnerTasks.kts @@ -168,7 +168,10 @@ variableSet("task_progress_overall") { player -> } itemAdded(inventory = "bank") { player -> - player["hang_on_to_something_task"] = true + if (!player["hang_on_to_something_task", false]) { + player["hang_on_to_something_task"] = true + player.addVarbit("task_reward_items", "magic_staff") + } } npcDeath("cow*") { cow -> diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/Tasks.kt b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/Tasks.kt index ab89d78ad..2bfdc4054 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/Tasks.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/Tasks.kt @@ -169,225 +169,6 @@ object Tasks { return get().get(id)!!.values.toInt(this[id, default]) } - - fun script_3223(player: Player, arg0: Int, arg1: Int): String { - var int2: Int - var str3: String? - str3 = "" - int2 = 0 - when (arg0) { - 147, 23, 294, 167, 249 -> if (arg1 == 1) { - str3 = "You must have access to the fairy ring network to complete this Task." - if (player["fairy_rings_unlocked", false]) { - int2 = 1 - } - } - 49 -> if (arg1 == 1) { - str3 = "You must unlock 500 music tracks in order to perform the Air Guitar emote." - if (player["unlocked_emote_air_guitar", false]) { - int2 = 1 - } - } - 59 -> if (arg1 == 2) { - str3 = "You must also have completed the Abyss miniquest." - if (player.questComplete("enter_the_abyss")) { - int2 = 1 - } - } - 107 -> if (arg1 == 1) { - str3 = "You must have progressed to a certain point in the Dragon Slayer quest." - if (player.getInt("dragon_slayer", "unstarted") >= 2 && player["dragon_slayer_received_shield", false] || player.questComplete("dragon_slayer")) { - int2 = 1 - } - } - 178 -> if (arg1 == 1) { - str3 = "You must begin the relevant section of Otto Godblessed's barbarian training." - if (player["barbarian_training_fishing_unlocked", false]) { - int2 = 1 - } - } - 180 -> if (arg1 == 1) { - str3 = "You must begin the relevant section of Otto Godblessed's barbarian training." - if (player["barbarian_training_pyre_unlocked", false]) { - int2 = 1 - } - } - 177 -> if (arg1 == 1) { - str3 = "You must begin the relevant section of Otto Godblessed's barbarian training." - if (player["barbarian_training_pyre_unlocked", false]) { - int2 = 1 - } - } - 316 -> if (arg1 == 1) { - str3 = "You must begin the relevant section of Otto Godblessed's barbarian training." - if (player["barbarian_training_fishing_unlocked", false]) { - int2 = 1 - } - } - 321 -> if (arg1 == 1) { - str3 = "You must begin the relevant section of Otto Godblessed's barbarian training." - if (player["barbarian_training_pyre_unlocked", false]) { - int2 = 1 - } - } - 322 -> if (arg1 == 1) { - str3 = "You must begin the relevant section of Otto Godblessed's barbarian training." - if (player["barbarian_training_hasta_unlocked", false]) { - int2 = 1 - } - } - 323 -> if (arg1 == 1) { - str3 = "You must begin the relevant section of Otto Godblessed's barbarian training." - if (player["barbarian_training_mix_unlocked", false]) { - int2 = 1 - } - } - 175 -> if (arg1 == 1) { - str3 = "You must complete the Bar Crawl miniquest." - if (player.questComplete("bar_crawl_miniquest") || player["bar_crawl_started", false]) { - int2 = 1 - } - } - 331, 219 -> if (arg1 == 2) { - str3 = "You must have a total combat level of at least 100 to accept an assignment in Shilo Village." - if (player.summoningCombatLevel >= 100) { - int2 = 1 - } - } - 248 -> if (arg1 == 1) { - str3 = "You must have completed the Knight Waves in Camelot." - if (player["knights_waves", 0] == 8) { - int2 = 1 - } - } - 3011, 276 -> if (arg1 == 1) { - str3 = "You require 33 Quest Points to enter the Champions' Guild." - if (player["quest_points", 0] >= 33) { - int2 = 1 - } - } - 281 -> if (arg1 == 1) { - str3 = "You must unlock all four emotes by completing levels of the Stronghold of Security." - if (player["unlocked_emote_flap", false] && player["unlocked_emote_slap_head", false] && player["unlocked_emote_idea", false] && player["unlocked_emote_stomp", false]) { - int2 = 1 - } - } - 285 -> if (arg1 == 1) { - str3 = "You must learn the secret of the Senntisten necklace." - if (player["teleport_to_digsite_with_pendant", false]) { - int2 = 1 - } - } - 289 -> if (arg1 == 1) { - str3 = "You must have a total combat level of at least 40 to accept an assignment from Vannaka." - if (player.summoningCombatLevel >= 40) { - int2 = 1 - } - } - 300 -> if (arg1 == 1) { - str3 = "Completing quests will increase your access to Kudos with the Varrock Museum." - if (kudosCount(player) >= 153) { - int2 = 1 - } - } - 3000 -> if (arg1 == 2) { - if (minutes() >= player["varp_451", 0]) { - int2 = 1 - } - str3 = "You may gather the Tears of Guthix once every week." - } else if (arg1 == 3) { - if (player["quest_points", 0] >= player["varbit_456", 0] || player["total_experience", 0.0] >= player["varp_450", 0.0]) { - int2 = 1 - } - str3 = "You must have gained a Quest Point or 100,000 total experience to enter Juna's cavern." - } - 3013, 3001 -> if (arg1 == 1) { - str3 = "You must have a total combat level of at least 40 to fight for the Void Knights." - if (player.combatLevel >= 40) { - int2 = 1 - } - } - 3002 -> if (arg1 == 1) { - str3 = "You must have Larry or Chuck explain the purpose of penguin spying." - if (player["penguin_hide_and_seek_explained", false]) { - int2 = 1 - } - } else if (arg1 == 2) { - str3 = "You must have spied on fewer than ten penguins already this week." - if (player["penguins_found_weekly", 0] < 10) { - int2 = 1 - } - } else if (arg1 == 3) { - str3 = "You may spy on penguins if your total Penguin Points are less than the maximum of fifty." - if (player["penguin_points", 0] < 50) { - int2 = 1 - } - } - 12 -> if (arg1 == 1) { - str3 = "You must have Larry or Chuck explain the purpose of Penguin Hide and Seek." - if (player["penguin_hide_and_seek_explained", false]) { - int2 = 1 - } - } - 3003 -> if (arg1 == 1) { - str3 = "You may not chop down more than two evil trees per day." - if (player["nurture_evil_tree_stage", 0] < 2) { - int2 = 1 - } - } - 3007 -> if (arg1 == 1) { - str3 = "You may attempt the Agility, Magic and Ranged performances after a week has passed since your last show." - if (!player["circus_magic", false] || !player["circus_agility", false] || !player["circus_ranged", false]) { - int2 = 1 - } - } - 3008 -> if (arg1 == 2) { - str3 = "You must wait at least a day since you last faced Bork." - if (player["bork_defeated_day", 0] != days()) { - int2 = 1 - } - } - 3010 -> if (arg1 == 2) { - str3 = "At least a week must pass since you last faced the Skeletal Horror." - if (minutes() < player["varbit_6305", 0]) { - int2 = 1 - } - } - 3012 -> if (arg1 == 1) { - str3 = "You require 50 Runecrafting to enter the Runecrafters' Guild." - if (player.hasMax(Skill.Runecrafting, 50)) { - int2 = 1 - } - } - 3015 -> if (arg1 == 2) { - str3 = "You must have at least 65 Attack or Defence in order to take on a case." - if (player.hasMax(Skill.Attack, 65) || player.hasMax(Skill.Defence, 65)) { - int2 = 1 - } - } - 3031 -> if (arg1 == 1) { - str3 = "You must have a total combat level of at least 48 to fight in the Clan Wars." - if (player.summoningCombatLevel >= 48) { - int2 = 1 - } - } - 3034 -> if (arg1 == 1) { - str3 = "To enter the Warriors' Guild your Attack or Strength level must be 99, or your combined Attack and Strength levels must total 130 or more." - if (player.levels.getMax(Skill.Strength) + player.levels.getMax(Skill.Attack) >= 130 || player.hasMax(Skill.Attack, 99) || player.hasMax(Skill.Strength, 99)) { - int2 = 1 - } - } - else -> { - str3 = "" - int2 = 0 - } - } - if (int2 == 1) { - str3 = "$str3" - } - return str3 - } - private fun minutes() = TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis()) private fun days(): Int { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts index 6e7f3bf55..1387955e7 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts @@ -50,11 +50,11 @@ suspend fun CharacterContext.menu() { choice { option("And what do you do?") { npc("We will look after your items and money for you. Leave your valuables with us if you want to keep them safe.") - player["you_can_bank_on_us_task"] = true + achievement() } option("Didn't you used to be called the Bank of Varrock?") { npc("Yes we did, but people kept on coming into our branches outside of Varrock and telling us that our signs were wrong. They acted as if we didn't know what town we were in or something.") - player["you_can_bank_on_us_task"] = true + achievement() } } } @@ -71,4 +71,11 @@ npcApproach("Collect", "banker*") { player.approachRange(2) pause() player.open("collection_box") +} + +fun CharacterContext.achievement() { + if (!player["you_can_bank_on_us_task", false]) { + player["you_can_bank_on_us_task"] = true + player.addVarbit("task_reward_items", "red_dye") + } } \ No newline at end of file diff --git a/game/src/test/kotlin/world/gregs/voidps/world/activity/achievement/LumbridgeBeginnerTasksTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/activity/achievement/LumbridgeBeginnerTasksTest.kt index 3bfcc7eb3..61cbe7dd2 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/activity/achievement/LumbridgeBeginnerTasksTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/activity/achievement/LumbridgeBeginnerTasksTest.kt @@ -222,6 +222,7 @@ internal class LumbridgeBeginnerTasksTest : WorldTest() { player.dialogueContinue() assertTrue(player["you_can_bank_on_us_task", false]) + assertTrue(player.containsVarbit("task_reward_items", "red_dye")) } @Test @@ -235,6 +236,7 @@ internal class LumbridgeBeginnerTasksTest : WorldTest() { player.interfaceOption("bank_side", "inventory", "Deposit-10", item = Item("coins"), slot = 0) assertTrue(player["hang_on_to_something_task", false]) + assertTrue(player.containsVarbit("task_reward_items", "magic_staff")) } @Test